pointmass3d_model.cpp
Go to the documentation of this file.
1 #include "pointmass3d_model.h"
2 #include <argos3/core/simulator/entity/embodied_entity.h>
3 
4 namespace argos {
5 
6  /****************************************/
7  /****************************************/
8 
10  CEmbodiedEntity& c_entity) :
11  CPhysicsModel(c_engine, c_entity),
12  m_cPM3DEngine(c_engine) {
13  /* Register the origin anchor update method */
14  RegisterAnchorMethod(GetEmbodiedEntity().GetOriginAnchor(),
16  /* Set initial position */
18  }
19 
20  /****************************************/
21  /****************************************/
22 
28  }
29 
30  /****************************************/
31  /****************************************/
32 
33  void CPointMass3DModel::MoveTo(const CVector3& c_position,
34  const CQuaternion& c_orientation) {
35  m_cPosition = c_position;
37  }
38 
39  /****************************************/
40  /****************************************/
41 
43  /* Go through other objects and check if the BB intersect */
44  for(auto it = GetPM3DEngine().GetPhysicsModels().begin();
45  it != GetPM3DEngine().GetPhysicsModels().end(); ++it) {
46  if((it->second != this) &&
47  GetBoundingBox().Intersects(it->second->GetBoundingBox()))
48  return true;
49  }
50  return false;
51  }
52 
53  /****************************************/
54  /****************************************/
55 
57  s_anchor.Position = m_cPosition;
58  }
59 
60  /****************************************/
61  /****************************************/
62 
63 }
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
This entity is a link to a body in the physics engine.
const SAnchor & GetOriginAnchor() const
Returns a const reference to the origin anchor associated to this entity.
An anchor related to the body of an entity.
Definition: physics_model.h:38
CVector3 Position
The position of the anchor wrt the global coordinate system.
Definition: physics_model.h:51
bool Intersects(const SBoundingBox &s_bb) const
Definition: physics_model.h:91
void RegisterAnchorMethod(const SAnchor &s_anchor, void(MODEL::*pt_method)(SAnchor &))
Registers an anchor method.
CEmbodiedEntity & GetEmbodiedEntity()
Returns the embodied entity associated to this physics model.
const SBoundingBox & GetBoundingBox() const
Returns an axis-aligned box that contains the physics model.
virtual void CalculateBoundingBox()=0
Calculates the axis-aligned box that contains the entire physics model.
virtual void UpdateEntityStatus()
Updates the status of the associated entity.
A 3D vector class.
Definition: vector3.h:31
std::map< std::string, CPointMass3DModel * > & GetPhysicsModels()
CPointMass3DModel(CPointMass3DEngine &c_engine, CEmbodiedEntity &c_entity)
CVector3 m_cVelocity
The linear velocity of this model in the engine.
virtual void MoveTo(const CVector3 &c_position, const CQuaternion &c_orientation)
virtual bool IsCollidingWithSomething() const
Returns true if this model is colliding with another model.
virtual void UpdateOriginAnchor(SAnchor &s_anchor)
Updates the origin anchor associated to the embodied entity.
CPointMass3DEngine & GetPM3DEngine()
Returns a reference to the physics engine controlling this model.
CVector3 m_cAcceleration
The acceleration of this model in the engine.
CVector3 m_cPosition
The position of the model in this engine.