|  | 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 Member Functions
gameplay::PhysicsController Class Reference

`#include <PhysicsController.h>`

Inheritance diagram for gameplay::PhysicsController:

List of all members.

## Classes

class | CollisionCallback
struct | CollisionInfo
class | DebugDrawer
class | HitFilter
struct | HitResult
class | Listener

## Public Member Functions

const char * | getTypeName () const
void | addStatusListener (PhysicsController::Listener *listener)
void | removeStatusListener (Listener *listener)
PhysicsFixedConstraint * | createFixedConstraint (PhysicsRigidBody *a, PhysicsRigidBody *b=NULL)
PhysicsGenericConstraint * | createGenericConstraint (PhysicsRigidBody *a, PhysicsRigidBody *b=NULL)
PhysicsGenericConstraint * | createGenericConstraint (PhysicsRigidBody *a, const Quaternion &rotationOffsetA, const Vector3 &translationOffsetA, PhysicsRigidBody *b=NULL, const Quaternion &rotationOffsetB=Quaternion(), const Vector3 &translationOffsetB=Vector3())
PhysicsHingeConstraint * | createHingeConstraint (PhysicsRigidBody *a, const Quaternion &rotationOffsetA, const Vector3 &translationOffsetA, PhysicsRigidBody *b=NULL, const Quaternion &rotationOffsetB=Quaternion(), const Vector3 &translationOffsetB=Vector3())
PhysicsSocketConstraint * | createSocketConstraint (PhysicsRigidBody *a, PhysicsRigidBody *b=NULL)
PhysicsSocketConstraint * | createSocketConstraint (PhysicsRigidBody *a, const Vector3 &translationOffsetA, PhysicsRigidBody *b=NULL, const Vector3 &translationOffsetB=Vector3())
PhysicsSpringConstraint * | createSpringConstraint (PhysicsRigidBody *a, PhysicsRigidBody *b)
PhysicsSpringConstraint * | createSpringConstraint (PhysicsRigidBody *a, const Quaternion &rotationOffsetA, const Vector3 &translationOffsetA, PhysicsRigidBody *b, const Quaternion &rotationOffsetB, const Vector3 &translationOffsetB)
const Vector3 & | getGravity () const
void | setGravity (const Vector3 &gravity)
void | drawDebug (const Matrix &viewProjection)
bool | rayTest (const Ray &ray, float distance, PhysicsController::HitResult *result=NULL, PhysicsController::HitFilter *filter=NULL)
bool | sweepTest (PhysicsCollisionObject *object, const Vector3 &endPosition, PhysicsController::HitResult *result=NULL, PhysicsController::HitFilter *filter=NULL)

## Detailed Description

Defines a class for controlling game physics.

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

## Member Function Documentation

void gameplay::PhysicsController::addStatusListener | ( | PhysicsController::Listener * | listener | ) |

Adds a listener to the physics controller.

Parameters:

  listener | The listener to add.

PhysicsFixedConstraint* gameplay::PhysicsController::createFixedConstraint | ( | PhysicsRigidBody * | a,
|  | PhysicsRigidBody * | b = `NULL`
| ) |  |

Creates a fixed constraint.

Parameters:

  a | The first (possibly only) rigid body to constrain. If this is the only rigid body specified the constraint applies between it and the global physics world object.
  b | The second rigid body to constrain (optional).

Returns:
  Pointer to the created PhysicsFixedConstraint object.

PhysicsGenericConstraint* gameplay::PhysicsController::createGenericConstraint | ( | PhysicsRigidBody * | a,
|  | PhysicsRigidBody * | b = `NULL`
| ) |  |

Creates a generic constraint so that the rigid body (or bodies) is (are) constrained to its (their) current world position(s).

Parameters:

  a | The first (possibly only) rigid body to constrain. If this is the only rigid body specified the constraint applies between it and the global physics world object.
  b | The second rigid body to constrain (optional).

Returns:
  Pointer to the created PhysicsGenericConstraint object.

