Package 

Class Animator


  • 
    public class Animator
    
                        

    Updates matrices according to glTF animation and skin definitions.

    Animator is owned by FilamentAsset and can be used for two things:

    • Updating matrices in TransformManager components according to glTF animation definitions.
    • Updating bone matrices in RenderableManager components according to glTF skin definitions.
    • Method Summary

      Modifier and Type Method Description
      void applyAnimation(@IntRange(from = 0) int animationIndex, float time) Applies rotation, translation, and scale to entities that have been targeted by the givenanimation definition.
      void updateBoneMatrices() Computes root-to-node transforms for all bone nodes, then passes the results into setBonesAsMatrices.
      void applyCrossFade(int previousAnimIndex, float previousAnimTime, float alpha) Applies a blended transform to the union of nodes affected by two animations.Used for cross-fading from a previous skinning-based animation or rigid body animation.First, this stashes the current transform hierarchy into a transient memory buffer.Next, this applies previousAnimIndex / previousAnimTime to the actual asset by internallycalling applyAnimation().Finally, the stashed local transforms are lerped (via the scale / translation / rotationcomponents) with their live counterparts, and the results are pushed to the asset.To achieve a cross fade effect with skinned models, clients will typically call animatormethods in this order: (1) applyAnimation (2) applyCrossFade (3) updateBoneMatrices.
      void resetBoneMatrices() Pass the identity matrix into all bone nodes, useful for returning to the T pose.
      int getAnimationCount() Returns the number of animation definitions in the glTF asset.
      float getAnimationDuration(@IntRange(from = 0) int animationIndex) Returns the duration of the specified glTF animation in seconds.
      String getAnimationName(@IntRange(from = 0) int animationIndex) Returns a weak reference to the string name of the specified animation, or anempty string if none was specified.
      • Methods inherited from class java.lang.Object

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

      • applyAnimation

         void applyAnimation(@IntRange(from = 0) int animationIndex, float time)

        Applies rotation, translation, and scale to entities that have been targeted by the givenanimation definition. Uses TransformManager.

        Parameters:
        animationIndex - Zero-based index for the animation of interest.
        time - Elapsed time of interest in seconds.
      • updateBoneMatrices

         void updateBoneMatrices()

        Computes root-to-node transforms for all bone nodes, then passes the results into setBonesAsMatrices.Uses TransformManager and RenderableManager.

        NOTE: this operation is independent of animation.

      • applyCrossFade

         void applyCrossFade(int previousAnimIndex, float previousAnimTime, float alpha)

        Applies a blended transform to the union of nodes affected by two animations.Used for cross-fading from a previous skinning-based animation or rigid body animation.First, this stashes the current transform hierarchy into a transient memory buffer.Next, this applies previousAnimIndex / previousAnimTime to the actual asset by internallycalling applyAnimation().Finally, the stashed local transforms are lerped (via the scale / translation / rotationcomponents) with their live counterparts, and the results are pushed to the asset.To achieve a cross fade effect with skinned models, clients will typically call animatormethods in this order: (1) applyAnimation (2) applyCrossFade (3) updateBoneMatrices. Theanimation that clients pass to applyAnimation is the "current" animation corresponding toalpha=1, while the "previous" animation passed to applyCrossFade corresponds to alpha=0.

      • resetBoneMatrices

         void resetBoneMatrices()

        Pass the identity matrix into all bone nodes, useful for returning to the T pose.

        NOTE: this operation is independent of animation.

      • getAnimationCount

         int getAnimationCount()

        Returns the number of animation definitions in the glTF asset.

      • getAnimationDuration

         float getAnimationDuration(@IntRange(from = 0) int animationIndex)

        Returns the duration of the specified glTF animation in seconds.

        Parameters:
        animationIndex - Zero-based index for the animation of interest.
      • getAnimationName

         String getAnimationName(@IntRange(from = 0) int animationIndex)

        Returns a weak reference to the string name of the specified animation, or anempty string if none was specified.

        Parameters:
        animationIndex - Zero-based index for the animation of interest.