[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" |
---|
[3655] | 13 | |
---|
[4726] | 14 | #include "tinyxml.h" |
---|
| 15 | |
---|
[5405] | 16 | // FORWARD DECLARATION |
---|
[3925] | 17 | template<class T> class tList; |
---|
[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 | |
---|
[4726] | 39 | void loadParams(const TiXmlElement* root); |
---|
| 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); |
---|
[4726] | 47 | void addConnection(const char* emitter, const char* system); |
---|
[3931] | 48 | |
---|
[4726] | 49 | |
---|
[3931] | 50 | bool removeSystem(ParticleSystem* system); |
---|
| 51 | bool removeEmitter(ParticleEmitter* emitter); |
---|
[3943] | 52 | bool breakConnection(ParticleEmitter* emitter, ParticleSystem* system); |
---|
| 53 | bool breakConnection(ParticleConnection* connection); |
---|
[3931] | 54 | |
---|
[4338] | 55 | ParticleSystem* getSystemByName(const char* systemName) const; |
---|
| 56 | ParticleSystem* getSystemByNumber(unsigned int number) const; |
---|
| 57 | ParticleEmitter* getEmitterByName(const char* emitterName) const; |
---|
| 58 | ParticleEmitter* getEmitterByNumber(unsigned int number) const; |
---|
| 59 | |
---|
[3944] | 60 | void debug(); |
---|
| 61 | |
---|
[3655] | 62 | private: |
---|
[4746] | 63 | ParticleEngine(); |
---|
[4394] | 64 | static ParticleEngine* singletonRef; //!< The reference to the engine. |
---|
[3925] | 65 | |
---|
[4394] | 66 | tList<ParticleSystem>* systemList; //!< A list of Systems handled by the ParticleEngine. |
---|
| 67 | tList<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 */ |
---|