本文整理汇总了Java中com.jme3.math.Matrix4f.toTranslationVector方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix4f.toTranslationVector方法的具体用法?Java Matrix4f.toTranslationVector怎么用?Java Matrix4f.toTranslationVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.math.Matrix4f
的用法示例。
在下文中一共展示了Matrix4f.toTranslationVector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: controlUpdate
import com.jme3.math.Matrix4f; //导入方法依赖的package包/类
@Override
protected void controlUpdate(float tpf) {
for (int i = 0; i < boneMarkArray.length; i++) {
Matrix4f m = skeletonControl.getOffsetMatrices()[i].clone();
PMDBone bone = boneArray[i];
// if (bone.getBoneName().equals("右腕")) {
// Matrix4f m2 = boneMarkArray[i].getLocalToWorldMatrix(new Matrix4f()).clone();
// m.invertLocal();
// m.loadIdentity();
Vector3f bonePos = new Vector3f(bone.getBoneHeadPos().x,
bone.getBoneHeadPos().y,
bone.getBoneHeadPos().z);
// System.out.println("projectionMatrix = "+projectionMatrix);
// System.out.println("bonePos1 = "+bonePos);
m.mult(bonePos, bonePos);
// System.out.println("bonePos2 = "+bonePos);
Transform t = new Transform(m.toTranslationVector());
cam.getScreenCoordinates(bonePos, bonePos);
// System.out.println("bonePos3 = "+bonePos);
t.setTranslation(bonePos);
boneMarkArray[i].setLocalTransform(t);
// }
// System.out.println("m2 = "+m2);
}
}
示例2: getTransform
import com.jme3.math.Matrix4f; //导入方法依赖的package包/类
/**
* The method retreives the transform from a feature in a given space.
*
* @param oma
* the OMA of the feature (spatial or armature node)
* @param subtargetName
* the feature's subtarget (bone in a case of armature's node)
* @param space
* the space the transform is evaluated to
* @return thensform of a feature in a given space
*/
public Transform getTransform(Long oma, String subtargetName, Space space) {
Spatial feature = (Spatial) blenderContext.getLoadedFeature(oma, LoadedFeatureDataType.LOADED_FEATURE);
boolean isArmature = blenderContext.getMarkerValue(ArmatureHelper.ARMATURE_NODE_MARKER, feature) != null;
if (isArmature) {
BoneContext targetBoneContext = blenderContext.getBoneByName(subtargetName);
Bone bone = targetBoneContext.getBone();
switch (space) {
case CONSTRAINT_SPACE_WORLD:
return new Transform(bone.getModelSpacePosition(), bone.getModelSpaceRotation(), bone.getModelSpaceScale());
case CONSTRAINT_SPACE_LOCAL:
Transform localTransform = new Transform(bone.getLocalPosition(), bone.getLocalRotation());
localTransform.setScale(bone.getLocalScale());
return localTransform;
case CONSTRAINT_SPACE_POSE:
Node nodeWithAnimationControl = blenderContext.getControlledNode(targetBoneContext.getSkeleton());
Matrix4f m = this.toMatrix(nodeWithAnimationControl.getWorldTransform());
Matrix4f boneAgainstModifiedNodeMatrix = this.toMatrix(bone.getLocalPosition(), bone.getLocalRotation(), bone.getLocalScale());
Matrix4f boneWorldMatrix = m.multLocal(boneAgainstModifiedNodeMatrix);
Matrix4f armatureWorldMatrix = this.toMatrix(feature.getWorldTransform()).invertLocal();
Matrix4f r2 = armatureWorldMatrix.multLocal(boneWorldMatrix);
Vector3f loc2 = r2.toTranslationVector();
Quaternion rot2 = r2.toRotationQuat().normalizeLocal().multLocal(POS_POSE_SPACE_QUATERNION);
Vector3f scl2 = r2.toScaleVector();
return new Transform(loc2, rot2, scl2);
case CONSTRAINT_SPACE_PARLOCAL:
Matrix4f parentLocalMatrix = Matrix4f.IDENTITY;
if (bone.getParent() != null) {
Bone parent = bone.getParent();
parentLocalMatrix = this.toMatrix(parent.getLocalPosition(), parent.getLocalRotation(), parent.getLocalScale());
} else {
// we need to clone it because otherwise we could spoil
// the IDENTITY matrix
parentLocalMatrix = parentLocalMatrix.clone();
}
Matrix4f boneLocalMatrix = this.toMatrix(bone.getLocalPosition(), bone.getLocalRotation(), bone.getLocalScale());
Matrix4f result = parentLocalMatrix.multLocal(boneLocalMatrix);
Vector3f loc = result.toTranslationVector();
Quaternion rot = result.toRotationQuat().normalizeLocal().multLocal(NEG_PARLOC_SPACE_QUATERNION);
Vector3f scl = result.toScaleVector();
return new Transform(loc, rot, scl);
default:
throw new IllegalStateException("Unknown space type: " + space);
}
} else {
switch (space) {
case CONSTRAINT_SPACE_LOCAL:
return feature.getLocalTransform();
case CONSTRAINT_SPACE_WORLD:
return feature.getWorldTransform();
case CONSTRAINT_SPACE_PARLOCAL:
case CONSTRAINT_SPACE_POSE:
throw new IllegalStateException("Nodes can have only Local and World spaces applied!");
default:
throw new IllegalStateException("Unknown space type: " + space);
}
}
}