org.odejava.collision
Class Contact

java.lang.Object
  extended by org.odejava.collision.Contact
Direct Known Subclasses:
BulkContact

public class Contact
extends Object

This class can be used for accessing collision data buffers. Usable only with JavaCollision. Created 11.02.2004 (dd.mm.yyyy)

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

Field Summary
static int BODY_ID1
           
static int BODY_ID2
           
static int BOUNCE
           
static int BOUNCE_VEL
           
static int DEPTH
           
static int FDIR1
           
protected  FloatBuffer floatBuf
          Buffer holding the float data for these sets of contacts
static int FLOATBUF_CHUNK_SIZE
           
static int GEOM_ID1
           
static int GEOM_ID2
           
protected  int index
          The current index that this class is working on, if used in that way
static int INTBUF_CHUNK_SIZE
           
protected  LongBuffer longBuf
          Buffer holding the integer data for these sets of contacts
protected  int maxContacts
          The maximum number of contacts processable
static int MODE
           
static int MOTION1
           
static int MOTION2
           
static int MU
           
static int MU2
           
static int NORMAL
           
static int POSITION
           
static int SLIP1
           
static int SLIP2
           
static int SOFT_CFM
           
static int SOFT_ERP
           
 
Constructor Summary
Contact(JavaCollision jCollision)
          Create a new contact collection that sources it's data from the two NIO buffers.
Contact(LongBuffer longBuf, FloatBuffer floatBuf)
          Create a new contact collection that sources it's data from the two NIO buffers.
 
Method Summary
 boolean geom1EqualTo(Geom geom)
          Tests the passed geom with the first Geom involved and returns true if they are equal.
 boolean geom2EqualTo(Geom geom)
          Tests the passed geom with the second Geom involved and returns true if they are equal.
 long getBodyID1()
           
 long getBodyID1(int idx)
           
 long getBodyID2()
           
 long getBodyID2(int idx)
           
 float getBounce()
           
 float getBounce(int idx)
           
 float getBounceVel()
           
 float getBounceVel(int idx)
           
 float getDepth()
           
 float getDepth(int idx)
           
 void getFdir1(float[] fdir1)
           
 void getFdir1(float[] fdir1, int idx)
           
 Geom getGeom1()
          Returns the first Geom object involved in this contact.
 Geom getGeom1(int idx)
          Returns the first Geom object involved in this contact.
 Geom getGeom2()
          Returns the second Geom object involved in this contact.
 Geom getGeom2(int idx)
          Returns the second Geom object involved in this contact.
 long getGeomID1()
          Returns the native address of the first Geom object involved in this contact.
 long getGeomID1(int idx)
          Returns the native address of the first Geom object involved in this contact.
 long getGeomID2()
          Returns the native address of the second Geom object involved in this contact.
 long getGeomID2(int idx)
          Returns the native address of the second Geom object involved in this contact.
 int getMaxContacts()
          Get the total maximum possible contacts that could be used from this set.
 long getMode()
          Note, if mode = -1 then default surface parameter values are used.
 long getMode(int idx)
          Note, if mode = -1 then default surface parameter values are used.
 float getMotion1()
           
 float getMotion1(int idx)
           
 float getMotion2()
           
 float getMotion2(int idx)
           
 float getMu()
           
 float getMu(int idx)
           
 float getMu2()
           
 float getMu2(int idx)
           
 float[] getNormal()
           
 void getNormal(float[] normal)
           
 void getNormal(float[] normal, int idx)
           
 float[] getNormal(int idx)
           
 void getNormal(org.openmali.vecmath2.Vector3f normal)
           
 void getNormal(org.openmali.vecmath2.Vector3f normal, int idx)
           
 float[] getPosition()
           
 void getPosition(float[] position)
           
 void getPosition(float[] position, int idx)
           
 float[] getPosition(int idx)
           
 void getPosition(org.openmali.vecmath2.Tuple3f position)
           
 void getPosition(org.openmali.vecmath2.Tuple3f position, int idx)
           
 float getSlip1()
           
 float getSlip1(int idx)
           
 float getSlip2()
           
 float getSlip2(int idx)
           
 float getSoftCfm()
           
 float getSoftCfm(int idx)
           
 float getSoftErp()
           
 float getSoftErp(int idx)
           
 void ignoreContact()
          Ignore contact so it does not affect to simulation.
 void nextContact()
          Increment the internal working index by one to access the next contact.
 void setBodyID1(int id)
           
 void setBodyID1(int id, int idx)
           
 void setBodyID2(int id, int idx)
           
 void setBodyID2(long id)
           
 void setBounce(float bounce)
           
 void setBounce(float bounce, int idx)
           
 void setBounceVel(float bounceVel)
           
 void setBounceVel(float bounceVel, int idx)
           
 void setDepth(float depth)
           
 void setDepth(float depth, int idx)
           
 void setFdir1(float[] fdir1)
           
 void setFdir1(float[] fdir1, int idx)
           
 void setFdir1(org.openmali.vecmath2.Vector3f fdir1)
           
 void setFdir1(org.openmali.vecmath2.Vector3f fdir1, int idx)
           
 void setGeomID1(long id)
           
 void setGeomID1(long id, int idx)
           
 void setGeomID2(long id)
           
 void setGeomID2(long id, int idx)
           
 void setIndex(int index)
          Set the working index to the the given value.
 void setMode(int mode)
          Note, if mode = -1 then default surface parameter values are used.
 void setMode(int mode, int idx)
          Note, if mode = -1 then default surface parameter values are used.
 void setMotion1(float motion1)
           
 void setMotion1(float motion1, int idx)
           
 void setMotion2(float motion2)
           
 void setMotion2(float motion2, int idx)
           
 void setMu(float mu)
           
 void setMu(float mu, int idx)
           
 void setMu2(float mu2)
           
 void setMu2(float mu2, int idx)
           
 void setNormal(float[] normal)
           
 void setNormal(float[] normal, int idx)
           
 void setNormal(org.openmali.vecmath2.Vector3f normal)
           
 void setNormal(org.openmali.vecmath2.Vector3f normal, int idx)
           
 void setPosition(float[] position)
           
 void setPosition(float[] position, int idx)
           
 void setPosition(org.openmali.vecmath2.Tuple3f position)
           
 void setPosition(org.openmali.vecmath2.Tuple3f position, int idx)
           
 void setSlip1(float slip1)
           
 void setSlip1(float slip1, int idx)
           
 void setSlip2(float slip2)
           
 void setSlip2(float slip2, int idx)
           
 void setSoftCfm(float softCfm)
           
 void setSoftCfm(float softCfm, int idx)
           
 void setSoftErp(float softErp)
           
 void setSoftErp(float softErp, int idx)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTBUF_CHUNK_SIZE

