|  | overview |  | wiki |  | api reference |  | download

- Main Page
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Functions Variables Typedefs Enumerations Enumerator
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
gameplay::PhysicsCollisionObject Class Reference

`#include <PhysicsCollisionObject.h>`

Inheritance diagram for gameplay::PhysicsCollisionObject:

List of all members.

## Classes

class | CollisionListener
class | CollisionPair
class | PhysicsMotionState
class | ScriptListener

## Public Types

enum | Type { RIGID_BODY, CHARACTER, GHOST_OBJECT, VEHICLE, VEHICLE_WHEEL, NONE }

## Public Member Functions

virtual | ~PhysicsCollisionObject ()
virtual PhysicsCollisionObject::Type | getType () const =0
PhysicsCollisionShape::Type | getShapeType () const
Node * | getNode () const
PhysicsCollisionShape * | getCollisionShape () const
bool | isKinematic () const
bool | isStatic () const
bool | isDynamic () const
bool | isEnabled () const
void | setEnabled (bool enable)
void | addCollisionListener (CollisionListener *listener, PhysicsCollisionObject *object=NULL)
void | removeCollisionListener (CollisionListener *listener, PhysicsCollisionObject *object=NULL)
void | addCollisionListener (const char *function, PhysicsCollisionObject *object=NULL)
void | removeCollisionListener (const char *function, PhysicsCollisionObject *object=NULL)
bool | collidesWith (PhysicsCollisionObject *object) const

## Protected Member Functions

| PhysicsCollisionObject (Node *node, int group=PHYSICS_COLLISION_GROUP_DEFAULT, int mask=PHYSICS_COLLISION_MASK_DEFAULT)
virtual btCollisionObject * | getCollisionObject () const =0

## Protected Attributes

Node * | _node
PhysicsCollisionShape * | _collisionShape
bool | _enabled
std::vector< ScriptListener * > * | _scriptListeners

## Detailed Description

Defines the base class for all physics objects that support collision events.

See also:
  http://gameplay3d.github.io/GamePlay/docs/file-formats.html#wiki-Collision_Objects

## Member Enumeration Documentation

enum gameplay::PhysicsCollisionObject::Type

Represents the different types of collision objects.

Enumerator:

  RIGID_BODY | PhysicsRigidBody type.
  CHARACTER | PhysicsCharacter type.
  GHOST_OBJECT | PhysicsGhostObject type.
  VEHICLE | PhysicsVehicle type.
  VEHICLE_WHEEL | PhysicsVehicleWheel type.
  NONE | No collision object.

## Constructor & Destructor Documentation

virtual gameplay::PhysicsCollisionObject::~PhysicsCollisionObject | ( |  | ) | `[virtual]`

Virtual destructor.

gameplay::PhysicsCollisionObject::PhysicsCollisionObject | ( | Node * | node,
|  | int | group = `PHYSICS_COLLISION_GROUP_DEFAULT`,
|  | int | mask = `PHYSICS_COLLISION_MASK_DEFAULT`
| ) |  | `[protected]`

Constructor.

## Member Function Documentation

void gameplay::PhysicsCollisionObject::addCollisionListener | ( | CollisionListener * | listener,
|  | PhysicsCollisionObject * | object = `NULL`
| ) |  |

Adds a collision listener for this collision object.

Parameters:

  listener | The listener to add.
  object | Optional collision object used to filter the collision event.

void gameplay::PhysicsCollisionObject::addCollisionListener | ( | const char * | function,
|  | PhysicsCollisionObject * | object = `NULL`
| ) |  |

Adds a collision listener for this collision object.

Note: the given script function must be global and it must match the function signature of PhysicsCollisionObject::CollisionListener::collisionEvent.

Parameters:

  function | A valid global script function to add as a listener callback.
  object | Optional collision object used to filter the collision event.

bool gameplay::PhysicsCollisionObject::collidesWith | ( | PhysicsCollisionObject * | object | ) | const

Checks if this collision object collides with the given object.

