1 | /*! |
---|
2 | \file particle_emitter.h |
---|
3 | \brief Definition of a ParticleEmitter |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef _PARTICLE_EMITTER_H |
---|
7 | #define _PARTICLE_EMITTER_H |
---|
8 | |
---|
9 | #include "p_node.h" |
---|
10 | |
---|
11 | // FORWARD DEFINITION |
---|
12 | struct Particle; |
---|
13 | class ParticleSystem; |
---|
14 | class TiXmlElement; |
---|
15 | |
---|
16 | //! The form of the Emitter to emit from |
---|
17 | typedef enum EMITTER_TYPE {EMITTER_DOT = 1, |
---|
18 | EMITTER_PLANE = 2, |
---|
19 | EMITTER_SPHERE= 4, |
---|
20 | EMITTER_CUBE = 8}; |
---|
21 | |
---|
22 | //! A class to handle an Emitter. |
---|
23 | class ParticleEmitter : public PNode { |
---|
24 | |
---|
25 | public: |
---|
26 | ParticleEmitter(const Vector& direction, float angle = .5, |
---|
27 | float emissionRate = 1.0, float velocity = 1.0); |
---|
28 | ParticleEmitter(const TiXmlElement* root); |
---|
29 | virtual ~ParticleEmitter(void); |
---|
30 | |
---|
31 | void loadParams(const TiXmlElement* root); |
---|
32 | |
---|
33 | /* controlling the emitter: interface */ |
---|
34 | void start(); |
---|
35 | void stop(); |
---|
36 | void tick(float dt, ParticleSystem* system); |
---|
37 | |
---|
38 | /* controlling the behavour: these can be used as Animation interfaces */ |
---|
39 | void setType(EMITTER_TYPE type); |
---|
40 | void setType(const char* type); |
---|
41 | void setSize(float emitterSize); |
---|
42 | void setEmissionRate(float emissionRate); |
---|
43 | void setSpread(float angle, float randomAngle = 0.0); |
---|
44 | void setEmissionVelocity(float velocity, float randomVelocity = 0.0); |
---|
45 | |
---|
46 | /** \returns the type of the emitter */ |
---|
47 | inline EMITTER_TYPE getType(void) const { return this->type; }; |
---|
48 | /** \returns the Size of the emitter */ |
---|
49 | inline float getSize(void) const { return this->emitterSize; }; |
---|
50 | /** \returns the emissionRate */ |
---|
51 | inline float getEmissionRate(void) const { return this->emissionRate; }; |
---|
52 | /** \returns the SpreadAngle of the emitter */ |
---|
53 | inline float getSpread(void) { return this->angle; }; |
---|
54 | /** \returns the EmissionVelocity of the emitter */ |
---|
55 | inline float getEmissionVelocity(void) { return this->velocity; }; |
---|
56 | |
---|
57 | void debug(void); |
---|
58 | |
---|
59 | private: |
---|
60 | EMITTER_TYPE type; //!< The type of emitter this is |
---|
61 | float emitterSize; //!< The size of the emitter (not for EMITTER_DOT) |
---|
62 | Vector direction; //!< emition direction |
---|
63 | float angle; //!< max angle from the direction of the emitter |
---|
64 | float randomAngle; //!< random emission angle (angle +- angleRandom is the emitted angle. |
---|
65 | float emissionRate; //!< amount of particles per seconds emitted by emitter. |
---|
66 | float velocity; //!< the initial speed of a Particles. |
---|
67 | float randomVelocity; //!< the random variation from the initial Speed. |
---|
68 | |
---|
69 | float saveTime; //!< The time that was missing by the last Tick (otherwise there would be no emission when framefate is too big). |
---|
70 | }; |
---|
71 | |
---|
72 | #endif /* _PARTICLE_EMITTER_H */ |
---|