PixelLightAPI  .
Public Member Functions | Public Attributes | Protected Member Functions
PLPhysics::Body Class Reference

Abstract PL physics (rigid) body base class. More...

#include <Body.h>

Inheritance diagram for PLPhysics::Body:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual PLPHYSICS_API ~Body ()
 Destructor.
PLPHYSICS_API BodyImpl & GetBodyImpl () const
 Returns a reference to the physics API specific body implementation.
PLPHYSICS_API bool IsActive () const
 Returns whether the body is currently active or not.
PLPHYSICS_API void SetActive (bool bActive=true)
 Sets whether the body is currently active or not.
PLPHYSICS_API float GetCollisionVolume () const
 Returns the collision volume of the physics body.
PLPHYSICS_API float GetMass () const
 Returns the mass of the physics body.
PLPHYSICS_API void GetCenterOfMass (PLMath::Vector3 &vPosition) const
 Gets the relative center of the mass.
PLPHYSICS_API void SetCenterOfMass (const PLMath::Vector3 &vPosition)
 Sets the relative center of the mass.
PLPHYSICS_API void GetPosition (PLMath::Vector3 &vPosition) const
 Gets the body position.
PLPHYSICS_API void SetPosition (const PLMath::Vector3 &vPosition)
 Sets the body position.
PLPHYSICS_API void GetRotation (PLMath::Quaternion &qRotation) const
 Gets the body rotation.
PLPHYSICS_API void SetRotation (const PLMath::Quaternion &qRotation)
 Sets the body rotation.
PLPHYSICS_API void GetTransformMatrix (PLMath::Matrix3x4 &mTrans) const
 Gets the body transform matrix.
PLPHYSICS_API void SetTransformMatrix (const PLMath::Matrix3x4 &mTrans)
 Sets the body transform matrix.
PLPHYSICS_API void GetAABoundingBox (PLMath::AABoundingBox &cAABoundingBox) const
 Gets the global space axis aligned bounding box of the body.
PLPHYSICS_API void GetLinearVelocity (PLMath::Vector3 &vVelocity) const
 Gets the linear body velocity.
PLPHYSICS_API void SetLinearVelocity (const PLMath::Vector3 &vVelocity)
 Sets the linear body velocity.
PLPHYSICS_API void GetAngularVelocity (PLMath::Vector3 &vVelocity) const
 Gets the angular body velocity.
PLPHYSICS_API void SetAngularVelocity (const PLMath::Vector3 &vVelocity)
 Sets the angular body velocity.
PLPHYSICS_API void GetForce (PLMath::Vector3 &vForce) const
 Gets the force applied to the body at the next simulation update.
PLPHYSICS_API void AddForce (const PLMath::Vector3 &vForce)
 Adds a force to the body.
PLPHYSICS_API void SetForce (const PLMath::Vector3 &vForce)
 Sets the force applied to the body at the next simulation update.
PLPHYSICS_API void GetTorque (PLMath::Vector3 &vTorque) const
 Gets the torque applied to the body at the next simulation update.
PLPHYSICS_API void AddTorque (const PLMath::Vector3 &vTorque)
 Adds a torque to the body.
PLPHYSICS_API void SetTorque (const PLMath::Vector3 &vTorque)
 Sets the torque applied to the body at the next simulation update.
PLPHYSICS_API bool IsAutoFreeze () const
 Returns whether the body is frozen automatically or not.
PLPHYSICS_API void SetAutoFreeze (bool bAutoFreeze=true)
 Sets whether the body is frozen automatically or not.
PLPHYSICS_API void GetFreezeThreshold (float &fLinearVelocity, float &fAngularVelocity, PLCore::uint32 &nSteps) const
 Returns the freeze threshold.
PLPHYSICS_API void SetFreezeThreshold (float fLinearVelocity=0.01f, float fAngularVelocity=0.01f, PLCore::uint32 nSteps=10)
 Sets the freeze threshold.
PLPHYSICS_API bool IsFrozen () const
 Returns whether the body is currently frozen or not.
PLPHYSICS_API void SetFrozen (bool bFrozen=true)
 Sets whether the body is currently frozen or not.
PLPHYSICS_API bool IsCollisionActive () const
 Returns whether the body can collide or not.
PLPHYSICS_API void SetCollisionActive (bool bActive=true)
 Sets whether the body can collide or not.
