org.xith3d.schedops.movement
Class AnimatableGroup

java.lang.Object
  extended by org.xith3d.scenegraph.SceneGraphObject
      extended by org.xith3d.scenegraph.Node
          extended by org.xith3d.scenegraph.GroupNode
              extended by org.xith3d.scenegraph.Group
                  extended by org.xith3d.scenegraph.TransformGroup
                      extended by org.xith3d.schedops.movement.AnimatableGroup
All Implemented Interfaces:
org.jagatoo.datatypes.NamableObject, org.jagatoo.datatypes.NamedObject, org.openmali.spatial.SpatialNode, Animatable, ScheduledOperation, Updatable, Transformable
Direct Known Subclasses:
RotatableGroup, TranslatableGroup

public class AnimatableGroup
extends TransformGroup
implements Animatable

This class is useful to automatically animate a branch in your scenegraph.


Field Summary
protected  GroupAnimator groupAnimator
           
protected static java.util.Random RND
           
 
Fields inherited from class org.xith3d.scenegraph.GroupNode
children, hostGroup, numChildren, totalNumChildren, totalNumShapes
 
Fields inherited from class org.xith3d.scenegraph.Node
bounds, boundsAutoCompute, boundsDirty, globalIgnoreBounds, instanceBoundsTypeHint, transformGroup, untransformedBounds
 
Fields inherited from class org.xith3d.scenegraph.SceneGraphObject
XITH3D_USERDATAKEY_OLDUSERDATA
 
Constructor Summary
AnimatableGroup(GroupAnimator groupAnimator)
          Creates a new AnimatableGroup.
 
Method Summary
 boolean animate(long gameTime, long frameTime, UpdatingThread.TimingMode timingMode)
          Calculates positions and rotation of contained objects to render them at their new placement, if the animation has been started.
 GroupAnimator getGroupAnimator()
           
 TransformationDirectives getTransformationDirectives()
           
 boolean isAlive()
          if false, the object will be removed from the scheduler next loop iteration
 boolean isAnimating()
          
 boolean isPersistent()
          If this operation is persistent, it remains scheduled after beeing executed once.
 void setAlive(boolean alive)
          Sets this Object alive or dead
 void setScale(float factor)
          Sets this group's scale to the specified factor.
 void setTransformationDirectives(TransformationDirectives tfDirecs)
          Changes the TransformationDirectives used by this AnimatableGroup.
 void setTranslation(float transX, float transY, float transZ)
          Moves this Group by the specified vector-components.
 void setTranslation(org.openmali.vecmath2.Vector3f translation)
          Moves this Group by the specified vector.
 void startAnimation(long gameTime, UpdatingThread.TimingMode timingMode)
          Starts the animation of this object.
 void stopAnimation()
          Stops the animation of this object.
 void update(long gameTime, long frameTime, UpdatingThread.TimingMode timingMode)
          Updates this Updatable object.
 
Methods inherited from class org.xith3d.scenegraph.TransformGroup
getLocalTransform, getLocalTransform, getPosition, getPosition, getTransform, getTransform, getWorldTransform, newInstance, onTransformChanged, setLocalTransform, setPosition, setPosition, setTransform, traverse, updateTransform
 
Methods inherited from class org.xith3d.scenegraph.Group
moveTo
 
Methods inherited from class org.xith3d.scenegraph.GroupNode
absorbDetails, addChild, addChild, checkChild, dump, dump, ensureCapacity, expandBounds, findAll, findAll, findFirst, findFirst, freeOpenGLResources, getChild, getChildren, getChildren, getClipper, getPickHost, getScissorRect, getTotalNumChildren, getTotalNumShapes, indexOf, isPickHost, mergeInheritedClipper, mergeInheritedNodes, mergeInheritedScissorRect, numChildren, removeAllChildren, removeChild, removeChild, setBoundsDirty, setBoundsDirtyUpward, setChild, setClipper, setLive, setPickHost, setPickHost, setScissorRect, setShowBounds, sharedCopy, sharedCopy, traverse, unmergeInheritedFog, unmergeInheritedLight, unmergeInheritedNodes, updateBounds, updateBoundsCheap
 
