/** * Resets the node's feature to its starting transformation. */ private void reset() { if (spatial != null) { spatial.setLocalTransform(spatialStartTransform); for (SimulationNode child : children) { child.reset(); } } else if (skeleton != null) { for (Entry<Bone, Transform> entry : boneStartTransforms.entrySet()) { Transform t = entry.getValue(); entry.getKey().setBindTransforms(t.getTranslation(), t.getRotation(), t.getScale()); entry.getKey().updateModelTransforms(); } skeleton.reset(); } }
public Bone getJmeBone() { if (bone == null) { bone = new Bone(name); bone.setBindTransforms(jmeLocalBindPose.getTranslation(), jmeLocalBindPose.getRotation(), jmeLocalBindPose.getScale()); } return bone; } }
public void buildBindPoseBoneTransform() { if(bone != null) { Matrix4f t = bindTransform; if(t != null) { Matrix4f parentMatrix = parentFbxNode != null ? parentFbxNode.bindTransform : Matrix4f.IDENTITY; if(parentMatrix == null) parentMatrix = node.getLocalToWorldMatrix(null); t = parentMatrix.invert().multLocal(t); bone.setBindTransforms(t.toTranslationVector(), t.toRotationQuat(), t.toScaleVector()); } else { bone.setBindTransforms(node.getLocalTranslation(), node.getLocalRotation(), node.getLocalScale()); } } }
bone.setBindTransforms(Vector3f.ZERO, Quaternion.IDENTITY, Vector3f.UNIT_XYZ); bone.setUserControl(true); skeleton = new Skeleton(new Bone[]{ bone });
Vector3f scale = boneLocalMatrix.toScaleVector(); bone.setBindTransforms(poseLocation, rotation, scale); for (BoneContext child : children) { bone.addChild(child.buildBone(bones, skeletonOwnerOma, blenderContext));
case CONSTRAINT_SPACE_LOCAL: assert bone.getParent() != null : "CONSTRAINT_SPACE_LOCAL should be evaluated as CONSTRAINT_SPACE_POSE if the bone has no parent!"; bone.setBindTransforms(transform.getTranslation(), transform.getRotation(), transform.getScale()); break; case CONSTRAINT_SPACE_WORLD: { boneMatrixInModelSpace = parentMatrixInModelSpace.invertLocal().multLocal(boneMatrixInModelSpace); bone.setBindTransforms(boneMatrixInModelSpace.toTranslationVector(), boneMatrixInModelSpace.toRotationQuat(), boneMatrixInModelSpace.toScaleVector()); break; boneMatrixInModelSpace = parentMatrixInModelSpace.invertLocal().multLocal(boneMatrixInModelSpace); bone.setBindTransforms(boneMatrixInModelSpace.toTranslationVector(), boneMatrixInModelSpace.toRotationQuat(), boneMatrixInModelSpace.toScaleVector()); break; bone.setBindTransforms(boneMatrixInModelSpace.toTranslationVector(), boneMatrixInModelSpace.toRotationQuat(), boneMatrixInModelSpace.toScaleVector()); break; default:
axis = null; } else if (qName.equals("bone")) { bone.setBindTransforms(position, rotation, scale); bone = null; position = null;
axis = null; } else if (qName.equals("bone")) { bone.setBindTransforms(position, rotation, scale); bone = null; position = null;
axis = null; } else if (qName.equals("bone")) { bone.setBindTransforms(position, rotation, scale); bone = null; position = null;
public Bone getJmeBone() { if (bone == null) { bone = new Bone(name); bone.setBindTransforms(jmeLocalBindPose.getTranslation(), jmeLocalBindPose.getRotation(), jmeLocalBindPose.getScale()); } return bone; } }
public void buildBindPoseBoneTransform() { if(bone != null) { Matrix4f t = bindTransform; if(t != null) { Matrix4f parentMatrix = parentFbxNode != null ? parentFbxNode.bindTransform : Matrix4f.IDENTITY; if(parentMatrix == null) parentMatrix = node.getLocalToWorldMatrix(null); t = parentMatrix.invert().multLocal(t); bone.setBindTransforms(t.toTranslationVector(), t.toRotationQuat(), t.toScaleVector()); } else { bone.setBindTransforms(node.getLocalTranslation(), node.getLocalRotation(), node.getLocalScale()); } } }
Bone bone = new Bone(limb.name); Transform t = limb.bindTransform; bone.setBindTransforms(t.getTranslation(), t.getRotation(), t.getScale()); bones.put(limbId, bone);
v1.subtractLocal(v2); bone.setBindTransforms(v1, Quaternion.IDENTITY, new Vector3f(1, 1, 1)); } else { bone.setBindTransforms(v1, Quaternion.IDENTITY, new Vector3f(1, 1, 1));
public void resetToBind() { for (int i = 0; i < skeleton.getBoneCount(); i++) { Bone bone = skeleton.getBone(i); PMDBone pmdBone = pmdModel.getBoneList().getBones()[i]; if (pmdBone.getParentBoneIndex() < skeleton.getBoneCount()) { Bone parentBone = skeleton.getBone(pmdBone.getParentBoneIndex()); PMDBone parentPMDBone = pmdModel.getBoneList().getBones()[pmdBone.getParentBoneIndex()]; // parentBone.addChild(bone); Vector3f v1 = new Vector3f(); Vector3f v2 = new Vector3f(); v1.set(pmdBone.getBoneHeadPos().x, pmdBone.getBoneHeadPos().y, pmdBone.getBoneHeadPos().z); v2.set(parentPMDBone.getBoneHeadPos().x, parentPMDBone.getBoneHeadPos().y, parentPMDBone.getBoneHeadPos().z); v1.subtractLocal(v2); bone.setBindTransforms(v1, Quaternion.IDENTITY, new Vector3f(1, 1, 1)); } else { Vector3f v1 = new Vector3f(); v1.set(pmdBone.getBoneHeadPos().x, pmdBone.getBoneHeadPos().y, pmdBone.getBoneHeadPos().z); bone.setBindTransforms(v1, Quaternion.IDENTITY, new Vector3f(1, 1, 1)); } } for (PMDMesh mesh : targets) { resetToBind(mesh); } for (Skin skin : skinArray) { skin.setWeight(0f); } setUpdateNeeded(true); }
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); } }
Vector3f bindTrans = matrices[i].toTranslationVector(); Vector3f bindScale = Vector3f.UNIT_XYZ; jmeBones[i].setBindTransforms(bindTrans, bindRot, bindScale); boneNodes[i].setParsedData(jmeBones[i]);
bone.setBindTransforms(new Vector3f(0, 0, 0), new Quaternion(Quaternion.IDENTITY), new Vector3f(Vector3f.UNIT_XYZ));