irr::newton::Body Class Reference

Class to management rigid bodies. More...

#include <body.hpp>

Inheritance diagram for irr::newton::Body:

irr::newton::IrrNewt_Base irr::newton::CharacterController irr::newton::TreeBody List of all members.

Public Member Functions

void addForce (irr::core::vector3df force)
void addForceContinuous (irr::core::vector3df force)
void addImpulse (irr::core::vector3df delta_velocity, irr::core::vector3df impulse_center)
void addTorque (irr::core::vector3df torque)
void autoCalcInertia ()
 Body ()
 Body (irr::newton::World *world, irr::scene::ISceneNode *node, irr::scene::IMesh *mesh, E_SHAPE_TYPE i_shape_type, irr::core::vector3df box_size_correction)
irr::core::aabbox3d< irr::f32 > calculateAABB ()
void drawDebugInfo ()
irr::core::vector3df getCentreOfMass ()
irr::core::vector3df getForce ()
irr::f32 getMass ()
irr::core::matrix4 getMatrix ()
irr::core::vector3df getMomentOfInertia ()
NewtonBody * getNewtonBody ()
NewtonCollision * getNewtonCollision ()
irr::scene::ISceneNode * getNode ()
irr::core::vector3df getOmega ()
irr::newton::BodygetParent ()
irr::core::vector3df getPosition ()
irr::core::vector3df getPositionGeometry ()
irr::core::vector3df getRotationGeometry ()
irr::core::vector3df getShapeSize ()
irr::core::vector3df getVelocity ()
irr::newton::WorldgetWorld ()
bool isAffectedByForce ()
bool isAffectedByVelocity ()
void setAngularDamping (core::vector3df value)
void setAutoFreeze (bool value)
void setCentreOfMass (irr::core::vector3df centre)
void setContinuousCollisionMode (bool value)
void setCoriolisForcesMode (bool value)
void setForce (irr::core::vector3df new_force)
void setFreeze (bool value)
void setLinearDamping (irr::f32 value)
void setMass (irr::f32 mass)
void setMaterial (irr::newton::Material *new_material)
void setMomentOfInertia (irr::core::vector3df inertia)
void setNodeMatrixToBody ()
void setOmega (irr::core::vector3df omega)
void setParent (irr::newton::Body *parent)
void setPosition (irr::core::vector3df pos)
void setRotation (irr::core::vector3df rot)
void setRotationGeometry (irr::core::vector3df rot)
void setScale (irr::core::vector3df scale)
void setShapeSize (irr::core::vector3df new_box_size)
void setTorque (irr::core::vector3df new_torque)
virtual void setVelocity (irr::core::vector3df velocity)

Protected Member Functions

void CalcBoxSize (irr::scene::IMesh *mesh)
void Create ()
void erase ()
void init ()
virtual void reserved_destroy ()

Protected Attributes

irr::core::matrix4 applied_offset
NewtonBody * body
irr::core::aabbox3d< irr::f32 > box
irr::core::vector3df box_size
bool camera
NewtonCollision * collision
irr::core::vector3df force
irr::core::vector3df force_continuos
irr::newton::Materialmaterial
irr::scene::ISceneNode * node
irr::newton::Bodyparent
E_SHAPE_TYPE shape_type
irr::core::vector3df torque
irr::newton::Worldworld

Friends

void __cdecl defBodyForceAndTorqueCallback (const NewtonBody *body)
void __cdecl defBodyTransformCallback (const NewtonBody *body, const float *matrix)
void irr::newton::RagDoll::build (irr::core::array< irr::newton::Body * > parts)

Detailed Description

Class to management rigid bodies.


Constructor & Destructor Documentation

irr::newton::Body::Body ( irr::newton::World world,
irr::scene::ISceneNode *  node,
irr::scene::IMesh *  mesh,
E_SHAPE_TYPE  i_shape_type,
irr::core::vector3df  box_size_correction 
)

Body constructor. Use irr::newton::World::createBody or irr::newton::World::createBodyAuto to create a body. Don't call this constructor directly

irr::newton::Body::Body (  )  [inline]

default constructor. don't call it directly. use World::createBody() to create a body


Member Function Documentation

void irr::newton::Body::addForce ( irr::core::vector3df  force  ) 

add a force to the body you can add a force to a body at any time, not only when the body is created This function add the force 1 time

Parameters:
force the force to add
Returns:
none
See also:
Body::setForce()

void irr::newton::Body::addForceContinuous ( irr::core::vector3df  force  ) 