PLPHYSICS_API bool GetUseGravity () const
 Returns whether the body ignores the gravity or not.
PLPHYSICS_API void SetUseGravity (bool bUseGravity=true)
 Sets whether the body ignores the gravity or not.
PLPHYSICS_API PLCore::uint8 GetCollisionGroup () const
 Returns the collision group the body is in.
PLPHYSICS_API void SetCollisionGroup (PLCore::uint8 nCollisionGroup=0)
 Sets the collision group the body is in.
PLPHYSICS_API PLCore::uint32 GetNumOfPartners () const
 Returns the number of partner bodies.
PLPHYSICS_API BodyGetPartner (PLCore::uint32 nIndex) const
 Returns a partner body.
virtual PLPHYSICS_API void SetMass (float fMass=0.0f)
 Sets the mass of the physics body.
virtual PLPHYSICS_API bool IsBody () const override
 Returns whether or not this is a body.
virtual PLPHYSICS_API bool IsJoint () const override
 Returns whether or not this is a joint.
virtual PLPHYSICS_API bool IsSensor () const override
 Returns whether or not this is a sensor.

Public Attributes

PLCore::Event EventTransform

Protected Member Functions

PLPHYSICS_API Body (World &cWorld, BodyImpl &cBodyImpl)
 Constructor.

Detailed Description

Abstract PL physics (rigid) body base class.

Remarks:
If a physics body is created, it is frozen automatically. Bodies can interact if they are in collision groups (see GetCollisionGroup()) which can collide, (see World::GetGroupCollision()) and if within the body pair flag (see World::GetBodyPairFlags()) World::Ignore is NOT set - AND at least, IsCollisionActive() of both must return 'true'.

Constructor & Destructor Documentation

virtual PLPHYSICS_API PLPhysics::Body::~Body ( ) [virtual]

Destructor.

PLPHYSICS_API PLPhysics::Body::Body ( World cWorld,
BodyImpl &  cBodyImpl 
) [protected]

Constructor.

Parameters:
[in]cWorldWorld this body is in
[in]cBodyImplReference to the physics API specific body implementation

Member Function Documentation

PLPHYSICS_API BodyImpl& PLPhysics::Body::GetBodyImpl ( ) const

Returns a reference to the physics API specific body implementation.

Returns:
Reference to the physics API specific body implementation
PLPHYSICS_API bool PLPhysics::Body::IsActive ( ) const

Returns whether the body is currently active or not.

Returns:
'true' if the body is currently active, else 'false'
Note:
  • With 'active' we mean 'totally ignored' and not 'just currently frozen' (see IsFrozen())
PLPHYSICS_API void PLPhysics::Body::SetActive ( bool  bActive = true)

Sets whether the body is currently active or not.

Parameters:
[in]bActive'true' if the body is currently active, else 'false'
See also:
PLPHYSICS_API float PLPhysics::Body::GetCollisionVolume ( ) const

Returns the collision volume of the physics body.

Returns:
The collision volume of the physics body
Remarks:
The collision volume of the body can for instance be used for buoyancy.
PLPHYSICS_API float PLPhysics::Body::GetMass ( ) const

Returns the mass of the physics body.

Returns:
Mass of the physics body
PLPHYSICS_API void PLPhysics::Body::GetCenterOfMass ( PLMath::Vector3 vPosition) const

Gets the relative center of the mass.

Parameters:
[out]vPositionWill receive the relative center of the mass
Note:
  • The relative center of the mass does't 'move' the body, it just has an influence on it's behavior
PLPHYSICS_API void PLPhysics::Body::SetCenterOfMass ( const PLMath::Vector3 vPosition)

Sets the relative center of the mass.

Parameters:
[in]vPositionNew relative center of the mass (PLMath::Vector3::Zero by default)
See also:
PLPHYSICS_API void PLPhysics::Body::GetPosition ( PLMath::Vector3 vPosition) const

Gets the body position.

Parameters:
[out]vPositionWill receive the current body position
PLPHYSICS_API void PLPhysics::Body::SetPosition ( const PLMath::Vector3 vPosition)

Sets the body position.

Parameters:
[in]vPositionNew body position
PLPHYSICS_API void PLPhysics::Body::GetRotation ( PLMath::Quaternion qRotation) const

Gets the body rotation.

Parameters:
[out]qRotationWill receive the body rotation
PLPHYSICS_API void PLPhysics::Body::SetRotation ( const PLMath::Quaternion qRotation)

