Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/collision_detection/src/lib/particles/particle_emitter.h @ 6782

Last change on this file since 6782 was 5405, checked in by bensch, 19 years ago

orxonox/trunk: renamed definition to the right term declaration…

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