[4558] | 1 | /*! |
---|
[5039] | 2 | * @file physics_engine.h |
---|
[4836] | 3 | * Definition of the PhysicsEngine-singleton Class |
---|
[4558] | 4 | |
---|
[3954] | 5 | */ |
---|
| 6 | |
---|
[4121] | 7 | #ifndef _PHYSICS_ENGINE_H |
---|
| 8 | #define _PHYSICS_ENGINE_H |
---|
[3954] | 9 | |
---|
| 10 | #include "base_object.h" |
---|
[4392] | 11 | |
---|
[4183] | 12 | #include "physics_connection.h" |
---|
[4392] | 13 | #include "physics_interface.h" |
---|
[9869] | 14 | #include "fields/field.h" |
---|
[5776] | 15 | #include <list> |
---|
[3954] | 16 | |
---|
[4183] | 17 | // Forward Declaration |
---|
| 18 | template<class T> class tList; |
---|
[4728] | 19 | class TiXmlElement; |
---|
[3954] | 20 | |
---|
[4558] | 21 | //! A class, that brings things into motion through Physics. |
---|
[9869] | 22 | class PhysicsEngine : public BaseObject |
---|
| 23 | { |
---|
| 24 | ObjectListDeclaration(PhysicsEngine); |
---|
| 25 | public: |
---|
[4746] | 26 | virtual ~PhysicsEngine(); |
---|
[4836] | 27 | /** @returns a Pointer to the only object of this Class */ |
---|
[4746] | 28 | inline static PhysicsEngine* getInstance() { if (!singletonRef) singletonRef = new PhysicsEngine(); return singletonRef; }; |
---|
[3954] | 29 | |
---|
[6512] | 30 | virtual void loadParams(const TiXmlElement* root); |
---|
[4733] | 31 | void loadFields(const TiXmlElement* root); |
---|
| 32 | void loadConnections(const TiXmlElement* root); |
---|
[4392] | 33 | |
---|
[7221] | 34 | PhysicsInterface* getPhysicsInterfaceByName(const std::string& physicsInterfaceName) const; |
---|
[4392] | 35 | |
---|
[4728] | 36 | void addField(Field* field); |
---|
| 37 | void removeField(Field* field); |
---|
[7221] | 38 | Field* getFieldByName(const std::string& fieldName) const; |
---|
[3954] | 39 | |
---|
[4728] | 40 | void addConnection(PhysicsConnection* connection); |
---|
| 41 | void removeConnection(PhysicsConnection* connection); |
---|
[7221] | 42 | PhysicsConnection* getPhysicsConnectionByName(const std::string& physicsConnectionName) const; |
---|
[4183] | 43 | |
---|
[4378] | 44 | |
---|
[4728] | 45 | void tick(float dt); |
---|
| 46 | |
---|
[4746] | 47 | void debug() const; |
---|
[4728] | 48 | |
---|
[9869] | 49 | private: |
---|
[4746] | 50 | PhysicsEngine(); |
---|
[3954] | 51 | |
---|
[9869] | 52 | private: |
---|
[4558] | 53 | static PhysicsEngine* singletonRef; //!< the singleton reference of the PhysicsEngine |
---|
| 54 | |
---|
[5776] | 55 | std::list<Field*> fields; //!< a list of physicsl fields. |
---|
| 56 | std::list<PhysicsConnection*> connections; //!< a list of physical connections. |
---|
[5779] | 57 | const std::list<BaseObject*>* interfaces; //!< The list of physical interfaces. |
---|
[3954] | 58 | }; |
---|
| 59 | |
---|
[4183] | 60 | |
---|
| 61 | |
---|
[4121] | 62 | #endif /* _PHYSICS_ENGINE_H */ |
---|