Sets the body rotation.

Parameters:
[in]qRotationNew body rotation
PLPHYSICS_API void PLPhysics::Body::GetTransformMatrix ( PLMath::Matrix3x4 mTrans) const

Gets the body transform matrix.

Parameters:
[out]mTransWill receive the body transform matrix
PLPHYSICS_API void PLPhysics::Body::SetTransformMatrix ( const PLMath::Matrix3x4 mTrans)

Sets the body transform matrix.

Parameters:
[in]mTransNew body transform matrix
PLPHYSICS_API void PLPhysics::Body::GetAABoundingBox ( PLMath::AABoundingBox cAABoundingBox) const

Gets the global space axis aligned bounding box of the body.

Parameters:
[out]cAABoundingBoxWill receive the global space axis aligned bounding box of the body
PLPHYSICS_API void PLPhysics::Body::GetLinearVelocity ( PLMath::Vector3 vVelocity) const

Gets the linear body velocity.

Parameters:
[out]vVelocityWill receive the current linear body velocity
PLPHYSICS_API void PLPhysics::Body::SetLinearVelocity ( const PLMath::Vector3 vVelocity)

Sets the linear body velocity.

Parameters:
[in]vVelocityNew linear body velocity
PLPHYSICS_API void PLPhysics::Body::GetAngularVelocity ( PLMath::Vector3 vVelocity) const

Gets the angular body velocity.

Parameters:
[out]vVelocityWill receive the current angular body velocity
PLPHYSICS_API void PLPhysics::Body::SetAngularVelocity ( const PLMath::Vector3 vVelocity)

Sets the angular body velocity.

Parameters:
[in]vVelocityNew angular body velocity
PLPHYSICS_API void PLPhysics::Body::GetForce ( PLMath::Vector3 vForce) const

Gets the force applied to the body at the next simulation update.

Parameters:
[out]vForceWill receive the force applied to the body at the next simulation update
Remarks:
The forces are accumulated on to each body, and the accumulators are zeroed after each simulation update.
PLPHYSICS_API void PLPhysics::Body::AddForce ( const PLMath::Vector3 vForce)

Adds a force to the body.

Parameters:
[in]vForceForce to add
Remarks:
If the simulation is currently inactive, it's NOT recommended to add forces because they are not reset each frame!
See also:
PLPHYSICS_API void PLPhysics::Body::SetForce ( const PLMath::Vector3 vForce)

Sets the force applied to the body at the next simulation update.

Parameters:
[in]vForceForce to set
Remarks:
It's not recommended to set the force directly by using this function, use AddForce() instead whenever possible!
See also:
PLPHYSICS_API void PLPhysics::Body::GetTorque ( PLMath::Vector3 vTorque) const

Gets the torque applied to the body at the next simulation update.

Parameters:
[out]vTorqueWill receive the torque applied to the body at the next simulation update
Remarks:
The torques are accumulated on to each body, and the accumulators are zeroed after each simulation update.
PLPHYSICS_API void PLPhysics::Body::AddTorque ( const PLMath::Vector3 vTorque)

Adds a torque to the body.

Parameters:
[in]vTorqueTorque to add
Remarks:
If the simulation is currently inactive, it's NOT recommended to add torques because they are not reset each frame!
See also:
PLPHYSICS_API void PLPhysics::Body::SetTorque ( const PLMath::Vector3 vTorque)

Sets the torque applied to the body at the next simulation update.

Parameters:
[in]vTorqueTorque to set
Remarks:
It's not recommended to set the torque directly by using this function, use AddTorque() instead whenever possible!
See also:
PLPHYSICS_API bool PLPhysics::Body::IsAutoFreeze ( ) const

Returns whether the body is frozen automatically or not.

Returns:
'true' if the body is frozen automatically, else 'false'
Remarks:
A disabled body that is connected through a joint to an enabled body will be automatically re-enabled at
PLPHYSICS_API void PLPhysics::Body::SetAutoFreeze ( bool  bAutoFreeze = true)

Sets whether the body is frozen automatically or not.

Parameters:
[in]bAutoFreeze'true' if the body is frozen automatically, else 'false'
PLPHYSICS_API void PLPhysics::Body::GetFreezeThreshold ( float &  fLinearVelocity,
float &  fAngularVelocity,
PLCore::uint32 &  nSteps 
) const

