Cyclone | Cyclone: cyclone::RigidBody Class Reference |
#include <body.h>
Collaboration diagram for cyclone::RigidBody:
Public Member Functions | |
Integration and Simulation Functions | |
These functions are used to simulate the rigid body's motion over time. A normal application sets up one or more rigid bodies, applies permanent forces (i.e. gravity), then adds transient forces each frame, and integrates, prior to rendering.
Currently the only integration function provided is the first order Newton Euler method. | |
void | calculateDerivedData () |
Calculates internal data from state data.CalculateDerivedData. | |
void | integrate (real duration) |
Integrates the rigid body forward in time by the given amount. | |
Accessor Functions for the Rigid Body's State | |
These functions provide access to the rigid body's characteristics or state. These data can be accessed individually, or en masse as an array of values (e.g. getCharacteristics, getState). When setting new data, make sure the calculateInternals function, or an integration routine, is called before trying to get data from the body, since the class contains a number of dependent values that will need recalculating. | |
void | setMass (const real mass) |
Sets the mass of the rigid body. | |
real | getMass () const |
Gets the mass of the rigid body. | |
void | setInverseMass (const real inverseMass) |
Sets the inverse mass of the rigid body. | |
real | getInverseMass () const |
Gets the inverse mass of the rigid body. | |
bool | hasFiniteMass () const |
Returns true if the mass of the body is not-infinite. | |
void | setInertiaTensor (const Matrix3 &inertiaTensor) |
Sets the intertia tensor for the rigid body. | |
void | getInertiaTensor (Matrix3 *inertiaTensor) const |
Copies the current inertia tensor of the rigid body into the given matrix. | |
Matrix3 | getInertiaTensor () const |
Gets a copy of the current inertia tensor of the rigid body. | |
void | getInertiaTensorWorld (Matrix3 *inertiaTensor) const |
Copies the current inertia tensor of the rigid body into the given matrix. | |
Matrix3 | getInertiaTensorWorld () const |
Gets a copy of the current inertia tensor of the rigid body. | |
void | setInverseInertiaTensor (const Matrix3 &inverseInertiaTensor) |
Sets the inverse intertia tensor for the rigid body. | |
void | getInverseInertiaTensor (Matrix3 *inverseInertiaTensor) const |
Copies the current inverse inertia tensor of the rigid body into the given matrix. | |
Matrix3 | getInverseInertiaTensor () const |
Gets a copy of the current inverse inertia tensor of the rigid body. | |
void | getInverseInertiaTensorWorld (Matrix3 *inverseInertiaTensor) const |
Copies the current inverse inertia tensor of the rigid body into the given matrix. | |
Matrix3 | getInverseInertiaTensorWorld () const |
Gets a copy of the current inverse inertia tensor of the rigid body. | |
void | setDamping (const real linearDamping, const real angularDamping) |
Sets both linear and angular damping in one function call. | |
void | setLinearDamping (const real linearDamping) |
Sets the linear damping for the rigid body. | |
real | getLinearDamping () const |
Gets the current linear damping value. | |
void | setAngularDamping (const real angularDamping) |
Sets the angular damping for the rigid body. | |
real | getAngularDamping () const |
Gets the current angular damping value. | |
void | setPosition (const Vector3 &position) |
Sets the position of the rigid body. | |
void | setPosition (const real x, const real y, const real z) |
Sets the position of the rigid body by component. | |
void | getPosition (Vector3 *position) const |
Fills the given vector with the position of the rigid body. | |
Vector3 | getPosition () const |
Gets the position of the rigid body. | |
void | setOrientation (const Quaternion &orientation) |
Sets the orientation of the rigid body. | |
void | setOrientation (const real r, const real i, const real j, const real k) |
Sets the orientation of the rigid body by component. | |
void | getOrientation (Quaternion *orientation) const |
Fills the given quaternion with the current value of the rigid body's orientation. | |
Quaternion | getOrientation () const |
Gets the orientation of the rigid body. | |
void | getOrientation (Matrix3 *matrix) const |
Fills the given matrix with a transformation representing the rigid body's orientation. | |
void | getOrientation (real matrix[9]) const |
Fills the given matrix data structure with a transformation representing the rigid body's orientation. | |
void | getTransform (Matrix4 *transform) const |
Fills the given matrix with a transformation representing the rigid body's position and orientation. | |
void | getTransform (real matrix[16]) const |
Fills the given matrix data structure with a transformation representing the rigid body's position and orientation. | |
void | getGLTransform (float matrix[16]) const |
Fills the given matrix data structure with a transformation representing the rigid body's position and orientation. | |
Matrix4 | getTransform () const |
Gets a transformation representing the rigid body's position and orientation. | |
Vector3 | getPointInLocalSpace (const Vector3 &point) const |
Converts the given point from world space into the body's local space. | |
Vector3 | getPointInWorldSpace (const Vector3 &point) const |
Converts the given point from world space into the body's local space. | |
Vector3 | getDirectionInLocalSpace (const Vector3 &direction) const |
Converts the given direction from world space into the body's local space. | |
Vector3 | getDirectionInWorldSpace (const Vector3 &direction) const |
Converts the given direction from world space into the body's local space. | |
void | setVelocity (const Vector3 &velocity) |
Sets the velocity of the rigid body. | |
void | setVelocity (const real x, const real y, const real z) |
Sets the velocity of the rigid body by component. | |
void | getVelocity (Vector3 *velocity) const |
Fills the given vector with the velocity of the rigid body. | |
Vector3 | getVelocity () const |
Gets the velocity of the rigid body. | |
void | addVelocity (const Vector3 &deltaVelocity) |
Applies the given change in velocity. | |
void | setRotation (const Vector3 &rotation) |
Sets the rotation of the rigid body. | |
void | setRotation (const real x, const real y, const real z) |
Sets the rotation of the rigid body by component. | |
void | getRotation (Vector3 *rotation) const |
Fills the given vector with the rotation of the rigid body. | |
Vector3 | getRotation () const |
Gets the rotation of the rigid body. | |
void | addRotation (const Vector3 &deltaRotation) |
Applies the given change in rotation. | |
bool | getAwake () const |
Returns true if the body is awake and responding to integration. | |
void | setAwake (const bool awake=true) |
Sets the awake state of the body. | |
bool | getCanSleep () const |
Returns true if the body is allowed to go to sleep at any time. | |
void | setCanSleep (const bool canSleep=true) |
Sets whether the body is ever allowed to go to sleep. | |
Retrieval Functions for Dynamic Quantities | |
These functions provide access to the acceleration properties of the body. The acceleration is generated by the simulation from the forces and torques applied to the rigid body. Acceleration cannot be directly influenced, it is set during integration, and represent the acceleration experienced by the body of the previous simulation step. | |
void | getLastFrameAcceleration (Vector3 *linearAcceleration) const |
Fills the given vector with the current accumulated value for linear acceleration. | |
Vector3 | getLastFrameAcceleration () const |
Gets the current accumulated value for linear acceleration. | |
Force, Torque and Acceleration Set-up Functions | |
These functions set up forces and torques to apply to the rigid body. | |
void | clearAccumulators () |
Clears the forces and torques in the accumulators. | |
void | addForce (const Vector3 &force) |
Adds the given force to centre of mass of the rigid body.AddForceAtCenter. | |
void | addForceAtPoint (const Vector3 &force, const Vector3 &point) |
Adds the given force to the given point on the rigid body. | |
void | addForceAtBodyPoint (const Vector3 &force, const Vector3 &point) |
Adds the given force to the given point on the rigid body. | |
void | addTorque (const Vector3 &torque) |
Adds the given torque to the rigid body. | |
void | setAcceleration (const Vector3 &acceleration) |
Sets the constant acceleration of the rigid body. | |
void | setAcceleration (const real x, const real y, const real z) |
Sets the constant acceleration of the rigid body by component. | |
void | getAcceleration (Vector3 *acceleration) const |
Fills the given vector with the acceleration of the rigid body. | |
Vector3 | getAcceleration () const |
Gets the acceleration of the rigid body. | |
Protected Attributes | |
Characteristic Data and State | |
This data holds the state of the rigid body. There are two sets of data: characteristics and state. Characteristics are properties of the rigid body independent of its current kinematic situation. This includes mass, moment of inertia and damping properties. Two identical rigid bodys will have the same values for their characteristics. State includes all the characteristics and also includes the kinematic situation of the rigid body in the current simulation. By setting the whole state data, a rigid body's exact game state can be replicated. Note that state does not include any forces applied to the body. Two identical rigid bodies in the same simulation will not share the same state values. The state values make up the smallest set of independent data for the rigid body. Other state data is calculated from their current values. When state data is changed the dependent values need to be updated: this can be achieved either by integrating the simulation, or by calling the calculateInternals function. This two stage process is used because recalculating internals can be a costly process: all state changes should be carried out at the same time, allowing for a single call.
| |
real | inverseMass |
Holds the inverse of the mass of the rigid body.RigidBodyIntro. | |
Matrix3 | inverseInertiaTensor |
Holds the inverse of the body's inertia tensor.InverseInertiaTensor. | |
real | linearDamping |
Holds the amount of damping applied to linear motion. | |
real | angularDamping |
Holds the amount of damping applied to angular motion.AngularDamping. | |
Vector3 | position |
Holds the linear position of the rigid body in world space. | |
Quaternion | orientation |
Holds the angular orientation of the rigid body in world space. | |
Vector3 | velocity |
Holds the linear velocity of the rigid body in world space. | |
Vector3 | rotation |
Holds the angular velocity, or rotation, or the rigid body in world space.RigidBodyIntro. | |
Derived Data | |
These data members hold information that is derived from the other data in the class. | |
Matrix3 | inverseInertiaTensorWorld |
Holds the inverse inertia tensor of the body in world space. | |
real | motion |
Holds the amount of motion of the body. | |
bool | isAwake |
A body can be put to sleep to avoid it being updated by the integration functions or affected by collisions with the world. | |
bool | canSleep |
Some bodies may never be allowed to fall asleep.SleepData. | |
Matrix4 | transformMatrix |
>RigidBodyIntro RigidBodyIntro | |
Force and Torque Accumulators | |
These data members store the current force, torque and acceleration of the rigid body. Forces can be added to the rigid body in any order, and the class decomposes them into their constituents, accumulating them for the next simulation step. At the simulation step, the accelerations are calculated and stored to be applied to the rigid body. | |
Vector3 | forceAccum |
Holds the accumulated force to be applied at the next integration step. | |
Vector3 | torqueAccum |
Holds the accumulated torque to be applied at the next integration step. | |
Vector3 | acceleration |
Holds the acceleration of the rigid body. | |
Vector3 | lastFrameAcceleration |
Holds the linear acceleration of the rigid body, for the previous frame. |
/<RigidBodyIntro
It has position and orientation data, along with first derivatives. It can be integrated forward through time, and have forces, torques and impulses (linear or angular) applied to it. The rigid body manages its state and allows access through a set of methods.
A ridid body contains 64 words (the size of which is given by the precision: sizeof(real)). It contains no virtual functions, so should take up exactly 64 words in memory. Of this total 15 words are padding, distributed among the Vector3 data members. />RigidBodyIntro
|
Adds the given force to centre of mass of the rigid body.AddForceAtCenter. The force is expressed in world-coordinates.
|
|
Adds the given force to the given point on the rigid body. The direction of the force is given in world coordinates, but the application point is given in body space. This is useful for spring forces, or other forces fixed to the body.
|
|
Adds the given force to the given point on the rigid body. Both the force and the application point are given in world space. Because the force is not applied at the centre of mass, it may be split into both a force and torque.
|
|
Applies the given change in rotation.
|
|
Adds the given torque to the rigid body. The force is expressed in world-coordinates.
|
|
Applies the given change in velocity.
|
|
Calculates internal data from state data.CalculateDerivedData. This should be called after the body's state is altered directly (it is called automatically during integration). If you change the body's state and then intend to integrate before querying any data (such as the transform matrix), then you can ommit this step. |
|
Clears the forces and torques in the accumulators. This will be called automatically after each intergration step. |
|
Gets the acceleration of the rigid body.
|
|
Fills the given vector with the acceleration of the rigid body.
|
|
Gets the current angular damping value.
|
|
Returns true if the body is awake and responding to integration.
|
|
Returns true if the body is allowed to go to sleep at any time.
|
|
Converts the given direction from world space into the body's local space.
|
|
Converts the given direction from world space into the body's local space.
|
|
Fills the given matrix data structure with a transformation representing the rigid body's position and orientation. The matrix is transposed from that returned by getTransform. This call returns a matrix suitable for applying as an OpenGL transform.
|
|
Gets a copy of the current inertia tensor of the rigid body.
|
|
Copies the current inertia tensor of the rigid body into the given matrix.
|
|
Gets a copy of the current inertia tensor of the rigid body.
|
|
Copies the current inertia tensor of the rigid body into the given matrix.
|
|
Gets a copy of the current inverse inertia tensor of the rigid body.
|
|
Copies the current inverse inertia tensor of the rigid body into the given matrix.
|
|
Gets a copy of the current inverse inertia tensor of the rigid body.
|
|
Copies the current inverse inertia tensor of the rigid body into the given matrix.
|
|
Gets the inverse mass of the rigid body.
|
|
Gets the current accumulated value for linear acceleration. The acceleration accumulators are set during the integration step. They can be read to determine the rigid body's acceleration over the last integration step. The linear acceleration is given in world space.
|
|
Fills the given vector with the current accumulated value for linear acceleration. The acceleration accumulators are set during the integration step. They can be read to determine the rigid body's acceleration over the last integration step. The linear acceleration is given in world space.
|
|
Gets the current linear damping value.
|
|
Gets the mass of the rigid body.
|
|
Fills the given matrix data structure with a transformation representing the rigid body's orientation.
|
|
Fills the given matrix with a transformation representing the rigid body's orientation.
|
|
Gets the orientation of the rigid body.
|
|
Fills the given quaternion with the current value of the rigid body's orientation.
|
|
Converts the given point from world space into the body's local space.
|
|
Converts the given point from world space into the body's local space.
|
|
Gets the position of the rigid body.
|
|
Fills the given vector with the position of the rigid body.
|
|
Gets the rotation of the rigid body.
|
|
Fills the given vector with the rotation of the rigid body.
|
|
Gets a transformation representing the rigid body's position and orientation.
|
|
Fills the given matrix data structure with a transformation representing the rigid body's position and orientation.
|
|
Fills the given matrix with a transformation representing the rigid body's position and orientation.
|
|
Gets the velocity of the rigid body.
|
|
Fills the given vector with the velocity of the rigid body.
|
|
Returns true if the mass of the body is not-infinite.
|
|
Integrates the rigid body forward in time by the given amount. This function uses a Newton-Euler integration method, which is a linear approximation to the correct integral. For this reason it may be inaccurate in some cases. |
|
Sets the constant acceleration of the rigid body by component.
|
|
Sets the constant acceleration of the rigid body.
|
|
Sets the angular damping for the rigid body.
|
|
Sets the awake state of the body. If the body is set to be not awake, then its velocities are also cancelled, since a moving body that is not awake can cause problems in the simulation.
|
|
Sets whether the body is ever allowed to go to sleep. Bodies under the player's control, or for which the set of transient forces applied each frame are not predictable, should be kept awake.
|
|
Sets both linear and angular damping in one function call.
|
|
Sets the intertia tensor for the rigid body.
|
|
Sets the inverse intertia tensor for the rigid body.
|
|
Sets the inverse mass of the rigid body.
|
|
Sets the linear damping for the rigid body.
|
|
Sets the mass of the rigid body.
|
|
Sets the orientation of the rigid body by component.
|
|
Sets the orientation of the rigid body.
|
|
Sets the position of the rigid body by component.
|
|
Sets the position of the rigid body.
|
|
Sets the rotation of the rigid body by component. The rotation is given in world space.
|
|
Sets the rotation of the rigid body.
|
|
Sets the velocity of the rigid body by component. The velocity is given in world space.
|
|
Sets the velocity of the rigid body.
|
|
Holds the acceleration of the rigid body. This value can be used to set acceleration due to gravity (its primary use), or any other constant acceleration. |
|
Holds the amount of damping applied to angular motion.AngularDamping. Damping is required to remove energy added through numerical instability in the integrator. |
|
Some bodies may never be allowed to fall asleep.SleepData. User controlled bodies, for example, should be always awake. |
|
Holds the accumulated force to be applied at the next integration step.
|
|
Holds the inverse of the body's inertia tensor.InverseInertiaTensor. The intertia tensor provided must not be degenerate (that would mean the body had zero inertia for spinning along one axis). As long as the tensor is finite, it will be invertible. The inverse tensor is used for similar reasons to the use of inverse mass. The inertia tensor, unlike the other variables that define a rigid body, is given in body space.
|
|
Holds the inverse inertia tensor of the body in world space. The inverse inertia tensor member is specified in the body's local space.
|
|
Holds the inverse of the mass of the rigid body.RigidBodyIntro. It is more useful to hold the inverse mass because integration is simpler, and because in real time simulation it is more useful to have bodies with infinite mass (immovable) than zero mass (completely unstable in numerical simulation). |
|
A body can be put to sleep to avoid it being updated by the integration functions or affected by collisions with the world.
|
|
Holds the linear acceleration of the rigid body, for the previous frame.
|
|
Holds the amount of damping applied to linear motion. Damping is required to remove energy added through numerical instability in the integrator. |
|
Holds the amount of motion of the body. This is a recency weighted mean that can be used to put a body to sleap. |
|
Holds the angular orientation of the rigid body in world space.
|
|
Holds the linear position of the rigid body in world space.
|
|
Holds the angular velocity, or rotation, or the rigid body in world space.RigidBodyIntro.
|
|
Holds the accumulated torque to be applied at the next integration step.
|
|
>RigidBodyIntro RigidBodyIntro This can be achieved by calling the getPointIn*Space functions. /<RigidBodyIntro
|
|
Holds the linear velocity of the rigid body in world space.
|
© 2000-2003 Icosagon. All Rights Reserved.
Distributed under licence.
Cyclone Version 2.0.5 (Documentation generated Fri Nov 10 20:44:18 2006). |