Parameters:

  object | The collision object to test for collision with.

Returns:
  true if this object collides with the specified one; false otherwise.

virtual btCollisionObject* gameplay::PhysicsCollisionObject::getCollisionObject | ( |  | ) | const`[protected, pure virtual]`

Returns the Bullet Physics collision object.

Returns:
  The Bullet collision object.

Implemented in gameplay::PhysicsRigidBody, gameplay::PhysicsVehicle, gameplay::PhysicsVehicleWheel, gameplay::PhysicsCharacter, and gameplay::PhysicsGhostObject.

PhysicsCollisionShape* gameplay::PhysicsCollisionObject::getCollisionShape | ( |  | ) | const

Returns the collision shape.

Returns:
  The collision shape.

Node* gameplay::PhysicsCollisionObject::getNode | ( |  | ) | const

Returns the node associated with this collision object.

PhysicsCollisionShape::Type gameplay::PhysicsCollisionObject::getShapeType | ( |  | ) | const

Returns the type of the shape for this collision object.

virtual PhysicsCollisionObject::Type gameplay::PhysicsCollisionObject::getType | ( |  | ) | const`[pure virtual]`

Returns the type of the collision object.

Implemented in gameplay::PhysicsRigidBody, gameplay::PhysicsCharacter, gameplay::PhysicsVehicle, gameplay::PhysicsVehicleWheel, and gameplay::PhysicsGhostObject.

bool gameplay::PhysicsCollisionObject::isDynamic | ( |  | ) | const

Returns whether this collision object is dynamic.

A dynamic collision object is simulated entirely by the physics system, such as with dynamic rigid bodies.

Returns:
  true if the collision object is dynamic.

bool gameplay::PhysicsCollisionObject::isEnabled | ( |  | ) | const

Check if the collision object is enabled.

Returns:
  true if the collision object is enabled.

bool gameplay::PhysicsCollisionObject::isKinematic | ( |  | ) | const

Returns whether this collision object is kinematic.

A kinematic collision object is an object that is not simulated by the physics system and instead has its transform driven manually.

Returns:
  true if the collision object is kinematic.

bool gameplay::PhysicsCollisionObject::isStatic | ( |  | ) | const

Returns whether this collision object is static.

A static collision object is not simulated by the physics system and cannot be transformed once created.

Returns:
  true if the collision object is static.

Reimplemented in gameplay::PhysicsRigidBody.

void gameplay::PhysicsCollisionObject::removeCollisionListener | ( | CollisionListener * | listener,
|  | PhysicsCollisionObject * | object = `NULL`
| ) |  |

Removes a collision listener.

Parameters:

  listener | The listener to remove.
  object | Optional collision object used to filter the collision event.

void gameplay::PhysicsCollisionObject::removeCollisionListener | ( | const char * | function,
|  | PhysicsCollisionObject * | object = `NULL`
| ) |  |

Removes a collision listener.

Parameters:

  function | The previously added script function to remove.
  object | Optional collision object used to filter the collision event.

void gameplay::PhysicsCollisionObject::setEnabled | ( | bool | enable | ) |

Sets the collision object to be enabled or disabled.

Parameters:

  enable | true enables the collision object, false disables it.

Reimplemented in gameplay::PhysicsRigidBody, gameplay::PhysicsVehicle, and gameplay::PhysicsVehicleWheel.

## Member Data Documentation

PhysicsCollisionShape* gameplay::PhysicsCollisionObject::_collisionShape `[protected]`

The PhysicsCollisionObject's collision shape.

bool gameplay::PhysicsCollisionObject::_enabled `[protected]`

If the collision object is enabled or not.

Node* gameplay::PhysicsCollisionObject::_node `[protected]`

Pointer to Node contained by this collision object.

std::vector<ScriptListener*>* gameplay::PhysicsCollisionObject::_scriptListeners `[protected]`

The list of script listeners.

All Classes Functions Variables Typedefs Enumerations Enumerator