Class AnimationController
- java.lang.Object
-
- com.badlogic.gdx.graphics.g3d.utils.BaseAnimationController
-
- com.badlogic.gdx.graphics.g3d.utils.AnimationController
-
public class AnimationController extends BaseAnimationController
Class to control one or moreAnimation
s on aModelInstance
. Use thesetAnimation(String, int, float, AnimationListener)
method to change the current animation. Use theanimate(String, int, float, AnimationListener, float)
method to start an animation, optionally blending onto the current animation. Use thequeue(String, int, float, AnimationListener, float)
method to queue an animation to be played when the current animation is finished. Use theaction(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 sameNode
s).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AnimationController.AnimationDesc
Class describing how to play andAnimation
.static interface
AnimationController.AnimationListener
Listener that will be informed when an animation is looped or completed.-
Nested classes/interfaces inherited from class com.badlogic.gdx.graphics.g3d.utils.BaseAnimationController
BaseAnimationController.Transform
-
-
Field Summary
Fields Modifier and Type Field Description boolean
allowSameAnimation
Whether to allow the same animation to be played while playing that animation.protected Pool<AnimationController.AnimationDesc>
animationPool
AnimationController.AnimationDesc
current
The animation currently playing.boolean
inAction
Whether an action is being performed.boolean
paused
When true a call toupdate(float)
will not be processed.AnimationController.AnimationDesc
previous
The animation which previously played.AnimationController.AnimationDesc
queued
The animation queued to be played when thecurrent
animation is completed.float
queuedTransitionTime
The transition time which should be applied to the queued animation.float
transitionCurrentTime
The current transition time.float
transitionTargetTime
The target transition time.-
Fields inherited from class com.badlogic.gdx.graphics.g3d.utils.BaseAnimationController
target
-
-
Constructor Summary
Constructors Constructor Description AnimationController(ModelInstance target)
Construct a new AnimationController.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected AnimationController.AnimationDesc
action(Animation anim, float offset, float duration, int loopCount, float speed, AnimationController.AnimationListener listener, float transitionTime)
Apply an action animation on top of the current animation.protected AnimationController.AnimationDesc
action(AnimationController.AnimationDesc anim, float transitionTime)
Apply an action animation on top of the current animation.AnimationController.AnimationDesc
action(java.lang.String id, float offset, float duration, int loopCount, float speed, AnimationController.AnimationListener listener, float transitionTime)
Apply an action animation on top of the current animation.AnimationController.AnimationDesc
action(java.lang.String id, int loopCount, float speed, AnimationController.AnimationListener listener, float transitionTime)
Apply an action animation on top of the current animation.protected AnimationController.AnimationDesc
animate(Animation anim, float offset, float duration, int loopCount, float speed, 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(AnimationController.AnimationDesc anim, float transitionTime)
Changes the current animation by blending the new on top of the old during the transition time.AnimationController.AnimationDesc
animate(java.lang.String id, float transitionTime)
Changes the current animation by blending the new on top of the old during the transition time.AnimationController.AnimationDesc
animate(java.lang.String id, float offset, float duration, int loopCount, float speed, AnimationController.AnimationListener listener, float transitionTime)
Changes the current animation by blending the new on top of the old during the transition time.AnimationController.AnimationDesc
animate(java.lang.String id, int loopCount, float speed, AnimationController.AnimationListener listener, float transitionTime)
Changes the current animation by blending the new on top of the old during the transition time.AnimationController.AnimationDesc
animate(java.lang.String id, int loopCount, AnimationController.AnimationListener listener, float transitionTime)
Changes the current animation by blending the new on top of the old during the transition time.AnimationController.AnimationDesc
animate(java.lang.String id, 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
queue(Animation anim, float offset, float duration, int loopCount, float speed, AnimationController.AnimationListener listener, float transitionTime)
Queue an animation to be applied when the current is finished.protected AnimationController.AnimationDesc
queue(AnimationController.AnimationDesc anim, float transitionTime)
Queue an animation to be applied when the current is finished.AnimationController.AnimationDesc
queue(java.lang.String id, float offset, float duration, int loopCount, float speed, AnimationController.AnimationListener listener, float transitionTime)
Queue an animation to be applied when thecurrent
animation is finished.AnimationController.AnimationDesc
queue(java.lang.String id, int loopCount, float speed, AnimationController.AnimationListener listener, float transitionTime)
Queue an animation to be applied when thecurrent
animation is finished.protected AnimationController.AnimationDesc
setAnimation(Animation anim, float offset, float duration, int loopCount, float speed, AnimationController.AnimationListener listener)
Set the active animation, replacing any current animation.protected AnimationController.AnimationDesc
setAnimation(AnimationController.AnimationDesc anim)
Set the active animation, replacing any current animation.AnimationController.AnimationDesc
setAnimation(java.lang.String id)
Set the active animation, replacing any current animation.AnimationController.AnimationDesc
setAnimation(java.lang.String id, float offset, float duration, int loopCount, float speed, AnimationController.AnimationListener listener)
Set the active animation, replacing any current animation.AnimationController.AnimationDesc
setAnimation(java.lang.String id, int loopCount)
Set the active animation, replacing any current animation.AnimationController.AnimationDesc
setAnimation(java.lang.String id, int loopCount, float speed, AnimationController.AnimationListener listener)
Set the active animation, replacing any current animation.AnimationController.AnimationDesc
setAnimation(java.lang.String id, int loopCount, AnimationController.AnimationListener listener)
Set the active animation, replacing any current animation.AnimationController.AnimationDesc
setAnimation(java.lang.String id, AnimationController.AnimationListener listener)
Set the active animation, replacing any current animation.void
update(float delta)
Update any animations currently being played.-
Methods inherited from class com.badlogic.gdx.graphics.g3d.utils.BaseAnimationController
apply, applyAnimation, applyAnimation, applyAnimations, begin, end, removeAnimation
-
-
-
-
Field Detail
-
animationPool
protected final Pool<AnimationController.AnimationDesc> animationPool
-
current
public AnimationController.AnimationDesc current
The animation currently playing. Do not alter this value.
-
queued
public AnimationController.AnimationDesc queued
The animation queued to be played when thecurrent
animation is completed. Do not alter this value.
-
queuedTransitionTime
public float queuedTransitionTime
The transition time which should be applied to the queued animation. Do not alter this value.
-
previous
public AnimationController.AnimationDesc previous
The animation which previously played. Do not alter this value.
-
transitionCurrentTime
public float transitionCurrentTime
The current transition time. Do not alter this value.
-
transitionTargetTime
public float transitionTargetTime
The target transition time. Do not alter this value.
-
inAction
public boolean inAction
Whether an action is being performed. Do not alter this value.
-
paused
public boolean paused
When true a call toupdate(float)
will not be processed.
-
allowSameAnimation
public boolean allowSameAnimation
Whether to allow the same animation to be played while playing that animation.
-
-
Constructor Detail
-
AnimationController
public AnimationController(ModelInstance target)
Construct a new AnimationController.- Parameters:
target
- TheModelInstance
on which the animations will be performed.
-
-
Method Detail
-
update
public void update(float delta)
Update any animations currently being played.- Parameters:
delta
- The time elapsed since last update, change this to alter the overall speed (can be negative).
-
setAnimation
public AnimationController.AnimationDesc setAnimation(java.lang.String id)
Set the active animation, replacing any current animation.- Parameters:
id
- The ID of theAnimation
within theModelInstance
.- Returns:
- The
AnimationController.AnimationDesc
which can be read to get the progress of the animation. Will be invalid when the animation is completed.
-
setAnimation
public AnimationController.AnimationDesc setAnimation(java.lang.String id, int loopCount)
Set the active animation, replacing any current animation.- Parameters:
id
- The ID of theAnimation
within theModelInstance
.loopCount
- The number of times to loop the animation, zero to play the animation only once, negative to continuously loop the animation.- Returns:
- The
AnimationController.AnimationDesc
which can be read to get the progress of the animation. Will be invalid when the animation is completed.
-
setAnimation
public AnimationController.AnimationDesc setAnimation(java.lang.String id, AnimationController.AnimationListener listener)
Set the active animation, replacing any current animation.- Parameters:
id
- The ID of theAnimation
within theModelInstance
.listener
- TheAnimationController.AnimationListener
which will be informed when the animation is looped or completed.- Returns:
- The
AnimationController.AnimationDesc
which can be read to get the progress of the animation. Will be invalid when the animation is completed.
-
setAnimation
public AnimationController.AnimationDesc setAnimation(java.lang.String id, int loopCount, AnimationController.AnimationListener listener)
Set the active animation, replacing any current animation.- Parameters:
id
- The ID of theAnimation
within theModelInstance
.loopCount
- The number of times to play the animation, 1 to play the animation only once, negative to continuously loop the animation.listener
- TheAnimationController.AnimationListener
which will be informed when the animation is looped or completed.- Returns:
- The
AnimationController.AnimationDesc
which can be read to get the progress of the animation. Will be invalid when the animation is completed.
-
setAnimation
public AnimationController.AnimationDesc setAnimation(java.lang.String id, int loopCount, float speed, AnimationController.AnimationListener listener)
Set the active animation, replacing any current animation.- Parameters:
id
- The ID of theAnimation
within theModelInstance
.loopCount
- The number of times to play the animation, 1 to play the animation only once, negative to continuously loop the animation.speed
- 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.listener
- TheAnimationController.AnimationListener
which will be informed when the animation is looped or completed.- Returns:
- The
AnimationController.AnimationDesc
which can be read to get the progress of the animation. Will be invalid when the animation is completed.
-
setAnimation
public AnimationController.AnimationDesc setAnimation(java.lang.String id, float offset, float duration, int loopCount, float speed, AnimationController.AnimationListener listener)
Set the active animation, replacing any current animation.- Parameters:
id
- The ID of theAnimation
within theModelInstance
.offset
- The offset in seconds to the start of the animation.duration
- The duration in seconds of the animation (or negative to play till the end of the animation).loopCount
- The number of times to play the animation, 1 to play the animation only once, negative to continuously loop the animation.speed
- 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.listener
- TheAnimationController.AnimationListener
which will be informed when the animation is looped or completed.- Returns:
- The
AnimationController.AnimationDesc
which can be read to get the progress of the animation. Will be invalid when the animation is completed.
-
setAnimation
protected AnimationController.AnimationDesc setAnimation(Animation anim, float offset, float duration, int loopCount, float speed, AnimationController.AnimationListener listener)
Set the active animation, replacing any current animation.
-
setAnimation
protected AnimationController.AnimationDesc setAnimation(AnimationController.AnimationDesc anim)
Set the active animation, replacing any current animation.
-
animate
public AnimationController.AnimationDesc animate(java.lang.String id, float transitionTime)
Changes the current animation by blending the new on top of the old during the transition time.- Parameters:
id
- The ID of theAnimation
within theModelInstance
.transitionTime
- The time to transition the new animation on top of the currently playing animation (if any).- Returns:
- The
AnimationController.AnimationDesc
which can be read to get the progress of the animation. Will be invalid when the animation is completed.
-
animate
public AnimationController.AnimationDesc animate(java.lang.String id, AnimationController.AnimationListener listener, float transitionTime)
Changes the current animation by blending the new on top of the old during the transition time.- Parameters:
id
- The ID of theAnimation
within theModelInstance
.listener
- TheAnimationController.AnimationListener
which will be informed when the animation is looped or completed.transitionTime
- The time to transition the new animation on top of the currently playing animation (if any).- Returns:
- The
AnimationController.AnimationDesc
which can be read to get the progress of the animation. Will be invalid when the animation is completed.
-
animate
public AnimationController.AnimationDesc animate(java.lang.String id, int loopCount, AnimationController.AnimationListener listener, float transitionTime)
Changes the current animation by blending the new on top of the old during the transition time.- Parameters:
id
- The ID of theAnimation
within theModelInstance
.loopCount
- The number of times to loop the animation, zero to play the animation only once, negative to continuously loop the animation.listener
- TheAnimationController.AnimationListener
which will be informed when the animation is looped or completed.transitionTime
- The time to transition the new animation on top of the currently playing animation (if any).- Returns:
- The
AnimationController.AnimationDesc
which can be read to get the progress of the animation. Will be invalid when the animation is completed.
-
animate
public AnimationController.AnimationDesc animate(java.lang.String id, int loopCount, float speed, AnimationController.AnimationListener listener, float transitionTime)
Changes the current animation by blending the new on top of the old during the transition time.- Parameters:
id
- The ID of theAnimation
within theModelInstance
.loopCount
- The number of times to play the animation, 1 to play the animation only once, negative to continuously loop the animation.speed
- 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.listener
- TheAnimationController.AnimationListener
which will be informed when the animation is looped or completed.transitionTime
- The time to transition the new animation on top of the currently playing animation (if any).- Returns:
- The
AnimationController.AnimationDesc
which can be read to get the progress of the animation. Will be invalid when the animation is completed.
-
animate
public AnimationController.AnimationDesc animate(java.lang.String id, float offset, float duration, int loopCount, float speed, AnimationController.AnimationListener listener, float transitionTime)
Changes the current animation by blending the new on top of the old during the transition time.- Parameters:
id
- The ID of theAnimation
within theModelInstance
.offset
- The offset in seconds to the start of the animation.duration
- The duration in seconds of the animation (or negative to play till the end of the animation).loopCount
- The number of times to play the animation, 1 to play the animation only once, negative to continuously loop the animation.speed
- 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.listener
- TheAnimationController.AnimationListener
which will be informed when the animation is looped or completed.transitionTime
- The time to transition the new animation on top of the currently playing animation (if any).- Returns:
- The
AnimationController.AnimationDesc
which can be read to get the progress of the animation. Will be invalid when the animation is completed.
-
animate
protected AnimationController.AnimationDesc animate(Animation anim, float offset, float duration, int loopCount, float speed, AnimationController.AnimationListener listener, float transitionTime)
Changes the current animation by blending the new on top of the old during the transition time.
-
animate
protected AnimationController.AnimationDesc animate(AnimationController.AnimationDesc anim, float transitionTime)
Changes the current animation by blending the new on top of the old during the transition time.
-
queue
public AnimationController.AnimationDesc queue(java.lang.String id, int loopCount, float speed, AnimationController.AnimationListener listener, float transitionTime)
Queue an animation to be applied when thecurrent
animation is finished. If the current animation is continuously looping it will be synchronized on next loop.- Parameters:
id
- The ID of theAnimation
within theModelInstance
.loopCount
- The number of times to play the animation, 1 to play the animation only once, negative to continuously loop the animation.speed
- 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.listener
- TheAnimationController.AnimationListener
which will be informed when the animation is looped or completed.transitionTime
- The time to transition the new animation on top of the currently playing animation (if any).- Returns:
- The
AnimationController.AnimationDesc
which can be read to get the progress of the animation. Will be invalid when the animation is completed.
-
queue
public AnimationController.AnimationDesc queue(java.lang.String id, float offset, float duration, int loopCount, float speed, AnimationController.AnimationListener listener, float transitionTime)
Queue an animation to be applied when thecurrent
animation is finished. If the current animation is continuously looping it will be synchronized on next loop.- Parameters:
id
- The ID of theAnimation
within theModelInstance
.offset
- The offset in seconds to the start of the animation.duration
- The duration in seconds of the animation (or negative to play till the end of the animation).loopCount
- The number of times to play the animation, 1 to play the animation only once, negative to continuously loop the animation.speed
- 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.listener
- TheAnimationController.AnimationListener
which will be informed when the animation is looped or completed.transitionTime
- The time to transition the new animation on top of the currently playing animation (if any).- Returns:
- The
AnimationController.AnimationDesc
which can be read to get the progress of the animation. Will be invalid when the animation is completed.
-
queue
protected AnimationController.AnimationDesc queue(Animation anim, float offset, float duration, int loopCount, float speed, AnimationController.AnimationListener listener, float transitionTime)
Queue an animation to be applied when the current is finished. If current is continuous it will be synced on next loop.
-
queue
protected AnimationController.AnimationDesc queue(AnimationController.AnimationDesc anim, float transitionTime)
Queue an animation to be applied when the current is finished. If current is continuous it will be synced on next loop.
-
action
public AnimationController.AnimationDesc action(java.lang.String id, int loopCount, float speed, AnimationController.AnimationListener listener, float transitionTime)
Apply an action animation on top of the current animation.- Parameters:
id
- The ID of theAnimation
within theModelInstance
.loopCount
- The number of times to play the animation, 1 to play the animation only once, negative to continuously loop the animation.speed
- 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.listener
- TheAnimationController.AnimationListener
which will be informed when the animation is looped or completed.transitionTime
- The time to transition the new animation on top of the currently playing animation (if any).- Returns:
- The
AnimationController.AnimationDesc
which can be read to get the progress of the animation. Will be invalid when the animation is completed.
-
action
public AnimationController.AnimationDesc action(java.lang.String id, float offset, float duration, int loopCount, float speed, AnimationController.AnimationListener listener, float transitionTime)
Apply an action animation on top of the current animation.- Parameters:
id
- The ID of theAnimation
within theModelInstance
.offset
- The offset in seconds to the start of the animation.duration
- The duration in seconds of the animation (or negative to play till the end of the animation).loopCount
- The number of times to play the animation, 1 to play the animation only once, negative to continuously loop the animation.speed
- 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.listener
- TheAnimationController.AnimationListener
which will be informed when the animation is looped or completed.transitionTime
- The time to transition the new animation on top of the currently playing animation (if any).- Returns:
- The
AnimationController.AnimationDesc
which can be read to get the progress of the animation. Will be invalid when the animation is completed.
-
action
protected AnimationController.AnimationDesc action(Animation anim, float offset, float duration, int loopCount, float speed, AnimationController.AnimationListener listener, float transitionTime)
Apply an action animation on top of the current animation.
-
action
protected AnimationController.AnimationDesc action(AnimationController.AnimationDesc anim, float transitionTime)
Apply an action animation on top of the current animation.
-
-