PhysicsBody Class Reference

Rigid Body is defined with many attributes. More...

List of all members.

Public Member Functions

 PhysicsBody ()
 Default Constructor.
 PhysicsBody (PhysicsBody body)
 Copy Constructor.
 PhysicsBody (PhysicsShape conv, float m)
 Constructor.
void Clear ()
 Clear all members.
void CopyBody (PhysicsBody body)
 Copy all members of rigid body.
void MoveTo (Vector2 pt, float rt, float dt)
 Update position, rotation, velocity, angularVelocity.
bool InsideBody (Vector2 pos, PhysicsShape con)
 Check whether the point is inside rigid body.
void SetBodyStatic ()
 Set rigid body as Static.
void SetBodyKinematic ()
 Set rigid body as Kinematic.
void SetBodyTrigger ()
 Set rigid body as Trigger.
void BackToDynamic ()
 Make kinematic rigid body go back to dynamic rigid body.
void WakeUpDynamic ()
 Wake up dynamic object which is sleeping.
void WakeUpKinematic ()
 Wake up kinematic object which is sleeping.
bool IsKinematicOrStatic ()
 Check whether object is kinematic or static.
bool IsKinematic ()
 Check whether object is kinematic.
bool IsStatic ()
 Check whether object is static.
bool IsDynamic ()
 Check whether object is dynamic.
bool IsTrigger ()
 Check whether object is trigger.
void ApplyForce (Vector2 power)
 Apply force to the center of mass.
void ApplyForce (Vector2 power, Vector2 pos, bool isGlobal=true)
 Apply force to any point.
void ApplyTorque (float rotPower)
 Apply torque to the rigid body.

Static Public Member Functions

static Vector2 MergeBody (PhysicsBody[] bodyList, uint[] indexList, uint num, PhysicsShape[] sceneShapes, uint[] map, bool flag=true)
 Merge of rigid body.
static Vector2 MergeBodyWithPos (PhysicsBody[] bodyList, uint[] indexList, uint num, PhysicsShape[] sceneShapes, uint[] map, Vector2 pos)
 Merge of rigid body with gravity center.

Public Attributes

Vector2 position = new Vector2(0, 0)
 position of rigid body
float rotation = 0.0f
 rotation of rigid body
Vector2 velocity = new Vector2(0, 0)
 velocity of rigid body
float angularVelocity = 0.0f
 angular velocity of rigid body
Vector2 localPosition = new Vector2(0, 0)
 local position of rigid body if it is used as compound shape
float localRotation = 0.0f
 local rotation of rigid body if it is used as compound shape
Vector2 acceleration = new Vector2(0, 0)
 acceleration of rigid body
Vector2 force = new Vector2(0, 0)
 external force acted to rigid body except for the gravity
float torque = 0.0f
 external torque acted to rigid body except for the gravity
float mass = 0.0f
 mass of rigid body
float invMass = 0.0f
 inverse of rigid body
float inertia = 0.0f
 inertia tensor of rigid body
float invInertia = 0.0f
 inverse inertia tensor of rigid body
Vector2 width = new Vector2(0, 0)
 AABB bounding for default position and rotation.
Vector2 aabbMin = new Vector2(0, 0)
 left bottom corner of AABB bounding updated for each frame
Vector2 aabbMax = new Vector2(0, 0)
 right top corner of AABB bounding updated for each frame
bool broadCollide = false
 check whether there is broad phase collision
bool narrowCollide = false
 check whether there is narrow phase collision
uint shapeIndex = 0
 index to the shape of rigid body
uint collisionFilter = 0
 collision filter to rigid body
uint groupFilter = 0xFFFFFFFF
 group filter to rigid body
float airFriction = 0.0f
 air friction is treated inside integrate phase
float colFriction = 0.0f
 collision friction is treated inside solver phase
bool sleep = false
 sleep status, if it is true, it will be ignored for simulation
uint sleepCount = 0
 counter to check whether rigid body falls into sleep status
bool picking = true
 picking enabled or disabled for default simulation loop implementation
float oldMass = 0.0f
 old mass of rigid body
float oldInvMass = 0.0f
 old inverse mass of rigid body
float oldInertia = 0.0f
 old inertia tensor of rigid body
float oldInvInertia = 0.0f
 old inverse inertia tensor of rigid body
float penetrationRepulse = 0.2f
 repulse accelaration for penetration
float penetLimit = 0.03f
 penetration limitation
float tangentFriction = 0.3f
 tangent friction for repluse
float restitutionCoeff = 0.0f
 restitution coefficient for repluse
object userData = null
 reference to user data

Properties

Vector2 Position [get, set]
 setter and getter of position
float Rotation [get, set]
 setter and getter of rotation
Vector2 Velocity [get, set]
 setter and getter of velocity
float AngularVelocity [get, set]
 setter and getter of angular velocity
Vector2 LocalPosition [get, set]
 setter and getter of local position
float LocalRotation [get, set]
 setter and getter of local rotation
Vector2 Acceleration [get, set]
 setter and getter of acceleration
Vector2 Force [get, set]
 setter and getter of force
float Torque [get, set]
 setter and getter of torque
float Mass [get, set]
 setter and getter of mass
float InvMass [get, set]
 setter and getter of inverse mass
float Inertia [get, set]
 setter and getter of inertia tensor
float InvInertia [get, set]
 setter and getter of inverse inertia tensor
Vector2 Width [get, set]
 setter and getter of Width
Vector2 AabbMin [get, set]
 setter and getter of AaabbMin
