TDME2 1.9.121
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
Body Class Referencefinal

Dynamic rigid/static rigid/collision body class. More...

#include <tdme/engine/physics/Body.h>

Collaboration diagram for Body:
Collaboration graph

Public Member Functions

bool isCloned ()
 
void setCloned (bool cloned)
 Set cloned. More...
 
const string & getId ()
 
const string & getRootId ()
 
void setRootId (const string &rootId)
 Set root id. More...
 
int getType ()
 Return type, see TYPE_*. More...
 
uint16_t getCollisionTypeId ()
 
void setCollisionTypeId (uint16_t typeId)
 Set collision type id. More...
 
uint16_t getCollisionTypeIds ()
 
void setCollisionTypeIds (uint16_t collisionTypeIds)
 Set up collision type ids. More...
 
bool isEnabled ()
 
void setEnabled (bool enabled)
 Set up if rigid body is enabled. More...
 
bool isStatic ()
 
bool isSleeping ()
 
void setSleeping (bool sleeping)
 Set sleeping. More...
 
vector< BoundingVolume * > & getBoundingVolumes ()
 
void addBoundingVolume (BoundingVolume *boundingVolume)
 Add bounding volume. More...
 
BoundingBox computeBoundingBoxTransformed ()
 Compute bounding box transformed. More...
 
float getFriction ()
 
void setFriction (float friction)
 Set up friction. More...
 
float getRestitution ()
 
void setRestitution (float restitution)
 Set up restitution. More...
 
float getMass ()
 
void setMass (float mass)
 Set up mass. More...
 
const Vector3 getLinearVelocity ()
 
void setLinearVelocity (const Vector3 &linearVelocity)
 Set linear velocity. More...
 
const Vector3 getAngularVelocity ()
 
void setAngularVelocity (const Vector3 &angularVelocity)
 Set angular velocity. More...
 
float getLinearDamping ()
 
void setLinearDamping (float linearDamping)
 Set linear damping. More...
 
float getAngularDamping ()
 
void setAngularDamping (float angularDamping)
 Set angular damping. More...
 
const TransformationsgetTransformations ()
 
void fromTransformations (const Transformations &transformations)
 Synchronizes this rigid body with transformations. More...
 
void addForce (const Vector3 &forceOrigin, const Vector3 &force)
 Add force. More...
 
void addForce (const Vector3 &forceOrigin)
 Add force to center of mass. More...
 
void addTorque (const Vector3 &torque)
 Add torque. More...
 
void addCollisionListener (CollisionListener *listener)
 Add a collision listener to this rigid body. More...
 
void removeCollisionListener (CollisionListener *listener)
 Remove a collision listener to this rigid body. More...
 

Static Public Member Functions

static const Vector3 getNoRotationInertiaTensor ()
 

Static Public Attributes

static constexpr int32_t TYPE_STATIC { 0 }
 
static constexpr int32_t TYPE_DYNAMIC { 2 }
 
static constexpr int32_t TYPE_KINEMATIC { 1 }
 
static constexpr int32_t TYPE_COLLISION { 3 }
 
static constexpr uint16_t TYPEID_STATIC { 1 }
 
static constexpr uint16_t TYPEID_DYNAMIC { 2 }
 
static constexpr uint16_t TYPEIDS_ALL { 65535 }
 

Private Member Functions

 Body (World *world, const string &id, int type, bool enabled, uint16_t collisionTypeId, const Transformations &transformations, float restitution, float friction, float mass, const Vector3 &inertiaTensor, const vector< BoundingVolume * > boundingVolumes)
 Protected constructor. More...
 
 ~Body ()
 Destructor. More...
 
void resetProxyShapes ()
 Reset proxy shapes. More...
 
void fireOnCollision (Body *other, CollisionResponse &collisionResponse)
 Fire on collision. More...
 
void fireOnCollisionBegin (Body *other, CollisionResponse &collisionResponse)
 Fire on collision begin. More...
 
void fireOnCollisionEnd (Body *other)
 Fire on collision end. More...
 

Static Private Member Functions

