Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/particles/particle_emitter.h @ 6694

Last change on this file since 6694 was 6620, checked in by bensch, 19 years ago

trunk: particle-optimisation

File size: 3.9 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_TYPE              EMITTER_DOT
19#define PARTICLE_EMITTER_DEFAULT_INHERIT_SPEED     0.0
20#define PARTICLE_EMITTER_DEFAULT_SPREAD            M_PI
21
22//! The form of the Emitter to emit from
23typedef enum EMITTER_TYPE
24{
25  EMITTER_DOT     = 1,
26  EMITTER_PLANE   = 2,
27  EMITTER_SPHERE  = 4,
28  EMITTER_CUBE    = 8
29};
30
31//! A class to handle an Emitter.
32class ParticleEmitter : public PNode
33{
34  friend class ParticleSystem;
35public:
36  ParticleEmitter(const Vector& direction, float angle = .5,
37                  float emissionRate = 1.0, float velocity = 1.0);
38  ParticleEmitter(const TiXmlElement* root);
39  virtual ~ParticleEmitter();
40
41  void init();
42  virtual void loadParams(const TiXmlElement* root);
43
44  /* controlling the emitter: interface */
45  void start();
46  void stop();
47  void tick(float dt);
48
49  void setSystem(ParticleSystem* system);
50  ParticleSystem* getSystem() const { return this->system; };
51
52  /* controlling the behavour: these can be used as Animation interfaces */
53  void setType(EMITTER_TYPE type);
54  void setType(const char* type);
55  void setSize(float emitterSize);
56  void setEmissionRate(float emissionRate);
57  void setInheritSpeed(float value);
58  void setSpread(float angle, float randomAngle = 0.0);
59  void setEmissionVelocity(float velocity, float randomVelocity = 0.0);
60  void setEmissionMomentum(float momentum, float randomMomentum = 0.0);
61
62  void setDirection(float x, float y, float z) { this->direction = Vector(x,y,z); }
63  ; //!< todo this should be done via PNODE
64
65  /** @returns the type of the emitter */
66  inline EMITTER_TYPE getType() const { return this->type; };
67  /** @returns the Type as a const char * */
68  const char* getTypeC() const;
69  /** @returns the Size of the emitter */
70  inline float getSize() const { return this->emitterSize; };
71  /** @returns the emissionRate */
72  inline float getEmissionRate() const { return this->emissionRate; };
73  /** @returns the inherit-speed-factor */
74  inline float getInheritSpeed() const { return this->inheritSpeed; };
75  /** @returns the SpreadAngle of the emitter */
76  inline float getSpread() const { return this->angle; };
77  /** @returns the EmissionVelocity of the emitter */
78  inline float getEmissionVelocity() const { return this->velocity; };
79  /** @returns the EmissionMomentum of this emitter */
80  inline float getEmissionMomentum() const { return this->momentum; };
81
82  void debug() const;
83
84
85private:
86  ParticleSystem* system;            //!< The ParticleSystem this Emitter Emits into.
87
88  EMITTER_TYPE    type;              //!< The type of emitter this is.
89  float           emitterSize;       //!< The size of the emitter (not for EMITTER_DOT).
90  float           inheritSpeed;      //!< How much speed the particle inherits from the Emitters speed.
91  Vector          direction;         //!< emition direction.
92  float           angle;             //!< max angle from the direction of the emitter
93  float           randomAngle;       //!< random emission angle (angle +- angleRandom is the emitted angle.
94  float           emissionRate;      //!< amount of particles per seconds emitted by emitter.
95  float           velocity;          //!< the initial speed of a Particles.
96  float           randomVelocity;    //!< the random variation from the initial Speed.
97  float           momentum;          //!< The Initial spped of the Rotation.
98  float           momentumRandom;    //!< The random variation of the Momentum.
99
100  float           saveTime;          //!< The time that was missing by the last Tick (otherwise there would be no emission when framefate is too big).
101};
102
103#endif /* _PARTICLE_EMITTER_H */
Note: See TracBrowser for help on using the repository browser.