Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: more momentum implementation in particles

File size: 3.3 KB
Line 
1/*!
2    \file particle_emitter.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
12class ParticleSystem;
13class TiXmlElement;
14
15//! The form of the Emitter to emit from
16  typedef enum EMITTER_TYPE
17{
18  EMITTER_DOT     = 1,
19  EMITTER_PLANE   = 2,
20  EMITTER_SPHERE  = 4,
21  EMITTER_CUBE    = 8
22};
23
24//! A class to handle an Emitter.
25class ParticleEmitter : public PNode {
26
27 public:
28  ParticleEmitter(const Vector& direction, float angle = .5,
29                  float emissionRate = 1.0, float velocity = 1.0);
30  ParticleEmitter(const TiXmlElement* root);
31  virtual ~ParticleEmitter(void);
32
33  void loadParams(const TiXmlElement* root);
34
35  /* controlling the emitter: interface */
36  void start();
37  void stop();
38  void tick(float dt, ParticleSystem* system);
39
40  /* controlling the behavour: these can be used as Animation interfaces */
41  void setType(EMITTER_TYPE type);
42  void setType(const char* type);
43  void setSize(float emitterSize);
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
50  /** \returns the type of the emitter */
51  inline EMITTER_TYPE getType(void) const { return this->type; };
52  /** \returns the Type as a const char * */
53  const char* getTypeC(void) const;
54  /** \returns the Size of the emitter */
55  inline float getSize(void) const { return this->emitterSize; };
56  /** \returns the emissionRate */
57  inline float getEmissionRate(void) const { return this->emissionRate; };
58  /** \returns the inherit-speed-factor */
59  inline float getInheritSpeed(void) const { return this->inheritSpeed; };
60  /** \returns the SpreadAngle of the emitter */
61  inline float getSpread(void) const { return this->angle; };
62  /** \returns the EmissionVelocity of the emitter */
63  inline float getEmissionVelocity(void) const { return this->velocity; };
64  /** \returns the EmissionMomentum of this emitter */
65  inline float getEmissionMomentum(void) const { return this->momentum; };
66
67  void debug(void) const;
68
69 private:
70  EMITTER_TYPE    type;              //!< The type of emitter this is.
71  float           emitterSize;       //!< The size of the emitter (not for EMITTER_DOT).
72  float           inheritSpeed;      //!< How much speed the particle inherits from the Emitters speed.
73  Vector          direction;         //!< emition direction.
74  float           angle;             //!< max angle from the direction of the emitter
75  float           randomAngle;       //!< random emission angle (angle +- angleRandom is the emitted angle.
76  float           emissionRate;      //!< amount of particles per seconds emitted by emitter.
77  float           velocity;          //!< the initial speed of a Particles.
78  float           randomVelocity;    //!< the random variation from the initial Speed.
79  float           momentum;          //!< The Initial spped of the Rotation.
80  float           momentumRandom;    //!< The random variation of the Momentum.
81
82  float           saveTime;          //!< The time that was missing by the last Tick (otherwise there would be no emission when framefate is too big).
83};
84
85#endif /* _PARTICLE_EMITTER_H */
Note: See TracBrowser for help on using the repository browser.