org.xith3d.physics.collision
Class Collision

java.lang.Object
  extended by org.xith3d.physics.collision.Collision

public class Collision
extends java.lang.Object

Information about a collision : position, normal, depth, geoms that collided


Constructor Summary
protected Collision()
          Creates a new collision information object.
  Collision(org.openmali.vecmath2.Point3f pos, org.openmali.vecmath2.Vector3f normal, float depth, Collideable c1, Collideable c2)
          Creates a new collision information object.
 
Method Summary
static Collision fromPool()
           
static Collision fromPool(org.openmali.vecmath2.Point3f pos, org.openmali.vecmath2.Vector3f normal, float depth, Collideable c1, Collideable c2)
           
 Collideable getCollideable1()
          The first collideable involved in the collision
 Collideable getCollideable2()
          The second collideable involved in the collision
 float getDepth()
          The penetration depth of the collision.
 org.openmali.vecmath2.Vector3f getInvertedNormal()
          The "direction" of this collision.
 org.openmali.vecmath2.Vector3f getNormal()
          The "direction" of this collision.
 org.openmali.vecmath2.Point3f getPosition()
          The position of the contact.
 org.openmali.vecmath2.Vector3f getScaledInvertedNormal()
          The "direction" of this collision.
 org.openmali.vecmath2.Vector3f getScaledNormal()
          The "direction" of this collision.
protected  void set(org.openmali.vecmath2.Point3f pos, org.openmali.vecmath2.Vector3f normal, float depth, Collideable c1, Collideable c2)
          Sets this instance's a information.
static void toPool(Collision collision)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Collision

public Collision(org.openmali.vecmath2.Point3f pos,
                 org.openmali.vecmath2.Vector3f normal,
                 float depth,
                 Collideable c1,
                 Collideable c2)
Creates a new collision information object.

Parameters:
pos - contact position
normal - normal vector
depth - penetration depth
c1 - the colliding object n°1
c2 - the colliding object n°2

Collision

protected Collision()
Creates a new collision information object.

Method Detail

getCollideable1

public final Collideable getCollideable1()
The first collideable involved in the collision


getCollideable2

public final Collideable getCollideable2()
The second collideable involved in the collision


getPosition

public final org.openmali.vecmath2.Point3f getPosition()
The position of the contact. Of course, more than a point may be in contact (between Collideables), but we need an approximation for computations.


getNormal

public final org.openmali.vecmath2.Vector3f getNormal()
The "direction" of this collision. It's a vector normal to the collision. In other terms, it's a vector such that if you move the second collideable by the (normal * depth) vector, it no longer collides with the first collideable.


getScaledNormal

public final org.openmali.vecmath2.Vector3f getScaledNormal()
The "direction" of this collision. It's a vector normal to the collision scaled by the depth of the collision.


getInvertedNormal

public final org.openmali.vecmath2.Vector3f getInvertedNormal()
The "direction" of this collision. It's an inverted vector normal to the collision.


getScaledInvertedNormal

public final org.openmali.vecmath2.Vector3f getScaledInvertedNormal()
The "direction" of this collision. It's a vector normal to the collision scaled by the depth of the collision and inverted.


getDepth

public final float getDepth()
The penetration depth of the collision. If it just grazes, depth = 0.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

set

protected final void set(org.openmali.vecmath2.Point3f pos,
                         org.openmali.vecmath2.Vector3f normal,
                         float depth,
                         Collideable c1,
                         Collideable c2)
Sets this instance's a information.

Parameters:
pos - contact position
normal - normal vector
depth - penetration depth
c1 - the colliding object n°1
c2 - the colliding object n°2

fromPool

public static final Collision fromPool(org.openmali.vecmath2.Point3f pos,
                                       org.openmali.vecmath2.Vector3f normal,
                                       float depth,
                                       Collideable c1,
                                       Collideable c2)

fromPool

public static final Collision fromPool()

toPool

public static final void toPool(Collision collision)