Returns the freeze threshold.

Parameters:
[out]fLinearVelocityReceives the linear velocity threshold
[out]fAngularVelocityReceives the angular velocity threshold
[out]nStepsReceives the number of steps the linear and angular velocity must be below the thresholds before the body is frozen
Note:
  • nSteps may not be supported by each physics API, in this case, this setting has no effect
PLPHYSICS_API void PLPhysics::Body::SetFreezeThreshold ( float  fLinearVelocity = 0.01f,
float  fAngularVelocity = 0.01f,
PLCore::uint32  nSteps = 10 
)

Sets the freeze threshold.

Parameters:
[in]fLinearVelocityLinear velocity threshold
[in]fAngularVelocityAngular velocity threshold
[in]nStepsNumber of steps the linear and angular velocity must be below the thresholds before the body is frozen
See also:
PLPHYSICS_API bool PLPhysics::Body::IsFrozen ( ) const

Returns whether the body is currently frozen or not.

Returns:
'true' if the body is currently frozen, else 'false'
PLPHYSICS_API void PLPhysics::Body::SetFrozen ( bool  bFrozen = true)

Sets whether the body is currently frozen or not.

Parameters:
[in]bFrozen'true' if the body is currently frozen, else 'false'
PLPHYSICS_API bool PLPhysics::Body::IsCollisionActive ( ) const

Returns whether the body can collide or not.

Returns:
'true' if the body can collide, else 'false'
PLPHYSICS_API void PLPhysics::Body::SetCollisionActive ( bool  bActive = true)

Sets whether the body can collide or not.

Parameters:
[in]bActive'true' if the body can collide, else 'false'
PLPHYSICS_API bool PLPhysics::Body::GetUseGravity ( ) const

Returns whether the body ignores the gravity or not.

Returns:
'false' if the body ignores the gravity, else 'true'
PLPHYSICS_API void PLPhysics::Body::SetUseGravity ( bool  bUseGravity = true)

Sets whether the body ignores the gravity or not.

Parameters:
[in]bUseGravity'false' if the body ignores the gravity, else 'true'
PLPHYSICS_API PLCore::uint8 PLPhysics::Body::GetCollisionGroup ( ) const

Returns the collision group the body is in.

Returns:
The collision group the body is in (0-31)
See also:
PLPHYSICS_API void PLPhysics::Body::SetCollisionGroup ( PLCore::uint8  nCollisionGroup = 0)

Sets the collision group the body is in.

Parameters:
[in]nCollisionGroupThe collision group the body is in (0-31)
See also:
PLPHYSICS_API PLCore::uint32 PLPhysics::Body::GetNumOfPartners ( ) const

Returns the number of partner bodies.

Returns:
The number of partner bodies
Remarks:
Each body can have multiple partners. You can set certain flags for each of this pairs using World::SetBodyPairFlags(), for instance disabling contact generation between them. If a body pair flag is set to 0, the partners are removed automatically from each other.
See also:
  • GetBodyPairFlags() & SetBodyPairFlags()
PLPHYSICS_API Body* PLPhysics::Body::GetPartner ( PLCore::uint32  nIndex) const

Returns a partner body.

Parameters:
[in]nIndexIndex of the partner body to return
Returns:
The requested partner body, a null pointer on error
See also:
virtual PLPHYSICS_API void PLPhysics::Body::SetMass ( float  fMass = 0.0f) [virtual]

Sets the mass of the physics body.

Parameters:
[in]fMassNew mass of the physics body, 0 = static body
See also:
virtual PLPHYSICS_API bool PLPhysics::Body::IsBody ( ) const [override, virtual]

Returns whether or not this is a body.

Returns:
'true' if this is a body, else 'false'

Implements PLPhysics::Element.

virtual PLPHYSICS_API bool PLPhysics::Body::IsJoint ( ) const [override, virtual]

Returns whether or not this is a joint.

Returns:
'true' if this is a joint, else 'false'

Implements PLPhysics::Element.

virtual PLPHYSICS_API bool PLPhysics::Body::IsSensor ( ) const [override, virtual]

Returns whether or not this is a sensor.

Returns:
'true' if this is a sensor, else 'false'

Implements PLPhysics::Element.


Member Data Documentation

Transform was changed by the physics


The documentation for this class was generated from the following file:


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:21
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported