Base class for object models with multiple bodies. More...
#include <dynamics2d_multi_body_object_model.h>
Classes | |
struct | SBody |
Public Member Functions | |
CDynamics2DMultiBodyObjectModel (CDynamics2DEngine &c_engine, CComposableEntity &c_entity) | |
Class constructor. More... | |
virtual | ~CDynamics2DMultiBodyObjectModel () |
Class destructor. More... | |
CComposableEntity & | GetComposableEntity () |
Returns the associated composable entity as a non-const reference. More... | |
const CComposableEntity & | GetComposableEntity () const |
Returns the associated composable entity as a const reference. More... | |
SBody & | GetBody (size_t i) |
Returns the i-th body associated to the model. More... | |
const SBody & | GetBody (size_t i) const |
Returns the i-th body associated to the model. More... | |
virtual void | Reset () |
virtual void | MoveTo (const CVector3 &c_position, const CQuaternion &c_orientation) |
virtual void | CalculateBoundingBox () |
Calculates the axis-aligned box that contains the entire physics model. More... | |
virtual void | UpdateFromEntityStatus ()=0 |
Updates the state of this model from the status of the associated entity. More... | |
virtual bool | IsCollidingWithSomething () const |
Returns true if this model is colliding with another model. More... | |
virtual void | AddBody (cpBody *pt_body, const cpVect &t_offset_pos, cpFloat t_offset_orient, Real f_height) |
Adds a body. More... | |
Public Member Functions inherited from argos::CDynamics2DModel | |
CDynamics2DModel (CDynamics2DEngine &c_engine, CEmbodiedEntity &c_entity) | |
virtual | ~CDynamics2DModel () |
CDynamics2DEngine & | GetDynamics2DEngine () |
Returns the dynamics 2D engine state. More... | |
const CDynamics2DEngine & | GetDynamics2DEngine () const |
Returns the dynamics 2D engine state as a const reference. More... | |
Public Member Functions inherited from argos::CPhysicsModel | |
CPhysicsModel (CPhysicsEngine &c_engine, CEmbodiedEntity &c_entity) | |
virtual | ~CPhysicsModel () |
CPhysicsEngine & | GetEngine () |
Returns the physics engine associated to this physics model. More... | |
CEmbodiedEntity & | GetEmbodiedEntity () |
Returns the embodied entity associated to this physics model. More... | |
const CEmbodiedEntity & | GetEmbodiedEntity () const |
Returns the embodied entity associated to this physics model. More... | |
virtual void | UpdateEntityStatus () |
Updates the status of the associated entity. More... | |
virtual void | UpdatePhysics () |
Performs extra work just before the physics update takes place. More... | |
const SBoundingBox & | GetBoundingBox () const |
Returns an axis-aligned box that contains the physics model. More... | |
virtual void | CalculateAnchors () |
Calculates the anchors associated to this model. More... | |
SBoundingBox & | GetBoundingBox () |
Returns an axis-aligned box that contains the physics model. More... | |
template<typename MODEL > | |
void | RegisterAnchorMethod (const SAnchor &s_anchor, void(MODEL::*pt_method)(SAnchor &)) |
Registers an anchor method. More... | |
Additional Inherited Members | |
Public Types inherited from argos::CDynamics2DModel | |
typedef std::map< std::string, CDynamics2DModel * > | TMap |
Public Types inherited from argos::CPhysicsModel | |
typedef std::map< std::string, CPhysicsModel * > | TMap |
typedef std::vector< CPhysicsModel * > | TVector |
Base class for object models with multiple bodies.
This class offers all the basic functionality to manage models composed of multiple bodies.
Multi-body objects are often active objects such as robots.
To use this class, simply create a class that inherits from it. The default implementations for Reset(), MoveTo(), etc. should be already OK for your needs.
In the constructor of your class, be sure to call the method AddBody() when you have created the bodies and associated the shapes to them. If this method is not called, the default implementations will have segfaults.
This class retains ownership for the bodies and shapes you created once you call AddBody(). In other words, you don't need to free these objects because ~CDynamics2DMultiBodyObjectModel() does it for you.
Definition at line 44 of file dynamics2d_multi_body_object_model.h.
argos::CDynamics2DMultiBodyObjectModel::CDynamics2DMultiBodyObjectModel | ( | CDynamics2DEngine & | c_engine, |
CComposableEntity & | c_entity | ||
) |
Class constructor.
c_engine | The dynamics 2D engine that manages this model. |
c_entity | The composable entity associated to this model. |
CARGoSException | if c_entity does not contain an embodied entity. |
Definition at line 9 of file dynamics2d_multi_body_object_model.cpp.
|
virtual |
Class destructor.
Disposes of the object body and its shapes.
Definition at line 17 of file dynamics2d_multi_body_object_model.cpp.
|
virtual |
Adds a body.
You must call this method for this class' methods to work.
This class retains ownership of the passed body, so you don't need to explicitly delete anything.
Internally, this method also sets pc_body->userData
to point to this
, which is a requirement for ray cast queries to work properly.
Finally, this method also calculates the initial bounding box of the object.
pt_body | The object body. |
t_offset_pos | The position of the body wrt the origin anchor. |
t_offset_orient | The orientation of the body wrt the origin anchor. |
f_height | The object height. |
Definition at line 136 of file dynamics2d_multi_body_object_model.cpp.
|
virtual |
Calculates the axis-aligned box that contains the entire physics model.
The bounding box is often called AABB.
Implements argos::CPhysicsModel.
Reimplemented in argos::CDynamics2DFootBotModel.
Definition at line 88 of file dynamics2d_multi_body_object_model.cpp.
|
inline |
Returns the i-th body associated to the model.
Definition at line 96 of file dynamics2d_multi_body_object_model.h.
|
inline |
Returns the i-th body associated to the model.
Definition at line 104 of file dynamics2d_multi_body_object_model.h.
|
inline |
Returns the associated composable entity as a non-const reference.
Definition at line 80 of file dynamics2d_multi_body_object_model.h.
|
inline |
Returns the associated composable entity as a const reference.
Definition at line 88 of file dynamics2d_multi_body_object_model.h.
|
virtual |
Returns true
if this model is colliding with another model.
true
if this model is colliding with another model. Implements argos::CPhysicsModel.
Definition at line 116 of file dynamics2d_multi_body_object_model.cpp.
|
virtual |
Moves the entity to the wanted position and orientation within this engine. When you create a new model, you must implement this method. Don't forget to call UpdateEntityStatus() after you've changed the position.
This method should never be called directly from user code. It is called internally by CEmbodiedEntity::MoveTo(), which is meant to be called from user code.
CEmbodiedEntity::MoveTo() never calls this method if the embodied entity is static. This is because static entities cannot be moved around. Thus, there's no need in your code to check whether the associated entity is static.
c_position | The wanted position. |
c_orientation | The wanted orientation. |
Implements argos::CPhysicsModel.
Reimplemented in argos::CDynamics2DFootBotModel.
Definition at line 42 of file dynamics2d_multi_body_object_model.cpp.
|
virtual |
Implements argos::CDynamics2DModel.
Reimplemented in argos::CDynamics2DFootBotModel.
Definition at line 71 of file dynamics2d_multi_body_object_model.cpp.
|
pure virtual |
Updates the state of this model from the status of the associated entity.
This method takes the current state of the associated entity (e.g., desired wheel speed, turret rotationss, etc.) and updates the state of this model. Typically, in this method you apply forces and set speeds.
Implements argos::CPhysicsModel.
Implemented in argos::CDynamics2DFootBotModel.