@Override public ResultSample doInverseTest(final int count, final int maxCount, final long timeOutMS) { final Matrix4 m1 = new Matrix4(); final double near = 1.0, far = 1000.0, fovy = 90.0, aspect = 0.5; MathUtils.matrixPerspective(fovy, aspect, near, far, m1); 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, m1.toArray(null)); }
@Test(expected = ArithmeticException.class) public void testBadInvert() { final Matrix4 mat4A = new Matrix4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); mat4A.invertLocal(); }
/** * 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 testInvert() { final Matrix4 mat4A = new Matrix4().applyRotationX(MathUtils.QUARTER_PI).applyTranslationPost(1, 2, 3); final Matrix4 inverted = mat4A.invert(null); assertEquals(Matrix4.IDENTITY, mat4A.multiply(inverted, null)); assertEquals(mat4A, inverted.invertLocal()); }