net.java.dev.joode
Class World

java.lang.Object
  extended by net.java.dev.joode.World
All Implemented Interfaces:
java.io.Serializable, SimState

public class World
extends java.lang.Object
implements SimState

A world is the container for dynamic interactions. This will be the first class users typically instanciate. Once a world is create it is populated by creating bodies and joints (passing the world as a parameter) A world operates in descrete timesteps, call step or quickstep to move the world forward in time. Step is more accurate than quickstep. Quickstep allows joints to be violated severly so do not use if joint integrity is important.

The world object supports an event system. Event listeners can listen to the world to recieve notification of world level events, such as new joints and bodies being added to the system and world step events.

Created on 14-Oct-2005

Author:
Tom Larkworthy et al.
See Also:
Body, Joint, Serialized Form

Field Summary
 java.util.List<Body> bodies
          bodies in world
 ContactParameters contactp
          allows configuration of general contact parameters
 java.lang.Object data
          a storage field for user specific data
 java.util.List<Force> forces
          forces TODO: remove functionality
 float global_cfm
          See ODE docs for an exact definition global costraint force mixing parameter hardness of constraints Value of 0 denotes the hardest constraint type
 float global_erp
          See ODE docs for an exact definition
 java.util.Vector<Joint> joints
          joints in world
 
Constructor Summary
World()
          creates an empty world
World(java.lang.Object data)
          creates a new world and stores data in its data storage area
 
Method Summary
 void addBody(Body body)
          Normally this method is not needed for user use, as bodies add themselves to a world in their constructor.
 void addBodyListener(WorldBodyListener listener)
           
 void addForce(Force force)
          do not call directly, only gravities are implemented TODO: remove force functionality
 void addJoint(Joint joint)
          Normally this method is not needed for user use, as joints add themselves to a world in their constructor.
 void addJointListener(WorldJointListener listener)
           
 void addStepListener(WorldStepListener listener)
           
 void addWorldListener(WorldListener listener)
           
 World cloneState(ClonedReferences clones)
          creates a replica of the world state.
 void quickStep(float stepsize)
          steps the world forward stepsize seconds.
 void removeBody(Body body)
           
 void removeBodyListener(WorldBodyListener listener)
           
 void removeForce(Force force)
          do not calldirectly, destroy the force instead TODO: remove force functionality
 void removeJoint(Joint joint)
           
 void removeJointContacts()
          Since the majority of adds and removes of joints per-frame are for collision contacts, this method will speed the process by removing all contacts at once
 void removeJointListener(WorldJointListener listener)
           
 void removeStepListener(WorldStepListener listener)
           
 void removeWorldListener(WorldListener listener)
           
 void step(float stepsize)
          steps the world forward stepsize seconds, using Euler intergration.
 void stepFast()
          Calls quickStep(float) with a value of 0.1f.
 void stepMidPoint(float stepsize)
          steps the world forward stepsize seconds, using mid point method for intergration.
 void stepRungeKutter(float stepsize)
          steps the world forward stepsize seconds, using Runge-Kutter of order 4 intergration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bodies

public java.util.List<Body> bodies
bodies in world


joints

public java.util.Vector<Joint> joints
joints in world


forces

public java.util.List<Force> forces
forces TODO: remove functionality


data

public java.lang.Object data
a storage field for user specific data


global_erp

public float global_erp

See ODE docs for an exact definition

global error reduction parameter [0..1] value of one is perfect error reduction value of 0 is no error reduction, default is .2


global_cfm

public float global_cfm
See ODE docs for an exact definition global costraint force mixing parameter hardness of constraints Value of 0 denotes the hardest constraint type


contactp

public ContactParameters contactp
allows configuration of general contact parameters

Constructor Detail

World

public World(java.lang.Object data)
creates a new world and stores data in its data storage area

Parameters:
data -

World

public World()
creates an empty world

Method Detail

addBody

public void addBody(Body body)
Normally this method is not needed for user use, as bodies add themselves to a world in their constructor. However, there are situations where it is advantagous to instanciate a body with a null world, and add the body to a world later, such as when implementing the prototype pattern. Calling this method when a body has allready been added to the world will result in the body being in the body list twice, and it is likely to result in unexpected behaviour. All WorldBodyListeners are notified after the body is added.

Parameters:
body -

removeBody

public void removeBody(Body body)

addJoint

public void addJoint(Joint joint)
Normally this method is not needed for user use, as joints add themselves to a world in their constructor. However, there are situations where it is advantagous to instanciate a joint with a null world, and add the joint to a world later, such as when implementing the prototype pattern. Calling this method when a joint has allready been added to the world will result in the joint being in the joint list twice, and it is likely to result in unexpected behaviour. All WorldJointListeners are notified after the joint is added, if the joint is not a Contact joint.


removeJoint

public void removeJoint(Joint joint)

removeJointContacts

public void removeJointContacts()
Since the majority of adds and removes of joints per-frame are for collision contacts, this method will speed the process by removing all contacts at once


addForce

public void addForce(Force force)
do not call directly, only gravities are implemented TODO: remove force functionality


removeForce

public void removeForce(Force force)
do not calldirectly, destroy the force instead TODO: remove force functionality


step

public void step(float stepsize)
steps the world forward stepsize seconds, using Euler intergration. Step is the slower and more accurate that quickstep. All WorldStepListeners are notified of the step.

Parameters:
stepsize -

stepMidPoint

public void stepMidPoint(float stepsize)
steps the world forward stepsize seconds, using mid point method for intergration. Increased accuracy over the Euler method All WorldStepListeners are notified of the step.

Parameters:
stepsize -

stepRungeKutter

public void stepRungeKutter(float stepsize)
steps the world forward stepsize seconds, using Runge-Kutter of order 4 intergration. Accurate

Parameters:
stepsize -

quickStep

public void quickStep(float stepsize)
steps the world forward stepsize seconds. quickstep() is fast but innacurate, and is especially bad at respecting joint constraints (bug?). All WorldStepListeners are notified of the step.

Parameters:
stepsize -

stepFast

public void stepFast()
Calls quickStep(float) with a value of 0.1f. In API to match ODEJava interface


cloneState

public World cloneState(ClonedReferences clones)
creates a replica of the world state. Only references that implement the SimState interface are cloned. So tag user object data with the SimState interface if you wish it to be part of the clone system

Specified by:
cloneState in interface SimState
Parameters:
clones - instanciate a new one if top level cloning
See Also:
SimState

addBodyListener

public void addBodyListener(WorldBodyListener listener)

removeBodyListener

public void removeBodyListener(WorldBodyListener listener)

addJointListener

public void addJointListener(WorldJointListener listener)

removeJointListener

public void removeJointListener(WorldJointListener listener)

addStepListener

public void addStepListener(WorldStepListener listener)

removeStepListener

public void removeStepListener(WorldStepListener listener)

addWorldListener

public void addWorldListener(WorldListener listener)

removeWorldListener

public void removeWorldListener(WorldListener listener)