Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/particles/particle_emitter.h @ 10683

Last change on this file since 10683 was 10658, checked in by bknecht, 18 years ago

changes from landauf

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