net.java.dev.joode.collision
Class CollisionManager

java.lang.Object
  extended by net.java.dev.joode.collision.CollisionManager
All Implemented Interfaces:
NearCallback, WorldStepListener

public class CollisionManager
extends java.lang.Object
implements NearCallback, WorldStepListener

A simple, yet extensible, collision manager. The manager creates Contact joints in the dynamics system (World) representing collisions that have occured in geometry system (Space) This simple manager applies a default set of surface parameters to all contacts. However, before the contacts are added to the world, all listeners are notified of the contact. The listeners then have the option of vetoing the contact so it does not appear in the dynamics system or they can alter the properties of the contact itself.

Author:
Tom Larkworthy

Field Summary
protected  Contact[] contactBuffer
           
protected  JointGroupID contactGroup
           
protected  JointContact[] jointContacts
           
protected  int numContacts
           
protected  SurfaceParameters params
           
protected  Space space
           
protected  World world
           
 
Constructor Summary
CollisionManager(World world, Space space, SurfaceParameters defaultSurfaceParameters, boolean ignoreStaticContacts, int MAX_CONTACTS)
          Creates a CollisionManager.
 
Method Summary
 void addCollisionListener(CollisionListener l)
          Adds a collision listener.
 void call(java.lang.Object data, Geom g1, Geom g2)
          do not call.
 Contact getContact(int i)
           
 int getContactCount()
           
 boolean ignoreStatic()
          tells whether static collisions should be ignored or not
 void notifyQuickStep(World w, float stepSize)
          do not call.
 void notifyStep(World w, float stepSize)
          do not call.
 void removeCollisionListener(CollisionListener l)
          Removes a collision listener
 void setup(World world, Space space)
          changes the world and space this CollisionManager is listening to
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

world

protected World world

space

protected Space space

params

protected SurfaceParameters params

numContacts

protected int numContacts

contactBuffer

protected Contact[] contactBuffer

contactGroup

protected JointGroupID contactGroup

jointContacts

protected JointContact[] jointContacts
Constructor Detail

CollisionManager

public CollisionManager(World world,
                        Space space,
                        SurfaceParameters defaultSurfaceParameters,
                        boolean ignoreStaticContacts,
                        int MAX_CONTACTS)
Creates a CollisionManager. The constructor automatically adds the CollisionManager as a listener to the World, so no further configuration is necessary.

Parameters:
world - World contacts should be added to
space - the Space in which collisions are detected
defaultSurfaceParameters - set of surface parameters contacts are initialized to
ignoreStaticContacts - whether collisions between static geometries (no bodies) should be allowed
MAX_CONTACTS -
Method Detail

setup

public void setup(World world,
                  Space space)
changes the world and space this CollisionManager is listening to

Parameters:
world -
space -

call

public void call(java.lang.Object data,
                 Geom g1,
                 Geom g2)
do not call. TODO: refactor as delagate

Specified by:
call in interface NearCallback

getContactCount

public int getContactCount()

getContact

public Contact getContact(int i)

ignoreStatic

public boolean ignoreStatic()
Description copied from interface: NearCallback
tells whether static collisions should be ignored or not

Specified by:
ignoreStatic in interface NearCallback
Returns:

notifyQuickStep

public void notifyQuickStep(World w,
                            float stepSize)
do not call. TODO: refactor as delagate

Specified by:
notifyQuickStep in interface WorldStepListener

notifyStep

public void notifyStep(World w,
                       float stepSize)
do not call. TODO: refactor as delagate

Specified by:
notifyStep in interface WorldStepListener

addCollisionListener

public void addCollisionListener(CollisionListener l)
Adds a collision listener. The collsion listener has the power of veto, and can alter the contact parameters before the contact is added to the world.

Parameters:
l -

removeCollisionListener

public void removeCollisionListener(CollisionListener l)
Removes a collision listener

Parameters:
l -