APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.badlogic.gdx.graphics.g3d.utils

public Class AnimationController

extends BaseAnimationController
Class Inheritance
Imports
com.badlogic.gdx.graphics.g3d.ModelInstance, com.badlogic.gdx.graphics.g3d.model.Animation, .Node, com.badlogic.gdx.math.MathUtils, com.badlogic.gdx.utils.GdxRuntimeException, .Pool

Class to control one or more Animations on a ModelInstance. Use the setAnimation(String, int, float, AnimationListener) method to change the current animation. Use the animate(String, int, float, AnimationListener, float) method to start an animation, optionally blending onto the current animation. Use the queue(String, int, float, AnimationListener, float) method to queue an animation to be played when the current animation is finished. Use the action(String, int, float, AnimationListener, float) method to play a (short) animation on top of the current animation. You can use multiple AnimationControllers on the same ModelInstance, as long as they don't interfere with each other (don't affect the same Nodes).
Author
Xoppa

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
AnimationController.AnimationDesc

Class describing how to play and Animation.

public static interface
AnimationController.AnimationListener

Listener that will be informed when an animation is looped or completed.

Field Summary

Modifier and TypeField and Description
public boolean
allowSameAnimation

Whether to allow the same animation to be played while playing that animation.

protected final Pool<AnimationController.AnimationDesc>
public AnimationController.AnimationDesc
current

The animation currently playing.

public boolean
inAction

Whether an action is being performed.

private boolean
public boolean
paused

When true a call to update(float) will not be processed.

public AnimationController.AnimationDesc
previous

The animation which previously played.

public AnimationController.AnimationDesc
queued

The animation queued to be played when the current animation is completed.

public float
queuedTransitionTime

The transition time which should be applied to the queued animation.

public float
transitionCurrentTime

The current transition time.

public float
transitionTargetTime

The target transition time.

Inherited from com.badlogic.gdx.graphics.g3d.utils.BaseAnimationController:
target

Constructor Summary

AccessConstructor and Description
public
AnimationController(final ModelInstance
The ModelInstance on which the animations will be performed.
target
)

Construct a new AnimationController.

Method Summary

Modifier and TypeMethod and Description
public AnimationController.AnimationDesc

Returns:

The AnimationDesc which can be read to get the progress of the animation. Will be invalid when the animation is completed.
action
(final String
The ID of the Animation within the ModelInstance.
id
,
int
The number of times to play the animation, 1 to play the animation only once, negative to continuously loop the animation.
loopCount
,
float
The speed at which the animation should be played. Default is 1.0f. A value of 2.0f will play the animation at twice the normal speed, a value of 0.5f will play the animation at half the normal speed, etc. This value can be negative, causing the animation to played in reverse. This value cannot be zero.
speed
,
final AnimationController.AnimationListener
The AnimationListener which will be informed when the animation is looped or completed.
listener
,
float
The time to transition the new animation on top of the currently playing animation (if any).
transitionTime
)

Apply an action animation on top of the current animation.

public AnimationController.AnimationDesc

Returns:

The AnimationDesc which can be read to get the progress of the animation. Will be invalid when the animation is completed.
action
(final String
The ID of the Animation within the ModelInstance.
id
,
float
The offset in seconds to the start of the animation.
offset
,
float
The duration in seconds of the animation (or negative to play till the end of the animation).
duration
,
int
The number of times to play the animation, 1 to play the animation only once, negative to continuously loop the animation.
loopCount
,
float
The speed at which the animation should be played. Default is 1.0f. A value of 2.0f will play the animation at twice the normal speed, a value of 0.5f will play the animation at half the normal speed, etc. This value can be negative, causing the animation to played in reverse. This value cannot be zero.
speed
,
final AnimationController.AnimationListener
The AnimationListener which will be informed when the animation is looped or completed.
listener
,
float
The time to transition the new animation on top of the currently playing animation (if any).
transitionTime
)

Apply an action animation on top of the current animation.

protected AnimationController.AnimationDesc
action(final Animation anim, float offset, float duration, int loopCount, float speed, final AnimationController.AnimationListener listener, float transitionTime)

Apply an action animation on top of the current animation.

protected AnimationController.AnimationDesc
action(final AnimationController.AnimationDesc anim, float transitionTime)

Apply an action animation on top of the current animation.

public AnimationController.AnimationDesc

Returns:

The AnimationDesc which can be read to get the progress of the animation. Will be invalid when the animation is completed.
animate
(final String
The ID of the Animation within the ModelInstance.
id
,
float
The time to transition the new animation on top of the currently playing animation (if any).
transitionTime
)

Changes the current animation by blending the new on top of the old during the transition time.

public AnimationController.AnimationDesc

Returns:

The AnimationDesc which can be read to get the progress of the animation. Will be invalid when the animation is completed.
animate
(final String
The ID of the Animation within the ModelInstance.
id
,
final AnimationController.AnimationListener
The AnimationListener which will be informed when the animation is looped or completed.
listener
,
float
The time to transition the new animation on top of the currently playing animation (if any).
transitionTime
)

Changes the current animation by blending the new on top of the old during the transition time.

public AnimationController.AnimationDesc

Returns:

The AnimationDesc which can be read to get the progress of the animation. Will be invalid when the animation is completed.
animate
(final String
The ID of the Animation within the ModelInstance.
id
,
int
The number of times to loop the animation, zero to play the animation only once, negative to continuously loop the animation.
loopCount
,
final AnimationController.AnimationListener
The AnimationListener which will be informed when the animation is looped or completed.
listener
,
float
The time to transition the new animation on top of the currently playing animation (if any).
transitionTime
)

Changes the current animation by blending the new on top of the old during the transition time.

public AnimationController.AnimationDesc

Returns:

The AnimationDesc which can be read to get the progress of the animation. Will be invalid when the animation is completed.
animate
(final String
The ID of the Animation within the ModelInstance.
id
,
int
The number of times to play the animation, 1 to play the animation only once, negative to continuously loop the animation.
loopCount
,
float
The speed at which the animation should be played. Default is 1.0f. A value of 2.0f will play the animation at twice the normal speed, a value of 0.5f will play the animation at half the normal speed, etc. This value can be negative, causing the animation to played in reverse. This value cannot be zero.
speed
,
final AnimationController.AnimationListener
The AnimationListener which will be informed when the animation is looped or completed.
listener
,
float
The time to transition the new animation on top of the currently playing animation (if any).
transitionTime
)

Changes the current animation by blending the new on top of the old during the transition time.

public AnimationController.AnimationDesc

Returns:

The AnimationDesc which can be read to get the progress of the animation. Will be invalid when the animation is completed.
animate
(final String
The ID of the Animation within the ModelInstance.
id
,
float
The offset in seconds to the start of the animation.
offset
,
float
The duration in seconds of the animation (or negative to play till the end of the animation).
duration
,
int
The number of times to play the animation, 1 to play the animation only once, negative to continuously loop the animation.
loopCount
,
float
The speed at which the animation should be played. Default is 1.0f. A value of 2.0f will play the animation at twice the normal speed, a value of 0.5f will play the animation at half the normal speed, etc. This value can be negative, causing the animation to played in reverse. This value cannot be zero.
speed
,
final AnimationController.AnimationListener
The AnimationListener which will be informed when the animation is looped or completed.
listener
,
float
The time to transition the new animation on top of the currently playing animation (if any).
transitionTime
)

Changes the current animation by blending the new on top of the old during the transition time.

protected AnimationController.AnimationDesc
animate(final Animation anim, float offset, float duration, int loopCount, float speed, final AnimationController.AnimationListener listener, float transitionTime)

Changes the current animation by blending the new on top of the old during the transition time.

protected AnimationController.AnimationDesc
animate(final AnimationController.AnimationDesc anim, float transitionTime)

Changes the current animation by blending the new on top of the old during the transition time.

private AnimationController.AnimationDesc
obtain(final Animation anim, float offset, float duration, int loopCount, float speed, final AnimationController.AnimationListener listener)

private AnimationController.AnimationDesc
obtain(final String id, float offset, float duration, int loopCount, float speed, final AnimationController.AnimationListener listener)

private AnimationController.AnimationDesc
public AnimationController.AnimationDesc

Returns:

The AnimationDesc which can be read to get the progress of the animation. Will be invalid when the animation is completed.
queue
(final String
The ID of the Animation within the ModelInstance.
id
,
int
The number of times to play the animation, 1 to play the animation only once, negative to continuously loop the animation.
loopCount
,
float
The speed at which the animation should be played. Default is 1.0f. A value of 2.0f will play the animation at twice the normal speed, a value of 0.5f will play the animation at half the normal speed, etc. This value can be negative, causing the animation to played in reverse. This value cannot be zero.
speed
,
final AnimationController.AnimationListener
The AnimationListener which will be informed when the animation is looped or completed.
listener
,
float
The time to transition the new animation on top of the currently playing animation (if any).
transitionTime
)

Queue an animation to be applied when the current animation is finished.

public AnimationController.AnimationDesc

Returns:

The AnimationDesc which can be read to get the progress of the animation. Will be invalid when the animation is completed.
queue
(final String
The ID of the Animation within the ModelInstance.
id
,
float
The offset in seconds to the start of the animation.
offset
,
float
The duration in seconds of the animation (or negative to play till the end of the animation).
duration
,
int
The number of times to play the animation, 1 to play the animation only once, negative to continuously loop the animation.
loopCount
,
float
The speed at which the animation should be played. Default is 1.0f. A value of 2.0f will play the animation at twice the normal speed, a value of 0.5f will play the animation at half the normal speed, etc. This value can be negative, causing the animation to played in reverse. This value cannot be zero.
speed
,
final AnimationController.AnimationListener
The AnimationListener which will be informed when the animation is looped or completed.
listener
,
float
The time to transition the new animation on top of the currently playing animation (if any).
transitionTime
)

Queue an animation to be applied when the current animation is finished.

protected AnimationController.AnimationDesc
queue(final Animation anim, float offset, float duration, int loopCount, float speed, final AnimationController.AnimationListener listener, float transitionTime)

Queue an animation to be applied when the current is finished.

protected AnimationController.AnimationDesc
queue(final AnimationController.AnimationDesc anim, float transitionTime)

Queue an animation to be applied when the current is finished.

public AnimationController.AnimationDesc

Returns:

The AnimationDesc which can be read to get the progress of the animation. Will be invalid when the animation is completed.
setAnimation
(final String
The ID of the Animation within the ModelInstance.
id
)

Set the active animation, replacing any current animation.

public AnimationController.AnimationDesc

Returns:

The AnimationDesc which can be read to get the progress of the animation. Will be invalid when the animation is completed.
setAnimation
(final String
The ID of the Animation within the ModelInstance.
id
,
int
The number of times to loop the animation, zero to play the animation only once, negative to continuously loop the animation.
loopCount
)

Set the active animation, replacing any current animation.

public AnimationController.AnimationDesc

Returns:

The AnimationDesc which can be read to get the progress of the animation. Will be invalid when the animation is completed.
setAnimation
(final String
The ID of the Animation within the ModelInstance.
id
,
final AnimationController.AnimationListener
The AnimationListener which will be informed when the animation is looped or completed.
listener
)

Set the active animation, replacing any current animation.

public AnimationController.AnimationDesc

Returns:

The AnimationDesc which can be read to get the progress of the animation. Will be invalid when the animation is completed.
setAnimation
(final String
The ID of the Animation within the ModelInstance.
id
,
int
The number of times to play the animation, 1 to play the animation only once, negative to continuously loop the animation.
loopCount
,
final AnimationController.AnimationListener
The AnimationListener which will be informed when the animation is looped or completed.
listener
)

Set the active animation, replacing any current animation.

public AnimationController.AnimationDesc

Returns:

The AnimationDesc which can be read to get the progress of the animation. Will be invalid when the animation is completed.
setAnimation
(final String
The ID of the Animation within the ModelInstance.
id
,
int
The number of times to play the animation, 1 to play the animation only once, negative to continuously loop the animation.
loopCount
,
float
The speed at which the animation should be played. Default is 1.0f. A value of 2.0f will play the animation at twice the normal speed, a value of 0.5f will play the animation at half the normal speed, etc. This value can be negative, causing the animation to played in reverse. This value cannot be zero.
speed
,
final AnimationController.AnimationListener
The AnimationListener which will be informed when the animation is looped or completed.
listener
)

Set the active animation, replacing any current animation.

public AnimationController.AnimationDesc

Returns:

The AnimationDesc which can be read to get the progress of the animation. Will be invalid when the animation is completed.
setAnimation
(final String
The ID of the Animation within the ModelInstance.
id
,
float
The offset in seconds to the start of the animation.
offset
,
float
The duration in seconds of the animation (or negative to play till the end of the animation).
duration
,
int
The number of times to play the animation, 1 to play the animation only once, negative to continuously loop the animation.
loopCount
,
float
The speed at which the animation should be played. Default is 1.0f. A value of 2.0f will play the animation at twice the normal speed, a value of 0.5f will play the animation at half the normal speed, etc. This value can be negative, causing the animation to played in reverse. This value cannot be zero.
speed
,
final AnimationController.AnimationListener
The AnimationListener which will be informed when the animation is looped or completed.
listener
)

Set the active animation, replacing any current animation.

protected AnimationController.AnimationDesc
setAnimation(final Animation anim, float offset, float duration, int loopCount, float speed, final AnimationController.AnimationListener listener)

Set the active animation, replacing any current animation.

protected AnimationController.AnimationDesc
setAnimation(final AnimationController.AnimationDesc anim)

Set the active animation, replacing any current animation.

public void
update(float
The time elapsed since last update, change this to alter the overall speed (can be negative).
delta
)

Update any animations currently being played.

Inherited from com.badlogic.gdx.graphics.g3d.utils.BaseAnimationController:
applyapplyAnimationapplyAnimationapplyAnimationsbeginendgetFirstKeyframeIndexAtTimeremoveAnimation