Package com.jme3.anim
Class AnimComposer
java.lang.Object
com.jme3.scene.control.AbstractControl
com.jme3.anim.AnimComposer
- All Implemented Interfaces:
Savable
,Control
,JmeCloneable
,Cloneable
AnimComposer is a Spatial control that allows manipulation of
armature
(skeletal) animation.-
Field Summary
Fields inherited from class com.jme3.scene.control.AbstractControl
enabled, spatial
-
Constructor Summary
ConstructorDescriptionInstantiate a composer with a single layer, no actions, and no clips. -
Method Summary
Modifier and TypeMethodDescriptionactionBlended
(String name, BlendSpace blendSpace, String... clips) Creates an action that blends the named clips using the given blend space.actionSequence
(String name, Tween... tweens) Creates an action that will interpolate over an entire sequence of tweens in order.void
Register given action with specified name.void
addAnimClip
(AnimClip anim) Adds an animation to be available for playing to thisAnimControl
.void
cloneFields
(Cloner cloner, Object original) Callback fromCloner
to convert this shallow-cloned composer into a deep-cloned one, using the specified Cloner and original to resolve copied fields.protected void
controlRender
(RenderManager rm, ViewPort vp) used internallyprotected void
controlUpdate
(float tpf) used internallygetAnimClip
(String name) Retrieve an animation from the list of animations.Returns an unmodifiable collection of all available animations.Returns an unmodifiable set of all available animation names.Return the current action on the default layer.getCurrentAction
(String layerName) Return current action on specified layer.float
Determine the global speed applied to all layers.Provides access to the named layer.getLayerManager
(String layerName) Access the manager of the named layer.Enumerates the names of all layers.double
getTime()
Returns current time of the default layer.double
Returns current time of the specified layer.boolean
Tells if an action is contained in the list of actions.boolean
hasAnimClip
(String name) Tells if an animation is contained in the list of animations.jmeClone()
Create a shallow clone for the JME cloner.makeAction
(String name) Create a new ClipAction with specified clip name.void
makeLayer
(String name, AnimationMask mask) Add a layer to this composer.void
read
(JmeImporter im) De-serialize this composer from the specified importer, for example when loading from a J3O file.removeAction
(String name) Remove specified action.void
removeAnimClip
(AnimClip anim) Remove an animation so that it is no longer available for playing.void
Remove current action on default layer.void
removeCurrentAction
(String layerName) Remove current action on specified layer.void
removeLayer
(String name) Remove specified layer.void
reset()
Reset all layers to t=0 with no current action.setCurrentAction
(String name) Run an action on the default layer.setCurrentAction
(String actionName, String layerName) Run an action on specified layer.setCurrentAction
(String actionName, String layerName, boolean loop) Run an action on specified layer.void
setGlobalSpeed
(float globalSpeed) Alter the global speed applied to all layers.void
setLayerManager
(String layerName, Object manager) Assign a manager to the named layer.void
setTime
(double time) Sets current time on the default layer.void
Sets current time on the specified layer.void
write
(JmeExporter ex) Serialize this composer to the specified exporter, for example when saving to a J3O file.Methods inherited from class com.jme3.scene.control.AbstractControl
cloneForSpatial, getSpatial, isEnabled, render, setEnabled, setSpatial, update
-
Field Details
-
DEFAULT_LAYER
The name of the default layer.- See Also:
-
-
Constructor Details
-
AnimComposer
public AnimComposer()Instantiate a composer with a single layer, no actions, and no clips.
-
-
Method Details
-
hasAnimClip
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
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
Adds an animation to be available for playing to thisAnimControl
.- Parameters:
anim
- The animation to add.
-
removeAnimClip
Remove an animation so that it is no longer available for playing.- Parameters:
anim
- The animation to remove.
-
setCurrentAction
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
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
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
Return the current action on the default layer.- Returns:
- The action corresponding to the given name.
-
getCurrentAction
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
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
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
Sets current time on the specified layer.- Parameters:
layerName
- the name of the Layer to modifytime
- the desired time (in seconds)
-
action
- 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
- Parameters:
name
- The name of the action to return.- Returns:
- The action registered with specified name or null if nothing is registered.
-
addAction
Register given action with specified name.- Parameters:
name
- The name of the action.action
- The action to add.
-
makeAction
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
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
Remove specified action.- Parameters:
name
- The name of the action to remove.- Returns:
- The removed action.
-
makeLayer
Add a layer to this composer.- Parameters:
name
- the desired name for the new layermask
- the desired mask for the new layer (alias created)
-
removeLayer
Remove specified layer. This will stop the current action on this layer.- Parameters:
name
- The name of the layer to remove.
-
actionSequence
Creates an action that will interpolate over an entire sequence of tweens in order.- Parameters:
name
- a name for the new Actiontweens
- the desired sequence of tweens- Returns:
- a new instance
-
actionBlended
Creates an action that blends the named clips using the given blend space.- Parameters:
name
- a name for the new ActionblendSpace
- 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
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
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 classAbstractControl
- Parameters:
tpf
- time per frame (in seconds)
-
controlRender
used internally- Specified by:
controlRender
in classAbstractControl
- 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
Provides access to the named layer.- Parameters:
layerName
- the name of the layer to access- Returns:
- the pre-existing instance
-
getLayerManager
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
Enumerates the names of all layers.- Returns:
- an unmodifiable set of names
-
setLayerManager
Assign a manager to the named layer.- Parameters:
layerName
- the name of the layer to modifymanager
- the desired manager (typically an AnimEvent) or null for none
-
jmeClone
Create a shallow clone for the JME cloner.- Specified by:
jmeClone
in interfaceJmeCloneable
- Overrides:
jmeClone
in classAbstractControl
- Returns:
- a new instance
-
cloneFields
Callback fromCloner
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 interfaceJmeCloneable
- Overrides:
cloneFields
in classAbstractControl
- 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
De-serialize this composer from the specified importer, for example when loading from a J3O file.- Specified by:
read
in interfaceSavable
- Overrides:
read
in classAbstractControl
- Parameters:
im
- the importer to use (not null)- Throws:
IOException
- from the importer
-
write
Serialize this composer to the specified exporter, for example when saving to a J3O file.- Specified by:
write
in interfaceSavable
- Overrides:
write
in classAbstractControl
- Parameters:
ex
- the exporter to use (not null)- Throws:
IOException
- from the exporter
-