Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6823 was 6822, checked in by bensch, 20 years ago

trunk: ParticleEmitters now splitted into SubClasses.
Also fixed a little Boeg in the ClassID

File size: 3.2 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_INHERIT_SPEED     0.0
19#define PARTICLE_EMITTER_DEFAULT_SPREAD            M_PI
20
[4381]21//! A class to handle an Emitter.
[6619]22class ParticleEmitter : public PNode
23{
24  friend class ParticleSystem;
25public:
[6822]26  ParticleEmitter(const Vector& direction = Vector(1.0,0.0,0.0) , float angle = .5,
[4597]27                  float emissionRate = 1.0, float velocity = 1.0);
[4746]28  virtual ~ParticleEmitter();
[4597]29
[6822]30  virtual void loadParams(const TiXmlElement* root = NULL);
[3926]31
[3929]32  /* controlling the emitter: interface */
[3927]33  void start();
34  void stop();
[6620]35  void tick(float dt);
[3927]36
[6619]37  void setSystem(ParticleSystem* system);
38  ParticleSystem* getSystem() const { return this->system; };
39
[3929]40  /* controlling the behavour: these can be used as Animation interfaces */
[3931]41  void setEmissionRate(float emissionRate);
[4493]42  void setInheritSpeed(float value);
[3931]43  void setSpread(float angle, float randomAngle = 0.0);
[4338]44  void setEmissionVelocity(float velocity, float randomVelocity = 0.0);
[4690]45  void setEmissionMomentum(float momentum, float randomMomentum = 0.0);
[3929]46
[6822]47  void setDirection(float x, float y, float z) { this->direction = Vector(x,y,z); }; //!< todo this should be done via PNODE
[4726]48
[4836]49  /** @returns the emissionRate */
[4746]50  inline float getEmissionRate() const { return this->emissionRate; };
[4836]51  /** @returns the inherit-speed-factor */
[4746]52  inline float getInheritSpeed() const { return this->inheritSpeed; };
[4836]53  /** @returns the SpreadAngle of the emitter */
[4746]54  inline float getSpread() const { return this->angle; };
[4836]55  /** @returns the EmissionVelocity of the emitter */
[4746]56  inline float getEmissionVelocity() const { return this->velocity; };
[4836]57  /** @returns the EmissionMomentum of this emitter */
[4746]58  inline float getEmissionMomentum() const { return this->momentum; };
[4338]59
[6822]60  virtual void emitParticles(unsigned int count) const = 0;
61
[4746]62  void debug() const;
[3944]63
[6822]64protected:
[6619]65
[4690]66  float           inheritSpeed;      //!< How much speed the particle inherits from the Emitters speed.
67  Vector          direction;         //!< emition direction.
[4478]68  float           angle;             //!< max angle from the direction of the emitter
69  float           randomAngle;       //!< random emission angle (angle +- angleRandom is the emitted angle.
70  float           velocity;          //!< the initial speed of a Particles.
71  float           randomVelocity;    //!< the random variation from the initial Speed.
[4690]72  float           momentum;          //!< The Initial spped of the Rotation.
73  float           momentumRandom;    //!< The random variation of the Momentum.
[3932]74
[6822]75private:
76  ParticleSystem* system;            //!< The ParticleSystem this Emitter Emits into.
[4478]77  float           saveTime;          //!< The time that was missing by the last Tick (otherwise there would be no emission when framefate is too big).
[6822]78  float           emissionRate;      //!< amount of particles per seconds emitted by emitter.
[3926]79};
80
81#endif /* _PARTICLE_EMITTER_H */
Note: See TracBrowser for help on using the repository browser.