Package jme3utilities
Class MySkeleton
java.lang.Object
jme3utilities.MySkeleton
Utility methods for manipulating skeletonized spatials, armatures, armature
joints, skeletons, and skeleton bones.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcancelAttachments(com.jme3.anim.Joint joint) Cancel the attachments node (if any) of the specified Joint.static voidcancelAttachments(com.jme3.animation.Bone bone) Cancel the attachments node (if any) of the specified Bone.static com.jme3.math.TransformcopyBindTransform(com.jme3.animation.Bone bone, com.jme3.math.Transform storeResult) Copy the bind transform of the specified Bone.static com.jme3.math.TransformcopyLocalTransform(com.jme3.animation.Bone bone, com.jme3.math.Transform storeResult) Copy the transform of the specified Bone relative to its parent.static com.jme3.math.TransformcopyMeshTransform(com.jme3.animation.Bone bone, com.jme3.math.Transform storeResult) Copy the transform of the specified Bone relative to its mesh(es).static intcountLeafBones(com.jme3.animation.Skeleton skeleton) Count the leaf bones in the specified Skeleton.static intcountRootBones(com.jme3.animation.Skeleton skeleton) Count the root bones in the specified Skeleton.static intcountRootJoints(com.jme3.anim.Armature armature) Count the root joints in the specified Armature.static booleandescendsFrom(int boneIndex, int ancestorIndex, com.jme3.animation.Skeleton skeleton) Test whether the indexed bone descends from the indexed ancestor in the specified Skeleton.static com.jme3.animation.BoneFind a named Bone in a skeletonized Spatial.static com.jme3.animation.SkeletonfindSkeleton(com.jme3.scene.Spatial spatial) Find a Skeleton of the specified Spatial.static com.jme3.scene.NodegetAttachments(com.jme3.anim.Joint joint) Access the attachments node of the specified Joint.static com.jme3.scene.NodegetAttachments(com.jme3.animation.Bone bone) Access the attachments node of the specified Bone.static com.jme3.scene.GeometrygetTargetGeometry(com.jme3.anim.Joint joint) Access the target geometry of the specified Joint.static List<com.jme3.anim.Armature>listArmatures(com.jme3.scene.Spatial subtree, List<com.jme3.anim.Armature> addResult) Enumerate all Armature instances in the specified subtree of a scene graph.Enumerate all named bones in the specified skeleton.listBones(com.jme3.scene.Spatial spatial) Enumerate the names of all bones in a skeletonized spatial.static List<com.jme3.animation.Skeleton>listSkeletons(com.jme3.scene.Spatial subtree, List<com.jme3.animation.Skeleton> addResult) Enumerate all skeleton instances in the specified subtree of a scene graph.static Map<com.jme3.animation.Bone,com.jme3.scene.Spatial> mapAttachments(com.jme3.animation.Skeleton skeleton, Map<com.jme3.animation.Bone, com.jme3.scene.Spatial> storeResult) Map all attachments in the specified skeleton.static Map<com.jme3.animation.Bone,com.jme3.scene.Spatial> mapAttachments(com.jme3.scene.Spatial subtree, Map<com.jme3.animation.Bone, com.jme3.scene.Spatial> storeResult) Map all attachments nodes in the specified subtree of a scene graph.static List<com.jme3.animation.Bone>preOrderBones(com.jme3.animation.Skeleton skeleton) Enumerate all bones in a pre-order, depth-first traversal of the specified Skeleton, such that child bones never precede their ancestors.static List<com.jme3.anim.Joint>preOrderJoints(com.jme3.anim.Armature armature) Enumerate all joints in a pre-order, depth-first traversal of the specified Armature, such that child joints never precede their ancestors.static voidsetLocalTransform(com.jme3.animation.Bone bone, com.jme3.math.Transform transform) Alter the transform of the specified bone relative to its parent.static booleanRename of the specified bone.static voidsetUserControl(com.jme3.animation.Skeleton skeleton, boolean newSetting) Alter all the user-control flags in the specified Skeleton.static voidsetUserControl(com.jme3.scene.Spatial subtree, boolean newSetting) Alter all the user-control flags in the specified subtree of the scene graph.
-
Method Details
-
cancelAttachments
public static void cancelAttachments(com.jme3.animation.Bone bone) Cancel the attachments node (if any) of the specified Bone. The invoker is responsible for removing the Node from the scene graph.- Parameters:
bone- the Bone to modify (not null, modified)
-
cancelAttachments
public static void cancelAttachments(com.jme3.anim.Joint joint) Cancel the attachments node (if any) of the specified Joint. The invoker is responsible for removing the Node from the scene graph.- Parameters:
joint- the Joint to modify (not null, modified)
-
copyBindTransform
public static com.jme3.math.Transform copyBindTransform(com.jme3.animation.Bone bone, com.jme3.math.Transform storeResult) Copy the bind transform of the specified Bone.- Parameters:
bone- which Bone to read (not null, unaffected)storeResult- storage for the result (modified if not null)- Returns:
- the bone's bind transform (in its parent's coordinates, either storeResult or a new instance)
-
copyLocalTransform
public static com.jme3.math.Transform copyLocalTransform(com.jme3.animation.Bone bone, com.jme3.math.Transform storeResult) Copy the transform of the specified Bone relative to its parent.- Parameters:
bone- which Bone to read (not null, unaffected)storeResult- storage for the result (modified if not null)- Returns:
- the bone's Transform (in its parent's coordinates, either storeResult or a new instance)
-
copyMeshTransform
public static com.jme3.math.Transform copyMeshTransform(com.jme3.animation.Bone bone, com.jme3.math.Transform storeResult) Copy the transform of the specified Bone relative to its mesh(es).- Parameters:
bone- which Bone to read (not null, unaffected)storeResult- storage for the result (modified if not null)- Returns:
- the bone's Transform (in mesh coordinates, either storeResult or a new instance)
-
countLeafBones
public static int countLeafBones(com.jme3.animation.Skeleton skeleton) Count the leaf bones in the specified Skeleton.- Parameters:
skeleton- the Skeleton to read (not null, unaffected)- Returns:
- the count (≥0)
-
countRootBones
public static int countRootBones(com.jme3.animation.Skeleton skeleton) Count the root bones in the specified Skeleton.- Parameters:
skeleton- the Skeleton to read (not null, unaffected)- Returns:
- the count (≥0)
-
countRootJoints
public static int countRootJoints(com.jme3.anim.Armature armature) Count the root joints in the specified Armature.- Parameters:
armature- the Armature to read (not null, unaffected)- Returns:
- the count (≥0)
-
descendsFrom
public static boolean descendsFrom(int boneIndex, int ancestorIndex, com.jme3.animation.Skeleton skeleton) Test whether the indexed bone descends from the indexed ancestor in the specified Skeleton.- Parameters:
boneIndex- the index of Bone to test (≥0)ancestorIndex- the index of the ancestor Bone (≥0)skeleton- the Skeleton to read (not null, unaffected)- Returns:
- true if descends from the ancestor, otherwise false
-
findBone
Find a named Bone in a skeletonized Spatial.- Parameters:
spatial- the skeletonized Spatial to search (not null, alias created)boneName- the name of the Bone to access (not null)- Returns:
- a pre-existing instance, or null if not found
-
findSkeleton
public static com.jme3.animation.Skeleton findSkeleton(com.jme3.scene.Spatial spatial) Find a Skeleton of the specified Spatial.- Parameters:
spatial- the Spatial to search (not null, alias created)- Returns:
- a pre-existing instance, or null if none found
-
getAttachments
public static com.jme3.scene.Node getAttachments(com.jme3.animation.Bone bone) Access the attachments node of the specified Bone.Unlike
SkeletonControl.getAttachmentsNode(java.lang.String)this won't add a node to the scene graph.- Parameters:
bone- the Bone to read (not null, unaffected)- Returns:
- the pre-existing instance, or null if none
-
getAttachments
public static com.jme3.scene.Node getAttachments(com.jme3.anim.Joint joint) Access the attachments node of the specified Joint.Unlike Joint.getAttachmentsNode(), this won't add a node to the scene graph.
- Parameters:
joint- the Joint to read (not null, unaffected)- Returns:
- the pre-existing instance, or null if none
-
getTargetGeometry
public static com.jme3.scene.Geometry getTargetGeometry(com.jme3.anim.Joint joint) Access the target geometry of the specified Joint.- Parameters:
joint- the Joint to read (not null, unaffected)- Returns:
- the pre-existing instance, or null if none
-
listArmatures
public static List<com.jme3.anim.Armature> listArmatures(com.jme3.scene.Spatial subtree, List<com.jme3.anim.Armature> addResult) Enumerate all Armature instances in the specified subtree of a scene graph. Note: recursive!- Parameters:
subtree- (not null, aliases created)addResult- storage for results (added to if not null)- Returns:
- an expanded list (either storeResult or a new instance)
-
listBones
Enumerate all named bones in the specified skeleton.- Parameters:
skeleton- the skeleton to search (not null, unaffected)addResult- storage for results (added to if not null)- Returns:
- a list of names in arbitrary order, without any duplicates (either addResult or a new list)
-
listBones
Enumerate the names of all bones in a skeletonized spatial.- Parameters:
spatial- skeletonized spatial (not null, unaffected)- Returns:
- a new list of names in lexicographic order, without any duplicates (may be empty)
-
listSkeletons
public static List<com.jme3.animation.Skeleton> listSkeletons(com.jme3.scene.Spatial subtree, List<com.jme3.animation.Skeleton> addResult) Enumerate all skeleton instances in the specified subtree of a scene graph. Note: recursive!- Parameters:
subtree- (not null, aliases created)addResult- storage for results (added to if not null)- Returns:
- an expanded list (either storeResult or a new instance)
-
mapAttachments
public static Map<com.jme3.animation.Bone,com.jme3.scene.Spatial> mapAttachments(com.jme3.animation.Skeleton skeleton, Map<com.jme3.animation.Bone, com.jme3.scene.Spatial> storeResult) Map all attachments in the specified skeleton.- Parameters:
skeleton- the skeleton to search (not null, unaffected)storeResult- storage for results (added to if not null)- Returns:
- an expanded map (either storeResult or a new instance)
-
mapAttachments
public static Map<com.jme3.animation.Bone,com.jme3.scene.Spatial> mapAttachments(com.jme3.scene.Spatial subtree, Map<com.jme3.animation.Bone, com.jme3.scene.Spatial> storeResult) Map all attachments nodes in the specified subtree of a scene graph.- Parameters:
subtree- (not null, unaffected)storeResult- storage for results (added to if not null)- Returns:
- an expanded map (either storeResult or a new instance)
-
preOrderBones
Enumerate all bones in a pre-order, depth-first traversal of the specified Skeleton, such that child bones never precede their ancestors.- Parameters:
skeleton- the Skeleton to traverse (not null, unaffected)- Returns:
- a new list of pre-existing bones
-
preOrderJoints
Enumerate all joints in a pre-order, depth-first traversal of the specified Armature, such that child joints never precede their ancestors.- Parameters:
armature- the Armature to traverse (not null, unaffected)- Returns:
- a new list of pre-existing joints
-
setName
Rename of the specified bone. The caller is responsible for avoiding duplicate names.- Parameters:
bone- the Bone to rename (not null, modified)newName- the desired name- Returns:
- true if successful, otherwise false
-
setLocalTransform
public static void setLocalTransform(com.jme3.animation.Bone bone, com.jme3.math.Transform transform) Alter the transform of the specified bone relative to its parent. User control is temporarily overridden. The model transform is not updated.- Parameters:
bone- which bone to use (not null, unaffected)transform- the desired bone transform (in its parent's coordinates, not null, unaffected)
-
setUserControl
public static void setUserControl(com.jme3.animation.Skeleton skeleton, boolean newSetting) Alter all the user-control flags in the specified Skeleton.- Parameters:
skeleton- the Skeleton to alter (not null, modified)newSetting- true to select user control, false to select animation control
-
setUserControl
public static void setUserControl(com.jme3.scene.Spatial subtree, boolean newSetting) Alter all the user-control flags in the specified subtree of the scene graph.- Parameters:
subtree- subtree to alter (not null)newSetting- true to enable user control, false to disable
-