static Matrix4x4 computeInverseInertiaMatrix (BoundingBox *boundingBox, float mass, float scaleXAxis, float scaleYAxis, float scaleZAxis)
 Computes the inverse inertia matrix. More...
 

Private Attributes

Worldworld { nullptr }
 
reactphysics3d::RigidBody * rigidBody { nullptr }
 
reactphysics3d::CollisionBody * collisionBody { nullptr }
 
bool cloned { false }
 
string id
 
string rootId
 
int32_t type
 
float mass
 
uint16_t collideTypeIds
 
uint16_t collisionTypeId
 
Vector3 inertiaTensor
 
Transformations transformations
 
Vector3 transformationsScale
 
vector< BoundingVolume * > boundingVolumes
 
vector< reactphysics3d::ProxyShape * > proxyShapes
 
vector< CollisionListener * > collisionListener
 

Friends

class World
 

Detailed Description

Dynamic rigid/static rigid/collision body class.

Author
Andreas Drewke
Version
$Id$

Definition at line 42 of file Body.h.

Constructor & Destructor Documentation

◆ Body()

Body ( World world,
const string &  id,
int  type,
bool  enabled,
uint16_t  collisionTypeId,
const Transformations transformations,
float  restitution,
float  friction,
float  mass,
const Vector3 inertiaTensor,
const vector< BoundingVolume * >  boundingVolumes 
)
private

Protected constructor.

Parameters
worldworld
idid
typetype
enabledenabled
collisionTypeIdcollision type id
transformationstransformations
restitutionrestitution
frictionfriction
massmass in kg
inertiaTensorinertia tensor vector
boundingVolumesbounding volumes

Definition at line 62 of file Body.cpp.

◆ ~Body()

~Body ( )
private

Destructor.

Definition at line 111 of file Body.cpp.

Member Function Documentation

◆ addBoundingVolume()

void addBoundingVolume ( BoundingVolume boundingVolume)

Add bounding volume.

Parameters
boundingVolumebounding volume

◆ addCollisionListener()

void addCollisionListener ( CollisionListener listener)

Add a collision listener to this rigid body.

Parameters
listenerlistener

Definition at line 544 of file Body.cpp.

◆ addForce() [1/2]

void addForce ( const Vector3 forceOrigin)

Add force to center of mass.

Parameters
forceOriginforce

Definition at line 522 of file Body.cpp.

◆ addForce() [2/2]

void addForce ( const Vector3 forceOrigin,
const Vector3 force 
)

Add force.

Parameters
forceOriginposition of world force
forceforce

Definition at line 510 of file Body.cpp.

◆ addTorque()

void addTorque ( const Vector3 torque)

Add torque.

Parameters
torquetorque

Definition at line 533 of file Body.cpp.

◆ computeBoundingBoxTransformed()

BoundingBox computeBoundingBoxTransformed ( )

Compute bounding box transformed.

Definition at line 312 of file Body.cpp.

◆ computeInverseInertiaMatrix()

Matrix4x4 computeInverseInertiaMatrix ( BoundingBox boundingBox,
float  mass,
float  scaleXAxis,
float  scaleYAxis,
float  scaleZAxis 
)
staticprivate

Computes the inverse inertia matrix.

Parameters
boundingBoxbounding box
massmass
scaleXAxisscale x axis
scaleYAxisscale y axis
scaleZAxisscale z axis
Returns
inverse inertia matrix

Definition at line 122 of file Body.cpp.

◆ fireOnCollision()

void fireOnCollision ( Body other,
CollisionResponse collisionResponse 
)
private

Fire on collision.

Parameters
otherother
collisionResponsecollision response

Definition at line 554 of file Body.cpp.

◆ fireOnCollisionBegin()

void fireOnCollisionBegin ( Body other,
CollisionResponse collisionResponse 
)
private

Fire on collision begin.

Parameters
otherother
collisionResponsecollision response

Definition at line 561 of file Body.cpp.

◆ fireOnCollisionEnd()

void fireOnCollisionEnd ( Body other)
private

Fire on collision end.

Parameters
otherother

Definition at line 568 of file Body.cpp.

◆ fromTransformations()

