Package com.jme3.anim

Class Armature

java.lang.Object
com.jme3.anim.Armature
All Implemented Interfaces:
Savable, JmeCloneable, Cloneable

public class Armature extends Object implements JmeCloneable, Savable
Created by Nehon on 15/12/2017.
  • Constructor Details

    • Armature

      protected Armature()
      Serialization only
    • Armature

      public Armature(Joint[] jointList)
      Creates an armature from a joint list. The root joints are found automatically.

      Note that using this constructor will cause the joints in the list to have their bind pose recomputed based on their local transforms.

      Parameters:
      jointList - The list of joints to manage by this Armature
  • Method Details

    • update

      public void update()
      Update all joints in this Armature.
    • setModelTransformClass

      public void setModelTransformClass(Class<? extends JointModelTransform> modelTransformClass)
      Sets the JointModelTransform implementation Default is MatrixJointModelTransform
      Parameters:
      modelTransformClass - which implementation to use
      See Also:
    • getRoots

      public Joint[] getRoots()
      returns the array of all root joints of this Armature
      Returns:
      the pre-existing array
    • getJointList

      public List<Joint> getJointList()
      Access all joints in this Armature.
      Returns:
      a new list of pre-existing joints
    • getJoint

      public Joint getJoint(int index)
      return a joint for the given index
      Parameters:
      index - a zero-based joint index (≥0)
      Returns:
      the pre-existing instance
    • getJoint

      public Joint getJoint(String name)
      returns the joint with the given name
      Parameters:
      name - the name to search for
      Returns:
      the pre-existing instance or null if not found
    • getJointIndex

      public int getJointIndex(Joint joint)
      returns the bone index of the given bone
      Parameters:
      joint - the Joint to search for
      Returns:
      the index (≥0) or -1 if not found
    • getJointIndex

      public int getJointIndex(String name)
      returns the joint index of the joint that has the given name
      Parameters:
      name - the name to search for
      Returns:
      the index (≥0) or -1 if not found
    • saveBindPose

      public void saveBindPose()
      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.
    • applyBindPose

      public void applyBindPose()
      This method sets this armature to its bind pose (aligned with the mesh to deform). Note that this is only useful for debugging purpose.
    • saveInitialPose

      public void saveInitialPose()
      Saves the current local transform as the initial transform. Initial transform is the one applied to the armature when loaded.
    • applyInitialPose

      public void applyInitialPose()
      Applies the initial pose to this armature
    • computeSkinningMatrices

      public Matrix4f[] computeSkinningMatrices()
      Compute the skinning matrices for each bone of the armature that would be used to transform vertices of associated meshes
      Returns:
      the pre-existing array
    • getJointCount

      public int getJointCount()
      returns the number of joints of this armature
      Returns:
      the count (≥0)
    • jmeClone

      public Object jmeClone()
      Description copied from interface: JmeCloneable
      Performs a regular shallow clone of the object. Some fields may also be cloned but generally only if they will never be shared with other objects. (For example, local Vector3fs and so on.)

      This method is separate from the regular clone() method so that objects might still maintain their own regular java clone() semantics (perhaps even using Cloner for those methods). However, because Java's clone() has specific features in the sense of Object's clone() implementation, it's usually best to have some path for subclasses to bypass the public clone() method that might be cloning fields and instead get at the superclass protected clone() methods. For example, through super.jmeClone() or another protected clone method that some base class eventually calls super.clone() in.

      Specified by:
      jmeClone in interface JmeCloneable
      Returns:
      a new instance
    • cloneFields

      public void cloneFields(Cloner cloner, Object original)
      Description copied from interface: JmeCloneable
      Implemented to perform deep cloning for this object, resolving local cloned references using the specified cloner. The object can call cloner.clone(fieldValue) to deep clone any of its fields.

      Note: during normal clone operations the original object will not be needed as the clone has already had all of the fields shallow copied.

      Specified by:
      cloneFields in interface JmeCloneable
      Parameters:
      cloner - The cloner that is performing the cloning operation. The cloneFields method can call back into the cloner to make clones of its subordinate fields.
      original - The original object from which this object was cloned. This is provided for the very rare case that this object needs to refer to its original for some reason. In general, all of the relevant values should have been transferred during the shallow clone, and this object need only clone what it wants.
    • read

      public void read(JmeImporter im) throws IOException
      De-serialize this Armature from the specified importer, for example when loading from a J3O file.
      Specified by:
      read in interface Savable
      Parameters:
      im - the importer to read from (not null)
      Throws:
      IOException - from the importer
    • write

      public void write(JmeExporter ex) throws IOException
      Serialize this Armature to the specified exporter, for example when saving to a J3O file.
      Specified by:
      write in interface Savable
      Parameters:
      ex - the exporter to write to (not null)
      Throws:
      IOException - from the exporter