org.xith3d.physics.simulation
Class Body

java.lang.Object
  extended by org.xith3d.physics.util.PlaceableImpl
      extended by org.xith3d.physics.simulation.Body
All Implemented Interfaces:
org.jagatoo.datatypes.Enableable, org.jagatoo.datatypes.NamableObject, org.jagatoo.datatypes.NamedObject, ListeningPlaceable, Placeable

public abstract class Body
extends PlaceableImpl
implements org.jagatoo.datatypes.NamableObject, org.jagatoo.datatypes.Enableable

A body has a position, an orientation, a linear and angular velocity, and some forces applied to it. It's part of a SimulationWorld and can be stepped.


Field Summary
protected  java.util.ArrayList<Collideable> collideables
          Our collideables : used for collision detection
protected  SimulationWorld world
          The simulation engine we belong to
 
Fields inherited from class org.xith3d.physics.util.PlaceableImpl
position, rotation, valueCheckedBeforeChanged
 
Constructor Summary
Body(SimulationWorld world)
          Creates a new Body.
 
Method Summary
 void addCollideable(Collideable collideable)
          Adds a collideable to this Body.
abstract  void addForce(float fx, float fy, float fz)
          Adds a force to this body.
 void addForce(org.openmali.vecmath2.Vector3f force)
          Adds a force to this body.
abstract  void addTorque(float tx, float ty, float tz)
          Adds a torque to this body.
 void addTorque(org.openmali.vecmath2.Tuple3f torque)
          Adds a torque to this body.
abstract  org.openmali.vecmath2.Vector3f getAngularVelocity()
           
 Collideable getCollideable(int i)
           
 int getCollideablesCount()
           
abstract  org.openmali.vecmath2.Vector3f getLinearVelocity()
           
abstract  float getMass()
           
 java.lang.String getName()
           
 java.lang.Object getParameter(java.lang.String member)
          Gets a member, by name.
 java.lang.Object getUserObject()
           
 SimulationWorld getWorld()
           
abstract  boolean isEnabled()
           
abstract  boolean isGravityEnabled()
           
protected  void refresh()
          Refreshes this Body's position and rotation from the implementation as well as all the child-Collideable's ones.
 void removeCollideable(Collideable collideable)
          Removes a collideable for this Body.
 void resetAngularVelocity()
          Sets the angular velocity, as "euler angles" (but for speed), about the X, Y, and Z axis to zero.
 void resetLinearVelocity()
          Sets the linear velocity of this object to zero.
abstract  void setAngularVelocity(float velX, float velY, float velZ)
          Sets the angular velocity, as "euler angles" (but for speed), about the X, Y, and Z axis
 void setAngularVelocity(org.openmali.vecmath2.Tuple3f angularVel)
          Sets the angular velocity, as "euler angles" (but for speed), about the X, Y, and Z axis
abstract  void setEnabled(boolean enabled)
          Enables or disables this Body.
abstract  void setGravityEnabled(boolean enabled)
          Enables/Disables gravity specifically for this Body.
abstract  void setLinearVelocity(float velX, float velY, float velZ)
          Sets the linear velocity of this object
 void setLinearVelocity(org.openmali.vecmath2.Vector3f linearVel)
          Sets the linear velocity of this object
abstract  void setMass(float mass)
          Sets this Body's mass.
 void setName(java.lang.String name)
          Sets this Bodie's name.
 void setParameter(java.lang.String member, java.lang.Object value)
          Sets a parameter, by name.
 void setUserObject(java.lang.Object userObject)
          Sets this Bodie's user-object.
 java.lang.String toString()
          
 
Methods inherited from class org.xith3d.physics.util.PlaceableImpl
addRepositionListener, getPosition, getPosition, getPositionX, getPositionY, getPositionZ, getRotation, getRotation, getRotationMatrix, getRotationMatrix, getRotationX, getRotationY, getRotationZ, onPositionChanged, onRotationChanged, removeRepositionListener, setPosition, setPosition, setPositionX, setPositionY, setPositionZ, setRotation, setRotation, setRotationMatrix, setRotationX, setRotationY, setRotationZ
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

world

protected final SimulationWorld world
The simulation engine we belong to


collideables

protected final java.util.ArrayList<Collideable> collideables
Our collideables : used for collision detection

Constructor Detail

Body

public Body(SimulationWorld world)
Creates a new Body. At creation time, the Body has no collideable, which means it isn't "solid". It's just a "simulated position and rotation". If you want it to react to collisions (which you probably want), you have to add some collideables to it.

Parameters:
world - the simulation world we belong to
See Also:
addCollideable(Collideable)
Method Detail

getWorld