PhysicsGenericConstraint* gameplay::PhysicsController::createGenericConstraint | ( | PhysicsRigidBody * | a,
|  | const Quaternion & | rotationOffsetA,
|  | const Vector3 & | translationOffsetA,
|  | PhysicsRigidBody * | b = `NULL`,
|  | const Quaternion & | rotationOffsetB = `Quaternion()`,
|  | const Vector3 & | translationOffsetB = `Vector3()`
| ) |  |

Creates a generic constraint.

Parameters:

  a | The first (possibly only) rigid body to constrain. If this is the only rigid body specified the constraint applies between it and the global physics world object.
  rotationOffsetA | The rotation offset for the first rigid body (in its local space) with respect to the constraint joint.
  translationOffsetA | The translation offset for the first rigid body (in its local space) with respect to the constraint joint.
  b | The second rigid body to constrain (optional).
  rotationOffsetB | The rotation offset for the second rigid body (in its local space) with respect to the constraint joint (optional).
  translationOffsetB | The translation offset for the second rigid body (in its local space) with respect to the constraint joint (optional).

Returns:
  Pointer to the created PhysicsGenericConstraint object.

PhysicsHingeConstraint* gameplay::PhysicsController::createHingeConstraint | ( | PhysicsRigidBody * | a,
|  | const Quaternion & | rotationOffsetA,
|  | const Vector3 & | translationOffsetA,
|  | PhysicsRigidBody * | b = `NULL`,
|  | const Quaternion & | rotationOffsetB = `Quaternion()`,
|  | const Vector3 & | translationOffsetB = `Vector3()`
| ) |  |

Creates a hinge constraint.

Parameters:

  a | The first (possibly only) rigid body to constrain. If this is the only rigid body specified the constraint applies between it and the global physics world object.
  rotationOffsetA | The rotation offset for the first rigid body (in its local space) with respect to the constraint joint.
  translationOffsetA | The translation offset for the first rigid body (in its local space) with respect to the constraint joint.
  b | The second rigid body to constrain (optional).
  rotationOffsetB | The rotation offset for the second rigid body (in its local space) with respect to the constraint joint (optional).
  translationOffsetB | The translation offset for the second rigid body (in its local space) with respect to the constraint joint (optional).

Returns:
  Pointer to the created PhysicsHingeConstraint object.

PhysicsSocketConstraint* gameplay::PhysicsController::createSocketConstraint | ( | PhysicsRigidBody * | a,
|  | PhysicsRigidBody * | b = `NULL`
| ) |  |

Creates a socket constraint so that the rigid body (or bodies) is (are) constrained using its (their) current world position(s) for the translation offset(s) to the constraint.

Parameters:

  a | The first (possibly only) rigid body to constrain. If this is the only rigid body specified the constraint applies between it and the global physics world object.
  b | The second rigid body to constrain (optional).

Returns:
  Pointer to the created PhysicsSocketConstraint object.

PhysicsSocketConstraint* gameplay::PhysicsController::createSocketConstraint | ( | PhysicsRigidBody * | a,
|  | const Vector3 & | translationOffsetA,
|  | PhysicsRigidBody * | b = `NULL`,
|  | const Vector3 & | translationOffsetB = `Vector3()`
| ) |  |

Creates a socket constraint.

Parameters:

  a | The first (possibly only) rigid body to constrain. If this is the only rigid body specified the constraint applies between it and the global physics world object.
  translationOffsetA | The translation offset for the first rigid body (in its local space) with respect to the constraint joint.
  b | The second rigid body to constrain (optional).
  translationOffsetB | The translation offset for the second rigid body (in its local space) with respect to the constraint joint (optional).

Returns:
  Pointer to the created PhysicsSocketConstraint object.

PhysicsSpringConstraint* gameplay::PhysicsController::createSpringConstraint | ( | PhysicsRigidBody * | a,
|  | PhysicsRigidBody * | b
| ) |  |

Creates a spring constraint so that the rigid body (or bodies) is (are) constrained using its (their) current world position(s) for the translation offset(s) to the constraint.

