Interface AnimatableModel
-
- All Known Implementing Classes:
RenderableInstance
public interface AnimatableModelAn AnimatableModel is an object whose properties can be animated by anModelAnimation. The object animation transformation can be done at the desired frame callback place.ModelAnimationupdates the value (like in a standardObjectAnimatorcontext) 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 Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default android.animation.ObjectAnimatoranimate(boolean repeat)Constructs and returns anObjectAnimatorfor allModelAnimationof this object.default android.animation.ObjectAnimatoranimate(int... animationIndexes)Constructs and returns anObjectAnimatorfor targetedModelAnimationwith a a given index of this object.default android.animation.ObjectAnimatoranimate(ModelAnimation... animations)Constructs and returns anObjectAnimatorfor a targetedModelAnimationof this object.default android.animation.ObjectAnimatoranimate(java.lang.String... animationNames)Constructs and returns anObjectAnimatorfor targetedModelAnimationwith a given name of this object.booleanapplyAnimationChange(ModelAnimation animation)Occurs when aModelAnimationhas received any property changed.ModelAnimationgetAnimation(int animationIndex)Get the associatedModelAnimationat the given index or throw anIndexOutOfBoundsException.default ModelAnimationgetAnimation(java.lang.String name)Get the associatedModelAnimationby name or null if none exist with the given name.intgetAnimationCount()Returns the number ofModelAnimationdefinitions in the model.default intgetAnimationIndex(java.lang.String name)Get the Zero-based index for the animation name of interest or -1 if not found.default java.lang.StringgetAnimationName(int animationIndex)Get the name of theModelAnimationat the Zero-based indexdefault java.util.List<java.lang.String>getAnimationNames()Get the names of theModelAnimationdefault ModelAnimationgetAnimationOrThrow(java.lang.String name)Get the associatedModelAnimationby name or throw an Exception if none exist with the given name.default booleanhasAnimations()Return true ifgetAnimationCount()> 0default voidonModelAnimationChanged(ModelAnimation animation)Called form theModelAnimationwhen it dirty state changed.default voidsetAnimationsFramePosition(int framePosition)Sets the current position of (seeks) all the animations to the specified frame number according to theModelAnimation.getFrameRate()default voidsetAnimationsTimePosition(float timePosition)Sets the current position of (seeks) the animation to the specified time position in seconds.
-
-
-
Method Detail
-
getAnimation
ModelAnimation getAnimation(int animationIndex)
Get the associatedModelAnimationat the given index or throw anIndexOutOfBoundsException.- Parameters:
animationIndex- Zero-based index for the animation of interest.
-
getAnimationCount
int getAnimationCount()
Returns the number ofModelAnimationdefinitions in the model.
-
onModelAnimationChanged
default void onModelAnimationChanged(ModelAnimation animation)
Called form theModelAnimationwhen it dirty state changed.
-
applyAnimationChange
boolean applyAnimationChange(ModelAnimation animation)
Occurs when aModelAnimationhas received any property changed.
Depending on the returned value, theModelAnimationwill set his isDirty to false or not.
You can choose between applying changes on theObjectAnimatorChoreographer.FrameCallbackor use your ownChoreographerto handle an update/render update hierarchy.
Time position should be applied inside a globalChoreographerframe 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 associatedModelAnimationby name or null if none exist with the given name.
-
getAnimationOrThrow
default ModelAnimation getAnimationOrThrow(java.lang.String name)
Get the associatedModelAnimationby 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 theModelAnimationat the Zero-based indexThis 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 theModelAnimationThis 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.
-
hasAnimations
default boolean hasAnimations()
Return true ifgetAnimationCount()> 0
-
setAnimationsTimePosition
default void setAnimationsTimePosition(float timePosition)
Sets the current position of (seeks) the animation to the specified time position in seconds. This time should beThis 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 ofModelAnimation.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 theModelAnimation.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 andModelAnimation.getFrameCount().- See Also:
ModelAnimation.getFrameCount()
-
animate
default android.animation.ObjectAnimator animate(boolean repeat)
Constructs and returns anObjectAnimatorfor allModelAnimationof this object.Don't forget to call
ObjectAnimator.start()- Parameters:
repeat- repeat/loop the animation- Returns:
- The constructed ObjectAnimator
- See Also:
ModelAnimator.ofAnimationTime(AnimatableModel, ModelAnimation, float...)
-
animate
default android.animation.ObjectAnimator animate(java.lang.String... animationNames)
Constructs and returns anObjectAnimatorfor targetedModelAnimationwith a given name of this object.
Don't forget to callObjectAnimator.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 anObjectAnimatorfor targetedModelAnimationwith a a given index of this object.
Don't forget to callObjectAnimator.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 anObjectAnimatorfor a targetedModelAnimationof 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
LinearInterpolatorin order to match the natural animation interpolation.
Don't forget to callObjectAnimator.start()- Parameters:
animations- The animations of interest- Returns:
- The constructed ObjectAnimator
- See Also:
ModelAnimator.ofAnimationTime(AnimatableModel, ModelAnimation, float...)
- The duration value to the max
-
-