Methods inherited from class org.xith3d.scenegraph.Node
cloneNode, detach, duplicateNode, freeOpenGLResources, getBounds, getBoundsAutoCompute, getBoundsType, getBoundsTypeHint, getDefaultPickable, getIndentString, getInheritedNodeAttributes, getModListener, getOrderedChild, getOrderedState, getParent, getRoot, getShadowAttachment, getShowBounds, getTransformGroup, getTreeCell, getWorldBounds, getWorldTransform, isBillboard, isIgnoreBounds, isOccluder, isPickable, isRenderable, isUpdatableNode, popGlobalIgnoreBounds, printBounds, pushGlobalIgnoreBounds, setBounds, setBoundsAutoCompute, setBoundsTypeHint, setDefaultPickable, setGlobalIgnoreBounds, setIgnoreBounds, setIsOccluder, setModListener, setOrderedChild, setParent, setPickable, setPickableRecursive, setPickableRecursive, setRenderable, setShadowAttachment, setShowBounds, setTransformGroup, setTreeCell, updateOrderedChild, updateTransformGroup, updateWorldTransform
 
Methods inherited from class org.xith3d.scenegraph.SceneGraphObject
getName, getUserData, getUserData, getUserDataMap, isLive, setName, setUserData, setUserData, setUserDataRecursive, setUserDataRecursive, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xith3d.scenegraph.Transformable
getName, setName
 

Field Detail

RND

protected static final java.util.Random RND

groupAnimator

protected final GroupAnimator groupAnimator
Constructor Detail

AnimatableGroup

public AnimatableGroup(GroupAnimator groupAnimator)
Creates a new AnimatableGroup.

Parameters:
groupAnimator - the GroupAnimator used to animate this group
Method Detail

getGroupAnimator

public GroupAnimator getGroupAnimator()

getTransformationDirectives

public TransformationDirectives getTransformationDirectives()
Returns:
the directives for this Group's rotation

setTransformationDirectives

public void setTransformationDirectives(TransformationDirectives tfDirecs)
Changes the TransformationDirectives used by this AnimatableGroup.

Parameters:
tfDirecs - the new TransformationDirectives

isAnimating

public boolean isAnimating()

Specified by:
isAnimating in interface Animatable
Returns:
is this object's animation running

startAnimation

public void startAnimation(long gameTime,
                           UpdatingThread.TimingMode timingMode)
Starts the animation of this object.

Specified by:
startAnimation in interface Animatable

stopAnimation

public void stopAnimation()
Stops the animation of this object.

Specified by:
stopAnimation in interface Animatable

isPersistent

public boolean isPersistent()
If this operation is persistent, it remains scheduled after beeing executed once.

Specified by:
isPersistent in interface ScheduledOperation

animate

public boolean animate(long gameTime,
                       long frameTime,
                       UpdatingThread.TimingMode timingMode)
Calculates positions and rotation of contained objects to render them at their new placement, if the animation has been started.

Parameters:
gameTime - the amount of milliseconds since the game started
frameTime - miliseconds needed to render one frame
Returns:
a boolean telling whether the rotation has been done or not

update

public void update(long gameTime,
                   long frameTime,
                   UpdatingThread.TimingMode timingMode)
Updates this Updatable object.

Specified by:
update in interface Updatable
Parameters:
gameTime - the gameTime in Milliseconds
frameTime - the frameTime in Milliseconds (needed time for the last frame)
timingMode - the TimingMode to use for frameTime.

setAlive

public void setAlive(boolean alive)
Sets this Object alive or dead

Specified by:
setAlive in interface ScheduledOperation
Parameters:
alive - if false, the object will be removed from the scheduler next loop iteration

isAlive

public boolean isAlive()
if false, the object will be removed from the scheduler next loop iteration

Specified by:
isAlive in interface ScheduledOperation

setTranslation

public void setTranslation(float transX,
                           float transY,
                           float transZ)
Moves this Group by the specified vector-components.

Parameters:
transX - the x-amount to move by
transY - the y-amount to move by
transZ - the z-amount to move by

setTranslation

public void setTranslation(org.openmali.vecmath2.Vector3f translation)
Moves this Group by the specified vector.

Parameters:
translation - the amount to move by

setScale

public void setScale(float factor)
Sets this group's scale to the specified factor. should be implemented in the TransformGroup class to economize coding!

Parameters:
factor - the factor to scale to