#include <body.hpp>
Inheritance diagram for irr::newton::Body:
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::Body * | getParent () |
irr::core::vector3df | getPosition () |
irr::core::vector3df | getPositionGeometry () |
irr::core::vector3df | getRotationGeometry () |
irr::core::vector3df | getShapeSize () |
irr::core::vector3df | getVelocity () |
irr::newton::World * | getWorld () |
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::Material * | material |
irr::scene::ISceneNode * | node |
irr::newton::Body * | parent |
E_SHAPE_TYPE | shape_type |
irr::core::vector3df | torque |
irr::newton::World * | world |
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) |
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
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
force | the force to add |
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
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()
torque | the vector to add to the torque accumulator |
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
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
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
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
irr::f32 irr::newton::Body::getMass | ( | ) |
get body mass
irr::core::matrix4 irr::newton::Body::getMatrix | ( | ) |
get 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
NewtonCollision * irr::newton::Body::getNewtonCollision | ( | ) | [inline] |
get newton collision
irr::scene::ISceneNode * irr::newton::Body::getNode | ( | ) | [inline] |
Get irrlicht scene node associated to this body
irr::core::vector3df irr::newton::Body::getOmega | ( | ) |
get body angular velocity
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)
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.
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
irr::core::vector3df irr::newton::Body::getShapeSize | ( | ) | [inline] |
get shape size on the 3 axis
irr::core::vector3df irr::newton::Body::getVelocity | ( | ) |
get body linear velocity
irr::newton::World * irr::newton::Body::getWorld | ( | ) | [inline] |
get IrrNewt world
void irr::newton::Body::init | ( | ) | [protected] |
bool irr::newton::Body::isAffectedByForce | ( | ) | [inline] |
is the body moving because a force move it?
bool irr::newton::Body::isAffectedByVelocity | ( | ) | [inline] |
is the body moving because a velocity move it?
virtual void irr::newton::Body::reserved_destroy | ( | ) | [inline, protected, virtual] |
void irr::newton::Body::setAngularDamping | ( | core::vector3df | value | ) |
set angular damping of the body
value | new body angular damping |
void irr::newton::Body::setAutoFreeze | ( | bool | value | ) |
Set the auto-activation mode for this body
value | true for auto activation on (controlled by newton), false for auto activation off (controlled by the application) |
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."
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. "
value | true to enable gyroscopic forces mode, false to disable it |
void irr::newton::Body::setForce | ( | irr::core::vector3df | new_force | ) | [inline] |
copy a user defined vector to the force accumulator
new_force | the new force of the body |
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
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
value | new body linear damping |
void irr::newton::Body::setMass | ( | irr::f32 | mass | ) |
Set mass of the body
mass | new mass of the body |
void irr::newton::Body::setMaterial | ( | irr::newton::Material * | new_material | ) |
set body material
new_material | new body material |
void irr::newton::Body::setMomentOfInertia | ( | irr::core::vector3df | inertia | ) |
Set moments of inertia of the body
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
void irr::newton::Body::setOmega | ( | irr::core::vector3df | omega | ) |
set body angular velocity
omega | the new angular velocity of the body |
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
parent | the other body parent to this body |
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
pos | new body position in 3 dimension space |
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
rot | new body rotation on the 3 axis |
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
rot | new body rotation on the 3 axis |
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
scale | new body scale on the 3 axis |
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
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
new_torque | the new torque of the body |
virtual void irr::newton::Body::setVelocity | ( | irr::core::vector3df | velocity | ) | [virtual] |
set body linear velocity
velocity | the new linear velocity of the body |
Reimplemented in irr::newton::CharacterController.
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] |
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] |