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