void fromTransformations ( const Transformations transformations)

Synchronizes this rigid body with transformations.

Parameters
transformationstransformations

Definition at line 461 of file Body.cpp.

◆ getAngularDamping()

float getAngularDamping ( )
Returns
return angular damping

Definition at line 439 of file Body.cpp.

◆ getAngularVelocity()

const Vector3 getAngularVelocity ( )
Returns
angular velocity

Definition at line 400 of file Body.cpp.

◆ getBoundingVolumes()

vector< BoundingVolume * > & getBoundingVolumes ( )
Returns
bounding volumes

Definition at line 220 of file Body.cpp.

◆ getCollisionTypeId()

uint16_t getCollisionTypeId ( )
Returns
type id

Definition at line 174 of file Body.cpp.

◆ getCollisionTypeIds()

uint16_t getCollisionTypeIds ( )
Returns
collision type ids bitmask

Definition at line 187 of file Body.cpp.

◆ getFriction()

float getFriction ( )
Returns
friction

Definition at line 328 of file Body.cpp.

◆ getId()

const string & getId ( )
Returns
id

Definition at line 156 of file Body.cpp.

◆ getLinearDamping()

float getLinearDamping ( )
Returns
return linear damping

Definition at line 421 of file Body.cpp.

◆ getLinearVelocity()

const Vector3 getLinearVelocity ( )
Returns
linear velocity

Definition at line 379 of file Body.cpp.

◆ getMass()

float getMass ( )
Returns
mass

Definition at line 364 of file Body.cpp.

◆ getNoRotationInertiaTensor()

const Vector3 getNoRotationInertiaTensor ( )
static
Returns
no rotation inertia tensor

Definition at line 118 of file Body.cpp.

◆ getRestitution()

float getRestitution ( )
Returns
restitution / bouncyness

Definition at line 346 of file Body.cpp.

◆ getRootId()

const string & getRootId ( )
Returns
root id

Definition at line 161 of file Body.cpp.

◆ getTransformations()

const Transformations & getTransformations ( )
Returns
transformations

Definition at line 457 of file Body.cpp.

◆ getType()

int32_t getType ( )

Return type, see TYPE_*.

Returns
type

Definition at line 170 of file Body.cpp.

◆ isCloned()

bool isCloned ( )
Returns
if rigid body has been cloned from another rigid body

Definition at line 148 of file Body.cpp.

◆ isEnabled()

bool isEnabled ( )
Returns
if enabled

Definition at line 200 of file Body.cpp.

◆ isSleeping()

bool isSleeping ( )
Returns
if sleeping

Definition at line 211 of file Body.cpp.

◆ isStatic()

bool isStatic ( )
Returns
object is static

◆ removeCollisionListener()

void removeCollisionListener ( CollisionListener listener)

Remove a collision listener to this rigid body.

Parameters
listenerlistener

Definition at line 549 of file Body.cpp.

◆ resetProxyShapes()

void resetProxyShapes ( )
private

Reset proxy shapes.

Definition at line 224 of file Body.cpp.

◆ setAngularDamping()

void setAngularDamping ( float  angularDamping)

Set angular damping.

Parameters
angularDampinganuglar damping

Definition at line 448 of file Body.cpp.

◆ setAngularVelocity()

void setAngularVelocity ( const Vector3 angularVelocity)

Set angular velocity.

Parameters
angularVelocityangular velocity

Definition at line 413 of file Body.cpp.

◆ setCloned()

void setCloned ( bool  cloned)

Set cloned.

Parameters
clonedcloned

Definition at line 152 of file Body.cpp.

◆ setCollisionTypeId()

void setCollisionTypeId ( uint16_t  typeId)

Set collision type id.

Parameters
typeIdtype id

Definition at line 179 of file Body.cpp.

◆ setCollisionTypeIds()

void setCollisionTypeIds ( uint16_t  collisionTypeIds)

Set up collision type ids.

Parameters
collisionTypeIdscollisionTypeIds

Definition at line 192 of file Body.cpp.

◆ setEnabled()

void setEnabled ( bool  enabled)

Set up if rigid body is enabled.

