Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 4479 was 4478, checked in by bensch, 20 years ago

orxonox/trunk: particles documented

File size: 2.6 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
16typedef enum EMITTER_TYPE { EMITTER_DOT   = 1,
17                            EMITTER_PLANE = 2,
18                            EMITTER_SPHERE= 4,
19                            EMITTER_CUBE  = 8 };
20
21//! A class to handle an Emitter.
22class ParticleEmitter : public PNode {
23
24 public:
25  ParticleEmitter(const Vector& direction, float angle = .5,
26                  float emissionRate = 1.0, float velocity = 1.0);
27  ParticleEmitter(const TiXmlElement* root);
28  virtual ~ParticleEmitter(void);
29 
30  void loadParams(const TiXmlElement* root);
31
32  /* controlling the emitter: interface */
33  void start();
34  void stop();
35  void tick(float dt, ParticleSystem* system);
36
37  /* controlling the behavour: these can be used as Animation interfaces */
38  void setType(EMITTER_TYPE type);
39  void setType(const char* type);
40  void setSize(float emitterSize);
41  void setEmissionRate(float emissionRate);
42  void setSpread(float angle, float randomAngle = 0.0);
43  void setEmissionVelocity(float velocity, float randomVelocity = 0.0);
44
45  /** \returns the type of the emitter */
46  inline EMITTER_TYPE getType(void) const { return this->type; };
47  /** \returns the Size of the emitter */
48  inline float getSize(void) const { return this->emitterSize; };
49  /** \returns the emissionRate */
50  inline float getEmissionRate(void) const { return this->emissionRate; };
51  /** \returns the SpreadAngle of the emitter */
52  inline float getSpread(void) { return this->angle; };
53  /** \returns the EmissionVelocity of the emitter */
54  inline float getEmissionVelocity(void) { return this->velocity; };
55
56  void debug(void);
57
58
59 private:
60  EMITTER_TYPE    type;              //!< The type of emitter this is
61  float           emitterSize;       //!< The size of the emitter (not for EMITTER_DOT)
62  Vector          direction;         //!< emition direction
63  float           angle;             //!< max angle from the direction of the emitter
64  float           randomAngle;       //!< random emission angle (angle +- angleRandom is the emitted angle.
65  float           emissionRate;      //!< amount of particles per seconds emitted by emitter.
66  float           velocity;          //!< the initial speed of a Particles.
67  float           randomVelocity;    //!< the random variation from the initial Speed.
68
69  float           saveTime;          //!< The time that was missing by the last Tick (otherwise there would be no emission when framefate is too big).
70};
71
72#endif /* _PARTICLE_EMITTER_H */
Note: See TracBrowser for help on using the repository browser.