Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

trunk: particle-optimisation

File size: 3.9 KB
RevLine 
[4597]1/*!
[5039]2 * @file particle_emitter.h
[4836]3  *  Definition of a ParticleEmitter
[3926]4*/
5
6#ifndef _PARTICLE_EMITTER_H
7#define _PARTICLE_EMITTER_H
8
9#include "p_node.h"
10
[5405]11// FORWARD DECLARATION
[3926]12class ParticleSystem;
[4437]13class TiXmlElement;
[3926]14
[4726]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
[4338]22//! The form of the Emitter to emit from
[6619]23typedef enum EMITTER_TYPE
[4597]24{
25  EMITTER_DOT     = 1,
26  EMITTER_PLANE   = 2,
27  EMITTER_SPHERE  = 4,
28  EMITTER_CUBE    = 8
29};
[3926]30
[4381]31//! A class to handle an Emitter.
[6619]32class ParticleEmitter : public PNode
33{
34  friend class ParticleSystem;
35public:
[4176]36  ParticleEmitter(const Vector& direction, float angle = .5,
[4597]37                  float emissionRate = 1.0, float velocity = 1.0);
[4437]38  ParticleEmitter(const TiXmlElement* root);
[4746]39  virtual ~ParticleEmitter();
[4597]40
[4726]41  void init();
[6512]42  virtual void loadParams(const TiXmlElement* root);
[3926]43
[3929]44  /* controlling the emitter: interface */
[3927]45  void start();
46  void stop();
[6620]47  void tick(float dt);
[3927]48
[6619]49  void setSystem(ParticleSystem* system);
50  ParticleSystem* getSystem() const { return this->system; };
51
[3929]52  /* controlling the behavour: these can be used as Animation interfaces */
[4338]53  void setType(EMITTER_TYPE type);
[4437]54  void setType(const char* type);
[4338]55  void setSize(float emitterSize);
[3931]56  void setEmissionRate(float emissionRate);
[4493]57  void setInheritSpeed(float value);
[3931]58  void setSpread(float angle, float randomAngle = 0.0);
[4338]59  void setEmissionVelocity(float velocity, float randomVelocity = 0.0);
[4690]60  void setEmissionMomentum(float momentum, float randomMomentum = 0.0);
[3929]61
[6619]62  void setDirection(float x, float y, float z) { this->direction = Vector(x,y,z); }
63  ; //!< todo this should be done via PNODE
[4726]64
[4836]65  /** @returns the type of the emitter */
[4746]66  inline EMITTER_TYPE getType() const { return this->type; };
[4836]67  /** @returns the Type as a const char * */
[4746]68  const char* getTypeC() const;
[4836]69  /** @returns the Size of the emitter */
[4746]70  inline float getSize() const { return this->emitterSize; };
[4836]71  /** @returns the emissionRate */
[4746]72  inline float getEmissionRate() const { return this->emissionRate; };
[4836]73  /** @returns the inherit-speed-factor */
[4746]74  inline float getInheritSpeed() const { return this->inheritSpeed; };
[4836]75  /** @returns the SpreadAngle of the emitter */
[4746]76  inline float getSpread() const { return this->angle; };
[4836]77  /** @returns the EmissionVelocity of the emitter */
[4746]78  inline float getEmissionVelocity() const { return this->velocity; };
[4836]79  /** @returns the EmissionMomentum of this emitter */
[4746]80  inline float getEmissionMomentum() const { return this->momentum; };
[4338]81
[4746]82  void debug() const;
[3944]83
[6619]84
85private:
86  ParticleSystem* system;            //!< The ParticleSystem this Emitter Emits into.
87
[4690]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.
[4478]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.
[4690]97  float           momentum;          //!< The Initial spped of the Rotation.
98  float           momentumRandom;    //!< The random variation of the Momentum.
[3932]99
[4478]100  float           saveTime;          //!< The time that was missing by the last Tick (otherwise there would be no emission when framefate is too big).
[3926]101};
102
103#endif /* _PARTICLE_EMITTER_H */
Note: See TracBrowser for help on using the repository browser.