ModelAnimation

open class ModelAnimation

An ModelAnimation is a reusable set of keyframe tracks which represent an animation.

This class provides support for animating time positions on a targeted AnimatableModel

Here are some use cases for animations :

  • On a very basic 3D model like a single infinite rotating sphere, you should not have to use this class but probably instead just call animate
  • For a synchronised animation set like animating a cube and a sphere position and rotation at same time or sequentially, please consider using an android.animation.AnimatorSet playing a ofAnimation or ofPropertyValuesHolder
  • If the mesh is a character, for example, there may be one ModelAnimation for a walkcycle, a second for a jump, a third for sidestepping and so on. Assuming a character object has a skeleton, one keyframe track could store the data for the position changes of the lower arm bone over time, a different track the data for the rotation changes of the same bone, a third the track position, rotation or scaling of another bone, and so on. It should be clear, that an ModelAnimation can act on lots of such tracks. Assuming the model has morph targets (for example one morph target showing a friendly face and another showing an angry face), each track holds the information as to how the influence of a certain morph target changes during the performance of the clip. In this case you should manage one android.animation.ObjectAnimator coming from ofAnimation per action. And an android.animation.AnimatorSet to play them sequentially or together.

Constructors

Link copied to clipboard
constructor(model: AnimatableModel, name: String, index: Int, duration: Float, frameRate: Int)
ModelAnimation constructed from an Animator

Types

Link copied to clipboard
This class holds information about a property and the values that that property should take during an animation.

Properties

Link copied to clipboard
open val duration: Float
Link copied to clipboard
A Property wrapper around the fractionPosition functionality handled by the setFractionPosition and getFractionPosition methods
Link copied to clipboard
A Property wrapper around the framePosition functionality handled by the setFramePosition and getFramePosition methods
Link copied to clipboard
open val frameRate: Int
Link copied to clipboard
open var isDirty: Boolean
Link copied to clipboard
open val name: String
Link copied to clipboard
A Property wrapper around the timePosition functionality handled by the setTimePosition and getTimePosition methods.
Link copied to clipboard
Time position is applied inside a global android.view.Choreographer frame callback to ensure that the transformations are applied in a hierarchical order.

Functions

Link copied to clipboard
open fun fractionToTime(fraction: Float, duration: Float): Float
Get the elapsed time in seconds of a fraction position
Link copied to clipboard
open fun frameToTime(frame: Int, frameRate: Int): Float
Get the elapsed time in seconds of a frame position
Link copied to clipboard
open fun geIndex(): Int
Returns The Zero-based index of the target animation as defined in the original AnimatableModel
Link copied to clipboard
Returns the duration of this animation in milliseconds.
Link copied to clipboard
open fun getFractionAtTime(time: Float): Float
Get the fraction position at the elapsed time in seconds.
Link copied to clipboard
Get the fractional value at the current animation position.
Link copied to clipboard
open fun getFrameAtTime(time: Float): Int
Get the frame position at the elapsed time in seconds.
Link copied to clipboard
open fun getFrameCount(): Int
Returns the total number of frames of this animation.
Link copied to clipboard
open fun getFramePosition(): Int
Get the current frame number at the current animation position.
Link copied to clipboard
open fun getTimeAtFraction(fraction: Float): Float
Get the elapsed time in seconds of a fraction position
Link copied to clipboard
open fun getTimeAtFrame(frame: Int): Float
Get the elapsed time in seconds of a frame position
Link copied to clipboard
open fun secondsToMillis(time: Float): Long
Convert time in seconds to time in millis
Link copied to clipboard
open fun setFractionPosition(fractionPosition: Float)
Sets the current position of (seeks) the animation to the specified fraction position.
Link copied to clipboard
open fun setFramePosition(frameNumber: Int)
Sets the current position of (seeks) the animation to the specified frame number according to the getFrameRate.
Link copied to clipboard
open fun timeToFraction(time: Float, duration: Float): Float
Get the fraction position at the elapsed time in seconds.
Link copied to clipboard
open fun timeToFrame(time: Float, frameRate: Int): Int
Get the frame position at the elapsed time in seconds.