public static final int INTBUF_CHUNK_SIZE
See Also:
Constant Field Values

GEOM_ID1

public static final int GEOM_ID1
See Also:
Constant Field Values

GEOM_ID2

public static final int GEOM_ID2
See Also:
Constant Field Values

BODY_ID1

public static final int BODY_ID1
See Also:
Constant Field Values

BODY_ID2

public static final int BODY_ID2
See Also:
Constant Field Values

MODE

public static final int MODE
See Also:
Constant Field Values

FLOATBUF_CHUNK_SIZE

public static final int FLOATBUF_CHUNK_SIZE
See Also:
Constant Field Values

POSITION

public static final int POSITION
See Also:
Constant Field Values

NORMAL

public static final int NORMAL
See Also:
Constant Field Values

DEPTH

public static final int DEPTH
See Also:
Constant Field Values

FDIR1

public static final int FDIR1
See Also:
Constant Field Values

MU

public static final int MU
See Also:
Constant Field Values

MU2

public static final int MU2
See Also:
Constant Field Values

BOUNCE

public static final int BOUNCE
See Also:
Constant Field Values

BOUNCE_VEL

public static final int BOUNCE_VEL
See Also:
Constant Field Values

SOFT_ERP

public static final int SOFT_ERP
See Also:
Constant Field Values

SOFT_CFM

public static final int SOFT_CFM
See Also:
Constant Field Values

MOTION1

public static final int MOTION1
See Also:
Constant Field Values

MOTION2

public static final int MOTION2
See Also:
Constant Field Values

SLIP1

public static final int SLIP1
See Also:
Constant Field Values

SLIP2

public static final int SLIP2
See Also:
Constant Field Values

longBuf

protected LongBuffer longBuf
Buffer holding the integer data for these sets of contacts


floatBuf

protected FloatBuffer floatBuf
Buffer holding the float data for these sets of contacts


index

protected int index
The current index that this class is working on, if used in that way


maxContacts

protected int maxContacts
The maximum number of contacts processable

Constructor Detail

Contact

public Contact(LongBuffer longBuf,
               FloatBuffer floatBuf)
