javax.vecmath.Matrix4f Java Examples
The following examples show how to use
javax.vecmath.Matrix4f.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OrientationInfoGenerator.java From OpenModsLib with MIT License | 6 votes |
private static Matrix3f roundAndReduceMatrixElements(Matrix4f m) { Preconditions.checkArgument(m.m30 == 0); Preconditions.checkArgument(m.m31 == 0); Preconditions.checkArgument(m.m32 == 0); Preconditions.checkArgument(m.m03 == 0); Preconditions.checkArgument(m.m13 == 0); Preconditions.checkArgument(m.m23 == 0); Preconditions.checkArgument(m.m33 == 1); final Matrix3f result = new Matrix3f(); result.m00 = Math.round(m.m00); result.m01 = Math.round(m.m01); result.m02 = Math.round(m.m02); result.m10 = Math.round(m.m10); result.m11 = Math.round(m.m11); result.m12 = Math.round(m.m12); result.m20 = Math.round(m.m20); result.m21 = Math.round(m.m21); result.m22 = Math.round(m.m22); return result; }
Example #2
Source File: AbstractShader.java From gama with GNU General Public License v3.0 | 6 votes |
static public FloatBuffer getFloatBuffer(final Matrix4f matrix) { final FloatBuffer result = FloatBuffer.allocate(16); result.put(0, matrix.m00); result.put(1, matrix.m01); result.put(2, matrix.m02); result.put(3, matrix.m03); result.put(4, matrix.m10); result.put(5, matrix.m11); result.put(6, matrix.m12); result.put(7, matrix.m13); result.put(8, matrix.m20); result.put(9, matrix.m21); result.put(10, matrix.m22); result.put(11, matrix.m23); result.put(12, matrix.m30); result.put(13, matrix.m31); result.put(14, matrix.m32); result.put(15, matrix.m33); return result; }
Example #3
Source File: ExternalCameraRendering.java From JglTF with MIT License | 6 votes |
/** * Writes the given matrix into the given array, in column-major order. * Neither the matrix nor the array may be <code>null</code>. The given * array must have a length of at least <code>offset+16</code>. * * @param m The matrix * @param a The array * @param offset The offset where to start writing into the array */ private static void writeMatrixToArrayColumnMajor4f( Matrix4f m, float a[], int offset) { int i = offset; a[i++] = m.m00; a[i++] = m.m10; a[i++] = m.m20; a[i++] = m.m30; a[i++] = m.m01; a[i++] = m.m11; a[i++] = m.m21; a[i++] = m.m31; a[i++] = m.m02; a[i++] = m.m12; a[i++] = m.m22; a[i++] = m.m32; a[i++] = m.m03; a[i++] = m.m13; a[i++] = m.m23; a[i++] = m.m33; }
Example #4
Source File: ExternalCameraRendering.java From JglTF with MIT License | 5 votes |
@Override public float[] getProjectionMatrix() { Matrix4f m = view.getProjectionMatrix(); writeMatrixToArrayColumnMajor4f(m, projectionMatrix, 0); return projectionMatrix; }
Example #5
Source File: PerspectiveAwareModel.java From OpenModsLib with MIT License | 5 votes |
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { IBakedModel model = models.get(cameraTransformType); if (model == null) model = base; return model.handlePerspective(cameraTransformType); }
Example #6
Source File: OrientationInfoGenerator.java From OpenModsLib with MIT License | 5 votes |
private static Multimap<Orientation, ModelRotation> calculateVanillaRotations(Map<Matrix3f, Orientation> fromMatrix) { final Multimap<Orientation, ModelRotation> toVanilla = HashMultimap.create(); for (ModelRotation rot : ModelRotation.values()) { final Matrix4f rotMatrix = TRSRTransformation.toVecmath(rot.getMatrix4d()); final Matrix3f key = roundAndReduceMatrixElements(rotMatrix); final Orientation orientation = fromMatrix.get(key); Preconditions.checkNotNull(orientation, rot); toVanilla.put(orientation, rot); } return toVanilla; }
Example #7
Source File: ExternalCameraRendering.java From JglTF with MIT License | 5 votes |
@Override public float[] getViewMatrix() { Matrix4f m = CameraUtils.computeViewMatrix(view.getCamera()); writeMatrixToArrayColumnMajor4f(m, viewMatrix, 0); return viewMatrix; }
Example #8
Source File: Skylight_BulletPhysics_Breakable3.java From PixelFlow with MIT License | 5 votes |
public Transform asBulletTransform(PMatrix3D mat_p5){ Matrix4f mat = new Matrix4f(); mat.setRow(0, mat_p5.m00, mat_p5.m01, mat_p5.m02, mat_p5.m03); mat.setRow(1, mat_p5.m10, mat_p5.m11, mat_p5.m12, mat_p5.m13); mat.setRow(2, mat_p5.m20, mat_p5.m21, mat_p5.m22, mat_p5.m23); mat.setRow(3, mat_p5.m30, mat_p5.m31, mat_p5.m32, mat_p5.m33); return new Transform(mat); }
Example #9
Source File: Skylight_BulletPhysics_Breakable_VideoExport.java From PixelFlow with MIT License | 5 votes |
public Transform asBulletTransform(PMatrix3D mat_p5){ Matrix4f mat = new Matrix4f(); mat.setRow(0, mat_p5.m00, mat_p5.m01, mat_p5.m02, mat_p5.m03); mat.setRow(1, mat_p5.m10, mat_p5.m11, mat_p5.m12, mat_p5.m13); mat.setRow(2, mat_p5.m20, mat_p5.m21, mat_p5.m22, mat_p5.m23); mat.setRow(3, mat_p5.m30, mat_p5.m31, mat_p5.m32, mat_p5.m33); return new Transform(mat); }
Example #10
Source File: Skylight_BulletPhysics_Breakable.java From PixelFlow with MIT License | 5 votes |
public Transform asBulletTransform(PMatrix3D mat_p5){ Matrix4f mat = new Matrix4f(); mat.setRow(0, mat_p5.m00, mat_p5.m01, mat_p5.m02, mat_p5.m03); mat.setRow(1, mat_p5.m10, mat_p5.m11, mat_p5.m12, mat_p5.m13); mat.setRow(2, mat_p5.m20, mat_p5.m21, mat_p5.m22, mat_p5.m23); mat.setRow(3, mat_p5.m30, mat_p5.m31, mat_p5.m32, mat_p5.m33); return new Transform(mat); }
Example #11
Source File: InfuserCoreBakedModel.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType cameraTransformType) { switch (cameraTransformType) { case GUI: return inventoryModel.handlePerspective(cameraTransformType); default: return handModel.handlePerspective(cameraTransformType); } }
Example #12
Source File: ModelCodex.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@Nonnull @Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(@Nonnull ItemCameraTransforms.TransformType cameraTransformType) { if ((cameraTransformType == ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND || cameraTransformType == ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND)) return Pair.of(this, null); IBakedModel original = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getModel(path2D); return original.handlePerspective(cameraTransformType); }
Example #13
Source File: BakedPitKilnModel.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { Pair<? extends IBakedModel, Matrix4f> pair = standard.handlePerspective(cameraTransformType); return Pair.of(this, pair.getRight()); }
Example #14
Source File: GTModelMortar.java From GT-Classic with GNU Lesser General Public License v3.0 | 4 votes |
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { return PerspectiveMapWrapper.handlePerspective(this, this.getCamera(), cameraTransformType); }
Example #15
Source File: ItemStateOverrideList.java From OpenModsLib with MIT License | 4 votes |
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { return original.handlePerspective(cameraTransformType); }
Example #16
Source File: BakedModelAdapter.java From OpenModsLib with MIT License | 4 votes |
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { return PerspectiveMapWrapper.handlePerspective(this, cameraTransforms, cameraTransformType); }
Example #17
Source File: GTModelWire.java From GT-Classic with GNU Lesser General Public License v3.0 | 4 votes |
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { return PerspectiveMapWrapper.handlePerspective(this, this.getCamera(), cameraTransformType); }
Example #18
Source File: GTModelOre.java From GT-Classic with GNU Lesser General Public License v3.0 | 4 votes |
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { return Pair.of(this, PerspectiveMapWrapper.handlePerspective(this, this.getCamera(), cameraTransformType).getRight()); }
Example #19
Source File: ModelPortableBarrel.java From BetterChests with GNU Lesser General Public License v3.0 | 4 votes |
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { Pair<? extends IBakedModel, Matrix4f> p = parent.handlePerspective(cameraTransformType); return ImmutablePair.of(this, p.getRight()); }
Example #20
Source File: ModelNullifierBaked.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { return PerspectiveMapWrapper.handlePerspective(this, this.transformMap, cameraTransformType); }
Example #21
Source File: ModelEnderTools.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { return PerspectiveMapWrapper.handlePerspective(this, this.transforms, cameraTransformType); }
Example #22
Source File: ModelEnderBucket.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { return PerspectiveMapWrapper.handlePerspective(this, this.transforms, cameraTransformType); }
Example #23
Source File: BakedWrapper.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, transforms, cameraTransformType); }
Example #24
Source File: BakedAnvilModel.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { Pair<? extends IBakedModel, Matrix4f> pair = standard.handlePerspective(cameraTransformType); return Pair.of(this, pair.getRight()); }
Example #25
Source File: Skylight_BulletPhysics_Cubes.java From PixelFlow with MIT License | 4 votes |
public void createFractureShape(){ reset(); float pos_z = 20f; int numx = 15; int numy = 5; int numz = 10; float dim = 20; float boundsx = numx * dim; float boundsy = numy * dim; // float boundsz = numz * dim; float mass = dim*dim*dim; float tx = -boundsx * 0.5f; float ty = -boundsy * 0.5f; float tz = pos_z + 0; colorMode(HSB, 360, 100,100); for(int z = 0; z < numz; z++){ for(int y = 0; y < numy; y++){ for(int x = 0; x < numx; x++){ float cx = dim *0.5f + x * dim; float cy = dim *0.5f + y * dim; float cz = dim *0.5f + z * dim; BObject body = new BBox(this, mass, dim, dim, dim); // setup initial body transform-matrix PMatrix3D mat_p5 = new PMatrix3D(); mat_p5.translate(tx, ty, tz); mat_p5.translate(cx, cy, cz); Matrix4f mat = new Matrix4f(); mat.setRow(0, mat_p5.m00, mat_p5.m01, mat_p5.m02, mat_p5.m03); mat.setRow(1, mat_p5.m10, mat_p5.m11, mat_p5.m12, mat_p5.m13); mat.setRow(2, mat_p5.m20, mat_p5.m21, mat_p5.m22, mat_p5.m23); mat.setRow(3, mat_p5.m30, mat_p5.m31, mat_p5.m32, mat_p5.m33); Transform transform = new Transform(mat); // rigid-body properties body.rigidBody.setWorldTransform(transform); body.rigidBody.setRestitution(.1f); body.rigidBody.setFriction(0.85f); body.rigidBody.setDamping(0.2f, 0.2f); body.displayShape = createShape(BOX, dim, dim, dim); body.displayShape.setStroke(false); body.displayShape.setFill(true); // float r = random(80, 130); float r = random(220, 270); float g = random(20,70); float b = 100; body.displayShape.setFill(color(r,g,b)); physics.addBody(body); group_bulletbodies.addChild(body.displayShape); } } } colorMode(RGB, 255, 255,255); }
Example #26
Source File: BakedSmallVesselModel.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { Pair<? extends IBakedModel, Matrix4f> pair = standard.handlePerspective(cameraTransformType); return Pair.of(this, pair.getRight()); }
Example #27
Source File: AbstractShader.java From gama with GNU General Public License v3.0 | 4 votes |
protected void loadMatrix(final int location, final Matrix4f matrix) { matrixBuffer = getFloatBuffer(matrix); matrixBuffer.flip(); gl.glUniformMatrix4fv(location, 1, false, matrixBuffer.array(), 0); }
Example #28
Source File: GTModelBlock.java From GT-Classic with GNU Lesser General Public License v3.0 | 4 votes |
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { return Pair.of(this, PerspectiveMapWrapper.handlePerspective(this, this.getCamera(), cameraTransformType).getRight()); }
Example #29
Source File: GTBakedTestTube.java From GT-Classic with GNU Lesser General Public License v3.0 | 4 votes |
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType cameraTransformType) { return Pair.of(this, GTModelUtils.getItemTransform(cameraTransformType)); }
Example #30
Source File: BakedModelHandler.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { CCRenderItem.notifyTransform(cameraTransformType); return PerspectiveMapWrapper.handlePerspective(this, TransformUtils.DEFAULT_BLOCK, cameraTransformType); }