add a force recursive to the body you can add a force to a body at any time, not only when the body is created This function add the force any time that World::update() function is called so the force is added always. useful for simulate gravity (in this case you should be use a force like (0,-9.8*body->getMass(),0)

void irr::newton::Body::addImpulse ( irr::core::vector3df  delta_velocity,
irr::core::vector3df  impulse_center 
)

Add an impulse to a specific point on a body

Parameters:
delta_velocity a vector containing the desired change in velocity to point impulse_center.
impulse_center a vector containing the center of the impulse in global space.

void irr::newton::Body::addTorque ( irr::core::vector3df  torque  ) 

add a torque to the body This add a user defined vetor to the torque accumulator to know what torque is, see Body::setTorque()

Parameters:
torque the vector to add to the torque accumulator
Returns:
none

void irr::newton::Body::autoCalcInertia (  ) 

This function auto calculate body moments of inertia and centre of mass You can calculate moments of inertia by yourself or leave newton to calculate it for you If you use this function for calculate moments of inertia, every time you call Body::setMass() and change body mass you need to call this function immediately afterwards

Returns:
none

void irr::newton::Body::CalcBoxSize ( irr::scene::IMesh *  mesh  )  [protected]

irr::core::aabbox3d<irr::f32> irr::newton::Body::calculateAABB (  ) 

Calculate newton body axis aligned boundgin box

Returns:
the axis aligned bounding box for the body calculate using newton

void irr::newton::Body::Create (  )  [protected]

void irr::newton::Body::drawDebugInfo (  ) 

draw debug info draw the geometry of the body as a wire frame rappresentation

Returns:
none
Warning:
It is very importat that you call this function between smgr->drawAll() and driver->endScene(), or you don't see the wire frame rappresentation

void irr::newton::Body::erase (  )  [protected]

irr::core::vector3df irr::newton::Body::getCentreOfMass (  ) 

Get the relative position of the center of mass of a rigid body see Body::setCentreOfMass()

irr::core::vector3df irr::newton::Body::getForce (  ) 

get the force wich you set using Body::addForce() or Body::setForce(). This don't get the net applied force

Returns:
body force wich you set

irr::f32 irr::newton::Body::getMass (  ) 

get body mass

irr::core::matrix4 irr::newton::Body::getMatrix (  ) 

get body matrix

Returns:
body matrix

irr::core::vector3df irr::newton::Body::getMomentOfInertia (  ) 

get moments of inertia of the body

NewtonBody * irr::newton::Body::getNewtonBody (  )  [inline]

get newton body

Returns:
newton body

NewtonCollision * irr::newton::Body::getNewtonCollision (  )  [inline]

get newton collision

Returns:
newton collision

irr::scene::ISceneNode * irr::newton::Body::getNode (  )  [inline]

Get irrlicht scene node associated to this body

Returns:
irrlicht scene node

irr::core::vector3df irr::newton::Body::getOmega (  ) 

get body angular velocity

Returns:
body angular velocity
See also:
Body::setOmega(), Body::addTorque(), Body::setTorque()

irr::newton::Body* irr::newton::Body::getParent (  )  [inline]

get body parent. Used for ragdoll. !This isn't equal to ISceneNode::getParent() and don't call it internally

irr::core::vector3df irr::newton::Body::getPosition (  )  [inline]

this function call ISceneNode::getPosition() internally. This gets the position of the scene node (equal to position of the rigid body)

See also:
Body::getPositionGeometry()

irr::core::vector3df irr::newton::Body::getPositionGeometry (  ) 

Get the position of the newton body(and not of the scene node) this is equal to the scene node position. I used it for debug purposes.

Returns:
newton body position

irr::core::vector3df irr::newton::Body::getRotationGeometry (  ) 

Get the rotation of the newton body(and not of the scene node) This may be different from the rotation of the scene node. See Body::setRotationGeometry() for more information

Returns:
newton body rotation
See also:
Body::setRotationGeometry()

irr::core::vector3df irr::newton::Body::getShapeSize (  )  [inline]

get shape size on the 3 axis

Returns:
shape size

irr::core::vector3df irr::newton::Body::getVelocity (  ) 

get body linear velocity

Returns:
body linear velocity

irr::newton::World * irr::newton::Body::getWorld (  )  [inline]

get IrrNewt world

Returns:
IrrNewt world

void irr::newton::Body::init (  )  [protected]

bool irr::newton::Body::isAffectedByForce (  )  [inline]

is the body moving because a force move it?

Returns:
true if the body is affected by forces, false if not

bool irr::newton::Body::isAffectedByVelocity (  )  [inline]

is the body moving because a velocity move it?

Returns:
true if the body is affected by velocity, false if not

virtual void irr::newton::Body::reserved_destroy (  )  [inline, protected, virtual]

Implements irr::newton::IrrNewt_Base.

Reimplemented in irr::newton::CharacterController.

void irr::newton::Body::setAngularDamping ( core::vector3df  value  ) 

set angular damping of the body

Parameters:
value new body angular damping

void irr::newton::Body::setAutoFreeze ( bool  value  ) 

Set the auto-activation mode for this body

Parameters:
value true for auto activation on (controlled by newton), false for auto activation off (controlled by the application)
See also:
Body::setFreeze()

void irr::newton::Body::setCentreOfMass ( irr::core::vector3df  centre  ) 

Set the relative position of the center of mass of a rigid body

From newton documentation "This function can be used to set the relative offset of the center of mass of a rigid body. when a rigid body is created the center of mass is set the the point c(0, 0, 0), and normally this is the best setting for a rigid body. However the are situations in which and object does not have symmetry or simple some kind of special effect is desired, and this origin need to be changed."

Parameters:
centre a vector containing the relative offset of the center of mass of the body.

void irr::newton::Body::setContinuousCollisionMode ( bool  value  ) 

Specify if the node needs a continuous collision mode. From newton documentation: "

continue collision mode enable allow the engine to predict colliding contact on rigid bodies Moving at high speed of subject to strong forces.

continue collision mode does not prevent rigid bodies from inter penetration instead it prevent bodies from passing trough each others by extrapolating contact points when the bodies normal contact calculation determine the bodies are not colliding.

Because there is penalty of about 40% to 80% depending of the shape complexity of the collision geometry, this feature is set off by default. It is the job of the application to determine what bodies need this feature on. Good guidelines are: very small objects, and bodies that move a height speed. "

void irr::newton::Body::setCoriolisForcesMode ( bool  value  ) 

From newton documentation: "Gyroscopic forces internal forces generated as a result of an asymmetric tensor. They are a pure mathematical consequence that the physics have to comply in order to agree with the math. As Gyroscopic forces are not real forces but the result of net unbalance of the changing inertia tensor or a rigid body when its angular velocity is measured on a reference frame different than the body’s own. Gyroscopic forces are extremely non linear by nature, therefore a first order implicit integrator will have a extremely hard time at dealing with this kind of forces, however because the fact that they are not real forces they do not make much difference in the outcome of the integration. Fortunately due to the fact that the magnitude of gyroscopic forces is proportional to the unbalance of the inertia tensor, it is possible to disregard the effect of this forces by assuming their inertial tensor is symmetric for the purpose of this calculation. For most cases an ordinary person is not capable to distinguish the motion of a body subject to gyroscopic forces and one that is not, especially when the motion is constrained. Because of this fact gyroscopic force are turned off by default in Newton, however there are cases when the desire effect is precisely to simulate these forces like a spinning top, or the design of a space navigational system, etc. The most important feature of gyroscopic forces is that they make the rigid body to process. "

Parameters:
value true to enable gyroscopic forces mode, false to disable it
Returns:
none

void irr::newton::Body::setForce ( irr::core::vector3df  new_force  )  [inline]

copy a user defined vector to the force accumulator

Parameters:
new_force the new force of the body
Returns:
none
See also:
irr::newton::Body::addForce()

void irr::newton::Body::setFreeze ( bool  value  ) 

freeze the body a freezed body is not affected by forces and torques if you don't use a body, call this function with true as argument to improve performance

Parameters:
value set it to true to freeze the body, false to unfreeze it

void irr::newton::Body::setLinearDamping ( irr::f32  value  ) 

set linear damping of the body

Parameters:
value new body linear damping

void irr::newton::Body::setMass ( irr::f32  mass  ) 

Set mass of the body

Parameters:
mass new mass of the body

void irr::newton::Body::setMaterial ( irr::newton::Material new_material  ) 

set body material

Parameters:
new_material new body material
Returns:
none

void irr::newton::Body::setMomentOfInertia ( irr::core::vector3df  inertia  ) 

Set moments of inertia of the body

Parameters:
inertia new moments of inertia

void irr::newton::Body::setNodeMatrixToBody (  ) 

This set rigid body position and rotation as the scene node position\rotation usually you don't need to call it

Returns:
none

void irr::newton::Body::setOmega ( irr::core::vector3df  omega  ) 

set body angular velocity

Parameters:
omega the new angular velocity of the body
Returns:
none
See also:
irr::newton::Body::addTorque()

void irr::newton::Body::setParent ( irr::newton::Body parent  )  [inline]

Set body parent. This is used for ragdoll. This isn't equal to ISceneNode::setParent() and don't call it internally

Parameters:
parent the other body parent to this body
Returns:
none

void irr::newton::Body::setPosition ( irr::core::vector3df  pos  ) 

Set the new position for the body. This change position of the scene node and the physics node. Use this function instead of irr::scene::ISceneNode::setPosition. If you use irr::scene::ISceneNode::setPosition to change body position no happens

Parameters:
pos new body position in 3 dimension space
Returns:
none

void irr::newton::Body::setRotation ( irr::core::vector3df  rot  ) 

Set the new rotation for the body. This change rotation of the scene node and the physics node. Use this function instead of irr::scene::ISceneNode::setRotation. If you use irr::scene::ISceneNode::setRotation to change body rotation no happens

Parameters:
rot new body rotation on the 3 axis
Returns:
none

void irr::newton::Body::setRotationGeometry ( irr::core::vector3df  rot  ) 

Set the new rotation only for the newton body(and not for scene node) This change rotation of the physics node only, but when World::update() is called the rotation of the scen node is changed indirectly. To avoid that (so to only change the rotation of the physics node and not the rotation of the scene node) create a character controller (World::createCharacterController()) and call CharacterController::setRotationUpdate() with false as argument

Parameters:
rot new body rotation on the 3 axis
Returns:
none

void irr::newton::Body::setScale ( irr::core::vector3df  scale  ) 

Set the new scale for the body. This change scale of the scene node and the physics node. Use this function instead of irr::scene::ISceneNode::setScale. If you use irr::scene::ISceneNode::setScale to change body scale you will get incorrect result

Parameters:
scale new body scale on the 3 axis
Returns:
none
Warning:
This method destroy and re create the body (newton doen't support body scaling)

avoid to use it. Prefer to scale the node before create the relative body (so before call createBody, createBodyAuto, createTreeBody and so on)

in this case the body is created scaled already

void irr::newton::Body::setShapeSize ( irr::core::vector3df  new_box_size  ) 

Set the size on the 3 axis of the shape

If the shape is a box, this function set 3 dimension of the box, if it is a elipsoid this function set the 3 dimension of the elipsoid, exc.. IrrNewt automatically calculate the dimension of the shape from the scene node when you create the body, if you want a different dimension use the box_size_correction parameter in createBody function avoid to call this function because it's cause body destruction and re-creation

See also:
irr::newton::World::createBody()

void irr::newton::Body::setTorque ( irr::core::vector3df  new_torque  )  [inline]

Copy a user defined vector to the torque accumulator Torque is a "rotation force" or a "angular force" which causes a change in rotational motion For more information go here http://en.wikipedia.org/wiki/Torque

Parameters:
new_torque the new torque of the body
Returns:
none
See also:
irr::newton::Body::addForce()

virtual void irr::newton::Body::setVelocity ( irr::core::vector3df  velocity  )  [virtual]

set body linear velocity

Parameters:
velocity the new linear velocity of the body
See also:
irr::newton::Body::addForce()

Reimplemented in irr::newton::CharacterController.


Friends And Related Function Documentation

void __cdecl defBodyForceAndTorqueCallback ( const NewtonBody *  body  )  [friend]

void __cdecl defBodyTransformCallback ( const NewtonBody *  body,
const float *  matrix 
) [friend]

void irr::newton::RagDoll::build ( irr::core::array< irr::newton::Body * >  parts  )  [friend]


Member Data Documentation

irr::core::matrix4 irr::newton::Body::applied_offset [protected]

NewtonBody* irr::newton::Body::body [protected]

irr::core::aabbox3d<irr::f32> irr::newton::Body::box [protected]

irr::core::vector3df irr::newton::Body::box_size [protected]

bool irr::newton::Body::camera [protected]

NewtonCollision* irr::newton::Body::collision [protected]

irr::core::vector3df irr::newton::Body::force [protected]

irr::core::vector3df irr::newton::Body::force_continuos [protected]

irr::newton::Material* irr::newton::Body::material [protected]

irr::scene::ISceneNode* irr::newton::Body::node [protected]

irr::newton::Body* irr::newton::Body::parent [protected]

E_SHAPE_TYPE irr::newton::Body::shape_type [protected]

irr::core::vector3df irr::newton::Body::torque [protected]

irr::newton::World* irr::newton::Body::world [protected]


The documentation for this class was generated from the following file:
Generated on Fri Dec 15 16:58:33 2006 for IrrNewt by  doxygen 1.5.1-p1