/** * Constructs a new matrix set to the values of the given matrix. * * @param source */ public Matrix4(final ReadOnlyMatrix4 source) { set(source); }
@Override public ResultSample doInverse3Test(final int count, final int maxCount, final long timeOutMS) { final Matrix4 mat = a3dMatrixRandom(); final Matrix3 m1 = new Matrix3( // mat.getM00(), mat.getM01(), mat.getM02(), // mat.getM10(), mat.getM11(), mat.getM12(), // mat.getM20(), mat.getM21(), mat.getM22()); mat.setIdentity(); final long start = System.currentTimeMillis(); int loopCount = 0; while (System.currentTimeMillis() - start < timeOutMS && loopCount != maxCount) { ++loopCount; for (int i = 0; i < count; ++i) { m1.invertLocal(); } } return populateResult(System.currentTimeMillis() - start, loopCount, mat.set(m1).toArray(null)); }
/** * Same as set(IDENTITY) * * @return this matrix for chaining */ public Matrix4 setIdentity() { return set(Matrix4.IDENTITY); }
/** * Constructs a new matrix set to the values of the given matrix. * * @param source */ public Matrix4(final ReadOnlyMatrix4 source) { set(source); }
/** * Same as set(IDENTITY) * * @return this matrix for chaining */ public Matrix4 setIdentity() { return set(Matrix4.IDENTITY); }
public void setProjectionMatrix(final ReadOnlyMatrix4 projection) { _projection.set(projection); _frustumDirty = true; }
public void setProjectionMatrix(final ReadOnlyMatrix4 projection) { _projection.set(projection); _frustumDirty = true; }
public void setTextureMatrix(final ReadOnlyMatrix4 matrix) { _texMatrix.set(matrix); }
/** * * @param left * @param right * @param bottom * @param top * @param nearZ * @param farZ * @param store */ public static void matrixOrtho(final double left, final double right, final double bottom, final double top, final double nearZ, final double farZ, final Matrix4 store) { store.set(2.0 / (right - left), 0.0, 0.0, 0.0, 0.0, 2.0 / (top - bottom), 0.0, 0.0, 0.0, 0.0, -2.0 / (farZ - nearZ), 0.0, -(right + left) / (right - left), -(top + bottom) / (top - bottom), -(farZ + nearZ) / (farZ - nearZ), 1.0); }
/** * * @param left * @param right * @param bottom * @param top * @param nearZ * @param farZ * @param store */ public static void matrixOrtho(final double left, final double right, final double bottom, final double top, final double nearZ, final double farZ, final Matrix4 store) { store.set(2.0 / (right - left), 0.0, 0.0, 0.0, 0.0, 2.0 / (top - bottom), 0.0, 0.0, 0.0, 0.0, -2.0 / (farZ - nearZ), 0.0, -(right + left) / (right - left), -(top + bottom) / (top - bottom), -(farZ + nearZ) / (farZ - nearZ), 1.0); }
/** * * @param left * @param right * @param bottom * @param top * @param nearZ * @param farZ * @param store */ public static void matrixFrustum(final double left, final double right, final double bottom, final double top, final double nearZ, final double farZ, final Matrix4 store) { final double x = 2.0 * nearZ / (right - left); final double y = 2.0 * nearZ / (top - bottom); final double a = (right + left) / (right - left); final double b = (top + bottom) / (top - bottom); final double c = -(farZ + nearZ) / (farZ - nearZ); final double d = -(2.0 * farZ * nearZ) / (farZ - nearZ); store.set(x, 0.0, 0.0, 0.0, 0.0, y, 0.0, 0.0, a, b, c, -1.0, 0.0, 0.0, d, 0.0); }
/** * * @param left * @param right * @param bottom * @param top * @param nearZ * @param farZ * @param store */ public static void matrixFrustum(final double left, final double right, final double bottom, final double top, final double nearZ, final double farZ, final Matrix4 store) { final double x = 2.0 * nearZ / (right - left); final double y = 2.0 * nearZ / (top - bottom); final double a = (right + left) / (right - left); final double b = (top + bottom) / (top - bottom); final double c = -(farZ + nearZ) / (farZ - nearZ); final double d = -(2.0 * farZ * nearZ) / (farZ - nearZ); store.set(x, 0.0, 0.0, 0.0, 0.0, y, 0.0, 0.0, a, b, c, -1.0, 0.0, 0.0, d, 0.0); }
/** * update modelViewProjection if necessary. */ private void checkModelViewProjection() { if (_updateMVPMatrix) { _modelViewProjection.set(getViewMatrix()).multiplyLocal(getProjectionMatrix()); _updateMVPMatrix = false; } }
/** * update modelViewProjection if necessary. */ private void checkModelViewProjection() { if (_updateMVPMatrix) { _modelViewProjection.set(getModelViewMatrix()).multiplyLocal(getProjectionMatrix()); _updateMVPMatrix = false; } }
public void updateTextureMatrix(final Matrix4 matrixStore) { update(); final ReadOnlyMatrix4 projectorView = getModelViewMatrix(); final ReadOnlyMatrix4 projectorProjection = getProjectionMatrix(); matrixStore.set(projectorView).multiplyLocal(projectorProjection).multiplyLocal(BIAS); } }
public void updateTextureMatrix(final Matrix4 matrixStore) { update(); final ReadOnlyMatrix4 projectorView = getViewMatrix(); final ReadOnlyMatrix4 projectorProjection = getProjectionMatrix(); matrixStore.set(projectorView).multiplyLocal(projectorProjection).multiplyLocal(BIAS); } }
/** * Update texture matrix. * * @param index * the index */ private void updateTextureMatrix(final int index) { // Create a matrix going from light to camera space final Camera cam = ContextManager.getCurrentContext().getCurrentCamera(); _shadowMatrix.set(cam.getViewMatrix()).invertLocal(); _shadowMatrix.multiplyLocal(_shadowMapRenderer.getCamera().getModelViewProjectionMatrix()) .multiplyLocal(SCALE_BIAS_MATRIX); // _shadowMapTexture[index].setTextureMatrix(_shadowMatrix); }
/** * Update texture matrix. * * @param index * the index */ private void updateTextureMatrix(final int index) { // Create a matrix going from light to camera space final Camera cam = ContextManager.getCurrentContext().getCurrentCamera(); _shadowMatrix.set(cam.getModelViewMatrix()).invertLocal(); _shadowMatrix.multiplyLocal(_shadowMapRenderer.getCamera().getModelViewProjectionMatrix()).multiplyLocal( SCALE_BIAS_MATRIX); _shadowMapTexture[index].setTextureMatrix(_shadowMatrix); }
@Test public void testOrthonormal() { final Matrix4 mat4 = new Matrix4(); assertTrue(mat4.isOrthonormal()); // just rotation mat4.set(new Matrix3().applyRotationX(MathUtils.QUARTER_PI)); assertTrue(mat4.isOrthonormal()); // non-uniform scale mat4.set(new Matrix3().scaleLocal(new Vector3(1, 2, 3)).applyRotationX(MathUtils.QUARTER_PI)); assertFalse(mat4.isOrthonormal()); // uniform scale mat4.set(new Matrix3().scaleLocal(new Vector3(2, 2, 2)).applyRotationX(MathUtils.QUARTER_PI)); assertFalse(mat4.isOrthonormal()); // uniform scale 1 mat4.set(new Matrix3().scaleLocal(new Vector3(1, 1, 1)).applyRotationX(MathUtils.QUARTER_PI)); assertTrue(mat4.isOrthonormal()); }
/** * Applies the given scale to this matrix and returns the result as a new matrix * * @param scale * @param store * a matrix to store the result in. If store is null, a new matrix is created. * @return the new matrix * @throws NullPointerException * if scale is null. */ @Override public Matrix4 scale(final ReadOnlyVector4 scale, final Matrix4 store) { Matrix4 result = store; if (result == null) { result = new Matrix4(); } return result.set( // _m00 * scale.getX(), _m01 * scale.getY(), _m02 * scale.getZ(), _m03 * scale.getW(), // _m10 * scale.getX(), _m11 * scale.getY(), _m12 * scale.getZ(), _m13 * scale.getW(), // _m20 * scale.getX(), _m21 * scale.getY(), _m22 * scale.getZ(), _m23 * scale.getW(), // _m30 * scale.getX(), _m31 * scale.getY(), _m32 * scale.getZ(), _m33 * scale.getW()); }