/** * 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; }
@Test(expected = InvalidTransformException.class) public void testFromHomogeneousMatrix() { final ValidatingTransform vt1 = new ValidatingTransform(); final Matrix4 matrix = new Matrix4(); vt1.fromHomogeneousMatrix(matrix); // good matrix.setM00(Double.NaN); vt1.fromHomogeneousMatrix(matrix); // bad }
/** * 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; }
/** * 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)); }
result.setM00(1.0 - (yy + zz)); result.setM01(xy - zw); result.setM02(xz + yw);
textureReflect.setMagnificationFilter(Texture.MagnificationFilter.Bilinear); Matrix4 matrix = new Matrix4(); matrix.setM00(-1.0); matrix.setM30(1.0); textureReflect.setTextureMatrix(matrix); TextureStoreFormat.GuessNoCompressedFormat, true); matrix = new Matrix4(); matrix.setM00(0.8); matrix.setM11(0.8); dudvTexture.setTextureMatrix(matrix);
result.setM00(1.0 - (yy + zz)); result.setM01(xy - zw); result.setM02(xz + yw);
rangeMatrix.setM00(maxX - minX); rangeMatrix.setM11(maxY - minY); rangeMatrix.setM30(minX);
rangeMatrix.setM00(maxX - minX); rangeMatrix.setM11(maxY - minY); rangeMatrix.setM30(minX);
assertEquals(Matrix4.IDENTITY, mat4A); mat4A.setM00(0.0); mat4A.setM01(0.1); mat4A.setM02(0.2);