Interface AnimatableModel
-
- All Known Implementing Classes:
RenderableInstance
public interface AnimatableModel
An AnimatableModel is an object whose properties can be animated by anModelAnimation
. The object animation transformation can be done at the desired frame callback place.ModelAnimation
updates the value (like in a standardObjectAnimator
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 Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default android.animation.ObjectAnimator
animate(boolean repeat)
Constructs and returns anObjectAnimator
for allModelAnimation
of this object.default android.animation.ObjectAnimator
animate(int... animationIndexes)
Constructs and returns anObjectAnimator
for targetedModelAnimation
with a a given index of this object.default android.animation.ObjectAnimator
animate(ModelAnimation... animations)
Constructs and returns anObjectAnimator
for a targetedModelAnimation
of this object.default android.animation.ObjectAnimator
animate(java.lang.String... animationNames)
Constructs and returns anObjectAnimator
for targetedModelAnimation
with a given name of this object.boolean
applyAnimationChange(ModelAnimation animation)
Occurs when aModelAnimation
has received any property changed.ModelAnimation
getAnimation(int animationIndex)
Get the associatedModelAnimation
at the given index or throw anIndexOutOfBoundsException
.default ModelAnimation
getAnimation(java.lang.String name)
Get the associatedModelAnimation
by name or null if none exist with the given name.int
getAnimationCount()
Returns the number ofModelAnimation
definitions in the model.default int
getAnimationIndex(java.lang.String name)
Get the Zero-based index for the animation name of interest or -1 if not found.default java.lang.String
getAnimationName(int animationIndex)
Get the name of theModelAnimation
at the Zero-based indexdefault java.util.List<java.lang.String>
getAnimationNames()
Get the names of theModelAnimation
default ModelAnimation
getAnimationOrThrow(java.lang.String name)
Get the associatedModelAnimation
by name or throw an Exception if none exist with the given name.default boolean
hasAnimations()
Return true ifgetAnimationCount()
> 0default void
onModelAnimationChanged(ModelAnimation animation)
Called form theModelAnimation
when it dirty state changed.default void
setAnimationsFramePosition(int framePosition)
Sets the current position of (seeks) all the animations to the specified frame number according to theModelAnimation.getFrameRate()
default void
setAnimationsTimePosition(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 associatedModelAnimation
at the given index or throw anIndexOutOfBoundsException
.- Parameters:
animationIndex
- Zero-based index for the animation of interest.
-
getAnimationCount
int getAnimationCount()
Returns the number ofModelAnimation
definitions in the model.
-
onModelAnimationChanged
default void onModelAnimationChanged(ModelAnimation animation)
Called form theModelAnimation
when it dirty state changed.
-
applyAnimationChange
boolean applyAnimationChange(ModelAnimation animation)
Occurs when aModelAnimation
has received any property changed.
Depending on the returned value, theModelAnimation
will set his isDirty to false or not.
You can choose between applying changes on theObjectAnimator
Choreographer.FrameCallback
or use your ownChoreographer
to handle an update/render update hierarchy.
Time position should be applied inside a globalChoreographer
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 associatedModelAnimation
by name or null if none exist with the given name.
-
getAnimationOrThrow
default ModelAnimation getAnimationOrThrow(java.lang.String name)
Get the associatedModelAnimation
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 theModelAnimation
at 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 theModelAnimation
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.
-
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 anObjectAnimator
for allModelAnimation
of 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 anObjectAnimator
for targetedModelAnimation
with 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 anObjectAnimator
for targetedModelAnimation
with 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 anObjectAnimator
for a targetedModelAnimation
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 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
-
-