org.xith3d.schedops.movement
Class GroupAnimator

java.lang.Object
  extended by org.xith3d.schedops.movement.GroupAnimator
All Implemented Interfaces:
Animatable, ScheduledOperation, Updatable
Direct Known Subclasses:
GroupRotator, GroupTranslator

public abstract class GroupAnimator
extends java.lang.Object
implements Animatable

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


Field Summary
protected static java.util.Random rnd
           
protected  Transform3D t3dMain
           
protected  java.util.ArrayList<Transformable> transformNodes
           
 
Constructor Summary
GroupAnimator(Transformable tn, TransformationDirectives tfDirecs)
          Creates a new GroupAnimator.
GroupAnimator(TransformationDirectives tfDirecs)
          Creates a new GroupAnimator.
 
Method Summary
 void addTransformNode(Transformable tn)
          Sets the TransformGroup to animate.
abstract  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.
 int getNumTransformNodes()
           
 TransformationDirectives getTransformationDirectives()
           
 Transformable getTransformNode()
           
 Transformable getTransformNode(int index)
           
 boolean isAlive()
          If false, the object will be removed from the scheduler next loop iteration.
 boolean isAnimating()
           
 boolean isPersistent()
          This operation IS persistent.
 void setAlive(boolean alive)
          Sets this Object alive or dead.
 void setScale(float factor)
          Sets this group's scale to the specified factor.
 void setTransform(Transform3D transform)
          This method could be implemented otherwise if the super method wasn't final.
 void setTransformationDirectives(TransformationDirectives tfDirecs)
          Changes the TransformationDirectives used by this AnimatableGroup.
 void setTransformNode(int index, Transformable tn)
          Sets the TransformGroup to animate.
 void setTransformNode(Transformable tn)
          Sets the TransformGroup to animate.
 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transformNodes

protected final java.util.ArrayList<Transformable> transformNodes

t3dMain

protected Transform3D t3dMain

rnd

protected static java.util.Random rnd
Constructor Detail

GroupAnimator

public GroupAnimator(TransformationDirectives tfDirecs)
Creates a new GroupAnimator.

Parameters:
tfDirecs - the new TransformationDirectives

GroupAnimator

public GroupAnimator(Transformable tn,
                     TransformationDirectives tfDirecs)
Creates a new GroupAnimator.

Parameters:
tn - the TransformNode to animate
tfDirecs - the new TransformationDirectives
Method Detail

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:
a boolean saying whether this AnimatableGroup is animating or not

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

animate

public abstract 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
timingMode -
Returns:
a boolean telling whether the rotation has been done or not

update

public final void update(long gameTime,
                         long frameTime,
                         UpdatingThread.TimingMode timingMode)
Description copied from interface: Updatable
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.

isPersistent

public final boolean isPersistent()
This operation IS persistent. This operation will remains scheduled after beeing executed once.

Specified by:
isPersistent in interface ScheduledOperation

setAlive

public final 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 final boolean isAlive()
If false, the object will be removed from the scheduler next loop iteration.

Specified by:
isAlive in interface ScheduledOperation

setTransform

public final void setTransform(Transform3D transform)
This method could be implemented otherwise if the super method wasn't final.


setTranslation

public final 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 final void setTranslation(org.openmali.vecmath2.Vector3f translation)
Moves this Group by the specified vector.

Parameters:
translation - the amount to move by

setScale

public final 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

getNumTransformNodes

public final int getNumTransformNodes()
Returns:
the number of Transformables, this GroupAnimator influences.

addTransformNode

public final void addTransformNode(Transformable tn)
Sets the TransformGroup to animate.

Parameters:
tn - the TransformNode to animate

setTransformNode

public final void setTransformNode(int index,
                                   Transformable tn)
Sets the TransformGroup to animate.

Parameters:
index -
tn - the TransformNode to animate

setTransformNode

public final void setTransformNode(Transformable tn)
Sets the TransformGroup to animate.

Parameters:
tn - the TransformNode to animate

getTransformNode

public final Transformable getTransformNode(int index)
Parameters:
index -
Returns:
the TransformNode to animate

getTransformNode

public final Transformable getTransformNode()
Returns:
the TransformNode to animate