/** * Note: data is cast to floats. * * @param store * the buffer to read our matrix data from. * @return this matrix for chaining. */ public Matrix4 fromFloatBuffer(final FloatBuffer source) { return fromFloatBuffer(source, true); }
/** * Note: data is cast to floats. * * @param store * the buffer to read our matrix data from. * @return this matrix for chaining. */ public Matrix4 fromFloatBuffer(final FloatBuffer source) { return fromFloatBuffer(source, true); }
@Override public void computeNormalMatrix(final boolean modelIsUniformScale) { final Matrix3 normal = Matrix3.fetchTempInstance(); final FloatBuffer dst = _matrixStore.get(RenderMatrixType.Normal); dst.clear(); final Matrix4 model = Matrix4.fetchTempInstance(); final FloatBuffer modelBuff = _matrixStore.get(RenderMatrixType.Model); modelBuff.clear(); model.fromFloatBuffer(modelBuff); if (modelIsUniformScale) { // normal matrix is just the 3x3 of the model matrix model.toMatrix3(normal); } else { // normal matrix is the inverse transpose of the 3x3 model matrix model.toMatrix3(normal); try { normal.invertLocal().transposeLocal(); } catch (final ArithmeticException ex) { // silently ignore for now - non invertable } } normal.toFloatBuffer(dst); } }
source.put(floatData, i, 16); source.flip(); final Matrix4 mat = new Matrix4().fromFloatBuffer(source); bindMatrices.add(new Transform().fromHomogeneousMatrix(mat));
fb.flip(); final Matrix4 mat4A = new Matrix4().fromFloatBuffer(fb); assertTrue(0 == mat4A.getM00()); assertTrue(1 == mat4A.getM01()); mat4A.fromFloatBuffer(fb, false); assertTrue(0 == mat4A.getM00()); assertTrue(4 == mat4A.getM01());