Create a new contact collection that sources it's data from the two NIO buffers. The initial index is set to zero.

Parameters:
longBuf - The integer data source
floatBuf - The floating point data source

Contact

public Contact(JavaCollision jCollision)
Create a new contact collection that sources it's data from the two NIO buffers. The initial index is set to zero.

Parameters:
jCollision - the JavaCollision to take the buffers from
Method Detail

setIndex

public void setIndex(int index)
Set the working index to the the given value. A check is made to make sure that the value is not past the end of the valid list. If it is, an array index exception is thrown.

Parameters:
index - The new index to use
Throws:
ArrayIndexOutOfBoundsException - Passed the end of the array

nextContact

public void nextContact()
Increment the internal working index by one to access the next contact. If this will move the value passed the maximum number then an exception is thrown.

Throws:
ArrayIndexOutOfBoundsException - Passed the end of the array

getMaxContacts

public int getMaxContacts()
Get the total maximum possible contacts that could be used from this set. The maximum number is the total permissable, not the total that are actually valid for this set. To check on the number of valid contacts, use the JavaCollision.getContactCount() method.


ignoreContact

public void ignoreContact()
Ignore contact so it does not affect to simulation. Note: if you wish to ignore certain geom <->geom collisions then use categoryBits and collideBits instead, that is a lot faster.


getGeomID1

public long getGeomID1()
Returns the native address of the first Geom object involved in this contact.

Returns:
the native address of the first Geom object involved in this contact.
See Also:
Geom.getNativeAddr(), Geom.getGeomFromNativeAddr(long)

getGeomID1

public long getGeomID1(int idx)
Returns the native address of the first Geom object involved in this contact.

Returns:
the native address of the first Geom object involved in this contact.
See Also:
Geom.getNativeAddr(), Geom.getGeomFromNativeAddr(long)

getGeom1

public Geom getGeom1()
Returns the first Geom object involved in this contact.

Returns:
the first Geom object involved in this contact

getGeom1

public Geom getGeom1(int idx)
Returns the first Geom object involved in this contact.

Returns:
the first Geom object involved in this contact

setGeomID1

public void setGeomID1(long id)

setGeomID1

public void setGeomID1(long id,
                       int idx)

getGeomID2

public long getGeomID2()
Returns the native address of the second Geom object involved in this contact.

Returns:
the native address of the second Geom object involved in this contact.
See Also:
Geom.getNativeAddr(), Geom.getGeomFromNativeAddr(long)

getGeomID2

public long getGeomID2(int idx)
Returns the native address of the second Geom object involved in this contact.

Returns:
the native address of the second Geom object involved in this contact.
See Also:
Geom.getNativeAddr(), Geom.getGeomFromNativeAddr(long)

getGeom2

public Geom getGeom2()
Returns the second Geom object involved in this contact.

Returns:
the second Geom object involved in this contact

getGeom2

public Geom getGeom2(int idx)
Returns the second Geom object involved in this contact.

Returns:
the second Geom object involved in this contact

geom1EqualTo

public boolean geom1EqualTo(Geom geom)
Tests the passed geom with the first Geom involved and returns true if they are equal. Compares native addresses which is faster than using getGeomX and testing for identity.

Parameters:
geom - the geom to test
Returns:
true if the passed geom is equal to the contact's first geom false if it isn't.

geom2EqualTo

public boolean geom2EqualTo(Geom geom)
Tests the passed geom with the second Geom involved and returns true if they are equal. Compares native addresses which is faster than using getGeomX and testing for identity.

Parameters:
geom - the geom to test
Returns:
true if the passed geom is equal to the contact's second geom false if it isn't.

setGeomID2

public void setGeomID2(long id)

setGeomID2

public void setGeomID2(long id,
                       int idx)

getBodyID1

public long getBodyID1()

getBodyID1

public long getBodyID1(int idx)

setBodyID1

public void setBodyID1(int id)

setBodyID1

public void setBodyID1(int id,
                       int idx)

getBodyID2

public long getBodyID2()

getBodyID2

public long getBodyID2(int idx)

setBodyID2

public void setBodyID2(long id)

setBodyID2

public void setBodyID2(int id,
                       int idx)

getMode

public long getMode()
Note, if mode = -1 then default surface parameter values are used. You can set default surface parameters through Collision class.

Returns:
mode of surface contact

getMode

public long getMode(int idx)
Note, if mode = -1 then default surface parameter values are used. You can set default surface parameters through Collision class.

