ARGoS
3
A parallel, multi-engine simulator for swarm robotics
|
00001 00007 #ifndef PHYSICS_MODEL_H 00008 #define PHYSICS_MODEL_H 00009 00010 namespace argos { 00011 class CPhysicsModel; 00012 class CPhysicsEngine; 00013 class CEmbodiedEntity; 00014 class CRay3; 00015 class CQuaternion; 00016 } 00017 00018 #include <argos3/core/utility/datatypes/datatypes.h> 00019 #include <argos3/core/utility/math/vector3.h> 00020 #include <map> 00021 #include <vector> 00022 #include <string> 00023 00024 namespace argos { 00025 00026 struct SBoundingBox { 00027 CVector3 MinCorner; 00028 CVector3 MaxCorner; 00029 00030 inline bool Intersects(const SBoundingBox& s_bb) const { 00031 return 00032 (MinCorner.GetX() < s_bb.MaxCorner.GetX()) && (MaxCorner.GetX() > s_bb.MinCorner.GetX()) && 00033 (MinCorner.GetY() < s_bb.MaxCorner.GetY()) && (MaxCorner.GetY() > s_bb.MinCorner.GetY()) && 00034 (MinCorner.GetZ() < s_bb.MaxCorner.GetZ()) && (MaxCorner.GetZ() > s_bb.MinCorner.GetZ()); 00035 } 00036 }; 00037 00038 class CPhysicsModel { 00039 00040 public: 00041 00042 typedef std::map<std::string, CPhysicsModel*> TMap; 00043 typedef std::vector<CPhysicsModel*> TVector; 00044 00045 public: 00046 00047 CPhysicsModel(CPhysicsEngine& c_engine, 00048 CEmbodiedEntity& c_entity) : 00049 m_cEngine(c_engine), 00050 m_cEmbodiedEntity(c_entity), 00051 m_sBoundingBox() {} 00052 00053 virtual ~CPhysicsModel() {} 00054 00059 inline CPhysicsEngine& GetEngine() { 00060 return m_cEngine; 00061 } 00062 00067 inline CEmbodiedEntity& GetEmbodiedEntity() { 00068 return m_cEmbodiedEntity; 00069 } 00070 00075 inline const CEmbodiedEntity& GetEmbodiedEntity() const { 00076 return m_cEmbodiedEntity; 00077 } 00078 00088 virtual bool MoveTo(const CVector3& c_position, 00089 const CQuaternion& c_orientation, 00090 bool b_check_only = false) = 0; 00091 00097 inline const SBoundingBox& GetBoundingBox() const { 00098 return m_sBoundingBox; 00099 } 00100 00105 virtual void CalculateBoundingBox() = 0; 00106 00111 virtual bool IsCollidingWithSomething() const = 0; 00112 00118 inline SBoundingBox& GetBoundingBox() { 00119 return m_sBoundingBox; 00120 } 00121 00122 friend class CEmbodiedEntity; 00123 00124 protected: 00125 00126 CPhysicsEngine& m_cEngine; 00127 CEmbodiedEntity& m_cEmbodiedEntity; 00128 SBoundingBox m_sBoundingBox; 00129 00130 }; 00131 00132 } 00133 00134 #endif