Class AnimationManager
java.lang.Object
com.ardor3d.extension.animation.skeletal.AnimationManager
AnimationManager describes and maintains an animation system. It tracks one or more layered animation state machines (AnimationLayer) and uses their combined result to update one or more poses (via a set AnimationApplier.) AnimationClips used in these layers are instanced and tracked specifically for this manager.
By default, an animation manager has a single base animation layer. Other layers may be added to this. It is important that the base layer (the layer at index 0) always has a full set of data to put a skeleton pose into a valid state.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected AnimationApplier
A logic object responsible for taking animation data and applying it to skeleton poses.protected List
<SkeletonPose> The pose(s) this manager manipulates on update.protected boolean
boolean flag to allow stop state to be updated one last time.protected final Map
<AnimationClip, AnimationClipInstance> Local instance information for any clips referenced by the layers/blend trees in this manager.protected AnimationManager.AnimationUpdateState
Sets the current animationState used to control if animation is playing, pausing or stopped.protected ReadOnlyTimer
A timer to use as our "global" time keeper.protected double
The global time we last processed an animation.protected final List
<AnimationLayer> Our animation layers.protected boolean
boolean flag to reset Clips automatically once they are stopped.protected final Spatial
The root of a scenegraph we can look for transform animation targets under.protected double
The throttle rate of animation.protected final List
<AnimationUpdateStateListener> Listeners for changes to this manager's AnimationUpdateState.protected final LoggingMap
<String, Double> A map of key / Double values, allowing control over elements under this manager without needing precise knowledge of the layout of those layers, blend trees, etc. -
Constructor Summary
ConstructorDescriptionAnimationManager
(ReadOnlyTimer globalTimer, SkeletonPose pose) Construct a new AnimationManager.AnimationManager
(ReadOnlyTimer globalTimer, SkeletonPose pose, Spatial sceneRoot) Construct a new AnimationManager. -
Method Summary
Modifier and TypeMethodDescriptionint
addAnimationLayer
(AnimationLayer layer) Add a new layer to our list of animation layers.void
Add an AnimationUpdateStateListener to this manager.void
addPose
(SkeletonPose pose) void
Remove any AnimationUpdateStateListeners registered with this manager.boolean
containsPose
(SkeletonPose pose) findAnimationClip
(String clipName) Retrieve an existing clip tracked by this manager.findAnimationLayer
(String layerName) findClipInstance
(String clipName) Retrieve an existing clip instance being tracked by this manager.protected void
Notify any listeners of the state changegetAnimationLayer
(int index) getClipInstance
(AnimationClip clip) Retrieve and track an instance of an animation clip to be used with this manager.double
int
getSkeletonPose
(int index) double
void
insertAnimationLayer
(AnimationLayer layer, int index) Insert a given animation layer into our list of layers.boolean
isPaused()
boolean
boolean
boolean
void
pause()
void
play()
boolean
boolean
Remove an AnimationUpdateStateListener from this manager.boolean
removePose
(SkeletonPose pose) void
resetClipInstance
(AnimationClip clip, double globalStartTime) Rewind and reactivate the clip instance associated with the given clip.void
setAnimationUpdateState
(AnimationManager.AnimationUpdateState newAnimationState) void
setApplier
(AnimationApplier applier) void
setGlobalTimer
(Timer timer) void
setResetClipsOnStop
(boolean resetClipsOnStop) void
setUpdateRate
(double updateRate) void
stop()
void
update()
Move associated layers forward to the current global time and then apply the associated animation data to any SkeletonPoses set on the manager.
-
Field Details
-
_globalTimer
A timer to use as our "global" time keeper. All animation sources under this manager will use this timer as their time reference. -
_applyToPoses
The pose(s) this manager manipulates on update. -
_sceneRoot
The root of a scenegraph we can look for transform animation targets under. -
_clipInstances
Local instance information for any clips referenced by the layers/blend trees in this manager. -
_applier
A logic object responsible for taking animation data and applying it to skeleton poses. -
_layers
Our animation layers. -
_valuesStore
A map of key / Double values, allowing control over elements under this manager without needing precise knowledge of the layout of those layers, blend trees, etc. Missing keys will return 0.0 and log a warning. -
_updateRate
protected double _updateRateThe throttle rate of animation. Default is 60fps (1/60.0). Set to 0 to disable throttling. -
_lastUpdate
protected double _lastUpdateThe global time we last processed an animation. (To use when checking our throttle.) -
_currentAnimationState
Sets the current animationState used to control if animation is playing, pausing or stopped. -
_canSetStopState
protected boolean _canSetStopStateboolean flag to allow stop state to be updated one last time. -
_resetClipsOnStop
protected boolean _resetClipsOnStopboolean flag to reset Clips automatically once they are stopped. -
_updateStateListeners
Listeners for changes to this manager's AnimationUpdateState.
-
-
Constructor Details
-
AnimationManager
Construct a new AnimationManager.- Parameters:
globalTimer
- the timer to use for global time keeping.pose
- a pose to update. Optional if we won't be animating aSkinnedMesh
.
-
AnimationManager
Construct a new AnimationManager.- Parameters:
globalTimer
- the timer to use for global time keeping.pose
- a pose to update. Optional if we won't be animating aSkinnedMesh
.sceneRoot
- a root we will use to search for spatials when doing transform animations.
-
-
Method Details
-
getCurrentGlobalTime
public double getCurrentGlobalTime()- Returns:
- the "local time", in seconds reported by our global timer.
-
getGlobalTimer
- Returns:
- the timer used by this manager for global time keeping.
-
setGlobalTimer
- Parameters:
timer
- the timer to be used by this manager for global time keeping.
-
isResetClipsOnStop
public boolean isResetClipsOnStop()- Returns:
- True if clips will reset if the currentUpdateState is Stop.
-
setResetClipsOnStop
public void setResetClipsOnStop(boolean resetClipsOnStop) - Parameters:
resetClipsOnStop
- True if clips are to be reset when currentUpdateState is Stop, false otherwise.
-
play
public void play() -
pause
public void pause() -
stop
public void stop() -
isPlaying
public boolean isPlaying() -
isPaused
public boolean isPaused() -
isStopped
public boolean isStopped() -
setAnimationUpdateState
- Parameters:
newAnimationState
- the new animation state in the animation Manager.
-
fireAnimationUpdateStateChange
Notify any listeners of the state change- Parameters:
oldState
- previous state
-
addAnimationUpdateStateListener
Add an AnimationUpdateStateListener to this manager.- Parameters:
listener
- the listener to add.
-
removeAnimationUpdateStateListener
Remove an AnimationUpdateStateListener from this manager.- Parameters:
listener
- the listener to remove.- Returns:
- true if the listener was found
-
clearAnimationUpdateStateListeners
public void clearAnimationUpdateStateListeners()Remove any AnimationUpdateStateListeners registered with this manager. -
getAnimationUpdateState
- Returns:
- the currentAnimationState.
-
addPose
- Parameters:
pose
- a pose to add to be updated by this manager.
-
removePose
- Parameters:
pose
- the pose to remove from this manager.- Returns:
- true if the pose was found to be removed.
-
containsPose
- Parameters:
pose
- a pose to look for- Returns:
- true if the pose was found in this manager.
-
getPoseCount
public int getPoseCount()- Returns:
- the number of poses managed by this manager.
-
getSkeletonPose
- Parameters:
index
- the index to pull the pose from.- Returns:
- pose at the given index
-
getApplier
- Returns:
- the logic object responsible for taking animation data and applying it to skeleton poses.
-
setApplier
- Parameters:
applier
- a logic object to be responsible for taking animation data and applying it to skeleton poses.
-
update
public void update()Move associated layers forward to the current global time and then apply the associated animation data to any SkeletonPoses set on the manager. -
getClipInstance
Retrieve and track an instance of an animation clip to be used with this manager.- Parameters:
clip
- the clip to instance.- Returns:
- our new clip instance.
-
findClipInstance
Retrieve an existing clip instance being tracked by this manager.- Parameters:
clipName
- the name of the clip to find an existing instance of. Case sensitive.- Returns:
- our existing clip instance, or null if we were not tracking a clip of the given name.
-
findAnimationClip
Retrieve an existing clip tracked by this manager.- Parameters:
clipName
- the name of the clip to find. Case sensitive.- Returns:
- our existing clip, or null if we were not tracking a clip of the given name.
-
resetClipInstance
Rewind and reactivate the clip instance associated with the given clip.- Parameters:
clip
- the clip to pull the instance for.globalStartTime
- the time to set the clip instance's start as.
-
getAnimationLayer
- Parameters:
index
- the index of the layer to retrieve.- Returns:
- the animation layer at that index, or null of index is outside the bounds of our list of layers.
-
findAnimationLayer
- Parameters:
layerName
- the name of the layer to find.- Returns:
- the first animation layer with a matching name, or null of none are found.
-
addAnimationLayer
Add a new layer to our list of animation layers.- Parameters:
layer
- the layer to add.- Returns:
- the index of our added layer in our list of animation layers.
-
insertAnimationLayer
Insert a given animation layer into our list of layers.- Parameters:
layer
- the layer to insert.index
- the index to insert at. Moves any layers at that index over by one before inserting.
-
removeAnimationLayer
- Parameters:
layer
- a layer to remove.- Returns:
- true if the layer is found to remove.
-
getBaseAnimationLayer
- Returns:
- our bottom most layer. This layer should always consist of a full skeletal pose data.
-
getUpdateRate
public double getUpdateRate()- Returns:
- the amount of time in seconds between frame rate updates. (throttle) default is 60fps (1.0/60.0).
-
setUpdateRate
public void setUpdateRate(double updateRate) - Parameters:
updateRate
- the new throttle rate. Default is 60fps (1.0/60.0). Set to 0 to disable throttling.
-
getCurrentSourceData
- Returns:
- the current source data from the layers of this manager.
-
getValuesStore
-
getClipInstancesStore
- Returns:
- the Map containing the AnimationClips and their respective AnimationClipInstances.
-