Interface AnimatableModel

  • All Known Implementing Classes:
    RenderableInstance

    public interface AnimatableModel
    An AnimatableModel is an object whose properties can be animated by an ModelAnimation. The object animation transformation can be done at the desired frame callback place. ModelAnimation updates the value (like in a standard ObjectAnimator context) or to apply them inside a global/common frame callback.

    An AnimatableModel can, for example, update the data of each animated property managed by an Animator.

    • Method Detail

      • getAnimation

        ModelAnimation getAnimation​(int animationIndex)
        Get the associated ModelAnimation at the given index or throw an IndexOutOfBoundsException.
        Parameters:
        animationIndex - Zero-based index for the animation of interest.
      • getAnimationCount

        int getAnimationCount()
        Returns the number of ModelAnimation definitions in the model.
      • onModelAnimationChanged

        default void onModelAnimationChanged​(ModelAnimation animation)
        Called form the ModelAnimation when it dirty state changed.
      • applyAnimationChange

        boolean applyAnimationChange​(ModelAnimation animation)
        Occurs when a ModelAnimation has received any property changed.
        Depending on the returned value, the ModelAnimation will set his isDirty to false or not.
        You can choose between applying changes on the ObjectAnimator Choreographer.FrameCallback or use your own Choreographer to handle an update/render update hierarchy.
        Time position should be applied inside a global Choreographer frame callback to ensure that the transformations are applied in a hierarchical order.
        Returns:
        true is the changes have been applied/handled
      • getAnimation

        default ModelAnimation getAnimation​(java.lang.String name)
        Get the associated ModelAnimation by name or null if none exist with the given name.
      • getAnimationOrThrow

        default ModelAnimation getAnimationOrThrow​(java.lang.String name)
        Get the associated ModelAnimation by name or throw an Exception if none exist with the given name.
      • getAnimationIndex

        default int getAnimationIndex​(java.lang.String name)
        Get the Zero-based index for the animation name of interest or -1 if not found.
      • getAnimationName

        default java.lang.String getAnimationName​(int animationIndex)
        Get the name of the ModelAnimation at the Zero-based index

        This name corresponds to the one defined and exported in the renderable asset. Typically the Action names defined in the 3D creation software.

        Returns:
        The string name of the ModelAnimation, String.valueOf(animation.getIndex())> if none was specified.
      • getAnimationNames

        default java.util.List<java.lang.String> getAnimationNames()
        Get the names of the ModelAnimation

        This names correspond to the ones defined and exported in the renderable asset. Typically the Action names defined in the 3D creation software.

        Returns:
        The string name of the ModelAnimation, String.valueOf(animation.getIndex())> if none was specified.
      • setAnimationsTimePosition

        default void setAnimationsTimePosition​(float timePosition)
        Sets the current position of (seeks) the animation to the specified time position in seconds. This time should be

        This method will apply rotation, translation, and scale to the Renderable that have been targeted. Uses TransformManager

        Parameters:
        timePosition - Elapsed time of interest in seconds. Between 0 and the max value of ModelAnimation.getDuration().
        See Also:
        ModelAnimation.getDuration()
      • setAnimationsFramePosition

        default void setAnimationsFramePosition​(int framePosition)
        Sets the current position of (seeks) all the animations to the specified frame number according to the ModelAnimation.getFrameRate()

        This method will apply rotation, translation, and scale to the Renderable that have been targeted. Uses TransformManager

        Parameters:
        framePosition - Frame number on the timeline. Between 0 and ModelAnimation.getFrameCount().
        See Also:
        ModelAnimation.getFrameCount()
      • animate

        default android.animation.ObjectAnimator animate​(java.lang.String... animationNames)
        Constructs and returns an ObjectAnimator for targeted ModelAnimation with a given name of this object.
        Don't forget to call ObjectAnimator.start()
        Parameters:
        animationNames - The string names of the animations.
        This name should correspond to the one defined and exported in the model.
        Typically the action name defined in the 3D creation software. ModelAnimation.getName()
        Returns:
        The constructed ObjectAnimator
        See Also:
        ModelAnimator.ofAnimationTime(AnimatableModel, ModelAnimation, float...)
      • animate

        default android.animation.ObjectAnimator animate​(int... animationIndexes)
        Constructs and returns an ObjectAnimator for targeted ModelAnimation with a a given index of this object.
        Don't forget to call ObjectAnimator.start()
        Parameters:
        animationIndexes - Zero-based indexes for the animations of interest.
        Returns:
        The constructed ObjectAnimator
        See Also:
        ModelAnimator.ofAnimationTime(AnimatableModel, ModelAnimation, float...)
      • animate

        default android.animation.ObjectAnimator animate​(ModelAnimation... animations)
        Constructs and returns an ObjectAnimator for a targeted ModelAnimation of this object. The setAutoCancel(true) won't work for new call with different animations.
        This method applies by default this to the returned ObjectAnimator :
        • The duration value to the max ModelAnimation.getDuration() in order to match the original animation speed.
        • The interpolator to LinearInterpolator in order to match the natural animation interpolation.

        Don't forget to call ObjectAnimator.start()
        Parameters:
        animations - The animations of interest
        Returns:
        The constructed ObjectAnimator
        See Also:
        ModelAnimator.ofAnimationTime(AnimatableModel, ModelAnimation, float...)