org.odejava.collision
Class JavaCollision

java.lang.Object
  extended by org.odejava.collision.Collision
      extended by org.odejava.collision.JavaCollision

public class JavaCollision
extends Collision

JavaCollision is currently the preferred way of doing collision on Odejava. Each Collide call updates buffers that contain collision data. Buffers are createad at the native side and Java accessed them using NIO's DirectBuffers. Created 11.02.2004 (dd.mm.yyyy)

Author:
Jani Laakso E-mail: jani.laakso@itmill.com see http://odejava.dev.java.net

Field Summary
 
Fields inherited from class org.odejava.collision.Collision
contactGroupId, deleted
 
Constructor Summary
JavaCollision(World world)
          Create Java version of collision class.
 
Method Summary
 void applyContacts()
          Apply contact data to simulation.
 void applyContacts(World world)
          Apply contact data to simulation.
 void collide(Space space)
          Collide uses ODE's spaceCollide.
 void collide2(long o1, long o2)
          Collide2 uses ODE's spaceCollide2.
 int getContactCount()
          Get the count of contacts (on buffers) generated by collide calls.
 FloatBuffer getContactFloatBuffer()
           
 LongBuffer getContactIntBuffer()
           
 void setMaxStepContactsPerNearcallback(int size)
          Sets contact data buffer to given size.
 
Methods inherited from class org.odejava.collision.Collision
delete, emptyContactGroup, getContactGroupId, setSurfaceBounce, setSurfaceBounceVel, setSurfaceMode, setSurfaceMotion1, setSurfaceMotion2, setSurfaceMu, setSurfaceMu2, setSurfaceSlip1, setSurfaceSlip2, setSurfaceSoftCfm, setSurfaceSoftErp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaCollision

public JavaCollision(World world)
Create Java version of collision class. A valid world instance must be provided for this collision group to work with.

Parameters:
world - The world instance that this collision should work with.
Throws:
NullPointerException - The world reference is null
Method Detail

setMaxStepContactsPerNearcallback

public void setMaxStepContactsPerNearcallback(int size)
Sets contact data buffer to given size. Buffers need to be big enough to contain contact data generated per single step. Default size is 4096.

Parameters:
size -

collide

public void collide(Space space)
Collide uses ODE's spaceCollide. Contact data is stored into buffers. After each collide call you have an possibility to read/write contact data using Contact class. Remember to add contacts to simulation by calling applyContacts method.

Parameters:
space -

collide2

public void collide2(long o1,
                     long o2)
Collide2 uses ODE's spaceCollide2. Arguments can be spaces or geoms addresses. Contact structures are stored to Collision.contactAddrs. Contacts need to be added into contact jointgroup with method applyContacts()

Parameters:
o1 -
o2 -

applyContacts

public void applyContacts(World world)
Apply contact data to simulation. Adds all contact joints to contact jointgroup. Call this after spaceCollide call if you are not creating contact joints manually at the Java side. Collision can be done with other spaces before stepping the world.


applyContacts

public final void applyContacts()
Apply contact data to simulation. Adds all contact joints to contact jointgroup. Call this after spaceCollide call if you are not creating contact joints manually at the Java side. Collision can be done with other spaces before stepping the world.


getContactCount

public int getContactCount()
Get the count of contacts (on buffers) generated by collide calls.

Returns:
the contact count

getContactIntBuffer

public LongBuffer getContactIntBuffer()

getContactFloatBuffer

public FloatBuffer getContactFloatBuffer()