com.jme.animation
Class SpatialTransformer

java.lang.Object
  extended bycom.jme.scene.Controller
      extended bycom.jme.animation.SpatialTransformer
All Implemented Interfaces:
java.io.Serializable

public class SpatialTransformer
extends Controller

Started Date: Jul 9, 2004

This class animates spatials by interpolating between various transformations. The user defines objects to be transformed and what rotation/translation/scale to give each object at various points in time. The user must call interpolateMissing() before using the controller in order to interpolate unspecified translation/rotation/scale.

Author:
Jack Lindamood, Philip Wainwright (bugfixes)
See Also:
Serialized Form

Nested Class Summary
 class SpatialTransformer.PointInTime
          Defines a point in time where at time time, ohject toChange[i] will assume transformation look[i].
 
Field Summary
 java.util.ArrayList keyframes
          Interpolated array of keyframe states
 int[] parentIndexes
          parentIndexes[i] states that toChange[i]'s parent is toChange[parentIndex[i]].
 Spatial[] toChange
          Refrences to the objects that will be changed.
 
Fields inherited from class com.jme.scene.Controller
RT_CLAMP, RT_CYCLE, RT_WRAP
 
Constructor Summary
SpatialTransformer(int numObjects)
          Constructs a new SpatialTransformer that will operate on numObjects Spatials
 
Method Summary
 int getNumObjects()
          Returns the number of Objects used by this SpatialTransformer
 void interpolateMissing()
          This must be called one time, once all translations/rotations/scales have been set.
 Controller putClone(Controller store, CloneCreator properties)
          This function should be overridden by any Spatial objects that want their Controller cloned by a CloneCreator.
 void setObject(Spatial objChange, int index, int parentIndex)
          Sets an object to animate.
 void setPosition(int indexInST, float time, Vector3f position)
          Sets object with index indexInST to translate by position at time time.
 void setRotation(int indexInST, float time, Quaternion rot)
          Sets object with index indexInST to rotate by rot at time time.
 void setScale(int indexInST, float time, Vector3f scale)
          Sets object with index indexInST to scale by scale at time time.
 void update(float time)
          Defined by extending classes, update is a signal to Controller that it should update whatever object(s) it is controlling.
 
Methods inherited from class com.jme.scene.Controller
getMaxTime, getMinTime, getRepeatType, getSpeed, isActive, setActive, setMaxTime, setMinTime, setRepeatType, setSpeed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

toChange

public Spatial[] toChange
Refrences to the objects that will be changed.


parentIndexes

public int[] parentIndexes
parentIndexes[i] states that toChange[i]'s parent is toChange[parentIndex[i]].


keyframes

public java.util.ArrayList keyframes
Interpolated array of keyframe states

Constructor Detail

SpatialTransformer

public SpatialTransformer(int numObjects)
Constructs a new SpatialTransformer that will operate on numObjects Spatials

Parameters:
numObjects - The number of spatials to change
Method Detail

update

public void update(float time)
Description copied from class: Controller
Defined by extending classes, update is a signal to Controller that it should update whatever object(s) it is controlling.

Specified by:
update in class Controller
Parameters:
time - The time in seconds between the last call to update and the current one

setObject

public void setObject(Spatial objChange,
                      int index,
                      int parentIndex)
Sets an object to animate. The object's index is index and it's parent index is parentIndex. A parent index of -1 indicates it has no parent.

Parameters:
objChange - The spatial that will be updated by this SpatialTransformer.
index - The index of that spatial in this transformer's array
parentIndex - The parentIndex in this transformer's array for this Spatial

setRotation

public void setRotation(int indexInST,
                        float time,
                        Quaternion rot)
Sets object with index indexInST to rotate by rot at time time.

Parameters:
indexInST - The index of the spatial to change
time - The time for the spatial to take this rotation
rot - The rotation to take

setPosition

public void setPosition(int indexInST,
                        float time,
                        Vector3f position)
Sets object with index indexInST to translate by position at time time.

Parameters:
indexInST - The index of the spatial to change
time - The time for the spatial to take this translation
position - The position to take

setScale

public void setScale(int indexInST,
                     float time,
                     Vector3f scale)
Sets object with index indexInST to scale by scale at time time.

Parameters:
indexInST - The index of the spatial to change
time - The time for the spatial to take this scale
scale - The scale to take

interpolateMissing

public void interpolateMissing()
This must be called one time, once all translations/rotations/scales have been set. It will interpolate unset values to make the animation look correct. Tail and head values are assumed to be the identity.


getNumObjects

public int getNumObjects()
Returns the number of Objects used by this SpatialTransformer

Returns:
The number of objects.

putClone

public Controller putClone(Controller store,
                           CloneCreator properties)
Description copied from class: Controller
This function should be overridden by any Spatial objects that want their Controller cloned by a CloneCreator. It stores into "store" the properties of this Controller.

Overrides:
putClone in class Controller
Parameters:
store - The Controller to store properties into. If null, null is returned.
properties - The CloneCreator controlling how things should be copied into the store Controller.
Returns:
The store controller, after a copy.