本文整理了Java中com.jme3.scene.Spatial.getWorldTransform()
方法的一些代码示例,展示了Spatial.getWorldTransform()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Spatial.getWorldTransform()
方法的具体详情如下:
包路径:com.jme3.scene.Spatial
类名称:Spatial
方法名:getWorldTransform
[英]getWorldTransform
retrieves the world transformation of the spatial.
[中]getWorldTransform
检索空间的世界变换。
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Update this control. Invoked once per frame, during the logical-state
* update, provided the control is added to a scene.
*
* @param tpf the time interval between frames (in seconds, ≥0)
*/
public void update(float tpf) {
if (enabled && spatial != null) {
if (getMotionState().applyTransform(spatial)) {
spatial.getWorldTransform();
applyWheelTransforms();
}
} else if (enabled) {
applyWheelTransforms();
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Update this control. Invoked once per frame, during the logical-state
* update, provided the control is added to a scene.
*
* @param tpf the time interval between frames (in seconds, ≥0)
*/
public void update(float tpf) {
if (enabled && spatial != null) {
if (getMotionState().applyTransform(spatial)) {
spatial.getWorldTransform();
applyWheelTransforms();
}
} else if (enabled) {
applyWheelTransforms();
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public ArmatureDebugger addArmatureFrom(Armature armature, Spatial forSpatial) {
ArmatureDebugger ad = armatures.get(armature);
if(ad != null){
return ad;
}
JointInfoVisitor visitor = new JointInfoVisitor(armature);
forSpatial.depthFirstTraversal(visitor);
ad = new ArmatureDebugger(forSpatial.getName() + "_Armature", armature, visitor.deformingJoints);
ad.setLocalTransform(forSpatial.getWorldTransform());
if (forSpatial instanceof Node) {
List<Geometry> geoms = new ArrayList<>();
findGeoms((Node) forSpatial, geoms);
if (geoms.size() == 1) {
ad.setLocalTransform(geoms.get(0).getWorldTransform());
}
}
armatures.put(armature, ad);
debugNode.attachChild(ad);
if (isInitialized()) {
ad.initialize(app.getAssetManager(), app.getCamera());
}
return ad;
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
Spatial armature = (Spatial) objectHelper.toObject(armatureStructure, blenderContext);
ConstraintHelper constraintHelper = blenderContext.getHelper(ConstraintHelper.class);
Matrix4f armatureWorldMatrix = constraintHelper.toMatrix(armature.getWorldTransform(), new Matrix4f());
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Alter the transforms of a rigidBody to match the transforms of a bone.
* This is used to make the ragdoll follow animated motion in Kinematic mode
*
* @param link the bone link connecting the bone and the rigidBody
* @param position temporary storage used in calculations (not null)
* @param tmpRot1 temporary storage used in calculations (not null)
*/
protected void matchPhysicObjectToBone(PhysicsBoneLink link, Vector3f position, Quaternion tmpRot1) {
//computing position from rotation and scale
targetModel.getWorldTransform().transformVector(link.bone.getModelSpacePosition(), position);
//computing rotation
tmpRot1.set(link.bone.getModelSpaceRotation()).multLocal(link.bone.getModelBindInverseRotation());
targetModel.getWorldRotation().mult(tmpRot1, tmpRot1);
tmpRot1.normalizeLocal();
//updating physics location/rotation of the physics bone
link.rigidBody.setPhysicsLocation(position);
link.rigidBody.setPhysicsRotation(tmpRot1);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Alter the transforms of a rigidBody to match the transforms of a bone.
* This is used to make the ragdoll follow animated motion in Kinematic mode
*
* @param link the bone link connecting the bone and the rigidBody
* @param position temporary storage used in calculations (not null)
* @param tmpRot1 temporary storage used in calculations (not null)
*/
protected void matchPhysicObjectToBone(PhysicsBoneLink link, Vector3f position, Quaternion tmpRot1) {
//computing position from rotation and scale
targetModel.getWorldTransform().transformVector(link.bone.getModelSpacePosition(), position);
//computing rotation
tmpRot1.set(link.bone.getModelSpaceRotation()).multLocal(link.bone.getModelBindInverseRotation());
targetModel.getWorldRotation().mult(tmpRot1, tmpRot1);
tmpRot1.normalizeLocal();
//updating physics location/rotation of the physics bone
link.rigidBody.setPhysicsLocation(position);
link.rigidBody.setPhysicsRotation(tmpRot1);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
Spatial model = (Spatial) blenderContext.getLoadedFeature(targetBoneContext.getSkeletonOwnerOma(), LoadedDataType.FEATURE);
Matrix4f boneModelMatrix = this.toMatrix(bone.getModelSpacePosition(), bone.getModelSpaceRotation(), bone.getModelSpaceScale(), tempVars.tempMat4);
Matrix4f modelWorldMatrix = this.toMatrix(model.getWorldTransform(), tempVars.tempMat42);
Matrix4f boneMatrixInWorldSpace = modelWorldMatrix.multLocal(boneModelMatrix);
result = new Transform(boneMatrixInWorldSpace.toTranslationVector(), boneMatrixInWorldSpace.toRotationQuat(), boneMatrixInWorldSpace.toScaleVector());
case CONSTRAINT_SPACE_POSE: {
Matrix4f boneWorldMatrix = this.toMatrix(this.getTransform(oma, subtargetName, Space.CONSTRAINT_SPACE_WORLD), tempVars.tempMat4);
Matrix4f armatureInvertedWorldMatrix = this.toMatrix(feature.getWorldTransform(), tempVars.tempMat42).invertLocal();
Matrix4f bonePoseMatrix = armatureInvertedWorldMatrix.multLocal(boneWorldMatrix);
result = new Transform(bonePoseMatrix.toTranslationVector(), bonePoseMatrix.toRotationQuat(), bonePoseMatrix.toScaleVector());
Matrix4f armatureInvertedWorldMatrix = this.toMatrix(feature.getWorldTransform(), tempVars.tempMat42).invertLocal();
Matrix4f bonePoseMatrix = armatureInvertedWorldMatrix.multLocal(boneWorldMatrix);
result = new Transform(bonePoseMatrix.toTranslationVector(), bonePoseMatrix.toRotationQuat(), bonePoseMatrix.toScaleVector());
return feature.getLocalTransform();
case CONSTRAINT_SPACE_WORLD:
return feature.getWorldTransform();
case CONSTRAINT_SPACE_PARLOCAL:
case CONSTRAINT_SPACE_POSE:
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
Vector3f position = vars.vect1;
targetModel.getWorldTransform().transformInverseVector(p, position);
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
Vector3f position = vars.vect1;
targetModel.getWorldTransform().transformInverseVector(p, position);
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
targetModel.getWorldTransform().transformInverseVector(p, position);
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
targetModel.getWorldTransform().transformInverseVector(p, position);
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
Matrix4f armatureWorldMatrix = this.toMatrix(feature.getWorldTransform(), tempVars.tempMat4);
Matrix4f boneMatrixInWorldSpace = armatureWorldMatrix.multLocal(this.toMatrix(transform, tempVars.tempMat42));
Matrix4f invertedModelMatrix = this.toMatrix(this.getTransform(targetBoneContext.getSkeletonOwnerOma(), null, Space.CONSTRAINT_SPACE_WORLD), tempVars.tempMat42).invertLocal();
Matrix4f armatureWorldMatrix = this.toMatrix(feature.getWorldTransform(), tempVars.tempMat4);
Matrix4f boneMatrixInWorldSpace = armatureWorldMatrix.multLocal(this.toMatrix(transform, tempVars.tempMat42));
Matrix4f invertedModelMatrix = this.toMatrix(this.getTransform(targetBoneContext.getSkeletonOwnerOma(), null, Space.CONSTRAINT_SPACE_WORLD), tempVars.tempMat42).invertLocal();
代码示例来源:origin: org.jmonkeyengine/jme3-bullet
public void update(float tpf) {
if (enabled && spatial != null) {
if (getMotionState().applyTransform(spatial)) {
spatial.getWorldTransform();
applyWheelTransforms();
}
} else if (enabled) {
applyWheelTransforms();
}
}
代码示例来源:origin: info.projectkyoto/mms-engine
public void update(float tpf) {
if (enabled && spatial != null) {
if (getMotionState().applyTransform(spatial)) {
spatial.getWorldTransform();
applyWheelTransforms();
}
} else if (enabled) {
applyWheelTransforms();
}
}
代码示例来源:origin: org.jmonkeyengine/jme3-plugins
private void setupControls() {
for (SkinData skinData : skinnedSpatials.keySet()) {
List<Spatial> spatials = skinnedSpatials.get(skinData);
Spatial spatial = skinData.parent;
if (spatials.isEmpty()) {
continue;
}
if (spatials.size() >= 1) {
spatial = findCommonAncestor(spatials);
}
if (skinData.parent != null && spatial != skinData.parent) {
skinData.rootBoneTransformOffset = spatial.getWorldTransform().invert();
skinData.rootBoneTransformOffset.combineWithParent(skinData.parent.getWorldTransform());
}
if (skinData.animControl != null && skinData.animControl.getSpatial() == null) {
spatial.addControl(skinData.animControl);
}
spatial.addControl(skinData.skeletonControl);
}
for (int i = 0; i < nodes.size(); i++) {
BoneWrapper bw = fetchFromCache("nodes", i, BoneWrapper.class);
if (bw == null || bw.attachedSpatial == null) {
continue;
}
SkinData skinData = fetchFromCache("skins", bw.skinIndex, SkinData.class);
skinData.skeletonControl.getAttachmentsNode(bw.bone.getName()).attachChild(bw.attachedSpatial);
}
}
代码示例来源:origin: org.jmonkeyengine/jme3-jbullet
/**
* Update this control. Invoked once per frame, during the logical-state
* update, provided the control is added to a scene.
*
* @param tpf the time interval between frames (in seconds, ≥0)
*/
public void update(float tpf) {
if (enabled && spatial != null) {
if (getMotionState().applyTransform(spatial)) {
spatial.getWorldTransform();
applyWheelTransforms();
}
} else if (enabled) {
applyWheelTransforms();
}
}
代码示例来源:origin: org.jmonkeyengine/jme3-core
public SkeletonDebugger addSkeleton(Skeleton skeleton, Spatial forSpatial, boolean guessBonesOrientation) {
SkeletonDebugger sd = new SkeletonDebugger(forSpatial.getName() + "_Skeleton", skeleton, guessBonesOrientation);
sd.setLocalTransform(forSpatial.getWorldTransform());
if (forSpatial instanceof Node) {
List<Geometry> geoms = new ArrayList<>();
findGeoms((Node) forSpatial, geoms);
if (geoms.size() == 1) {
sd.setLocalTransform(geoms.get(0).getWorldTransform());
}
}
skeletons.put(skeleton, sd);
debugNode.attachChild(sd);
if (isInitialized()) {
sd.initialize(app.getAssetManager());
}
return sd;
}
代码示例来源:origin: info.projectkyoto/mms-engine
/**
* Set the transforms of a rigidBody to match the transforms of a bone.
* this is used to make the ragdoll follow the skeleton motion while in Kinematic mode
* @param link the link containing the bone and the rigidBody
* @param position just a temp vector for position
* @param tmpRot1 just a temp quaternion for rotation
*/
private void matchPhysicObjectToBone(PhysicsBoneLink link, Vector3f position, Quaternion tmpRot1) {
//computing position from rotation and scale
targetModel.getWorldTransform().transformVector(link.bone.getModelSpacePosition(), position);
//computing rotation
tmpRot1.set(link.bone.getModelSpaceRotation()).multLocal(link.bone.getWorldBindInverseRotation());
targetModel.getWorldRotation().mult(tmpRot1, tmpRot1);
tmpRot1.normalizeLocal();
//updating physic location/rotation of the physic bone
link.rigidBody.setPhysicsLocation(position);
link.rigidBody.setPhysicsRotation(tmpRot1);
}
代码示例来源:origin: org.jmonkeyengine/jme3-jbullet
/**
* Alter the transforms of a rigidBody to match the transforms of a bone.
* This is used to make the ragdoll follow animated motion in Kinematic mode
*
* @param link the bone link connecting the bone and the rigidBody
* @param position temporary storage used in calculations (not null)
* @param tmpRot1 temporary storage used in calculations (not null)
*/
protected void matchPhysicObjectToBone(PhysicsBoneLink link, Vector3f position, Quaternion tmpRot1) {
//computing position from rotation and scale
targetModel.getWorldTransform().transformVector(link.bone.getModelSpacePosition(), position);
//computing rotation
tmpRot1.set(link.bone.getModelSpaceRotation()).multLocal(link.bone.getModelBindInverseRotation());
targetModel.getWorldRotation().mult(tmpRot1, tmpRot1);
tmpRot1.normalizeLocal();
//updating physics location/rotation of the physics bone
link.rigidBody.setPhysicsLocation(position);
link.rigidBody.setPhysicsRotation(tmpRot1);
}
代码示例来源:origin: org.jmonkeyengine/jme3-bullet
/**
* Set the transforms of a rigidBody to match the transforms of a bone. this
* is used to make the ragdoll follow the skeleton motion while in Kinematic
* mode
*
* @param link the link containing the bone and the rigidBody
* @param position just a temp vector for position
* @param tmpRot1 just a temp quaternion for rotation
*/
protected void matchPhysicObjectToBone(PhysicsBoneLink link, Vector3f position, Quaternion tmpRot1) {
//computing position from rotation and scale
targetModel.getWorldTransform().transformVector(link.bone.getModelSpacePosition(), position);
//computing rotation
tmpRot1.set(link.bone.getModelSpaceRotation()).multLocal(link.bone.getModelBindInverseRotation());
targetModel.getWorldRotation().mult(tmpRot1, tmpRot1);
tmpRot1.normalizeLocal();
//updating physic location/rotation of the physic bone
link.rigidBody.setPhysicsLocation(position);
link.rigidBody.setPhysicsRotation(tmpRot1);
}
内容来源于网络,如有侵权,请联系作者删除!