overview wiki api reference download
 All Classes Functions Variables Typedefs Enumerations Enumerator
Classes | Public Member Functions
gameplay::PhysicsController Class Reference

#include <PhysicsController.h>

Inheritance diagram for gameplay::PhysicsController:
gameplay::ScriptTarget

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)
PhysicsFixedConstraintcreateFixedConstraint (PhysicsRigidBody *a, PhysicsRigidBody *b=NULL)
PhysicsGenericConstraintcreateGenericConstraint (PhysicsRigidBody *a, PhysicsRigidBody *b=NULL)
PhysicsGenericConstraintcreateGenericConstraint (PhysicsRigidBody *a, const Quaternion &rotationOffsetA, const Vector3 &translationOffsetA, PhysicsRigidBody *b=NULL, const Quaternion &rotationOffsetB=Quaternion(), const Vector3 &translationOffsetB=Vector3())
PhysicsHingeConstraintcreateHingeConstraint (PhysicsRigidBody *a, const Quaternion &rotationOffsetA, const Vector3 &translationOffsetA, PhysicsRigidBody *b=NULL, const Quaternion &rotationOffsetB=Quaternion(), const Vector3 &translationOffsetB=Vector3())
PhysicsSocketConstraintcreateSocketConstraint (PhysicsRigidBody *a, PhysicsRigidBody *b=NULL)
PhysicsSocketConstraintcreateSocketConstraint (PhysicsRigidBody *a, const Vector3 &translationOffsetA, PhysicsRigidBody *b=NULL, const Vector3 &translationOffsetB=Vector3())
PhysicsSpringConstraintcreateSpringConstraint (PhysicsRigidBody *a, PhysicsRigidBody *b)
PhysicsSpringConstraintcreateSpringConstraint (PhysicsRigidBody *a, const Quaternion &rotationOffsetA, const Vector3 &translationOffsetA, PhysicsRigidBody *b, const Quaternion &rotationOffsetB, const Vector3 &translationOffsetB)
const Vector3getGravity () 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

Adds a listener to the physics controller.

Parameters:
listenerThe listener to add.

Creates a fixed constraint.

Parameters:
aThe 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.
bThe second rigid body to constrain (optional).
Returns:
Pointer to the created PhysicsFixedConstraint object.

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

Parameters:
aThe 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.
bThe 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:
aThe 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.
rotationOffsetAThe rotation offset for the first rigid body (in its local space) with respect to the constraint joint.
translationOffsetAThe translation offset for the first rigid body (in its local space) with respect to the constraint joint.
bThe second rigid body to constrain (optional).
rotationOffsetBThe rotation offset for the second rigid body (in its local space) with respect to the constraint joint (optional).
translationOffsetBThe 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:
aThe 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.
rotationOffsetAThe rotation offset for the first rigid body (in its local space) with respect to the constraint joint.
translationOffsetAThe translation offset for the first rigid body (in its local space) with respect to the constraint joint.
bThe second rigid body to constrain (optional).
rotationOffsetBThe rotation offset for the second rigid body (in its local space) with respect to the constraint joint (optional).
translationOffsetBThe 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.

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:
aThe 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.
bThe 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:
aThe 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.
translationOffsetAThe translation offset for the first rigid body (in its local space) with respect to the constraint joint.
bThe second rigid body to constrain (optional).
translationOffsetBThe 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.

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:
aThe 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.
bThe 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:
aThe 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.
rotationOffsetAThe rotation offset for the first rigid body (in its local space) with respect to the constraint joint.
translationOffsetAThe translation offset for the first rigid body (in its local space) with respect to the constraint joint.
bThe second rigid body to constrain (optional).
rotationOffsetBThe rotation offset for the second rigid body (in its local space) with respect to the constraint joint (optional).
translationOffsetBThe 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:
viewProjectionThe view projection matrix to use when drawing.

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:
rayThe ray to test intersection with.
distanceHow far along the given ray to test for intersections.
resultOptional 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).
filterOptional filter pointer used to control which objects are tested.
Returns:
True if the ray test collided with a physics object, false otherwise.

Removes a listener to the physics controller.

Parameters:
listenerThe listener to remove.

Sets the gravity vector for the simulated physics world.

Parameters:
gravityThe 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:
objectThe collision object to test.
endPositionThe end position of the sweep test, in world space.
resultOptional 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).
filterOptional 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