1 | /*! |
---|
2 | \file particle_e,otter.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 | |
---|
15 | typedef enum EMITTER_TYPE {EMITTER_DOT, |
---|
16 | EMITTER_PLANE, |
---|
17 | EMITTER_SPHERE, |
---|
18 | EMITTER_CUBE}; |
---|
19 | |
---|
20 | //! A default singleton class. |
---|
21 | class ParticleEmitter : public PNode { |
---|
22 | |
---|
23 | public: |
---|
24 | ParticleEmitter(const Vector& direction, float angle = .5, float emissionRate = 1.0, |
---|
25 | float velocity = 1.0); |
---|
26 | virtual ~ParticleEmitter(void); |
---|
27 | |
---|
28 | /* controlling the emitter: interface */ |
---|
29 | void start(); |
---|
30 | void stop(); |
---|
31 | void tick(float dt, ParticleSystem* system); |
---|
32 | |
---|
33 | /* controlling the behavour: these can be used as Animation interfaces */ |
---|
34 | void setEmissionRate(float emissionRate); |
---|
35 | void setSpread(float angle, float randomAngle = 0.0); |
---|
36 | void setVelocity(float velocity, float randomVelocity = 0.0); |
---|
37 | |
---|
38 | void debug(void); |
---|
39 | |
---|
40 | private: |
---|
41 | Vector direction; //!< emition direction |
---|
42 | float angle; //!< max angle from the direction of the emitter |
---|
43 | float randomAngle; //!< random emission angle (angle +- angleRandom is the emitted angle. |
---|
44 | float emissionRate; //!< amount of particles per seconds emitted by emitter. |
---|
45 | float velocity; //!< the initial speed of a Particles. |
---|
46 | float randomVelocity; //!< the random variation from the initial Speed. |
---|
47 | |
---|
48 | float saveTime; //!< The time that was missing by the last Tick (otherwise there would be no emission when framefate is too big). |
---|
49 | }; |
---|
50 | |
---|
51 | #endif /* _PARTICLE_EMITTER_H */ |
---|