Class Pose

  • All Implemented Interfaces:
    com.jme3.util.clone.JmeCloneable, java.lang.Cloneable

    public class Pose
    extends java.lang.Object
    implements com.jme3.util.clone.JmeCloneable
    Encapsulate a pose for a specific Armature or Skeleton.
    • Constructor Summary

      Constructors 
      Constructor Description
      Pose​(com.jme3.anim.Armature armature)
      Instantiate bind pose for the specified Armature.
      Pose​(com.jme3.animation.Skeleton skeleton)
      Instantiate bind pose for the specified Skeleton.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void applyTo​(com.jme3.anim.Armature targetArmature)
      Apply this Pose to the specified Armature.
      void applyTo​(com.jme3.animation.Skeleton targetSkeleton)
      Apply this Pose to the specified Skeleton.
      com.jme3.math.Transform bindTransform​(int boneIndex, com.jme3.math.Transform storeResult)
      Copy the local bind transform of the indexed joint/bone.
      com.jme3.animation.Animation capture​(java.lang.String animationName)
      Convert this Pose to an Animation.
      com.jme3.anim.AnimClip captureToClip​(java.lang.String clipName)
      Convert this Pose to a new AnimClip.
      void cloneFields​(com.jme3.util.clone.Cloner cloner, java.lang.Object original)
      Convert this shallow-cloned instance into a deep-cloned one, using the specified cloner and original to resolve copied fields.
      int countBones()
      Count the joints/bones in this Pose.
      int findBone​(java.lang.String boneName)
      Find the index of the named joint/bone in this Pose.
      java.lang.Object findSkeleton()
      Access the Armature or Skeleton, if known.
      Pose jmeClone()
      Create a shallow clone for the JME cloner.
      com.jme3.math.Quaternion localRotation​(int boneIndex, com.jme3.math.Quaternion storeResult)
      Calculate the local rotation of the indexed joint/bone.
      com.jme3.math.Transform localTransform​(int boneIndex, com.jme3.math.Transform storeResult)
      Calculate the local transform of the indexed joint/bone.
      com.jme3.math.Vector3f modelLocation​(int boneIndex, com.jme3.math.Vector3f storeResult)
      Calculate the location of the indexed bone in the coordinate system of an animated spatial.
      com.jme3.math.Quaternion modelOrientation​(int boneIndex, com.jme3.math.Quaternion storeResult)
      Calculate the orientation of the indexed joint/bone in the coordinate system of an animated spatial.
      com.jme3.math.Transform modelTransform​(int boneIndex, com.jme3.math.Transform storeResult)
      Calculate the model transform of the indexed joint/bone.
      static Pose newInstance​(com.jme3.scene.control.AbstractControl sControl)
      Instantiate bind pose for the specified SkeletonControl or SkinningControl.
      int[] preOrderIndices()
      Enumerate all bones/joints in a pre-order depth-first traversal of the skeleton/armature, such that child bones/joints are never visited before their ancestors.
      void resetRotation​(int boneIndex)
      Reset the user/animation rotation of the indexed joint/bone to identity.
      void resetScale​(int boneIndex)
      Reset the user/animation scale of the indexed joint/bone to identity.
      void resetTranslation​(int boneIndex)
      Reset the user/animation translation of the indexed joint/bone to zero.
      int[] rootBoneIndices()
      Enumerate all root bones/joints in the skeleton/armature.
      void set​(int boneIndex, com.jme3.math.Transform transform)
      Alter the user/animation transform of the indexed joint/bone.
      void setRotation​(int boneIndex, com.jme3.math.Quaternion rotation)
      Alter the user/animation rotation of the indexed joint/bone.
      void setScale​(int boneIndex, com.jme3.math.Vector3f scale)
      Alter the user/animation scale of the indexed joint/bone.
      void setToAnimation​(com.jme3.animation.Animation animation, float time, TweenTransforms techniques)
      Configure this Pose for the specified Animation at the specified time.
      void setToBind()
      Configure this Pose to represent bind pose.
      void setToClip​(com.jme3.anim.AnimClip clip, double time)
      Configure this Pose for the specified AnimClip at the specified time.
      void setToRetarget​(Pose sourcePose, SkeletonMapping map)
      Configure this Pose by re-targeting the specified source pose.
      void setTranslation​(int boneIndex, com.jme3.math.Vector3f translation)
      Alter the user/animation translation of the indexed joint/bone.
      com.jme3.math.Matrix4f[] skin​(com.jme3.math.Matrix4f[] storeResult)
      Calculate skinning matrices for this Pose.
      com.jme3.math.Transform userForLocal​(int boneIndex, com.jme3.math.Transform localTransform, com.jme3.math.Transform storeResult)
      Determine the user/animation Transform for the indexed joint/bone to give it the specified local Transform.
      com.jme3.math.Quaternion userForModel​(int boneIndex, com.jme3.math.Quaternion modelOrientation, com.jme3.math.Quaternion storeResult)
      Calculate the user/animation rotation for the indexed joint/bone to give it the specified orientation in the coordinate system of an animated spatial.
      com.jme3.math.Quaternion userRotation​(int boneIndex, com.jme3.math.Quaternion storeResult)
      Copy the user/animation rotation of the indexed joint/bone.
      com.jme3.math.Vector3f userScale​(int boneIndex, com.jme3.math.Vector3f storeResult)
      Copy the user/animation scale of the indexed joint/bone.
      com.jme3.math.Transform userTransform​(int boneIndex, com.jme3.math.Transform storeResult)
      Copy the user/animation transform of the indexed joint/bone.
      com.jme3.math.Vector3f userTranslation​(int boneIndex, com.jme3.math.Vector3f storeResult)
      Copy the user/animation translation of the indexed joint/bone.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Pose

        public Pose​(com.jme3.anim.Armature armature)
        Instantiate bind pose for the specified Armature.
        Parameters:
        armature - (may be null, otherwise an alias is created)
      • Pose

        public Pose​(com.jme3.animation.Skeleton skeleton)
        Instantiate bind pose for the specified Skeleton.
        Parameters:
        skeleton - (may be null, otherwise an alias is created)
    • Method Detail

      • applyTo

        public void applyTo​(com.jme3.anim.Armature targetArmature)
        Apply this Pose to the specified Armature.
        Parameters:
        targetArmature - the Armature to modify (not null)
      • applyTo

        public void applyTo​(com.jme3.animation.Skeleton targetSkeleton)
        Apply this Pose to the specified Skeleton.
        Parameters:
        targetSkeleton - the Skeleton to modify (not null)
      • bindTransform

        public com.jme3.math.Transform bindTransform​(int boneIndex,
                                                     com.jme3.math.Transform storeResult)
        Copy the local bind transform of the indexed joint/bone.
        Parameters:
        boneIndex - which joint/bone (≥0)
        storeResult - storage for the result (modified if not null)
        Returns:
        transform (either storeResult or a new instance)
      • capture

        public com.jme3.animation.Animation capture​(java.lang.String animationName)
        Convert this Pose to an Animation. The resulting Animation will have zero duration, a single keyframe at t=0, and all its tracks will be BoneTracks.
        Parameters:
        animationName - name for the new Animation (not null)
        Returns:
        a new instance
      • captureToClip

        public com.jme3.anim.AnimClip captureToClip​(java.lang.String clipName)
        Convert this Pose to a new AnimClip. The result will have zero duration, a single keyframe at t=0, and all its tracks will be TransformTracks.
        Parameters:
        clipName - name for the new clip (not null)
        Returns:
        a new instance
      • countBones

        public int countBones()
        Count the joints/bones in this Pose.
        Returns:
        count (≥0)
      • findBone

        public int findBone​(java.lang.String boneName)
        Find the index of the named joint/bone in this Pose.
        Parameters:
        boneName - which joint/bone (not null)
        Returns:
        the joint/bone index (≥0) or -1 if not found
      • findSkeleton

        public java.lang.Object findSkeleton()
        Access the Armature or Skeleton, if known.
        Returns:
        the pre-existing instance, or null
      • localRotation

        public com.jme3.math.Quaternion localRotation​(int boneIndex,
                                                      com.jme3.math.Quaternion storeResult)
        Calculate the local rotation of the indexed joint/bone.
        Parameters:
        boneIndex - which joint/bone (≥0)
        storeResult - storage for the result (modified if not null)
        Returns:
        the rotation in local coordinates (either storeResult or a new instance)
      • localTransform

        public com.jme3.math.Transform localTransform​(int boneIndex,
                                                      com.jme3.math.Transform storeResult)
        Calculate the local transform of the indexed joint/bone.
        Parameters:
        boneIndex - which joint/bone (≥0)
        storeResult - storage for the result (modified if not null)
        Returns:
        the Transform in local coordinates (either storeResult or a new instance)
      • modelLocation

        public com.jme3.math.Vector3f modelLocation​(int boneIndex,
                                                    com.jme3.math.Vector3f storeResult)
        Calculate the location of the indexed bone in the coordinate system of an animated spatial.
        Parameters:
        boneIndex - which bone (≥0)
        storeResult - storage for the result (modified if not null)
        Returns:
        location in model space (either storeResult or a new instance)
      • modelOrientation

        public com.jme3.math.Quaternion modelOrientation​(int boneIndex,
                                                         com.jme3.math.Quaternion storeResult)
        Calculate the orientation of the indexed joint/bone in the coordinate system of an animated spatial.
        Parameters:
        boneIndex - which joint/bone (≥0)
        storeResult - storage for the result (modified if not null)
        Returns:
        orientation in model space (either storeResult or a new instance)
      • modelTransform

        public com.jme3.math.Transform modelTransform​(int boneIndex,
                                                      com.jme3.math.Transform storeResult)
        Calculate the model transform of the indexed joint/bone. When applied as a left factor, the model transform converts from the joint/bone local coordinate system to the coordinate system of an animated spatial.
        Parameters:
        boneIndex - which joint/bone (≥0)
        storeResult - storage for the result (modified if not null)
        Returns:
        transform (either storeResult or a new instance)
      • newInstance

        public static Pose newInstance​(com.jme3.scene.control.AbstractControl sControl)
        Instantiate bind pose for the specified SkeletonControl or SkinningControl.
        Parameters:
        sControl - the Control to use (not null, must be a SkeletonControl or a SkinningControl)
        Returns:
        a new instance
      • preOrderIndices

        public int[] preOrderIndices()
        Enumerate all bones/joints in a pre-order depth-first traversal of the skeleton/armature, such that child bones/joints are never visited before their ancestors.
        Returns:
        a new array of joint/bone indices
      • resetRotation

        public void resetRotation​(int boneIndex)
        Reset the user/animation rotation of the indexed joint/bone to identity.
        Parameters:
        boneIndex - which joint/bone (≥0)
      • resetScale

        public void resetScale​(int boneIndex)
        Reset the user/animation scale of the indexed joint/bone to identity.
        Parameters:
        boneIndex - which joint/bone (≥0)
      • resetTranslation

        public void resetTranslation​(int boneIndex)
        Reset the user/animation translation of the indexed joint/bone to zero.
        Parameters:
        boneIndex - which joint/bone (≥0)
      • rootBoneIndices

        public int[] rootBoneIndices()
        Enumerate all root bones/joints in the skeleton/armature.
        Returns:
        a new array of indices
      • set

        public void set​(int boneIndex,
                        com.jme3.math.Transform transform)
        Alter the user/animation transform of the indexed joint/bone.
        Parameters:
        boneIndex - which joint/bone to transform (≥0)
        transform - the desired Transform (not null, unaffected)
      • setRotation

        public void setRotation​(int boneIndex,
                                com.jme3.math.Quaternion rotation)
        Alter the user/animation rotation of the indexed joint/bone.
        Parameters:
        boneIndex - which joint/bone to rotate (≥0)
        rotation - the desired rotation (not null, unaffected)
      • setScale

        public void setScale​(int boneIndex,
                             com.jme3.math.Vector3f scale)
        Alter the user/animation scale of the indexed joint/bone.
        Parameters:
        boneIndex - which joint/bone to scale (≥0)
        scale - the desired scale factor for each axis (not null, unaffected)
      • setToAnimation

        public void setToAnimation​(com.jme3.animation.Animation animation,
                                   float time,
                                   TweenTransforms techniques)
        Configure this Pose for the specified Animation at the specified time.
        Parameters:
        animation - which Animation (not null, unaffected)
        time - the animation time (in seconds)
        techniques - the tweening techniques to use (not null, unaffected)
      • setToBind

        public void setToBind()
        Configure this Pose to represent bind pose.
      • setToClip

        public void setToClip​(com.jme3.anim.AnimClip clip,
                              double time)
        Configure this Pose for the specified AnimClip at the specified time.
        Parameters:
        clip - which AnimClip (not null, unaffected)
        time - the animation time (in seconds)
      • setToRetarget

        public void setToRetarget​(Pose sourcePose,
                                  SkeletonMapping map)
        Configure this Pose by re-targeting the specified source pose.
        Parameters:
        sourcePose - which source pose to re-target (not null, unaffected)
        map - the skeleton map to use (not null, unaffected)
      • setTranslation

        public void setTranslation​(int boneIndex,
                                   com.jme3.math.Vector3f translation)
        Alter the user/animation translation of the indexed joint/bone.
        Parameters:
        boneIndex - which joint/bone to translate (≥0)
        translation - the desired translation (not null, unaffected)
      • skin

        public com.jme3.math.Matrix4f[] skin​(com.jme3.math.Matrix4f[] storeResult)
        Calculate skinning matrices for this Pose.
        Parameters:
        storeResult - storage for the results (modified if not null)
        Returns:
        skinning matrices (either storeResult or a new instance)
      • userForLocal

        public com.jme3.math.Transform userForLocal​(int boneIndex,
                                                    com.jme3.math.Transform localTransform,
                                                    com.jme3.math.Transform storeResult)
        Determine the user/animation Transform for the indexed joint/bone to give it the specified local Transform.
        Parameters:
        boneIndex - the index of the subject bone/joint (≥0)
        localTransform - the desired local Transform (not null)
        storeResult - storage for the result (modified if not null, may be localTransform)
        Returns:
        the required user Transform (either storeResult or a new instance)
      • userForModel

        public com.jme3.math.Quaternion userForModel​(int boneIndex,
                                                     com.jme3.math.Quaternion modelOrientation,
                                                     com.jme3.math.Quaternion storeResult)
        Calculate the user/animation rotation for the indexed joint/bone to give it the specified orientation in the coordinate system of an animated spatial.
        Parameters:
        boneIndex - which joint/bone (≥0)
        modelOrientation - desired orientation (not null, not zero, unaffected)
        storeResult - storage for the result (modified if not null)
        Returns:
        transform (either storeResult or a new instance)
      • userRotation

        public com.jme3.math.Quaternion userRotation​(int boneIndex,
                                                     com.jme3.math.Quaternion storeResult)
        Copy the user/animation rotation of the indexed joint/bone.
        Parameters:
        boneIndex - which joint/bone (≥0)
        storeResult - storage for the result (modified if not null)
        Returns:
        the user rotation (either storeResult or a new instance)
      • userScale

        public com.jme3.math.Vector3f userScale​(int boneIndex,
                                                com.jme3.math.Vector3f storeResult)
        Copy the user/animation scale of the indexed joint/bone.
        Parameters:
        boneIndex - which joint/bone (≥0)
        storeResult - storage for the result (modified if not null)
        Returns:
        the user scale factor for each axis (either storeResult or a new instance)
      • userTransform

        public com.jme3.math.Transform userTransform​(int boneIndex,
                                                     com.jme3.math.Transform storeResult)
        Copy the user/animation transform of the indexed joint/bone.
        Parameters:
        boneIndex - which joint/bone (≥0)
        storeResult - storage for the result (modified if not null)
        Returns:
        transform (either storeResult or a new instance)
      • userTranslation

        public com.jme3.math.Vector3f userTranslation​(int boneIndex,
                                                      com.jme3.math.Vector3f storeResult)
        Copy the user/animation translation of the indexed joint/bone.
        Parameters:
        boneIndex - which joint/bone (≥0)
        storeResult - storage for the result (modified if not null)
        Returns:
        user translation (either storeResult or a new instance)
      • cloneFields

        public void cloneFields​(com.jme3.util.clone.Cloner cloner,
                                java.lang.Object original)
        Convert this shallow-cloned instance into a deep-cloned one, using the specified cloner and original to resolve copied fields.
        Specified by:
        cloneFields in interface com.jme3.util.clone.JmeCloneable
        Parameters:
        cloner - the cloner currently cloning this control (not null)
        original - the control from which this control was shallow-cloned (not null)
      • jmeClone

        public Pose jmeClone()
        Create a shallow clone for the JME cloner.
        Specified by:
        jmeClone in interface com.jme3.util.clone.JmeCloneable
        Returns:
        a new instance