Parameters:

  a | The first (possibly only) rigid body to constrain. If this is the only rigid body specified the constraint applies between it and the global physics world object.
  b | The second rigid body to constrain (optional).

Returns:
  Pointer to the created PhysicsSpringConstraint object.

PhysicsSpringConstraint* gameplay::PhysicsController::createSpringConstraint | ( | PhysicsRigidBody * | a,
|  | const Quaternion & | rotationOffsetA,
|  | const Vector3 & | translationOffsetA,
|  | PhysicsRigidBody * | b,
|  | const Quaternion & | rotationOffsetB,
|  | const Vector3 & | translationOffsetB
| ) |  |

Creates a spring constraint.

Parameters:

  a | The first (possibly only) rigid body to constrain. If this is the only rigid body specified the constraint applies between it and the global physics world object.
  rotationOffsetA | The rotation offset for the first rigid body (in its local space) with respect to the constraint joint.
  translationOffsetA | The translation offset for the first rigid body (in its local space) with respect to the constraint joint.
  b | The second rigid body to constrain (optional).
  rotationOffsetB | The rotation offset for the second rigid body (in its local space) with respect to the constraint joint (optional).
  translationOffsetB | The translation offset for the second rigid body (in its local space) with respect to the constraint joint (optional).

Returns:
  Pointer to the created PhysicsSpringConstraint object.

void gameplay::PhysicsController::drawDebug | ( | const Matrix & | viewProjection | ) |

Draws debugging information (rigid body outlines, etc.) using the given view projection matrix.

Parameters:

  viewProjection | The view projection matrix to use when drawing.

const Vector3& gameplay::PhysicsController::getGravity | ( |  | ) | const

Gets the gravity vector for the simulated physics world.

Returns:
  The gravity vector.

const char* gameplay::PhysicsController::getTypeName | ( |  | ) | const`[virtual]`

Extends ScriptTarget::getTypeName() to return the type name of this class.

Returns:
  The type name of this class: "PhysicsController"

See also:
  ScriptTarget::getTypeName()

Implements gameplay::ScriptTarget.

bool gameplay::PhysicsController::rayTest | ( | const Ray & | ray,
|  | float | distance,
|  | PhysicsController::HitResult * | result = `NULL`,
|  | PhysicsController::HitFilter * | filter = `NULL`
| ) |  |

Performs a ray test on the physics world.

Parameters:

  ray | The ray to test intersection with.
  distance | How far along the given ray to test for intersections.
  result | Optional pointer to a HitTest structure to store the hit test result information in. When using a default (or no) filter, this will always be the closest object hit. Otherwise, if using a custom filter, it will be the last object passed to the HitFilter::hit method (which is not necessarily the closest or furthest).
  filter | Optional filter pointer used to control which objects are tested.

Returns:
  True if the ray test collided with a physics object, false otherwise.

void gameplay::PhysicsController::removeStatusListener | ( | Listener * | listener | ) |

Removes a listener to the physics controller.

Parameters:

  listener | The listener to remove.

void gameplay::PhysicsController::setGravity | ( | const Vector3 & | gravity | ) |

Sets the gravity vector for the simulated physics world.

Parameters:

  gravity | The gravity vector.

bool gameplay::PhysicsController::sweepTest | ( | PhysicsCollisionObject * | object,
|  | const Vector3 & | endPosition,
|  | PhysicsController::HitResult * | result = `NULL`,
|  | PhysicsController::HitFilter * | filter = `NULL`
| ) |  |

Performs a sweep test of the given collision object on the physics world.

The start position of the sweep test is defined by the current world position of the specified collision object.

Parameters:

  object | The collision object to test.
  endPosition | The end position of the sweep test, in world space.
  result | Optional pointer to a HitTest structure to store the hit test result information in. When using a default (or no) filter, this will always be the closest object hit. Otherwise, if using a custom filter, it will be the last object passed to the HitFilter::hit method (which is not necessarily the closest or furthest).
  filter | Optional filter pointer used to control which objects are tested.

Returns:
  True if the object intersects any other physics objects, false otherwise.

All Classes Functions Variables Typedefs Enumerations Enumerator