Parameters
enabledenabled

Definition at line 205 of file Body.cpp.

◆ setFriction()

void setFriction ( float  friction)

Set up friction.

Parameters
frictionfriction

Definition at line 337 of file Body.cpp.

◆ setLinearDamping()

void setLinearDamping ( float  linearDamping)

Set linear damping.

Parameters
linearDampinglinear damping

Definition at line 430 of file Body.cpp.

◆ setLinearVelocity()

void setLinearVelocity ( const Vector3 linearVelocity)

Set linear velocity.

Parameters
linearVelocityvelocity

Definition at line 392 of file Body.cpp.

◆ setMass()

void setMass ( float  mass)

Set up mass.

Parameters
massmass

Definition at line 369 of file Body.cpp.

◆ setRestitution()

void setRestitution ( float  restitution)

Set up restitution.

Parameters
restitutionrestitution

Definition at line 355 of file Body.cpp.

◆ setRootId()

void setRootId ( const string &  rootId)

Set root id.

Parameters
rootIdroot id

Definition at line 166 of file Body.cpp.

◆ setSleeping()

void setSleeping ( bool  sleeping)

Set sleeping.

Parameters
sleepingsleeping

Definition at line 216 of file Body.cpp.

Friends And Related Function Documentation

◆ World

friend class World
friend

Definition at line 44 of file Body.h.

Member Data Documentation

◆ boundingVolumes

vector<BoundingVolume*> boundingVolumes
private

Definition at line 75 of file Body.h.

◆ cloned

bool cloned { false }
private

Definition at line 65 of file Body.h.

◆ collideTypeIds

uint16_t collideTypeIds
private

Definition at line 70 of file Body.h.

◆ collisionBody

reactphysics3d::CollisionBody* collisionBody { nullptr }
private

Definition at line 64 of file Body.h.

◆ collisionListener

vector<CollisionListener*> collisionListener
private

Definition at line 77 of file Body.h.

◆ collisionTypeId

uint16_t collisionTypeId
private

Definition at line 71 of file Body.h.

◆ id

string id
private

Definition at line 66 of file Body.h.

◆ inertiaTensor

Vector3 inertiaTensor
private

Definition at line 72 of file Body.h.

◆ mass

float mass
private

Definition at line 69 of file Body.h.

◆ proxyShapes

vector<reactphysics3d::ProxyShape*> proxyShapes
private

Definition at line 76 of file Body.h.

◆ rigidBody

reactphysics3d::RigidBody* rigidBody { nullptr }
private

Definition at line 63 of file Body.h.

◆ rootId

string rootId
private

Definition at line 67 of file Body.h.

◆ transformations

Transformations transformations
private

Definition at line 73 of file Body.h.

◆ transformationsScale

Vector3 transformationsScale
private

Definition at line 74 of file Body.h.

◆ type

int32_t type
private

Definition at line 68 of file Body.h.

◆ TYPE_COLLISION

constexpr int32_t TYPE_COLLISION { 3 }
staticconstexpr

Definition at line 50 of file Body.h.

◆ TYPE_DYNAMIC

constexpr int32_t TYPE_DYNAMIC { 2 }
staticconstexpr

Definition at line 48 of file Body.h.

◆ TYPE_KINEMATIC

constexpr int32_t TYPE_KINEMATIC { 1 }
staticconstexpr

Definition at line 49 of file Body.h.

◆ TYPE_STATIC

constexpr int32_t TYPE_STATIC { 0 }
staticconstexpr

Definition at line 47 of file Body.h.

◆ TYPEID_DYNAMIC

constexpr uint16_t TYPEID_DYNAMIC { 2 }
staticconstexpr

Definition at line 53 of file Body.h.

◆ TYPEID_STATIC

constexpr uint16_t TYPEID_STATIC { 1 }
staticconstexpr

Definition at line 52 of file Body.h.

◆ TYPEIDS_ALL

constexpr uint16_t TYPEIDS_ALL { 65535 }
staticconstexpr

Definition at line 54 of file Body.h.

◆ world

World* world { nullptr }
private

Definition at line 62 of file Body.h.


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