Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/terrain/src/lib/particles/particle_emitter.h @ 9822

Last change on this file since 9822 was 6825, checked in by bensch, 19 years ago

trunk: new interface to ParticleEmitters

File size: 3.1 KB
Line 
1/*!
2 * @file particle_emitter.h
3  *  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 DECLARATION
12class ParticleSystem;
13class TiXmlElement;
14
15// Default values
16#define PARTICLE_EMITTER_DEFAULT_SIZE              1.0
17#define PARTICLE_EMITTER_DEFAULT_EMISSION_RATE     50
18#define PARTICLE_EMITTER_DEFAULT_INHERIT_SPEED     0.0
19#define PARTICLE_EMITTER_DEFAULT_SPREAD            M_PI
20#define PARTICLE_EMITTER_DEFAULT_VELOCITY          1.0
21
22//! A class to handle an Emitter.
23class ParticleEmitter : public PNode
24{
25  friend class ParticleSystem;
26public:
27  ParticleEmitter(float emissionRate = PARTICLE_EMITTER_DEFAULT_EMISSION_RATE,
28                  float velocity = PARTICLE_EMITTER_DEFAULT_VELOCITY,
29                  float angle = PARTICLE_EMITTER_DEFAULT_SPREAD);
30  virtual ~ParticleEmitter();
31
32  virtual void loadParams(const TiXmlElement* root = NULL);
33
34  /* controlling the emitter: interface */
35  void start();
36  void stop();
37  void tick(float dt);
38
39  void setSystem(ParticleSystem* system);
40  ParticleSystem* getSystem() const { return this->system; };
41
42  /* controlling the behavour: these can be used as Animation interfaces */
43  void setEmissionRate(float emissionRate);
44  void setInheritSpeed(float value);
45  void setSpread(float angle, float randomAngle = 0.0);
46  void setEmissionVelocity(float velocity, float randomVelocity = 0.0);
47  void setEmissionMomentum(float momentum, float randomMomentum = 0.0);
48
49  /** @returns the emissionRate */
50  inline float getEmissionRate() const { return this->emissionRate; };
51  /** @returns the inherit-speed-factor */
52  inline float getInheritSpeed() const { return this->inheritSpeed; };
53  /** @returns the SpreadAngle of the emitter */
54  inline float getSpread() const { return this->angle; };
55  /** @returns the EmissionVelocity of the emitter */
56  inline float getEmissionVelocity() const { return this->velocity; };
57  /** @returns the EmissionMomentum of this emitter */
58  inline float getEmissionMomentum() const { return this->momentum; };
59
60
61  void debug() const;
62
63protected:
64  virtual void emitParticles(unsigned int count) const = 0;
65
66protected:
67  float           inheritSpeed;      //!< How much speed the particle inherits from the Emitters speed.
68  float           angle;             //!< max angle from the direction of the emitter
69  float           randomAngle;       //!< random emission angle (angle +- angleRandom is the emitted angle.
70  float           velocity;          //!< the initial speed of a Particles.
71  float           randomVelocity;    //!< the random variation from the initial Speed.
72  float           momentum;          //!< The Initial spped of the Rotation.
73  float           momentumRandom;    //!< The random variation of the Momentum.
74
75private:
76  ParticleSystem* system;            //!< The ParticleSystem this Emitter Emits into.
77  float           saveTime;          //!< The time that was missing by the last Tick (otherwise there would be no emission when framefate is too big).
78  float           emissionRate;      //!< amount of particles per seconds emitted by emitter.
79};
80
81#endif /* _PARTICLE_EMITTER_H */
Note: See TracBrowser for help on using the repository browser.