Class Armature
- All Implemented Interfaces:
Savable
,JmeCloneable
,Cloneable
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
This method sets this armature to its bind pose (aligned with the mesh to deform).void
Applies the initial pose to this armaturevoid
cloneFields
(Cloner cloner, Object original) Implemented to perform deep cloning for this object, resolving local cloned references using the specified cloner.Matrix4f[]
Compute the skinning matrices for each bone of the armature that would be used to transform vertices of associated meshesgetJoint
(int index) return a joint for the given indexreturns the joint with the given nameint
returns the number of joints of this armatureint
getJointIndex
(Joint joint) returns the bone index of the given boneint
getJointIndex
(String name) returns the joint index of the joint that has the given nameAccess all joints in this Armature.Joint[]
getRoots()
returns the array of all root joints of this ArmaturejmeClone()
Performs a regular shallow clone of the object.void
read
(JmeImporter im) De-serialize this Armature from the specified importer, for example when loading from a J3O file.void
Saves the current Armature state as its bind pose.void
Saves the current local transform as the initial transform.void
setModelTransformClass
(Class<? extends JointModelTransform> modelTransformClass) Sets the JointModelTransform implementation Default isMatrixJointModelTransform
void
update()
Update all joints in this Armature.void
write
(JmeExporter ex) Serialize this Armature to the specified exporter, for example when saving to a J3O file.
-
Constructor Details
-
Armature
protected Armature()Serialization only -
Armature
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
Sets the JointModelTransform implementation Default isMatrixJointModelTransform
- Parameters:
modelTransformClass
- which implementation to use- See Also:
-
getRoots
returns the array of all root joints of this Armature- Returns:
- the pre-existing array
-
getJointList
Access all joints in this Armature.- Returns:
- a new list of pre-existing joints
-
getJoint
return a joint for the given index- Parameters:
index
- a zero-based joint index (≥0)- Returns:
- the pre-existing instance
-
getJoint
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
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
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
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
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 interfaceJmeCloneable
- Returns:
- a new instance
-
cloneFields
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 interfaceJmeCloneable
- 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
De-serialize this Armature from the specified importer, for example when loading from a J3O file.- Specified by:
read
in interfaceSavable
- Parameters:
im
- the importer to read from (not null)- Throws:
IOException
- from the importer
-
write
Serialize this Armature to the specified exporter, for example when saving to a J3O file.- Specified by:
write
in interfaceSavable
- Parameters:
ex
- the exporter to write to (not null)- Throws:
IOException
- from the exporter
-