[4677] | 1 | /*! |
---|
[5039] | 2 | * @file particle_engine.h |
---|
[4836] | 3 | * Definition of the ParticleEngine |
---|
[3655] | 4 | */ |
---|
| 5 | |
---|
[3923] | 6 | #ifndef _PARTICLE_ENGINE_H |
---|
| 7 | #define _PARTICLE_ENGINE_H |
---|
[3655] | 8 | |
---|
| 9 | #include "base_object.h" |
---|
[4726] | 10 | |
---|
[4176] | 11 | #include "particle_system.h" |
---|
| 12 | #include "particle_emitter.h" |
---|
[7130] | 13 | #include <list> |
---|
[3655] | 14 | |
---|
[5944] | 15 | #include "parser/tinyxml/tinyxml.h" |
---|
[4726] | 16 | |
---|
[5405] | 17 | // FORWARD DECLARATION |
---|
[3655] | 18 | |
---|
[4478] | 19 | //! A ParticleConnection enables us to emitt from any emitter into any other particleSystem |
---|
| 20 | typedef struct ParticleConnection |
---|
[3931] | 21 | { |
---|
[4478] | 22 | ParticleEmitter* emitter; //!< The emitter to emit system from. |
---|
| 23 | ParticleSystem* system; //!< The Particles emitted from emitter. |
---|
[3931] | 24 | }; |
---|
[3925] | 25 | |
---|
[4394] | 26 | //! The physicsEngine handles and stores Systems and Emitters. |
---|
| 27 | /** |
---|
| 28 | It is responsible for driving on the Particles (tick) |
---|
| 29 | It draw particles (draw) |
---|
| 30 | and it emitts particles into the system |
---|
| 31 | */ |
---|
[3923] | 32 | class ParticleEngine : public BaseObject { |
---|
[3655] | 33 | |
---|
| 34 | public: |
---|
[4746] | 35 | virtual ~ParticleEngine(); |
---|
[4836] | 36 | /** @returns a Pointer to the only object of this Class */ |
---|
[4746] | 37 | inline static ParticleEngine* getInstance() { if (!singletonRef) singletonRef = new ParticleEngine(); return singletonRef; }; |
---|
[3655] | 38 | |
---|
[6512] | 39 | virtual void loadParams(const TiXmlElement* root); |
---|
[4726] | 40 | |
---|
[3925] | 41 | void tick(float dt); |
---|
[4746] | 42 | void draw() const; |
---|
[3925] | 43 | |
---|
[3931] | 44 | void addSystem(ParticleSystem* system); |
---|
| 45 | void addEmitter(ParticleEmitter* emitter); |
---|
[3932] | 46 | void addConnection(ParticleEmitter* emitter, ParticleSystem* system); |
---|
[7225] | 47 | void addConnection(const std::string& emitter, const std::string& system); |
---|
[3931] | 48 | |
---|
[4726] | 49 | |
---|
[3931] | 50 | bool removeSystem(ParticleSystem* system); |
---|
| 51 | bool removeEmitter(ParticleEmitter* emitter); |
---|
[5447] | 52 | bool breakConnection(ParticleConnection* connection); |
---|
[3943] | 53 | bool breakConnection(ParticleEmitter* emitter, ParticleSystem* system); |
---|
[5447] | 54 | unsigned int breakConnections(ParticleEmitter* emitter); |
---|
| 55 | unsigned int breakConnections(ParticleSystem* system); |
---|
[3931] | 56 | |
---|
[5445] | 57 | ParticleSystem* getSystemByNumber(unsigned int number) const; |
---|
| 58 | ParticleEmitter* getEmitterByNumber(unsigned int number) const; |
---|
[4338] | 59 | |
---|
[3944] | 60 | void debug(); |
---|
| 61 | |
---|
[3655] | 62 | private: |
---|
[4746] | 63 | ParticleEngine(); |
---|
[4394] | 64 | static ParticleEngine* singletonRef; //!< The reference to the engine. |
---|
[3925] | 65 | |
---|
[7130] | 66 | std::list<ParticleSystem> systemList; //!< A list of Systems handled by the ParticleEngine. |
---|
| 67 | std::list<ParticleEmitter> emitterList; //!< A list of Emitters handled by the ParticleEngine. |
---|
[3931] | 68 | |
---|
[4394] | 69 | tList<ParticleConnection>* connectionList; //!< A list of Connections between Systems and Emitters. |
---|
[3655] | 70 | }; |
---|
| 71 | |
---|
[3923] | 72 | #endif /* _PARTICLE_ENGINE_H */ |
---|