@Override public void onAction(String name, boolean isPressed, float tpf) { if (isPressed) { composer.reset(); armature.applyBindPose(); } else { composer.setCurrentAction("anim"); } } }, "bind");
/** * Saves the current Armature state as its bind pose. * Note that the bind pose is supposed to be the one where the armature is aligned with the mesh to deform. * Saving this pose will affect how skinning works. */ public void saveBindPose() { //make sure all bones are updated update(); //Save the current pose as bind pose for (Joint joint : jointList) { joint.saveBindPose(); } }
public static void padJointTracks(List<TransformTrack> tracks, Joint staticJoint) { Joint j = staticJoint; if (j != null) { // joint has no track , we create one with the default pose float[] times = new float[]{0}; Vector3f[] translations = new Vector3f[]{j.getLocalTranslation()}; Quaternion[] rotations = new Quaternion[]{j.getLocalRotation()}; Vector3f[] scales = new Vector3f[]{j.getLocalScale()}; TransformTrack track = new TransformTrack(j, times, translations, rotations, scales); tracks.add(track); } }
public static ArmatureMask createMask(Armature armature, String... joints) { ArmatureMask mask = new ArmatureMask(); mask.addBones(armature, joints); for (String joint : joints) { mask.affectedJoints.set(armature.getJoint(joint).getId()); } return mask; }
private void recurseAddJoint(Joint joint) { affectedJoints.set(joint.getId()); for (Joint j : joint.getChildren()) { recurseAddJoint(j); } }
/** * Creates a transform track for the given bone index * * @param times a float array with the time of each frame * @param translations the translation of the bone for each frame * @param rotations the rotation of the bone for each frame * @param scales the scale of the bone for each frame */ public TransformTrack(HasLocalTransform target, float[] times, Vector3f[] translations, Quaternion[] rotations, Vector3f[] scales) { this.target = target; this.setKeyframes(times, translations, rotations, scales); }
public static ArmatureMask createMask(Armature armature, String fromJoint) { ArmatureMask mask = new ArmatureMask(); mask.addFromJoint(armature, fromJoint); return mask; }
/** * Add a joint and all its sub armature joints to be influenced by this animation mask. */ public void addFromJoint(Armature armature, String jointName) { Joint joint = findJoint(armature, jointName); recurseAddJoint(joint); }
@Override public void onAction(String name, boolean isPressed, float tpf) { if (isPressed) { composer.setCurrentAction("Wave", "LeftArm"); } } }, "mask");
@Override protected void controlUpdate(float tpf) { wasMeshUpdated = false; armature.update(); }
/** * This methods sets this armature in its bind pose (aligned with the mesh to deform) * Note that this is only useful for debugging purpose. */ public void applyBindPose() { for (Joint joint : rootJoints) { joint.applyBindPose(); } }
/** * Applies the initial pose to this armature */ public void applyInitialPose() { for (Joint rootJoint : rootJoints) { rootJoint.applyInitialPose(); } }
/** * Creates a morph track with the given Geometry as a target * * @param times a float array with the time of each frame * @param weights the morphs for each frames */ public MorphTrack(Geometry target, float[] times, float[] weights, int nbMorphTargets) { this.target = target; this.nbMorphTargets = nbMorphTargets; this.setKeyframes(times, weights); }
/** * Update all joints sin this Amature. */ public void update() { for (Joint rootJoint : rootJoints) { rootJoint.update(); } }
/** * Compute the skinning matrices for each bone of the armature that would be used to transform vertices of associated meshes * * @return */ public Matrix4f[] computeSkinningMatrices() { for (int i = 0; i < jointList.length; i++) { jointList[i].getOffsetTransform(skinningMatrixes[i]); } return skinningMatrixes; }
private void ensureTmpArraysCapacity(int capacity, int targetNumBuffers) { if (targetNumBuffers >= 1) { tmpPosArray = ensureCapacity(tmpPosArray, capacity); } if (targetNumBuffers >= 2) { tmpNormArray = ensureCapacity(tmpNormArray, capacity); } if (!approximateTangents && targetNumBuffers == 3) { tmpTanArray = ensureCapacity(tmpTanArray, capacity); } }
/** * Saves the current local transform as the initial transform. * Initial transform is the one applied to the armature when loaded. */ public void saveInitialPose() { for (Joint joint : jointList) { joint.saveInitialPose(); } }
@Override public void onAction(String name, boolean isPressed, float tpf) { if (isPressed) { composer.reset(); armature.applyBindPose(); } else { composer.setCurrentAction("anim"); } } }, "bind");