org.xith3d.schedops.movement
Class Bullet

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.Bullet
All Implemented Interfaces:
org.jagatoo.datatypes.NamableObject, org.jagatoo.datatypes.NamedObject, org.openmali.spatial.SpatialNode, Animatable, ScheduledOperation, Updatable, Transformable

public abstract class Bullet
extends TransformGroup
implements Animatable

This class can be used as a base for a bullet. Add it to the scheduler of an ExtRenderLoop by calling the method addScheduledOperation(bullet). It is automatically removed from its parent BranchGroup and the scheduler when maxLifetime has been reached.


Field Summary
 
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
Bullet(org.openmali.vecmath2.Vector3f velocity, long maxLifeTime)
          Creates a new Bullet.
 
Method Summary
 long getLifeTime()
           
 org.openmali.vecmath2.Tuple3f getLocation()
           
 long getMaxLifeTime()
           
 float getSpeed()
           
 org.openmali.vecmath2.Vector3f getVelocity()
           
 boolean isAlive()
          if false, the object will be removed from the scheduler next loop iteration
 boolean isAnimating()
          A Bullet's animation is always running until it is dead.
 boolean isPersistent()
          A Bullet is always persistent until it is dead.
 void setAlive(boolean alive)
          Sets this Object alive or dead.
 void setLocation(org.openmali.vecmath2.Tuple3f location)
          Sets this Bullet's current location.
 void setMaxLifeTime(long maxLifeTime)
          Sets the maximum time, this Bullet will be alive.
 void setSpeed(float speed)
          Sets this Bullet's speed along its velocity vector.
 void setVelocity(org.openmali.vecmath2.Vector3f velocity)
          Sets this bullet's velocity vector.
 void startAnimation(long gameTime, UpdatingThread.TimingMode timingMode)
          Starts the animation of this Bullet.
 void stopAnimation()
          A Bullet's animation cannot be stopped.
 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
 

Constructor Detail

Bullet

public Bullet(org.openmali.vecmath2.Vector3f velocity,
              long maxLifeTime)
Creates a new Bullet. This calls setVelocity, setLocation, setAlive, setMaxLifeTime.

Parameters:
velocity - the velocity vector this bullet will move along. Its length is the speed.
maxLifeTime - the maximum amount of milliseconds this bullet will remain in the scheduler.
Method Detail

isAnimating

public boolean isAnimating()
A Bullet's animation is always running until it is dead.

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 Bullet.

Specified by:
startAnimation in interface Animatable

stopAnimation

public void stopAnimation()
A Bullet's animation cannot be stopped. Use setAlive() instead.

Specified by:
stopAnimation in interface Animatable
See Also:
setAlive(boolean)

isPersistent

public boolean isPersistent()
A Bullet is always persistent until it is dead.

Specified by:
isPersistent in interface ScheduledOperation

getLifeTime

public long getLifeTime()
Returns:
the milliseconds this Bullet is alive.

setVelocity

public void setVelocity(org.openmali.vecmath2.Vector3f velocity)
Sets this bullet's velocity vector. The length of this vector is the speed.

Parameters:
velocity - the new velocity vector

getVelocity

public org.openmali.vecmath2.Vector3f getVelocity()
Returns:
this Bullet's velocity vector. The length of this vector is the speed.

setLocation

public void setLocation(org.openmali.vecmath2.Tuple3f location)
Sets this Bullet's current location.

Parameters:
location - the new location

getLocation

public org.openmali.vecmath2.Tuple3f getLocation()
Returns:
this Bullet's current location.

getSpeed

public float getSpeed()
Returns:
this Bullet's speed along its velocity vector.

setSpeed

public void setSpeed(float speed)
Sets this Bullet's speed along its velocity vector.

Parameters:
speed - the new speed for this Bullet

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.

setMaxLifeTime

public void setMaxLifeTime(long maxLifeTime)
Sets the maximum time, this Bullet will be alive.

Parameters:
maxLifeTime - maximum life time in milliseconds

getMaxLifeTime

public long getMaxLifeTime()
Returns:
the maximum time, this Bullet will be alive

setAlive

public void setAlive(boolean alive)
Sets this Object alive or dead. If it is killed, is is also removed from its parent group.

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()
Description copied from interface: ScheduledOperation
if false, the object will be removed from the scheduler next loop iteration

Specified by:
isAlive in interface ScheduledOperation
Returns:
false -> the object will be removed from the scheduler next loop iteration, true otherwise