1 | /*! |
---|
2 | * @file particle_engine.h |
---|
3 | * Definition of the ParticleEngine |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef _PARTICLE_ENGINE_H |
---|
7 | #define _PARTICLE_ENGINE_H |
---|
8 | |
---|
9 | #include "base_object.h" |
---|
10 | |
---|
11 | #include "particle_system.h" |
---|
12 | #include "particle_emitter.h" |
---|
13 | |
---|
14 | #include "tinyxml.h" |
---|
15 | |
---|
16 | // FORWARD DECLARATION |
---|
17 | template<class T> class tList; |
---|
18 | |
---|
19 | //! A ParticleConnection enables us to emitt from any emitter into any other particleSystem |
---|
20 | typedef struct ParticleConnection |
---|
21 | { |
---|
22 | ParticleEmitter* emitter; //!< The emitter to emit system from. |
---|
23 | ParticleSystem* system; //!< The Particles emitted from emitter. |
---|
24 | }; |
---|
25 | |
---|
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 | */ |
---|
32 | class ParticleEngine : public BaseObject { |
---|
33 | |
---|
34 | public: |
---|
35 | virtual ~ParticleEngine(); |
---|
36 | /** @returns a Pointer to the only object of this Class */ |
---|
37 | inline static ParticleEngine* getInstance() { if (!singletonRef) singletonRef = new ParticleEngine(); return singletonRef; }; |
---|
38 | |
---|
39 | void loadParams(const TiXmlElement* root); |
---|
40 | |
---|
41 | void tick(float dt); |
---|
42 | void draw() const; |
---|
43 | |
---|
44 | void addSystem(ParticleSystem* system); |
---|
45 | void addEmitter(ParticleEmitter* emitter); |
---|
46 | void addConnection(ParticleEmitter* emitter, ParticleSystem* system); |
---|
47 | void addConnection(const char* emitter, const char* system); |
---|
48 | |
---|
49 | |
---|
50 | bool removeSystem(ParticleSystem* system); |
---|
51 | bool removeEmitter(ParticleEmitter* emitter); |
---|
52 | bool breakConnection(ParticleEmitter* emitter, ParticleSystem* system); |
---|
53 | bool breakConnection(ParticleConnection* connection); |
---|
54 | |
---|
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 | |
---|
60 | void debug(); |
---|
61 | |
---|
62 | private: |
---|
63 | ParticleEngine(); |
---|
64 | static ParticleEngine* singletonRef; //!< The reference to the engine. |
---|
65 | |
---|
66 | tList<ParticleSystem>* systemList; //!< A list of Systems handled by the ParticleEngine. |
---|
67 | tList<ParticleEmitter>* emitterList; //!< A list of Emitters handled by the ParticleEngine. |
---|
68 | |
---|
69 | tList<ParticleConnection>* connectionList; //!< A list of Connections between Systems and Emitters. |
---|
70 | }; |
---|
71 | |
---|
72 | #endif /* _PARTICLE_ENGINE_H */ |
---|