com.jme3.animation
Class AnimControl

java.lang.Object
  extended by com.jme3.scene.control.AbstractControl
      extended by com.jme3.animation.AnimControl
All Implemented Interfaces:
Savable, Control, java.lang.Cloneable

public final class AnimControl
extends AbstractControl
implements java.lang.Cloneable

AnimControl is a Spatial control that allows manipulation of skeletal animation. The control currently supports: 1) Animation blending/transitions 2) Multiple animation channels 3) Multiple skins 4) Animation event listeners 5) Animated model cloning 6) Animated model binary import/export Planned: 1) Hardware skinning 2) Morph/Pose animation 3) Attachments 4) Add/remove skins


Field Summary
 
Fields inherited from class com.jme3.scene.control.AbstractControl
enabled, spatial
 
Constructor Summary
AnimControl()
          Serialization only.
AnimControl(Skeleton skeleton)
          Creates a new animation control for the given skeleton.
 
Method Summary
 void addAnim(Animation anim)
          Adds an animation to be available for playing to this AnimControl.
 void addListener(AnimEventListener listener)
          Adds a new listener to receive animation related events.
 void clearChannels()
          Clears all the channels that were created.
 void clearListeners()
          Clears all the listeners added to this AnimControl
 Control cloneForSpatial(Spatial spatial)
          Internal use only.
protected  void controlRender(RenderManager rm, ViewPort vp)
          Internal use only.
protected  void controlUpdate(float tpf)
          Internal use only.
 AnimChannel createChannel()
          Create a new animation channel, by default assigned to all bones in the skeleton.
 Animation getAnim(java.lang.String name)
          Retrieve an animation from the list of animations.
 float getAnimationLength(java.lang.String name)
          Returns the length of the given named animation.
 java.util.Collection<java.lang.String> getAnimationNames()
           
 AnimChannel getChannel(int index)
          Return the animation channel at the given index.
 int getNumChannels()
           
 Skeleton getSkeleton()
           
 void read(JmeImporter im)
           
 void removeAnim(Animation anim)
          Remove an animation so that it is no longer available for playing.
 void removeListener(AnimEventListener listener)
          Removes the given listener from listening to events.
 void setAnimations(java.util.HashMap<java.lang.String,Animation> animations)
           
 void setSpatial(Spatial spatial)
          Internal use only.
 void write(JmeExporter ex)
           
 
Methods inherited from class com.jme3.scene.control.AbstractControl
getSpatial, isEnabled, render, setEnabled, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnimControl

public AnimControl(Skeleton skeleton)
Creates a new animation control for the given skeleton. The method setAnimations(java.util.HashMap) must be called after initialization in order for this class to be useful.

Parameters:
skeleton - The skeleton to animate

AnimControl

public AnimControl()
Serialization only. Do not use.

Method Detail

cloneForSpatial

public Control cloneForSpatial(Spatial spatial)
Internal use only.

Specified by:
cloneForSpatial in interface Control
Returns:
A clone of this control for the spatial

setAnimations

public void setAnimations(java.util.HashMap<java.lang.String,Animation> animations)
Parameters:
animations - Set the animations that this AnimControl will be capable of playing. The animations should be compatible with the skeleton given in the constructor.

getAnim

public Animation getAnim(java.lang.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.

addAnim

public void addAnim(Animation anim)
Adds an animation to be available for playing to this AnimControl.

Parameters:
anim - The animation to add.

removeAnim

public void removeAnim(Animation anim)
Remove an animation so that it is no longer available for playing.

Parameters:
anim - The animation to remove.

createChannel

public AnimChannel createChannel()
Create a new animation channel, by default assigned to all bones in the skeleton.

Returns:
A new animation channel for this AnimControl.

getChannel

public AnimChannel getChannel(int index)
Return the animation channel at the given index.

Parameters:
index - The index, starting at 0, to retrieve the AnimChannel.
Returns:
The animation channel at the given index, or throws an exception if the index is out of bounds.
Throws:
java.lang.IndexOutOfBoundsException - If no channel exists at the given index.

getNumChannels

public int getNumChannels()
Returns:
The number of channels that are controlled by this AnimControl.
See Also:
createChannel()

clearChannels

public void clearChannels()
Clears all the channels that were created.

See Also:
createChannel()

getSkeleton

public Skeleton getSkeleton()
Returns:
The skeleton of this AnimControl.

addListener

public void addListener(AnimEventListener listener)
Adds a new listener to receive animation related events.

Parameters:
listener - The listener to add.

removeListener

public void removeListener(AnimEventListener listener)
Removes the given listener from listening to events.

Parameters:
listener -
See Also:
addListener(com.jme3.animation.AnimEventListener)

clearListeners

public void clearListeners()
Clears all the listeners added to this AnimControl

See Also:
addListener(com.jme3.animation.AnimEventListener)

setSpatial

public void setSpatial(Spatial spatial)
Internal use only.

Specified by:
setSpatial in interface Control
Overrides:
setSpatial in class AbstractControl
Parameters:
spatial - the spatial to be controlled. This should not be called from user code.

getAnimationNames

public java.util.Collection<java.lang.String> getAnimationNames()
Returns:
The names of all animations that this AnimControl can play.

getAnimationLength

public float getAnimationLength(java.lang.String name)
Returns the length of the given named animation.

Parameters:
name - The name of the animation
Returns:
The length of time, in seconds, of the named animation.

controlUpdate

protected void controlUpdate(float tpf)
Internal use only.

Specified by:
controlUpdate in class AbstractControl

controlRender

protected void controlRender(RenderManager rm,
                             ViewPort vp)
Internal use only.

Specified by:
controlRender in class AbstractControl

write

public void write(JmeExporter ex)
           throws java.io.IOException
Specified by:
write in interface Savable
Overrides:
write in class AbstractControl
Throws:
java.io.IOException

read

public void read(JmeImporter im)
          throws java.io.IOException
Specified by:
read in interface Savable
Overrides:
read in class AbstractControl
Throws:
java.io.IOException