Class AnimationLayer

java.lang.Object
com.ardor3d.extension.animation.skeletal.layer.AnimationLayer
All Implemented Interfaces:
StateOwner

public class AnimationLayer extends Object implements 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 Details

    • BASE_LAYER_NAME

      public static final String BASE_LAYER_NAME
      The layer name of the default base layer.
      See Also:
  • Constructor Details

    • AnimationLayer

      public AnimationLayer(String name)
      Construct a new AnimationLayer.
      Parameters:
      name - the name of this layer, used for id purposes.
  • Method Details

    • setCurrentState

      public boolean setCurrentState(String stateName, boolean rewind)
      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

      public void setCurrentState(AbstractFiniteState state, boolean rewind)
      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

      public boolean doTransition(String key)
      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

      public Set<String> getSteadyStateNames()
      Returns:
      a set containing the names of our steady states.
    • getCurrentState

      public AbstractFiniteState getCurrentState()
      Returns:
      the current active finite state in this machine.
    • getSteadyState

      public SteadyState getSteadyState(String stateName)
      Parameters:
      stateName - the name of the steady state we are looking for.
      Returns:
      our animation state, or null if none is found.
    • addSteadyState

      public void addSteadyState(SteadyState state)
      Add a new steady state to this layer.
      Parameters:
      state - the state to add.
    • removeSteadyState

      public boolean removeSteadyState(SteadyState state)
      Remove the given steady state from our layer
      Parameters:
      state - the state to remove
      Returns:
      true if the state was found for removal.
    • setManager

      public void setManager(AnimationManager manager)
      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

      public AnimationManager getManager()
      Returns:
      the manager associated with this layer.
    • getName

      public String getName()
      Returns:
      the name of this layer, used for identification, so best if unique.
    • getCurrentSourceData

      public Map<String,? extends Object> getCurrentSourceData()
      Returns:
      a source data mapping for the channels involved in the current state/transition of this layer.
    • updateLayerBlending

      public void updateLayerBlending(AnimationLayer previousLayer)
      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

      public void setLayerBlender(LayerBlender layerBlender)
      Parameters:
      layerBlender - the layer blender to use for combining this layer's contents with others in the animation manager.
    • getLayerBlender

      public LayerBlender getLayerBlender()
      Returns:
      the layer blender used for combining this layer's contents with others in the animation manager.
    • replaceState

      public void replaceState(AbstractFiniteState currentState, AbstractFiniteState newState)
      Description copied from interface: StateOwner
      Replace the given current state with the given new state
      Specified by:
      replaceState in interface StateOwner
      Parameters:
      currentState - the state to replace
      newState - the state to replace it with.
    • addTransition

      public void addTransition(String keyword, AbstractTransitionState state)
      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

      public AbstractTransitionState getTransition(String keyword)
      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

      public Set<String> getTransitionKeywords()
      Returns:
      a Set of the transition state keywords used by this layer.
    • removeTransition

      public AbstractTransitionState removeTransition(String keyword)
      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

      public boolean removeTransition(AbstractTransitionState transition)
      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.