@Override public Matrix4f getPose() { Matrix4f mat = new Matrix4f(); mat.setRotationQuaternion(getOrientation()); mat.setTranslation(getPosition()); return mat; } }
/** * Converts given transformation parameters into the matrix. * * @param position * the position of the feature * @param rotation * the rotation of the feature * @param scale * the scale of the feature * @param store * the matrix where the result will be stored * @return the store matrix */ private Matrix4f toMatrix(Vector3f position, Quaternion rotation, Vector3f scale, Matrix4f store) { store.loadIdentity(); store.setTranslation(position); store.setRotationQuaternion(rotation); store.setScale(scale); return store; }
/** * Fetches the world matrix transformation of the given node. * @param node * the node * @return the node's world transformation matrix */ private Matrix4f getWorldMatrix(Node node) { Matrix4f result = new Matrix4f(); result.setTranslation(node.getWorldTranslation()); result.setRotationQuaternion(node.getWorldRotation()); result.setScale(node.getWorldScale()); return result; }
@Override protected Matrix4f getTransformMatrix(Geometry g){ // Compute the Local matrix for the geometry cachedLocalMat.loadIdentity(); cachedLocalMat.setRotationQuaternion(g.localTransform.getRotation()); cachedLocalMat.setTranslation(g.localTransform.getTranslation()); TempVars vars = TempVars.get(); Matrix4f scaleMat = vars.tempMat4; scaleMat.loadIdentity(); scaleMat.scale(g.localTransform.getScale()); cachedLocalMat.multLocal(scaleMat); vars.release(); return cachedLocalMat; }
/** * Recomputes the matrix returned by {@link Geometry#getWorldMatrix() }. * This will require a localized transform update for this geometry. */ public void computeWorldMatrix() { // Force a local update of the geometry's transform checkDoTransformUpdate(); // Compute the cached world matrix cachedWorldMat.loadIdentity(); if (ignoreTransform) { return; } cachedWorldMat.setRotationQuaternion(worldTransform.getRotation()); cachedWorldMat.setTranslation(worldTransform.getTranslation()); TempVars vars = TempVars.get(); Matrix4f scaleMat = vars.tempMat4; scaleMat.loadIdentity(); scaleMat.scale(worldTransform.getScale()); cachedWorldMat.multLocal(scaleMat); vars.release(); }
hmdRelativeEyePoses[eye].setRotationQuaternion(rotation);
/** * This method transforms the first line of the bevel points positioning it * on the first point of the curve. * * @param startingLinePoints * the vbevel shape points * @param firstCurvePoint * the first curve's point * @param secondCurvePoint * the second curve's point * @return points of transformed bevel */ protected Vector3f[] transformToFirstLineOfBevelPoints(Vector3f[] startingLinePoints, Vector3f firstCurvePoint, Vector3f secondCurvePoint) { Vector3f planeNormal = secondCurvePoint.subtract(firstCurvePoint).normalizeLocal(); float angle = FastMath.acos(planeNormal.dot(Vector3f.UNIT_X)); Vector3f rotationVector = Vector3f.UNIT_X.cross(planeNormal).normalizeLocal(); Matrix4f m = new Matrix4f(); m.setRotationQuaternion(new Quaternion().fromAngleAxis(angle, rotationVector)); m.setTranslation(firstCurvePoint); Vector3f temp = new Vector3f(); Vector3f[] verts = new Vector3f[startingLinePoints.length]; for (int i = 0; i < verts.length; ++i) { verts[i] = m.mult(startingLinePoints[i], temp).clone(); } return verts; } }
rotationMat.setRotationQuaternion(jmeLocalNodeTransform.getRotation());
public Matrix4f toTransformMatrix() { Matrix4f trans = new Matrix4f(); trans.setTranslation(translation); trans.setRotationQuaternion(rot); trans.setScale(scale); return trans; }
@Override protected Matrix4f getTransformMatrix(Geometry g){ // Compute the Local matrix for the geometry cachedLocalMat.loadIdentity(); cachedLocalMat.setRotationQuaternion(g.localTransform.getRotation()); cachedLocalMat.setTranslation(g.localTransform.getTranslation()); TempVars vars = TempVars.get(); Matrix4f scaleMat = vars.tempMat4; scaleMat.loadIdentity(); scaleMat.scale(g.localTransform.getScale()); cachedLocalMat.multLocal(scaleMat); vars.release(); return cachedLocalMat; }
@Override protected Matrix4f getTransformMatrix(Geometry g){ // Compute the Local matrix for the geometry cachedLocalMat.loadIdentity(); cachedLocalMat.setRotationQuaternion(g.localTransform.getRotation()); cachedLocalMat.setTranslation(g.localTransform.getTranslation()); TempVars vars = TempVars.get(); Matrix4f scaleMat = vars.tempMat4; scaleMat.loadIdentity(); scaleMat.scale(g.localTransform.getScale()); cachedLocalMat.multLocal(scaleMat); vars.release(); return cachedLocalMat; }
/** * Recomputes the matrix returned by {@link Geometry#getWorldMatrix() }. * This will require a localized transform update for this geometry. */ public void computeWorldMatrix() { // Force a local update of the geometry's transform checkDoTransformUpdate(); // Compute the cached world matrix cachedWorldMat.loadIdentity(); cachedWorldMat.setRotationQuaternion(worldTransform.getRotation()); cachedWorldMat.setTranslation(worldTransform.getTranslation()); TempVars vars = TempVars.get(); Matrix4f scaleMat = vars.tempMat4; scaleMat.loadIdentity(); scaleMat.scale(worldTransform.getScale()); cachedWorldMat.multLocal(scaleMat); vars.release(); }
m2.setRotationQuaternion(bone.getModelSpaceRotation()); m2.multLocal(m); m2.toRotationMatrix(tmpMatrix3f); m2.setRotationQuaternion(centerBone.getModelSpaceRotation()); m2.multLocal(m); m2.toRotationMatrix(tmpMatrix3f);
/** * Recomputes the matrix returned by {@link Geometry#getWorldMatrix() }. * This will require a localized transform update for this geometry. */ public void computeOffsetTransform() { // Compute the cached world matrix cachedOffsetMat.loadIdentity(); cachedOffsetMat.setRotationQuaternion(prevLocalTransform.getRotation()); cachedOffsetMat.setTranslation(prevLocalTransform.getTranslation()); TempVars vars = TempVars.get(); Matrix4f scaleMat = vars.tempMat4; scaleMat.loadIdentity(); scaleMat.scale(prevLocalTransform.getScale()); cachedOffsetMat.multLocal(scaleMat); cachedOffsetMat.invertLocal(); tmpMat.loadIdentity(); tmpMat.setRotationQuaternion(localTransform.getRotation()); tmpMat.setTranslation(localTransform.getTranslation()); scaleMat.loadIdentity(); scaleMat.scale(localTransform.getScale()); tmpMat.multLocal(scaleMat); tmpMat.mult(cachedOffsetMat,cachedOffsetMat); vars.release(); }
super.getPhysicsLocation(tmpV); super.getPhysicsRotation(tmpQ); m2.setRotationQuaternion(tmpQ); m2.setTranslation(tmpV); m2.multLocal(invM); super.getPhysicsLocation(tmpV); super.getPhysicsRotation(tmpQ); m2.setRotationQuaternion(tmpQ); m2.setTranslation(tmpV); m2.multLocal(invM);
/** * Recomputes the matrix returned by {@link Geometry#getWorldMatrix() }. * This will require a localized transform update for this geometry. */ public void computeWorldMatrix() { // Force a local update of the geometry's transform checkDoTransformUpdate(); // Compute the cached world matrix cachedWorldMat.loadIdentity(); if (ignoreTransform) { return; } cachedWorldMat.setRotationQuaternion(worldTransform.getRotation()); cachedWorldMat.setTranslation(worldTransform.getTranslation()); TempVars vars = TempVars.get(); Matrix4f scaleMat = vars.tempMat4; scaleMat.loadIdentity(); scaleMat.scale(worldTransform.getScale()); cachedWorldMat.multLocal(scaleMat); vars.release(); }
rotationMat.setRotationQuaternion(jmeLocalNodeTransform.getRotation());
private void computeBindTransforms(BoneWrapper boneWrapper, Skeleton skeleton) { Bone bone = boneWrapper.bone; tmpTransforms.fromTransformMatrix(boneWrapper.modelBindMatrix); if (bone.getParent() != null) { //root bone, model transforms are the same as the local transforms //but for child bones we need to combine it with the parents inverse model transforms. tmpMat.setTranslation(bone.getParent().getModelSpacePosition()); tmpMat.setRotationQuaternion(bone.getParent().getModelSpaceRotation()); tmpMat.setScale(bone.getParent().getModelSpaceScale()); tmpMat.invertLocal(); tmpTransforms2.fromTransformMatrix(tmpMat); tmpTransforms.combineWithParent(tmpTransforms2); } bone.setBindTransforms(tmpTransforms.getTranslation(), tmpTransforms.getRotation(), tmpTransforms.getScale()); //resets the local transforms to bind transforms for all bones. //then computes the model transforms from local transforms for each bone. skeleton.resetAndUpdate(); skeleton.setBindingPose(); for (Integer childIndex : boneWrapper.children) { BoneWrapper child = fetchFromCache("nodes", childIndex, BoneWrapper.class); computeBindTransforms(child, skeleton); } }
trans.setRotationQuaternion(q); trans.setTranslation(pmdJoint.getJointPos().x, pmdJoint.getJointPos().y, transA.loadIdentity(); transA.setRotationQuaternion(rba.getPhysicsRotation()); transA.setTranslation(rba.getPhysicsLocation()); transB.setRotationQuaternion(rbb.getPhysicsRotation()); transB.invertLocal(); transB.multLocal(trans); q.fromRotationMatrix(m2); transJ.setRotationQuaternion(q); centerA.setRotationQuaternion(rba.getPhysicsRotation()); centerA.setTranslation(rba.getPhysicsLocation()); Matrix4f invCenterA = centerA.invert(); centerB.setRotationQuaternion(rbb.getPhysicsRotation()); centerB.setTranslation(rbb.getPhysicsLocation()); Matrix4f invCenterB = centerB.invert();
trans2.setRotationQuaternion(q); trans2.setTranslation(v); trans.setRotationQuaternion(q); trans.setTranslation(v); CollisionShape cs;