![]() |
An open-source, flexible 3D physical simulation framework
|
Declaration of the physical class, that implements the physics interface. More...
#include <WorldPhysics.h>
Public Member Functions | |
WorldPhysics (interfaces::ControlCenter *control) | |
The constructor for the physical world. More... | |
virtual | ~WorldPhysics (void) |
Close ODE environment. More... | |
virtual void | initTheWorld (void) |
This function initializes the ode world. More... | |
virtual void | freeTheWorld (void) |
This functions destroys the ode world. More... | |
virtual void | stepTheWorld (void) |
This function handles the calculation of a step in the world. More... | |
virtual bool | existsWorld (void) const |
Returns if a world exists. More... | |
virtual const utils::Vector | getCenterOfMass (const std::vector< interfaces::NodeInterface *> &nodes) const |
virtual void | update (std::vector< interfaces::draw_item > *drawItems) |
This is the update function that updates the position of the vertices of all draw_item structs contained in drawItems. More... | |
virtual int | checkCollisions (void) |
virtual interfaces::sReal | getVectorCollision (const utils::Vector &pos, const utils::Vector &ray) const |
dWorldID | getWorld (void) const |
Returns the ode ID of the world object. More... | |
dSpaceID | getSpace (void) const |
Returns the ode ID of the main space object. More... | |
bool | getCompositeBody (int comp_group, dBodyID *body, NodePhysics *node) |
Sets the body pointer param to the body for the comp_group_id. More... | |
void | destroyBody (dBodyID theBody, NodePhysics *node) |
Destroyes a body from a node: More... | |
dReal | getWorldStep (void) |
Returns the stepsize for calculating a world step. More... | |
void | resetCompositeMass (dBodyID theBody) |
resets the mass of a composite body More... | |
void | moveCompositeMassCenter (dBodyID theBody, dReal x, dReal y, dReal z) |
int | handleCollision (dGeomID theGeom) |
interfaces::sReal | getCollisionDepth (dGeomID theGeom) |
![]() | |
virtual | ~PhysicsInterface () |
Public Attributes | |
utils::Mutex | iMutex |
![]() | |
sReal | ground_friction |
sReal | ground_cfm |
sReal | ground_erp |
sReal | step_size |
Step size in seconds. More... | |
utils::Vector | world_gravity |
bool | fast_step |
bool | draw_contact_points |
sReal | world_cfm |
sReal | world_erp |
Static Public Attributes | |
static interfaces::PhysicsError | error = PHYSICS_NO_ERROR |
Private Member Functions | |
void | nearCallback (dGeomID o1, dGeomID o2) |
In this function the collision handling from ode is performed. More... | |
![]() | |
virtual | ~DrawInterface () |
Static Private Member Functions | |
static void | callbackForward (void *data, dGeomID o1, dGeomID o2) |
This static function is used to project a normal function pointer to a method from a class. More... | |
Private Attributes | |
utils::Mutex | drawLock |
dSpaceID | space |
dWorldID | world |
dGeomID | plane |
dJointGroupID | contactgroup |
bool | world_init |
interfaces::ControlCenter * | control |
utils::Vector | old_gravity |
interfaces::sReal | old_cfm |
interfaces::sReal | old_erp |
std::vector< body_nbr_tupel > | comp_body_list |
std::vector< interfaces::draw_item > | draw_intern |
std::vector< interfaces::draw_item > | draw_extern |
std::vector< dJointFeedback * > | contact_feedback_list |
bool | create_contacts |
bool | log_contacts |
int | num_contacts |
int | ray_collision |
Declaration of the physical class, that implements the physics interface.
Definition at line 85 of file WorldPhysics.h.
mars::sim::WorldPhysics::WorldPhysics | ( | interfaces::ControlCenter * | control | ) |
The constructor for the physical world.
pre:
post:
Definition at line 85 of file WorldPhysics.cpp.
|
virtual |
Close ODE environment.
pre:
post:
Definition at line 131 of file WorldPhysics.cpp.
|
staticprivate |
This static function is used to project a normal function pointer to a method from a class.
pre:
post:
Definition at line 752 of file WorldPhysics.cpp.
|
virtual |
Implements mars::interfaces::PhysicsInterface.
Definition at line 875 of file WorldPhysics.cpp.
void mars::sim::WorldPhysics::destroyBody | ( | dBodyID | theBody, |
NodePhysics * | node | ||
) |
Destroyes a body from a node:
This function checks if not more than one geom is connected to the body and destroyes the body in that case. In the other case the counter of the connected geoms is decreased.
pre:
post:
Definition at line 375 of file WorldPhysics.cpp.
|
virtual |
Returns if a world exists.
pre:
post:
Implements mars::interfaces::PhysicsInterface.
Definition at line 210 of file WorldPhysics.cpp.
|
virtual |
This functions destroys the ode world.
pre:
post:
Implements mars::interfaces::PhysicsInterface.
Definition at line 189 of file WorldPhysics.cpp.
|
virtual |
Implements mars::interfaces::PhysicsInterface.
Definition at line 805 of file WorldPhysics.cpp.
double mars::sim::WorldPhysics::getCollisionDepth | ( | dGeomID | theGeom | ) |
Definition at line 844 of file WorldPhysics.cpp.
bool mars::sim::WorldPhysics::getCompositeBody | ( | int | comp_group, |
dBodyID * | body, | ||
NodePhysics * | node | ||
) |
Sets the body pointer param to the body for the comp_group_id.
The functions sets the body pointer to the body ID that represents the composite object. If no body is aviable for the composite group a body will be created. The functions return if an body allready exists or if one had been created.
Careful with this function, bad implementation. This function should be only called if a new geom will be conected to the given body.
pre:
post:
Definition at line 335 of file WorldPhysics.cpp.
dSpaceID mars::sim::WorldPhysics::getSpace | ( | void | ) | const |
Returns the ode ID of the main space object.
pre:
post:
Definition at line 311 of file WorldPhysics.cpp.
|
virtual |
Implements mars::interfaces::PhysicsInterface.
Definition at line 883 of file WorldPhysics.cpp.
dWorldID mars::sim::WorldPhysics::getWorld | ( | void | ) | const |
Returns the ode ID of the world object.
pre:
post:
Definition at line 298 of file WorldPhysics.cpp.
dReal mars::sim::WorldPhysics::getWorldStep | ( | void | ) |
Returns the stepsize for calculating a world step.
pre:
post:
Definition at line 414 of file WorldPhysics.cpp.
int mars::sim::WorldPhysics::handleCollision | ( | dGeomID | theGeom | ) |
Definition at line 837 of file WorldPhysics.cpp.
|
virtual |
This function initializes the ode world.
pre:
post:
Implements mars::interfaces::PhysicsInterface.
Definition at line 150 of file WorldPhysics.cpp.
void mars::sim::WorldPhysics::moveCompositeMassCenter | ( | dBodyID | theBody, |
dReal | x, | ||
dReal | y, | ||
dReal | z | ||
) |
Definition at line 784 of file WorldPhysics.cpp.
|
private |
In this function the collision handling from ode is performed.
pre:
post:
A lot of the code is uncommented in this function. This code maybe used later to handle sensors or other special cases in the simulation.
test if a space is colliding with something
exit without doing anything if the two bodies are connected by a joint
Definition at line 434 of file WorldPhysics.cpp.
void mars::sim::WorldPhysics::resetCompositeMass | ( | dBodyID | theBody | ) |
resets the mass of a composite body
pre:
post:
Definition at line 765 of file WorldPhysics.cpp.
|
virtual |
This function handles the calculation of a step in the world.
pre:
post:
first clear the collision counters of all geoms
then we have to clear the contacts
first check for collisions
then calculate the next state for a time of step_size seconds
Implements mars::interfaces::PhysicsInterface.
Definition at line 226 of file WorldPhysics.cpp.
|
virtual |
This is the update function that updates the position of the vertices of all draw_item structs contained in drawItems.
Implements mars::interfaces::DrawInterface.
Definition at line 823 of file WorldPhysics.cpp.
|
private |
Definition at line 123 of file WorldPhysics.h.
|
private |
Definition at line 126 of file WorldPhysics.h.
|
private |
Definition at line 117 of file WorldPhysics.h.
|
private |
Definition at line 119 of file WorldPhysics.h.
|
private |
Definition at line 127 of file WorldPhysics.h.
|
private |
Definition at line 125 of file WorldPhysics.h.
|
private |
Definition at line 124 of file WorldPhysics.h.
|
private |
Definition at line 113 of file WorldPhysics.h.
|
static |
Definition at line 110 of file WorldPhysics.h.
|
mutable |
Definition at line 108 of file WorldPhysics.h.
|
private |
Definition at line 127 of file WorldPhysics.h.
|
private |
Definition at line 128 of file WorldPhysics.h.
|
private |
Definition at line 121 of file WorldPhysics.h.
|
private |
Definition at line 121 of file WorldPhysics.h.
|
private |
Definition at line 120 of file WorldPhysics.h.
|
private |
Definition at line 116 of file WorldPhysics.h.
|
private |
Definition at line 129 of file WorldPhysics.h.
|
private |
Definition at line 114 of file WorldPhysics.h.
|
private |
Definition at line 115 of file WorldPhysics.h.
|
private |
Definition at line 118 of file WorldPhysics.h.