Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.threed.jpct
Class CollisionEvent

    java.lang.Object
      com.threed.jpct.CollisionEvent

public class CollisionEvent
extends java.lang.Object

A collision event is caused by a collision of either the camera or an object with another object. To get a collision event in case of a collision, you need to implement the CollisionListener interface.
Collision events are send to the listeners after the actual collision detection/response took place.

See Also:
  `CollisionListener`

Field Summary
`static int` | `ALGORITHM_ELLIPSOID` The collision event was caused by a ellipsoid-polygon collision detection
`static int` | `ALGORITHM_RAY` The collision event was caused by a ray-polygon collision detection
`static int` | `ALGORITHM_SPHERE` The collision event was caused by a sphere-polygon collision detection
`static int` | `TYPE_SOURCE` The object is the source of the collision that has caused the event
`static int` | `TYPE_TARGET` The object is a target of the collision that has caused the event

Method Summary
`int` | `getAlgorithm()` Return the algorithm used to detect the collision that has caused the event.
`SimpleVector` | `getFirstContact()` Returns the position in world space of the first contact, if the event is of type TARGET.
`Object3D` | `getObject()` Returns the Object3D that has caused the event (i.e. to which this Listener has been added).
`int[]` | `getPolygonIDs()` Returns an array containing all the IDs of the object's polygons that were target of the collision that caused this event.
`Object3D` | `getSource()` Returns the source of the collision, if it's an Object3D (or null otherwise).
`Object3D[]` | `getTargets()` Returns the target objects that are involved in this collision.
`int` | `getType()` Returns the type of the collision event.
`java.lang.String` | `toString()` Overwrites toString() from java.lang.Object.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### TYPE_TARGET

    public static final int TYPE_TARGET

  The object is a target of the collision that has caused the event

  See Also:
    Constant Field Values

### TYPE_SOURCE

    public static final int TYPE_SOURCE

  The object is the source of the collision that has caused the event

  See Also:
    Constant Field Values

### ALGORITHM_RAY

    public static final int ALGORITHM_RAY

  The collision event was caused by a ray-polygon collision detection

  See Also:
    Constant Field Values

### ALGORITHM_SPHERE

    public static final int ALGORITHM_SPHERE

  The collision event was caused by a sphere-polygon collision detection

  See Also:
    Constant Field Values

### ALGORITHM_ELLIPSOID

    public static final int ALGORITHM_ELLIPSOID

  The collision event was caused by a ellipsoid-polygon collision detection

  See Also:
    Constant Field Values

Method Detail

### getObject

    public Object3D getObject()

  Returns the Object3D that has caused the event (i.e. to which this Listener has been added). The object can be a target or the source of the collision.

  Returns:
    the object

### getTargets

    public Object3D[] getTargets()

  Returns the target objects that are involved in this collision. This is the same array regardless of the type of collision, i.e. a listener on one of the targets will receive the same array as the source.

  Returns:
    the targets

### getSource

    public Object3D getSource()

  Returns the source of the collision, if it's an Object3D (or null otherwise). If type is TYPE_SOURCE, this method will return the same as getObject().

  Returns:
    the source or null

### getType

    public int getType()

  Returns the type of the collision event. This indicates if the object that has caused the event was a target (i.e. hit by something) or the source (i.e. hit something) of the collision.

  Returns:
    the type
  See Also:
    `TYPE_SOURCE`, `TYPE_TARGET`

### getAlgorithm

    public int getAlgorithm()

  Return the algorithm used to detect the collision that has caused the event.

  Returns:
    the algorithm
  See Also:
    `ALGORITHM_RAY`, `ALGORITHM_SPHERE`, `ALGORITHM_ELLIPSOID`

### getPolygonIDs

    public int[] getPolygonIDs()

  Returns an array containing all the IDs of the object's polygons that were target of the collision that caused this event. If the event is of TYPE_SOURCE or the corresponding listener states not to need this information, the method will return null in the former case and an undefinied result in the latter.

  Returns:
    int[] the list of polygon IDs

### getFirstContact

    public SimpleVector getFirstContact()

  Returns the position in world space of the first contact, if the event is of type TARGET. Returns null, if it is of type SOURCE. If the algorithm is spherical collision detection, this isn't the first point but the end position (caused by the way this algorithm works).

  Returns:
    the position

### toString

    public java.lang.String toString()

  Overwrites toString() from java.lang.Object. Useful for debugging collision detection code.

  Returns:
    a human readable String that contains information about the collision

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD