True Axis Physics SDK 1.2.0.1 Beta Documentation
www.trueaxis.com

TA::DynamicObject Class Reference

#include "TA/Physics/DynamicObject.h"

Inheritance diagram for TA::DynamicObject:

Inheritance graph

Detailed Description

Implements interactive objects in the physics simulation.

Call the static function TA::DynamicObject::CreateNew to create a new instance of this class.

All objects that need to react to physical forces should use this class in the simulation. TA::DynamicObject inherits from TA::PhysicsObject.

Dynamic objects can initialised by several methods:

Initialising with pCollisionObjectCombo allows for more complex collision objects. It also allows multiple dynamic objects to share the same collision objects to help reduce memory usage. The other initialisers are provided mostly for rapid prototyping purposes.

After the object has been initialised, various functions such as TA::DynamicObject::SetMass can be used to set the objects properties.

Dynamics objects can be added and removed from the physics simulation by use of the functions TA::Physics::AddDynamicObject and TA::Physics::RemoveDynamicObject. The function TA::DynamicObject::AddedToPhysics can be used to determine the current state.

Reference Counting:
This class is reference counted. After the object is created it will have a reference count of one. AddRef() and Release() can be called to increment and decrement the reference count. If the reference count is zero after a call to Release() the object will be automatically deleted. Reference counted objects should only be created using new.
Examples:

BallAndSocketJointExample.cpp, CollisionListExample.cpp, CollisionObjectComboExample.cpp, HingeJointExample.cpp, SimplePhysicsSimulationExample.cpp, and SliderJointExample.cpp.


Public Types

typedef List< PhysicsJoint
>::Iterator  
JointIterator
typedef DynamicObjectCollisionIterator  CollisionIterator
enum  ReinitFlags {
  REINIT_FLAG_UPDATE_MASS = 0x1,
  REINIT_FLAG_UPDATE_INERTIA_TENSOR = 0x2,
  REINIT_FLAG_UPDATE_CENTER_OFFSET = 0x4
}

Public Member Functions

