ARGoS
3
A parallel, multi-engine simulator for swarm robotics
|
Go to the documentation of this file.
7 #ifndef PHYSICS_MODEL_H
8 #define PHYSICS_MODEL_H
15 class CEmbodiedEntity;
19 #include <argos3/core/utility/datatypes/datatypes.h>
20 #include <argos3/core/utility/math/vector3.h>
21 #include <argos3/core/utility/math/quaternion.h>
68 const std::string& str_id,
106 typedef std::map<std::string, CPhysicsModel*>
TMap;
115 while(!m_vecAnchorMethodHolders.empty()) {
116 delete m_vecAnchorMethodHolders.back();
117 m_vecAnchorMethodHolders.pop_back();
134 return m_cEmbodiedEntity;
142 return m_cEmbodiedEntity;
199 return m_sBoundingBox;
227 return m_sBoundingBox;
248 class CAnchorMethodHolder {};
256 template <
typename MODEL>
class CAnchorMethodHolderImpl :
public CAnchorMethodHolder {
258 typedef void (MODEL::*TMethod)(SAnchor&);
260 CAnchorMethodHolderImpl(TMethod t_method) : Method(t_method) {}
273 template <
typename USER_IMPL>
274 void Thunk(SAnchor& s_anchor);
282 std::vector<CAnchorMethodHolder*> m_vecAnchorMethodHolders;
289 std::vector<TThunk> m_vecThunks;
299 template <
typename MODEL>
301 void(MODEL::*pt_method)(SAnchor&));
308 template <
typename MODEL>
309 void CPhysicsModel::Thunk(SAnchor& s_anchor) {
317 MODEL& cImpl =
static_cast<MODEL&
>(*this);
319 CAnchorMethodHolderImpl<MODEL>& cMethodHolder =
static_cast<CAnchorMethodHolderImpl<MODEL>&
>(*m_vecAnchorMethodHolders[s_anchor.Index]);
321 (cImpl.*(cMethodHolder.Method))(s_anchor);
324 template <
typename MODEL>
326 void(MODEL::*pt_method)(
SAnchor&)) {
328 m_vecThunks[s_anchor.
Index] = &CPhysicsModel::Thunk<MODEL>;
330 m_vecAnchorMethodHolders[s_anchor.
Index] =
new CAnchorMethodHolderImpl<MODEL>(pt_method);
CQuaternion Orientation
The orientation of the anchor wrt the global coordinate system.
Real GetZ() const
Returns the z coordinate of this vector.
virtual void CalculateBoundingBox()=0
Calculates the axis-aligned box that contains the entire physics model.
The namespace containing all the ARGoS related code.
virtual void UpdateEntityStatus()
Updates the status of the associated entity.
bool Intersects(const SBoundingBox &s_bb) const
This entity is a link to a body in the physics engine.
std::vector< CPhysicsModel * > TVector
UInt32 InUseCount
A counter for the devices using this anchor.
void Enable()
Enables this anchor.
CQuaternion OffsetOrientation
The initial orientation of the anchor wrt the body coordinate system.
Real GetX() const
Returns the x coordinate of this vector.
CPhysicsModel(CPhysicsEngine &c_engine, CEmbodiedEntity &c_entity)
virtual bool IsCollidingWithSomething() const =0
Returns true if this model is colliding with another model.
An anchor related to the body of an entity.
void RegisterAnchorMethod(const SAnchor &s_anchor, void(MODEL::*pt_method)(SAnchor &))
Registers an anchor method.
UInt32 Index
The index of the anchor assigned by the embodied entity.
CEmbodiedEntity & Body
The embodied entity that owns this anchor.
virtual void MoveTo(const CVector3 &c_position, const CQuaternion &c_orientation)=0
std::string Id
The id of the anchor.
const SBoundingBox & GetBoundingBox() const
Returns an axis-aligned box that contains the physics model.
unsigned int UInt32
32-bit unsigned integer.
virtual void CalculateAnchors()
Calculates the anchors associated to this model.
std::map< std::string, CPhysicsModel * > TMap
Real GetY() const
Returns the y coordinate of this vector.
SAnchor(CEmbodiedEntity &c_body, const std::string &str_id, UInt32 un_index, const CVector3 &c_offset_position, const CQuaternion &c_offset_orientation, const CVector3 &c_position, const CQuaternion &c_orientation)
Struct constructor.
void Disable()
Disables this anchor.
CVector3 Position
The position of the anchor wrt the global coordinate system.
CPhysicsEngine & GetEngine()
Returns the physics engine associated to this physics model.
const CEmbodiedEntity & GetEmbodiedEntity() const
Returns the embodied entity associated to this physics model.
SBoundingBox & GetBoundingBox()
Returns an axis-aligned box that contains the physics model.
CEmbodiedEntity & GetEmbodiedEntity()
Returns the embodied entity associated to this physics model.
CVector3 OffsetPosition
The initial position of the anchor wrt the body coordinate system.
virtual void UpdateFromEntityStatus()=0
Updates the state of this model from the status of the associated entity.