Package com.jme3.anim

Class AnimComposer

All Implemented Interfaces:
Savable, Control, JmeCloneable, Cloneable

public class AnimComposer extends AbstractControl
AnimComposer is a Spatial control that allows manipulation of armature (skeletal) animation.
  • Field Details

  • Constructor Details

    • AnimComposer

      public AnimComposer()
      Instantiate a composer with a single layer, no actions, and no clips.
  • Method Details

    • hasAnimClip

      public boolean hasAnimClip(String name)
      Tells if an animation is contained in the list of animations.
      Parameters:
      name - The name of the animation.
      Returns:
      true, if the named animation is in the list of animations.
    • getAnimClip

      public AnimClip getAnimClip(String name)
      Retrieve an animation from the list of animations.
      Parameters:
      name - The name of the animation to retrieve.
      Returns:
      The animation corresponding to the given name, or null, if no such named animation exists.
    • addAnimClip

      public void addAnimClip(AnimClip anim)
      Adds an animation to be available for playing to this AnimControl.
      Parameters:
      anim - The animation to add.
    • removeAnimClip

      public void removeAnimClip(AnimClip anim)
      Remove an animation so that it is no longer available for playing.
      Parameters:
      anim - The animation to remove.
    • setCurrentAction

      public Action setCurrentAction(String name)
      Run an action on the default layer. By default action will loop.
      Parameters:
      name - The name of the action to run.
      Returns:
      The action corresponding to the given name.
    • setCurrentAction

      public Action setCurrentAction(String actionName, String layerName)
      Run an action on specified layer. By default action will loop.
      Parameters:
      actionName - The name of the action to run.
      layerName - The layer on which action should run.
      Returns:
      The action corresponding to the given name.
    • setCurrentAction

      public Action setCurrentAction(String actionName, String layerName, boolean loop)
      Run an action on specified layer.
      Parameters:
      actionName - The name of the action to run.
      layerName - The layer on which action should run.
      loop - True if the action must loop.
      Returns:
      The action corresponding to the given name.
    • getCurrentAction

      public Action getCurrentAction()
      Return the current action on the default layer.
      Returns:
      The action corresponding to the given name.
    • getCurrentAction

      public Action getCurrentAction(String layerName)
      Return current action on specified layer.
      Parameters:
      layerName - The layer on which action should run.
      Returns:
      The action corresponding to the given name.
    • removeCurrentAction

      public void removeCurrentAction()
      Remove current action on default layer.
    • removeCurrentAction

      public void removeCurrentAction(String layerName)
      Remove current action on specified layer.
      Parameters:
      layerName - The name of the layer we want to remove its action.
    • getTime

      public double getTime()
      Returns current time of the default layer.
      Returns:
      The current time.
    • getTime

      public double getTime(String layerName)
      Returns current time of the specified layer.
      Parameters:
      layerName - The layer from which to get the time.
      Returns:
      the time (in seconds)
    • setTime

      public void setTime(double time)
      Sets current time on the default layer.
      Parameters:
      time - the desired time (in seconds)
    • setTime

      public void setTime(String layerName, double time)
      Sets current time on the specified layer.
      Parameters:
      layerName - the name of the Layer to modify
      time - the desired time (in seconds)
    • action

      public Action action(String name)
      Parameters:
      name - The name of the action to return.
      Returns:
      The action registered with specified name. It will make a new action if there isn't any.
      See Also:
    • getAction

      public Action getAction(String name)
      Parameters:
      name - The name of the action to return.
      Returns:
      The action registered with specified name or null if nothing is registered.
    • addAction

      public void addAction(String name, Action action)
      Register given action with specified name.
      Parameters:
      name - The name of the action.
      action - The action to add.
    • makeAction

      public Action makeAction(String name)
      Create a new ClipAction with specified clip name.
      Parameters:
      name - The name of the clip.
      Returns:
      a new action
      Throws:
      IllegalArgumentException - if clip with specified name not found.
    • hasAction

      public boolean hasAction(String name)
      Tells if an action is contained in the list of actions.
      Parameters:
      name - The name of the action.
      Returns:
      true, if the named action is in the list of actions.
    • removeAction

      public Action removeAction(String name)
      Remove specified action.
      Parameters:
      name - The name of the action to remove.
      Returns:
      The removed action.
    • makeLayer

      public void makeLayer(String name, AnimationMask mask)
      Add a layer to this composer.
      Parameters:
      name - the desired name for the new layer
      mask - the desired mask for the new layer (alias created)
    • removeLayer

      public void removeLayer(String name)
      Remove specified layer. This will stop the current action on this layer.
      Parameters:
      name - The name of the layer to remove.
    • actionSequence

      public BaseAction actionSequence(String name, Tween... tweens)
      Creates an action that will interpolate over an entire sequence of tweens in order.
      Parameters:
      name - a name for the new Action
      tweens - the desired sequence of tweens
      Returns:
      a new instance
    • actionBlended

      public BlendAction actionBlended(String name, BlendSpace blendSpace, String... clips)
      Creates an action that blends the named clips using the given blend space.
      Parameters:
      name - a name for the new Action
      blendSpace - how to blend the clips (not null, alias created)
      clips - the names of the clips to be used (not null)
      Returns:
      a new instance
    • reset

      public void reset()
      Reset all layers to t=0 with no current action.
    • getAnimClips

      public Collection<AnimClip> getAnimClips()
      Returns an unmodifiable collection of all available animations. When an attempt is made to modify the collection, an UnsupportedOperationException is thrown.
      Returns:
      the unmodifiable collection of animations
    • getAnimClipsNames

      public Set<String> getAnimClipsNames()
      Returns an unmodifiable set of all available animation names. When an attempt is made to modify the set, an UnsupportedOperationException is thrown.
      Returns:
      the unmodifiable set of animation names.
    • controlUpdate

      protected void controlUpdate(float tpf)
      used internally
      Specified by:
      controlUpdate in class AbstractControl
      Parameters:
      tpf - time per frame (in seconds)
    • controlRender

      protected void controlRender(RenderManager rm, ViewPort vp)
      used internally
      Specified by:
      controlRender in class AbstractControl
      Parameters:
      rm - the RenderManager rendering the controlled Spatial (not null)
      vp - the ViewPort being rendered (not null)
    • getGlobalSpeed

      public float getGlobalSpeed()
      Determine the global speed applied to all layers.
      Returns:
      the speed factor (1=normal speed)
    • setGlobalSpeed

      public void setGlobalSpeed(float globalSpeed)
      Alter the global speed applied to all layers.
      Parameters:
      globalSpeed - the desired speed factor (1=normal speed, default=1)
    • getLayer

      public AnimLayer getLayer(String layerName)
      Provides access to the named layer.
      Parameters:
      layerName - the name of the layer to access
      Returns:
      the pre-existing instance
    • getLayerManager

      public Object getLayerManager(String layerName)
      Access the manager of the named layer.
      Parameters:
      layerName - the name of the layer to access
      Returns:
      the current manager (typically an AnimEvent) or null for none
    • getLayerNames

      public Set<String> getLayerNames()
      Enumerates the names of all layers.
      Returns:
      an unmodifiable set of names
    • setLayerManager

      public void setLayerManager(String layerName, Object manager)
      Assign a manager to the named layer.
      Parameters:
      layerName - the name of the layer to modify
      manager - the desired manager (typically an AnimEvent) or null for none
    • jmeClone

      public Object jmeClone()
      Create a shallow clone for the JME cloner.
      Specified by:
      jmeClone in interface JmeCloneable
      Overrides:
      jmeClone in class AbstractControl
      Returns:
      a new instance
    • cloneFields

      public void cloneFields(Cloner cloner, Object original)
      Callback from Cloner to convert this shallow-cloned composer into a deep-cloned one, using the specified Cloner and original to resolve copied fields.
      Specified by:
      cloneFields in interface JmeCloneable
      Overrides:
      cloneFields in class AbstractControl
      Parameters:
      cloner - the Cloner that's cloning this composer (not null)
      original - the instance from which this composer was shallow-cloned (not null, unaffected)
    • read

      public void read(JmeImporter im) throws IOException
      De-serialize this composer from the specified importer, for example when loading from a J3O file.
      Specified by:
      read in interface Savable
      Overrides:
      read in class AbstractControl
      Parameters:
      im - the importer to use (not null)
      Throws:
      IOException - from the importer
    • write

      public void write(JmeExporter ex) throws IOException
      Serialize this composer to the specified exporter, for example when saving to a J3O file.
      Specified by:
      write in interface Savable
      Overrides:
      write in class AbstractControl
      Parameters:
      ex - the exporter to use (not null)
      Throws:
      IOException - from the exporter