JointIterator  GetJointIterator ()
Initialise / Finalise
void  InitialiseFromFile (const Char *szFileName)
void  InitialiseAsABox (const AABB &aabb)
void  InitialiseAsAnOrientedBox (const AABB &aabb, const MFrame &mFrame)
void  InitialiseAsACapsule (const Vec3 &v3Start, const Vec3 &v3End, float fRadius)
void  InitialiseAsASphere (const Vec3 &v3Center, float fRadius)
void  InitialiseAsACylinder (const Vec3 &v3Start, const Vec3 &v3End, float fRadius)
void  Initialise (CollisionObjectCombo *pCollisionObjectCombo)
void  Initialise (CollisionObjectComplex *pCollisionObjectComplex)
void  Finalise ()
Location
const MFrame &  GetFrame () const
void  SetFrame (const MFrame &frame)
const MFrame &  GetNextFrame () const
const MFrame &  GetPreviousFrame () const
const MFrame &  GetGraphicsFrame () const
const Vec3 &  GetPosition () const
void  SetPosition (const Vec3 &v3Position)
const Vec3 &  GetCenterOfMass () const
const Vec3 &  GetNextCenterOfMass () const
const Vec3 &  GetCenterOffset () const
void  SetCenterOffset (const Vec3 &v3CenterOffset)
void  SetFrameDirect (const MFrame &frame)
Mass / Inertia
float  GetMass () const
float  GetInverseMass () const
void  SetMass (float fMass)
const Mat33 &  GetInertia () const
void  SetInertiaFromBox (const AABB &aabb)
void  SetInertiaFromBox (float fX, float fY, float fZ)
const Mat33 &  GetInverseInertia () const
const Mat33 &  GetWorldSpaceInertia () const
const Mat33 &  GetWorldSpaceInverseInertia () const
Other properties
void  SetFriction (float fFriction)
float  GetFriction () const
void  SetRestitution (float fRestitution)
float  GetRestitution () const
void  SetGravityMult (float fGravityMult)
float  GetGravityMult () const
void  SetRotationDisabled (bool bValue)
bool  RotationDisabled () const
void  SetMovementDisabled (bool bValue)
bool  MovementDisabled () const
void  SetExtraStability (bool bValue)
bool  ExtraStability () const
void  SetRigidFrictionDisabled (bool bValue)
bool  RigidFrictionDisabled () const
void  SetCollisionDisabled (bool bValue)
bool  CollisionDisabled () const
void  SetUpdateDisabled (bool bValue)
bool  UpdateDisabled () const
void  SetGhost (bool bValue)
bool  Ghost () const
void  SetInfiniteMass (bool bValue)
bool  InfiniteMass () const
void  SetFindVelocityFromNextFrame (bool bValue)
bool  GetFindVelocityFromNextFrame () const
bool  IsWorldObject () const
void  SetRestTimeMultiplier (float fRestTimeMultiplier)
float  GetRestTimeMultiplier () const
void  SetID (int nID)
int  GetID () const
Physics *  GetPhysics ()
Moving or resting
bool  IsInMovingList () const
void  SetToMoving ()
void  SetToResting ()
Velocity and Impulse
const Vec3 &  GetLinearVelocity () const
void  SetLinearVelocity (const Vec3 &v3LinearVelocity)
const Vec3 &  GetAngularVelocity () const
void  SetAngularVelocity (const Vec3 &v3AngularVelocity)
void  SetVelocitiesToMoveToFrame (const MFrame &mFrame, float fDt)
Vec3  GetVelocityAtWorldPosition (const Vec3 &v3Position) const
void  ApplyImpulse (const Vec3 &v3WorldImpulse, const Vec3 &v3WorldPosition)
void  ApplyLinearImpulse (const Vec3 &v3WorldLinearImpulse)
void  ApplyAngularImpulse (const Vec3 &v3WorldAngularImpulse)
Accumulating forces
void  AssertForceAndTorqueCleared () const
void  AccumulateGravity ()
void  AccumulateForceAndTorque (const Vec3 &v3WorldForce, const Vec3 &v3WorldPosition)
void  AccumulateLinearForce (const Vec3 &v3WorldForce)
void  ApplyForceAndTorqueToVelocities (float fDt)
void  ClearForceAndTorque ()
Updating
void  Clear ()
void  UpdateWorldSpaceInertialTensor ()
virtual void  Update (float fDt)
virtual void  UpdateGraphics (float fDt, float fInterpolant)
void  Extrapolate (const MFrame &frameA, const MFrame &frameB, const Vec3 &v3VelocityA, const Vec3 &v3VelocityB, float fDt, float fExtrapolation)
virtual void  ApplyVelocityToNextFrame (float fDt)
void  ApplyNextFrame ()
Rendering
void  Render ()
Collision
void  CalculateWorldAABB ()
const AABB &  GetWorldAABB ()
CollisionObject &  GetCollisionObject ()
CollisionObjectCombo *  GetCollisionObjectCombo ()
CollisionObjectComplex *  GetCollisionObjectComplex ()
void  SetCollisionObject (CollisionObjectCombo *pCollisionObjectCombo, int nFlags=(REINIT_FLAG_UPDATE_MASS|REINIT_FLAG_UPDATE_INERTIA_TENSOR|REINIT_FLAG_UPDATE_CENTER_OFFSET))
void  SetCollisionObjectChanged (int nFlags=(REINIT_FLAG_UPDATE_MASS|REINIT_FLAG_UPDATE_INERTIA_TENSOR|REINIT_FLAG_UPDATE_CENTER_OFFSET))
void  ReinitCollisionAsABox (const AABB &aabb, int nFlags=(REINIT_FLAG_UPDATE_MASS|REINIT_FLAG_UPDATE_INERTIA_TENSOR|REINIT_FLAG_UPDATE_CENTER_OFFSET))
void  ReinitCollisionAsAnOrientedBox (const AABB &aabb, const MFrame &mFrame, int nFlags=(REINIT_FLAG_UPDATE_MASS|REINIT_FLAG_UPDATE_INERTIA_TENSOR|REINIT_FLAG_UPDATE_CENTER_OFFSET))
void  ReinitCollisionAsACapsule (const Vec3 &v3Start, const Vec3 &v3End, float fRadius, int nFlags=(REINIT_FLAG_UPDATE_MASS|REINIT_FLAG_UPDATE_INERTIA_TENSOR|REINIT_FLAG_UPDATE_CENTER_OFFSET))
void  ReinitCollisionAsASphere (const Vec3 &v3Center, float fRadius, int nFlags=(REINIT_FLAG_UPDATE_MASS|REINIT_FLAG_UPDATE_INERTIA_TENSOR|REINIT_FLAG_UPDATE_CENTER_OFFSET))
void  ReinitCollisionAsACylinder (const Vec3 &v3Start, const Vec3 &v3End, float fRadius, int nFlags=(REINIT_FLAG_UPDATE_MASS|REINIT_FLAG_UPDATE_INERTIA_TENSOR|REINIT_FLAG_UPDATE_CENTER_OFFSET))
CollisionIterator  GetCollisionIterator ()
void  SetCollisionListEnabled (bool bValue)
bool  CollisionListEnabled () const
bool  TestLineForCollision (const Vec3 &v3Start, const Vec3 &v3Normal, float fLength, Collision &collision) const
Line List Collisions
int  GetNumLineCollisions ()
const LineIntersection &  GetLineCollision (int nIndex) const
Joints
PhysicsJoint &  AddJoint (DynamicObject *pOtherObject)
void  RemoveAllJoints ()
void  RemoveJoint (PhysicsJoint &joint)
void  RemoveJointsToObject (DynamicObject *pDynamicObject)
Joints (Depreciated Functions)
PhysicsJoint &  AddJoint (DynamicObject *pOtherObject, const Vec3 &v3LocalPos, const Vec3 &v3LocalPosOnOtherObject, const Mat33 &m33DefaultRotationOfOtherObject, const EulerAngles &minAngles, const EulerAngles &maxAngles)
PhysicsJoint &  AddJointTypeHinge (DynamicObject *pOtherObject, const Vec3 &v3LocalPos, const Vec3 &v3LocalPosOnOtherObject, const Vec3 &v3LocalHingeAxis, const Vec3 &v3LocalHingeNormal, float fMinAngle, float fMaxAngle)
PhysicsJoint &  AddJointTypeSocket (DynamicObject *pOtherObject, const Vec3 &v3LocalPos, const Vec3 &v3LocalPosOnOtherObject, const Vec3 &v3LimitCenterNormal, const Vec3 &v3LimitCenterNormalOnOtherObject, float fMaxAngle)
PhysicsJoint &  AddJointTypeLimitedSocket (DynamicObject *pOtherObject, const Vec3 &v3LocalPos, const Vec3 &v3LocalPosOnOtherObject, const Mat33 &m33DefaultRotationOfOtherObject, float fMaxAngleY, float fMaxAngleXZ)
PhysicsJoint &  AddJointTypeSquareSocket (DynamicObject *pOtherObject, const Vec3 &v3LocalPos, const Vec3 &v3LocalPosOnOtherObject, const Mat33 &m33DefaultRotationOfOtherObject, float fMinX, float fMaxX, float fMinY, float fMaxY, float fMinZ, float fMaxZ)
PhysicsJoint &  AddJointTypeSlider (DynamicObject *pOtherObject, const Vec3 &v3LocalPos, const Vec3 &v3StartPosOnOtherObject, const Vec3 &v3EndPosPosOnOtherObject)
PhysicsJoint &  AddRotationConstraint (DynamicObject *pOtherObject, const Mat33 &m33DefaultRotationOfOtherObject, const EulerAngles &minAngles, const EulerAngles &maxAngles)
PhysicsJoint &  AddVectorConstraint (DynamicObject *pOtherObject, const Vec3 &v3LimitCenterNormal, const Vec3 &v3LimitCenterNormalOnOtherObject, float fMaxAngle)
Advanced collision detection control
bool  IsAllowedToCollideWith (const DynamicObject &otherObject) const
void  SetUserGroup (int nUserGroupId)
int  GetUserGroup () const
void  SetUserGroupItemId (int nUserGroupItemId)
int  GetUserGroupItemId () const
void  DisallowCollisionWithUserGroupItemId (int nUserGroupItemId)
void  AllowCollisionWithUserGroupItemId (int nUserGroupItemId)
void  SetCollisionUserData (void *pData)
void *  GetCollisionUserData () const
void  SetUserData (void *pData)
void *  GetUserData () const

Static Public Member Functions

static DynamicObject *TAC_CALL  CreateNew ()
Advanced collision detection control
static int TAC_CALL  CreateUserGroup ()

Static Public Attributes

static const float  JOINT_LIMIT_DISABLED

Protected Member Functions

void  InitialiseCommon ()
void  ClearLineIntersections ()

Data Structures

struct  LineIntersection
 This structure contains information about a line collision that has occurred. More...


© Copyright 2004-2006 TRUE AXIS PTY LTD Australia. All rights reserved.