public final SimulationWorld getWorld()
Returns:
the SimulationWorld, this Body belongs to.

setName

public final void setName(java.lang.String name)
Sets this Bodie's name.

Specified by:
setName in interface org.jagatoo.datatypes.NamableObject
Parameters:
name -

getName

public final java.lang.String getName()
Specified by:
getName in interface org.jagatoo.datatypes.NamedObject
Returns:
this Body's name.

setUserObject

public final void setUserObject(java.lang.Object userObject)
Sets this Bodie's user-object.

Parameters:
userObject -

getUserObject

public final java.lang.Object getUserObject()
Returns:
this Bodie's user-object.

setEnabled

public abstract void setEnabled(boolean enabled)
Enables or disables this Body.

Specified by:
setEnabled in interface org.jagatoo.datatypes.Enableable
Parameters:
enabled -

isEnabled

public abstract boolean isEnabled()
Specified by:
isEnabled in interface org.jagatoo.datatypes.Enableable
Returns:
true, if this Body is enabled.

setGravityEnabled

public abstract void setGravityEnabled(boolean enabled)
Enables/Disables gravity specifically for this Body.

Parameters:
enabled -

isGravityEnabled

public abstract boolean isGravityEnabled()
Returns:
if gravity is enabled specifically for this Body.

getLinearVelocity

public abstract org.openmali.vecmath2.Vector3f getLinearVelocity()
Returns:
the linear velocity of this body

setLinearVelocity

public abstract void setLinearVelocity(float velX,
                                       float velY,
                                       float velZ)
Sets the linear velocity of this object

Parameters:
velX -
velY -
velZ -

setLinearVelocity

public final void setLinearVelocity(org.openmali.vecmath2.Vector3f linearVel)
Sets the linear velocity of this object

Parameters:
linearVel -

resetLinearVelocity

public final void resetLinearVelocity()
Sets the linear velocity of this object to zero.


getAngularVelocity

public abstract org.openmali.vecmath2.Vector3f getAngularVelocity()
Returns:
the angular velocity, as "euler angles" (but for speed), about the X, Y, and Z axis

setAngularVelocity

public abstract void setAngularVelocity(float velX,
                                        float velY,
                                        float velZ)
Sets the angular velocity, as "euler angles" (but for speed), about the X, Y, and Z axis

Parameters:
velX -
velY -
velZ -

setAngularVelocity

public final void setAngularVelocity(org.openmali.vecmath2.Tuple3f angularVel)
Sets the angular velocity, as "euler angles" (but for speed), about the X, Y, and Z axis

Parameters:
angularVel -

resetAngularVelocity

public final void resetAngularVelocity()
Sets the angular velocity, as "euler angles" (but for speed), about the X, Y, and Z axis to zero.


addTorque

public abstract void addTorque(float tx,
                               float ty,
                               float tz)
Adds a torque to this body.

Parameters:
tx - X component
ty - Y component
tz - Z component

addTorque

public final void addTorque(org.openmali.vecmath2.Tuple3f torque)
Adds a torque to this body.

Parameters:
torque -

addForce

public abstract void addForce(float fx,
                              float fy,
                              float fz)
Adds a force to this body.

Parameters:
fx - X component
fy - Y component
fz - Z component

addForce

public final void addForce(org.openmali.vecmath2.Vector3f force)
Adds a force to this body.

Parameters:
force -

getParameter

public java.lang.Object getParameter(java.lang.String member)
Gets a member, by name.

Parameters:
member - the member to get
Returns:
the parameter, by name

setParameter

public void setParameter(java.lang.String member,
                         java.lang.Object value)
Sets a parameter, by name.

Parameters:
member - The name of the parameter
value - The "data" : could be Float, Vector3f, whatever..

setMass

public abstract void setMass(float mass)
Sets this Body's mass.

Parameters:
mass -

getMass

public abstract float getMass()
Returns:
this Body's mass.

addCollideable

public void addCollideable(Collideable collideable)
Adds a collideable to this Body. Collideables which are added to a Body are used for collision detection. A Body without any Collideable will just fall (if there's gravity) through anything. Note that the collideables are moved with the Body.

Parameters:
collideable -

removeCollideable

public void removeCollideable(Collideable collideable)
Removes a collideable for this Body.

Parameters:
collideable -

getCollideablesCount

public final int getCollideablesCount()
Returns:
the number of Collideables in this Body.

getCollideable

public final Collideable getCollideable(int i)
Parameters:
i -
Returns:
the i-th Collideable in this Body.

refresh

protected void refresh()
Refreshes this Body's position and rotation from the implementation as well as all the child-Collideable's ones.


toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object