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