Class AnimationLayer
java.lang.Object
com.ardor3d.extension.animation.skeletal.layer.AnimationLayer
- All Implemented Interfaces:
StateOwner
Animation layers are essentially independent state machines, managed by a single AnimationManager. Each maintains a
set of possible "steady states" - main states that the layer can be in. The layer can only be in one state at any
given time. It may transition between states, provided that a path is defined for transition from the current state
to the desired one.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addSteadyState
(SteadyState state) Add a new steady state to this layer.void
addTransition
(String keyword, AbstractTransitionState state) Add a new general transition to this layer.void
Set the currently playing state on this layer to null.boolean
doTransition
(String key) Attempt to perform a transition.getName()
getSteadyState
(String stateName) getTransition
(String keyword) boolean
removeSteadyState
(SteadyState state) Remove the given steady state from our layerboolean
removeTransition
(AbstractTransitionState transition) Remove the first instance of a specific transition state from this layer.removeTransition
(String keyword) Remove a transition state by keyword.void
replaceState
(AbstractFiniteState currentState, AbstractFiniteState newState) Replace the given current state with the given new statevoid
setCurrentState
(AbstractFiniteState state, boolean rewind) Sets the current finite state to the given state.boolean
setCurrentState
(String stateName, boolean rewind) Force the current state of the machine to the steady state with the given name.void
setLayerBlender
(LayerBlender layerBlender) void
setManager
(AnimationManager manager) Sets a reference back to the manager associated with this layer.void
updateLayerBlending
(AnimationLayer previousLayer) Update the layer blender in this animation layer to properly point to the previous layer.
-
Field Details
-
BASE_LAYER_NAME
The layer name of the default base layer.- See Also:
-
-
Constructor Details
-
AnimationLayer
Construct a new AnimationLayer.- Parameters:
name
- the name of this layer, used for id purposes.
-
-
Method Details
-
setCurrentState
Force the current state of the machine to the steady state with the given name. Used to set the FSM's initial state.- Parameters:
stateName
- the name of our state. If null, or is not present in this state machine, the current state is not changed.rewind
- if true, the clip(s) in the given state will be rewound by setting its start time to the current time and setting it active.- Returns:
- true if succeeds
-
setCurrentState
Sets the current finite state to the given state. Generally for transitional state use.- Parameters:
state
- our new state. If null, then no state is currently set on this layer.rewind
- if true, the clip(s) in the given state will be rewound by setting its start time to the current time and setting it active.
-
clearCurrentState
public void clearCurrentState()Set the currently playing state on this layer to null. -
doTransition
Attempt to perform a transition. First, check the current state to see if it has a transition for the given key. If not, check this layer for a general purpose transition. If no transition is found, this does nothing.- Parameters:
key
- the transition key, a string key used to look up a transition in the current animation state.- Returns:
- true if there is a current state and we were able to do the given transition.
-
getSteadyStateNames
- Returns:
- a set containing the names of our steady states.
-
getCurrentState
- Returns:
- the current active finite state in this machine.
-
getSteadyState
- Parameters:
stateName
- the name of the steady state we are looking for.- Returns:
- our animation state, or null if none is found.
-
addSteadyState
Add a new steady state to this layer.- Parameters:
state
- the state to add.
-
removeSteadyState
Remove the given steady state from our layer- Parameters:
state
- the state to remove- Returns:
- true if the state was found for removal.
-
setManager
Sets a reference back to the manager associated with this layer. Generally this is handled by the AnimationManager itself as layers are added to it.- Parameters:
manager
- the animation manager.
-
getManager
- Returns:
- the manager associated with this layer.
-
getName
- Returns:
- the name of this layer, used for identification, so best if unique.
-
getCurrentSourceData
- Returns:
- a source data mapping for the channels involved in the current state/transition of this layer.
-
updateLayerBlending
Update the layer blender in this animation layer to properly point to the previous layer.- Parameters:
previousLayer
- the layer before this layer in the animation manager.
-
setLayerBlender
- Parameters:
layerBlender
- the layer blender to use for combining this layer's contents with others in the animation manager.
-
getLayerBlender
- Returns:
- the layer blender used for combining this layer's contents with others in the animation manager.
-
replaceState
Description copied from interface:StateOwner
Replace the given current state with the given new state- Specified by:
replaceState
in interfaceStateOwner
- Parameters:
currentState
- the state to replacenewState
- the state to replace it with.
-
addTransition
Add a new general transition to this layer.- Parameters:
keyword
- the reference key for the added transition.state
- the transition state to add.- Throws:
IllegalArgumentException
- if keyword or state are null.
-
getTransition
- Parameters:
keyword
- the reference key for the transition state we wish to pull from this layer.- Returns:
- the transition related to the given keyword, or null if none are found.
- Throws:
IllegalArgumentException
- if keyword is null.
-
getTransitionKeywords
- Returns:
- a Set of the transition state keywords used by this layer.
-
removeTransition
Remove a transition state by keyword.- Parameters:
keyword
- the reference key for the transition state we wish to remove from this layer.- Returns:
- the removed transition, or null if none was found by the given keyword.
- Throws:
IllegalArgumentException
- if keyword is null.
-
removeTransition
Remove the first instance of a specific transition state from this layer.- Parameters:
transition
- the transition state we wish to remove from this steady state.- Returns:
- true if we found and removed the given transition.
- Throws:
IllegalArgumentException
- if transition is null.
-