Vector2 AabbMax [get, set]
 setter and getter of aabbMax
bool BroadCollide [get]
 getter of broadCollide
bool NarrowCollide [get]
 getter of narrowCollide
uint ShapeIndex [get, set]
 setter and getter of shape index
uint CollisionFilter [get, set]
 setter and getter of collisionFilter
uint GroupFilter [get, set]
 setter and getter of groupFilter
float AirFriction [get, set]
 setter and getter of airFriction
float ColFriction [get, set]
 setter and getter of colFriction
bool Sleep [get, set]
 setter and getter of sleep
uint SleepCount [get, set]
 setter and getter of sleepCount
bool Picking [get, set]
 setter and getter of picking
BodyType Type [get, set]
 setter and getter of type
float PenetrationRepulse [get, set]
 setter and getter of penetrationRepulse
float PenetLimit [get, set]
 setter and getter of penetLimit
float TangentFriction [get, set]
 setter and getter of tangentFriction
float RestitutionCoeff [get, set]
 setter and getter of restitutionCoeff
object UserData [get, set]
 setter and getter of userData

Detailed Description

Rigid Body is defined with many attributes.


Constructor & Destructor Documentation

Copy Constructor.

Parameters:
bodysource rigid body
PhysicsBody ( PhysicsShape  conv,
float  m 
)

Constructor.

Parameters:
convshape of rigid body
mmass of rigid body

Member Function Documentation

void ApplyForce ( Vector2  power)

Apply force to the center of mass.

Parameters:
powergiven force

available only for dynamic rigid body /

void ApplyForce ( Vector2  power,
Vector2  pos,
bool  isGlobal = true 
)

Apply force to any point.

Parameters:
powergiven force
posgiven force point
isGlobalpos is represented by global axis ? or local axis ? global axis at default

available only for dynamic rigid body

void ApplyTorque ( float  rotPower)

Apply torque to the rigid body.

Parameters:
rotPowergiven torque

available only for dynamic rigid body

void BackToDynamic ( )

Make kinematic rigid body go back to dynamic rigid body.

make kinamatic rigid body go back to dynamic rigid body, and necessary properties are restored to each variables

bool InsideBody ( Vector2  pos,
PhysicsShape  con 
)

Check whether the point is inside rigid body.

Parameters:
posgiven point
conshape of rigid body
Returns:
if it is inside, true is reaturne
static Vector2 MergeBody ( PhysicsBody[]  bodyList,
uint[]  indexList,
uint  num,
PhysicsShape[]  sceneShapes,
uint[]  map,
bool  flag = true 
) [static]

Merge of rigid body.

To merge multiple objects (compound object), index_list should be given in manner of the ascending order

Parameters:
bodyListgiven rigid body list of the scene
indexListgiven index list of rigid body list to be attached
numgiven number of rigid sceneBodies to be attached
sceneShapesgiven convex list of the scene
mapCompound map of the scene
flagwhether rearrange the position of merged rigid body
static Vector2 MergeBodyWithPos ( PhysicsBody[]  bodyList,
uint[]  indexList,
uint  num,
PhysicsShape[]  sceneShapes,
uint[]  map,
Vector2  pos 
) [static]

Merge of rigid body with gravity center.

To merge multiple objects (compound object), index_list should be given in manner of the ascending order

Parameters:
bodyListgiven rigid body list of the scene
indexListgiven index list of rigid body list to be attached
numgiven number of rigid sceneBodies to be attached
sceneShapesgiven convex list of the scene
mapCompound map of the scene
posgravity center of merged rigid body
void MoveTo ( Vector2  pt,
float  rt,
float  dt 
)

Update position, rotation, velocity, angularVelocity.

Parameters:
ptnew position of rigid body
rtnew rotation of rigid body
dttimestep

Set velocity and angularVelocity automatically by giving new position and rotation
position, rotation, velocity, angularVelocity are set by this function This is mainly for kinematic rigid body, and cannot be used for static rigid body

void SetBodyKinematic ( )

Set rigid body as Kinematic.

make rigid body set as kinematic, and necessary properties are saved to old variables

void SetBodyStatic ( )

Set rigid body as Static.

Once rigid body is set as static, it cannot be changed to dynamic rigid body any more

void WakeUpDynamic ( )

Wake up dynamic object which is sleeping.

same as sleep = false; sleepCount = 0;

void WakeUpKinematic ( )

Wake up kinematic object which is sleeping.

When kinematic object is moving, it is required for kinematic object not to be in sleep for correct collision
same as sleep = false; sleepCount = 0;


Member Data Documentation

float inertia = 0.0f

inertia tensor of rigid body

inertia tensor should be consistent with inverse inertia tensor

float invInertia = 0.0f

inverse inertia tensor of rigid body

inverse inertia tensor should be consistent with inertia tensor

float invMass = 0.0f

inverse of rigid body

inverse should be consistent with mass

float mass = 0.0f

mass of rigid body

mass should be consistent with inverse mass

float penetLimit = 0.03f

penetration limitation

To enable this value, it is required to set uniqueProperty of PhysicsScene as false

float penetrationRepulse = 0.2f

repulse accelaration for penetration

To enable this value, it is required to set uniqueProperty of PhysicsScene as false

float restitutionCoeff = 0.0f

restitution coefficient for repluse

To enable this value, it is required to set uniqueProperty of PhysicsScene as false

float tangentFriction = 0.3f

tangent friction for repluse

To enable this value, it is required to set uniqueProperty of PhysicsScene as false

object userData = null

reference to user data

user data should be managed by user properly