Returns:
mode of surface contact

setMode

public void setMode(int mode)
Note, if mode = -1 then default surface parameter values are used. You can set default surface parameters through Collision class.

Parameters:
mode - of surface contact

setMode

public void setMode(int mode,
                    int idx)
Note, if mode = -1 then default surface parameter values are used. You can set default surface parameters through Collision class.

Parameters:
mode - of surface contact

getPosition

public void getPosition(org.openmali.vecmath2.Tuple3f position)

getPosition

public void getPosition(org.openmali.vecmath2.Tuple3f position,
                        int idx)

getPosition

public void getPosition(float[] position)

getPosition

public void getPosition(float[] position,
                        int idx)

getPosition

public float[] getPosition()

getPosition

public float[] getPosition(int idx)

setPosition

public void setPosition(float[] position)

setPosition

public void setPosition(org.openmali.vecmath2.Tuple3f position)

setPosition

public void setPosition(float[] position,
                        int idx)

setPosition

public void setPosition(org.openmali.vecmath2.Tuple3f position,
                        int idx)

getNormal

public void getNormal(org.openmali.vecmath2.Vector3f normal)

getNormal

public void getNormal(org.openmali.vecmath2.Vector3f normal,
                      int idx)

getNormal

public void getNormal(float[] normal)

getNormal

public void getNormal(float[] normal,
                      int idx)

getNormal

public float[] getNormal()

getNormal

public float[] getNormal(int idx)

setNormal

public void setNormal(float[] normal)

setNormal

public void setNormal(org.openmali.vecmath2.Vector3f normal)

setNormal

public void setNormal(float[] normal,
                      int idx)

setNormal

public void setNormal(org.openmali.vecmath2.Vector3f normal,
                      int idx)

getDepth

public float getDepth()

getDepth

public float getDepth(int idx)

setDepth

public void setDepth(float depth)

setDepth

public void setDepth(float depth,
                     int idx)

getFdir1

public void getFdir1(float[] fdir1)

getFdir1

public void getFdir1(float[] fdir1,
                     int idx)

setFdir1

public void setFdir1(float[] fdir1)

setFdir1

public void setFdir1(org.openmali.vecmath2.Vector3f fdir1)

setFdir1

public void setFdir1(float[] fdir1,
                     int idx)

setFdir1

public void setFdir1(org.openmali.vecmath2.Vector3f fdir1,
                     int idx)

getMu

public float getMu()

getMu

public float getMu(int idx)

setMu

public void setMu(float mu)

setMu

public void setMu(float mu,
                  int idx)

getMu2

public float getMu2()

getMu2

public float getMu2(int idx)

setMu2

public void setMu2(float mu2)

setMu2

public void setMu2(float mu2,
                   int idx)

getBounce

public float getBounce()

getBounce

public float getBounce(int idx)

setBounce

public void setBounce(float bounce)

setBounce

public void setBounce(float bounce,
                      int idx)

getBounceVel

public float getBounceVel()

getBounceVel

public float getBounceVel(int idx)

setBounceVel

public void setBounceVel(float bounceVel)

setBounceVel

public void setBounceVel(float bounceVel,
                         int idx)

getSoftErp

public float getSoftErp()

getSoftErp

public float getSoftErp(int idx)

setSoftErp

public void setSoftErp(float softErp)

setSoftErp

public void setSoftErp(float softErp,
                       int idx)

getSoftCfm

public float getSoftCfm()

getSoftCfm

public float getSoftCfm(int idx)

setSoftCfm

public void setSoftCfm(float softCfm)

setSoftCfm

public void setSoftCfm(float softCfm,
                       int idx)

getMotion1

public float getMotion1()

getMotion1

public float getMotion1(int idx)

setMotion1

public void setMotion1(float motion1)

setMotion1

public void setMotion1(float motion1,
                       int idx)

getMotion2

public float getMotion2()

getMotion2

public float getMotion2(int idx)

setMotion2

public void setMotion2(float motion2)

setMotion2

public void setMotion2(float motion2,
                       int idx)

getSlip1

public float getSlip1()

getSlip1

public float getSlip1(int idx)

setSlip1

public void setSlip1(float slip1)

setSlip1

public void setSlip1(float slip1,
                     int idx)

getSlip2

public float getSlip2()

getSlip2

public float getSlip2(int idx)

setSlip2

public void setSlip2(float slip2)

setSlip2

public void setSlip2(float slip2,
                     int idx)