texMatrix.setIdentity(); texScale.zero(); boundTexture = -1;
@Override public void invalidate() { super.invalidate(); ambient.set(-1, -1, -1, -1); diffuse.set(-1, -1, -1, -1); specular.set(-1, -1, -1, -1); constant = -1; linear = -1; quadratic = -1; spotExponent = -1; spotCutoff = -1; enabled = false; position.set(-1, -1, -1, -1); modelViewMatrix.setIdentity(); } }
@Override public void invalidate() { super.invalidate(); ambient.set(-1, -1, -1, -1); diffuse.set(-1, -1, -1, -1); specular.set(-1, -1, -1, -1); constant = -1; linear = -1; quadratic = -1; spotExponent = -1; spotCutoff = -1; enabled = false; position.set(-1, -1, -1, -1); modelViewMatrix.setIdentity(); } }
@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)); }
final Matrix4 workingMat = Matrix4.fetchTempInstance(); final Matrix4 finalMat = Matrix4.fetchTempInstance(); finalMat.setIdentity(); for (final Element transform : transforms) { final double[] array = _colladaDOMUtil.parseDoubleArray(transform); if ("translate".equals(transform.getName())) { workingMat.setIdentity(); workingMat.setColumn(3, new Vector4(array[0], array[1], array[2], 1.0)); finalMat.multiplyLocal(workingMat); } else if ("rotate".equals(transform.getName())) { if (array[3] != 0) { workingMat.setIdentity(); final Matrix3 rotate = new Matrix3().fromAngleAxis(array[3] * MathUtils.DEG_TO_RAD, new Vector3( array[0], array[1], array[2])); workingMat.setIdentity(); workingMat.scale(new Vector4(array[0], array[1], array[2], 1), workingMat); finalMat.multiplyLocal(workingMat);
final Matrix4 workingMat = Matrix4.fetchTempInstance(); final Matrix4 finalMat = Matrix4.fetchTempInstance(); finalMat.setIdentity(); for (final TransformElement transform : transforms) { final double[] array = transform.getArray(); final TransformElementType type = transform.getType(); if (type == TransformElementType.Translation) { workingMat.setIdentity(); workingMat.setColumn(3, new Vector4(array[0], array[1], array[2], 1.0)); finalMat.multiplyLocal(workingMat); } else if (type == TransformElementType.Rotation) { if (array[3] != 0) { workingMat.setIdentity(); final Matrix3 rotate = new Matrix3().fromAngleAxis(array[3] * MathUtils.DEG_TO_RAD, new Vector3( array[0], array[1], array[2])); workingMat.setIdentity(); workingMat.scale(new Vector4(array[0], array[1], array[2], 1), workingMat); finalMat.multiplyLocal(workingMat);
/** * Updates the value of our projection matrix. */ protected void updateProjectionMatrix() { if (getProjectionMode() == ProjectionMode.Orthographic) { _projection.setIdentity(); _projection.setM00(2.0 / (_frustumRight - _frustumLeft)); _projection.setM11(2.0 / (_frustumTop - _frustumBottom)); _projection.setM22(-2.0 / (_frustumFar - _frustumNear)); _projection.setM30(-(_frustumRight + _frustumLeft) / (_frustumRight - _frustumLeft)); _projection.setM31(-(_frustumTop + _frustumBottom) / (_frustumTop - _frustumBottom)); _projection.setM32(-(_frustumFar + _frustumNear) / (_frustumFar - _frustumNear)); } else if (getProjectionMode() == ProjectionMode.Perspective) { _projection.setIdentity(); _projection.setM00((2.0 * _frustumNear) / (_frustumRight - _frustumLeft)); _projection.setM11((2.0 * _frustumNear) / (_frustumTop - _frustumBottom)); _projection.setM20((_frustumRight + _frustumLeft) / (_frustumRight - _frustumLeft)); _projection.setM21((_frustumTop + _frustumBottom) / (_frustumTop - _frustumBottom)); _projection.setM22(-(_frustumFar + _frustumNear) / (_frustumFar - _frustumNear)); _projection.setM23(-1.0); _projection.setM32(-(2.0 * _frustumFar * _frustumNear) / (_frustumFar - _frustumNear)); _projection.setM33(-0.0); } _updatePMatrix = false; }
/** * Updates the value of our projection matrix. */ protected void updateProjectionMatrix() { if (getProjectionMode() == ProjectionMode.Parallel) { _projection.setIdentity(); _projection.setM00(2.0 / (_frustumRight - _frustumLeft)); _projection.setM11(2.0 / (_frustumTop - _frustumBottom)); _projection.setM22(-2.0 / (_frustumFar - _frustumNear)); _projection.setM30(-(_frustumRight + _frustumLeft) / (_frustumRight - _frustumLeft)); _projection.setM31(-(_frustumTop + _frustumBottom) / (_frustumTop - _frustumBottom)); _projection.setM32(-(_frustumFar + _frustumNear) / (_frustumFar - _frustumNear)); } else if (getProjectionMode() == ProjectionMode.Perspective) { _projection.setIdentity(); _projection.setM00((2.0 * _frustumNear) / (_frustumRight - _frustumLeft)); _projection.setM11((2.0 * _frustumNear) / (_frustumTop - _frustumBottom)); _projection.setM20((_frustumRight + _frustumLeft) / (_frustumRight - _frustumLeft)); _projection.setM21((_frustumTop + _frustumBottom) / (_frustumTop - _frustumBottom)); _projection.setM22(-(_frustumFar + _frustumNear) / (_frustumFar - _frustumNear)); _projection.setM23(-1.0); _projection.setM32(-(2.0 * _frustumFar * _frustumNear) / (_frustumFar - _frustumNear)); _projection.setM33(-0.0); } _updatePMatrix = false; }
@Test public void testRotations() { final Vector4 rotated = new Vector4(); final Vector4 expected = new Vector4(); final Matrix4 worker = new Matrix4(); // test axis rotation methods against general purpose // X AXIS expected.set(1, 1, 1, 1); rotated.set(1, 1, 1, 1); worker.setIdentity().applyRotationX(MathUtils.QUARTER_PI).applyPost(expected, expected); worker.setIdentity().applyRotation(MathUtils.QUARTER_PI, 1, 0, 0).applyPost(rotated, rotated); assertTrue(rotated.distance(expected) <= MathUtils.EPSILON); // Y AXIS expected.set(1, 1, 1, 1); rotated.set(1, 1, 1, 1); worker.setIdentity().applyRotationY(MathUtils.QUARTER_PI).applyPost(expected, expected); worker.setIdentity().applyRotation(MathUtils.QUARTER_PI, 0, 1, 0).applyPost(rotated, rotated); assertTrue(rotated.distance(expected) <= MathUtils.EPSILON); // Z AXIS expected.set(1, 1, 1, 1); rotated.set(1, 1, 1, 1); worker.setIdentity().applyRotationZ(MathUtils.QUARTER_PI).applyPost(expected, expected); worker.setIdentity().applyRotation(MathUtils.QUARTER_PI, 0, 0, 1).applyPost(rotated, rotated); assertTrue(rotated.distance(expected) <= MathUtils.EPSILON); }
/** * Updates the value of our model view matrix. */ protected void updateModelViewMatrix() { _modelView.setIdentity(); _modelView.setM00(-_left.getX()); _modelView.setM10(-_left.getY()); _modelView.setM20(-_left.getZ()); _modelView.setM01(_up.getX()); _modelView.setM11(_up.getY()); _modelView.setM21(_up.getZ()); _modelView.setM02(-_direction.getX()); _modelView.setM12(-_direction.getY()); _modelView.setM22(-_direction.getZ()); _modelView.setM30(_left.dot(_location)); _modelView.setM31(-_up.dot(_location)); _modelView.setM32(_direction.dot(_location)); }
/** * Updates the value of our view matrix. */ protected void updateViewMatrix() { _view.setIdentity(); _view.setM00(-_left.getX()); _view.setM10(-_left.getY()); _view.setM20(-_left.getZ()); _view.setM01(_up.getX()); _view.setM11(_up.getY()); _view.setM21(_up.getZ()); _view.setM02(-_direction.getX()); _view.setM12(-_direction.getY()); _view.setM22(-_direction.getZ()); _view.setM30(_left.dot(_location)); _view.setM31(-_up.dot(_location)); _view.setM32(_direction.dot(_location)); }
assertTrue(3.3 == mat4A.getM33()); mat4A.setIdentity();
assertTrue(Matrix4.isValid(mat4)); for (int i = 0; i < 16; i++) { mat4.setIdentity(); mat4.setValue(i / 4, i % 4, Double.NaN); assertFalse(Matrix4.isValid(mat4)); mat4.setIdentity(); mat4.setValue(i / 4, i % 4, Double.POSITIVE_INFINITY); assertFalse(Matrix4.isValid(mat4)); mat4.setIdentity(); assertTrue(Matrix4.isValid(mat4));
rangeMatrix.setIdentity(); rangeMatrix.setM00(maxX - minX); rangeMatrix.setM11(maxY - minY);
rangeMatrix.setIdentity(); rangeMatrix.setM00(maxX - minX); rangeMatrix.setM11(maxY - minY);
mat4A.setIdentity(); mat4A.fromArray(values); assertTrue(0 == mat4A.getM00()); mat4A.setIdentity(); mat4A.fromArray(values, false); assertTrue(0 == mat4A.getM00());
mat4A.setIdentity(); mat4A.fromFloatBuffer(fb, false); assertTrue(0 == mat4A.getM00()); db.flip(); mat4A.setIdentity(); mat4A.fromDoubleBuffer(db); assertTrue(0 == mat4A.getM00()); mat4A.setIdentity(); mat4A.fromDoubleBuffer(db, false); assertTrue(0 == mat4A.getM00());
assertTrue(3.3 == mat4C.getM33()); mat4C.setIdentity(); assertTrue(mat4C.isIdentity()); mat4C.setIdentity(); mat4C.set(0.0, 0.1, 0.2, 0.3, 2.0, 2.1, 2.2, 2.3, 4.0, 4.1, 4.2, 4.3, 6.0, 6.1, 6.2, 6.3); for (int x = 0; x < 4; x++) {