public Quaternion toRotationQuat() { Quaternion quat = new Quaternion(); quat.fromRotationMatrix(toRotationMatrix()); return quat; }
private void updateInstance(Matrix4f worldMatrix, float[] store, int offset, Matrix3f tempMat3, Quaternion tempQuat) { worldMatrix.toRotationMatrix(tempMat3); tempMat3.invertLocal(); // NOTE: No need to take the transpose in order to encode // into quaternion, the multiplication in the shader is vec * quat // apparently... tempQuat.fromRotationMatrix(tempMat3); // Column-major encoding. The "W" field in each of the encoded // vectors represents the quaternion. store[offset + 0] = worldMatrix.m00; store[offset + 1] = worldMatrix.m10; store[offset + 2] = worldMatrix.m20; store[offset + 3] = tempQuat.getX(); store[offset + 4] = worldMatrix.m01; store[offset + 5] = worldMatrix.m11; store[offset + 6] = worldMatrix.m21; store[offset + 7] = tempQuat.getY(); store[offset + 8] = worldMatrix.m02; store[offset + 9] = worldMatrix.m12; store[offset + 10] = worldMatrix.m22; store[offset + 11] = tempQuat.getZ(); store[offset + 12] = worldMatrix.m03; store[offset + 13] = worldMatrix.m13; store[offset + 14] = worldMatrix.m23; store[offset + 15] = tempQuat.getW(); }
public BoundingVolume transform(Matrix4f trans, BoundingVolume store) { BoundingBox box; if (store == null || store.getType() != Type.AABB) { box = new BoundingBox(); } else { box = (BoundingBox) store; } TempVars vars = TempVars.get(); float w = trans.multProj(center, box.center); box.center.divideLocal(w); Matrix3f transMatrix = vars.tempMat3; trans.toRotationMatrix(transMatrix); // Make the rotation matrix all positive to get the maximum x/y/z extent transMatrix.absoluteLocal(); vars.vect1.set(xExtent, yExtent, zExtent); transMatrix.mult(vars.vect1, vars.vect1); // Assign the biggest rotations after scales. box.xExtent = FastMath.abs(vars.vect1.getX()); box.yExtent = FastMath.abs(vars.vect1.getY()); box.zExtent = FastMath.abs(vars.vect1.getZ()); vars.release(); return box; }
tempMatrix.set(viewMatrix); tempMatrix.multLocal(worldMatrix); tempMatrix.toRotationMatrix(normalMatrix); normalMatrix.invertLocal(); normalMatrix.transposeLocal(); case WorldNormalMatrix: tempMatrix.set(worldMatrix); tempMatrix.toRotationMatrix(worldNormalMatrix); worldNormalMatrix.invertLocal(); worldNormalMatrix.transposeLocal(); break; case WorldMatrixInverseTranspose: worldMatrix.toRotationMatrix(worldMatrixInvTrsp); worldMatrixInvTrsp.invertLocal().transposeLocal(); u.setValue(VarType.Matrix3, worldMatrixInvTrsp); tempMatrix.set(viewMatrix); tempMatrix.multLocal(worldMatrix); tempMatrix.toRotationMatrix(normalMatrixInv); normalMatrixInv.invertLocal(); normalMatrixInv.transposeLocal();
public void toRotationQuat(Quaternion q) { q.fromRotationMatrix(toRotationMatrix()); }
public void toRotationQuat(Quaternion q) { q.fromRotationMatrix(toRotationMatrix()); }
public Quaternion toRotationQuat() { Quaternion quat = new Quaternion(); quat.fromRotationMatrix(toRotationMatrix()); return quat; }
public Quaternion toRotationQuat() { Quaternion quat = new Quaternion(); quat.fromRotationMatrix(toRotationMatrix()); return quat; }
private FloatBuffer getNormalMatrixBuf() { if (normalMatrixBufDirty) { TempVars tmp = TempVars.get(); tmp.tempMat4.set(viewMatrix); tmp.tempMat4.multLocal(worldMatrix); tmp.tempMat4.toRotationMatrix(tmp.tempMat3); tmp.tempMat3.invertLocal(); tmp.tempMat3.transposeLocal(); tmp.tempMat3.fillFloatBuffer(normalMatrixBuf, true); normalMatrixBuf.position(0); tmp.release(); normalMatrixBufDirty = false; } return worldViewProjectionMatrixBuf; } /**
private void updateInstance(Matrix4f worldMatrix, float[] store, int offset, Matrix3f tempMat3, Quaternion tempQuat) { worldMatrix.toRotationMatrix(tempMat3); tempMat3.invertLocal(); // NOTE: No need to take the transpose in order to encode // into quaternion, the multiplication in the shader is vec * quat // apparently... tempQuat.fromRotationMatrix(tempMat3); // Column-major encoding. The "W" field in each of the encoded // vectors represents the quaternion. store[offset + 0] = worldMatrix.m00; store[offset + 1] = worldMatrix.m10; store[offset + 2] = worldMatrix.m20; store[offset + 3] = tempQuat.getX(); store[offset + 4] = worldMatrix.m01; store[offset + 5] = worldMatrix.m11; store[offset + 6] = worldMatrix.m21; store[offset + 7] = tempQuat.getY(); store[offset + 8] = worldMatrix.m02; store[offset + 9] = worldMatrix.m12; store[offset + 10] = worldMatrix.m22; store[offset + 11] = tempQuat.getZ(); store[offset + 12] = worldMatrix.m03; store[offset + 13] = worldMatrix.m13; store[offset + 14] = worldMatrix.m23; store[offset + 15] = tempQuat.getW(); }
m2.setRotationQuaternion(bone.getModelSpaceRotation()); m2.multLocal(m); m2.toRotationMatrix(tmpMatrix3f); tmpQ.fromRotationMatrix(tmpMatrix3f); super.setPhysicsRotation(tmpQ); m2.setRotationQuaternion(centerBone.getModelSpaceRotation()); m2.multLocal(m); m2.toRotationMatrix(tmpMatrix3f); tmpQ.fromRotationMatrix(tmpMatrix3f); super.setPhysicsRotation(tmpQ);
m2.toRotationMatrix(tmpMatrix3f); bone.getModelSpaceRotation().fromRotationMatrix(tmpMatrix3f); m2.toRotationMatrix(tmpMatrix3f); bone.getModelSpaceRotation().fromRotationMatrix(tmpMatrix3f);
public BoundingVolume transform(Matrix4f trans, BoundingVolume store) { BoundingBox box; if (store == null || store.getType() != Type.AABB) { box = new BoundingBox(); } else { box = (BoundingBox) store; } TempVars vars = TempVars.get(); float w = trans.multProj(center, box.center); box.center.divideLocal(w); Matrix3f transMatrix = vars.tempMat3; trans.toRotationMatrix(transMatrix); // Make the rotation matrix all positive to get the maximum x/y/z extent transMatrix.absoluteLocal(); vars.vect1.set(xExtent, yExtent, zExtent); transMatrix.mult(vars.vect1, vars.vect1); // Assign the biggest rotations after scales. box.xExtent = FastMath.abs(vars.vect1.getX()); box.yExtent = FastMath.abs(vars.vect1.getY()); box.zExtent = FastMath.abs(vars.vect1.getZ()); vars.release(); return box; }
public BoundingVolume transform(Matrix4f trans, BoundingVolume store) { BoundingBox box; if (store == null || store.getType() != Type.AABB) { box = new BoundingBox(); } else { box = (BoundingBox) store; } TempVars vars = TempVars.get(); float w = trans.multProj(center, box.center); box.center.divideLocal(w); Matrix3f transMatrix = vars.tempMat3; trans.toRotationMatrix(transMatrix); // Make the rotation matrix all positive to get the maximum x/y/z extent transMatrix.absoluteLocal(); vars.vect1.set(xExtent, yExtent, zExtent); transMatrix.mult(vars.vect1, vars.vect1); // Assign the biggest rotations after scales. box.xExtent = FastMath.abs(vars.vect1.getX()); box.yExtent = FastMath.abs(vars.vect1.getY()); box.zExtent = FastMath.abs(vars.vect1.getZ()); vars.release(); return box; }
private void pushMatrix(Transform transform, DAENode node, MeasuringUnit unit) { TransformedValue<Matrix4f> matrix = node.getContent(MatrixTransformer.create()); if (matrix.isDefined()) { Vector3f vec = matrix.get().toTranslationVector().mult(unit.getMeter()); Matrix3f rotation = matrix.get().toRotationMatrix(); Vector3f scale = new Vector3f(rotation.getRow(0).length(), rotation.getRow(1).length(), rotation.getRow(2).length()); Transform t = new Transform(vec, matrix.get().toRotationQuat(), scale); t = t.combineWithParent(transform); transform.set(t); } else { Todo.task("where is my matrix?"); } }
tempMatrix.set(viewMatrix); tempMatrix.multLocal(worldMatrix); tempMatrix.toRotationMatrix(normalMatrix); normalMatrix.invertLocal(); normalMatrix.transposeLocal(); case WorldNormalMatrix: tempMatrix.set(worldMatrix); tempMatrix.toRotationMatrix(worldNormalMatrix); worldNormalMatrix.invertLocal(); worldNormalMatrix.transposeLocal(); break; case WorldMatrixInverseTranspose: worldMatrix.toRotationMatrix(worldMatrixInvTrsp); worldMatrixInvTrsp.invertLocal().transposeLocal(); u.setValue(VarType.Matrix3, worldMatrixInvTrsp); tempMatrix.set(viewMatrix); tempMatrix.multLocal(worldMatrix); tempMatrix.toRotationMatrix(normalMatrixInv); normalMatrixInv.invertLocal(); normalMatrixInv.transposeLocal();
tempMat4.set(viewMatrix); tempMat4.multLocal(worldMatrix); tempMat4.toRotationMatrix(tempMat3); tempMat3.invertLocal(); tempMat3.transposeLocal(); tempMat4.set(viewMatrix); tempMat4.multLocal(worldMatrix); tempMat4.toRotationMatrix(tempMat3); tempMat3.invertLocal(); tempMat3.transposeLocal();
frameInA.toTranslationVector(), frameInB.toTranslationVector(), frameInA.toRotationMatrix(), frameInB.toRotationMatrix(), true);