Changeset 6822 in orxonox.OLD for trunk/src/lib/particles/dot_emitter.h
- Timestamp:
- Jan 29, 2006, 1:57:03 AM (19 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/particles/dot_emitter.h
r6820 r6822 1 1 /*! 2 * @file particle_emitter.h3 * Definition of a ParticleEmitter4 */2 * @file dot_emitter.h 3 * Definition of a DotEmitter 4 */ 5 5 6 #ifndef _ PARTICLE_EMITTER_H7 #define _ PARTICLE_EMITTER_H6 #ifndef _DOT_EMITTER_H 7 #define _DOT_EMITTER_H 8 8 9 #include "p_node.h" 10 11 // FORWARD DECLARATION 12 class ParticleSystem; 13 class TiXmlElement; 9 #include "particle_emitter.h" 14 10 15 11 // 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 }; 12 #define DOT_EMITTER_DEFAULT_SIZE 1.0 30 13 31 14 //! A class to handle an Emitter. 32 class ParticleEmitter : public PNode15 class DotEmitter : public ParticleEmitter 33 16 { 34 17 friend class ParticleSystem; 35 18 public: 36 ParticleEmitter(const Vector& direction, float angle = .5,37 38 ParticleEmitter(const TiXmlElement* root);39 virtual ~ ParticleEmitter();19 DotEmitter(const Vector& direction, float angle = .5, 20 float emissionRate = 1.0, float velocity = 1.0); 21 DotEmitter(const TiXmlElement* root); 22 virtual ~DotEmitter(); 40 23 41 void init();42 virtual void loadParams(const TiXmlElement* root);43 24 44 25 /* controlling the emitter: interface */ 45 void start();46 void stop();47 26 void tick(float dt); 48 27 49 void setSystem(ParticleSystem* system); 50 ParticleSystem* getSystem() const { return this->system; }; 51 52 /* controlling the behavour: these can be used as Animation interfaces */ 53 void setType(EMITTER_TYPE type); 54 void setType(const char* type); 55 void setSize(float emitterSize); 56 void setEmissionRate(float emissionRate); 57 void setInheritSpeed(float value); 58 void setSpread(float angle, float randomAngle = 0.0); 59 void setEmissionVelocity(float velocity, float randomVelocity = 0.0); 60 void setEmissionMomentum(float momentum, float randomMomentum = 0.0); 61 62 void setDirection(float x, float y, float z) { this->direction = Vector(x,y,z); } 63 ; //!< todo this should be done via PNODE 64 65 /** @returns the type of the emitter */ 66 inline EMITTER_TYPE getType() const { return this->type; }; 67 /** @returns the Type as a const char * */ 68 const char* getTypeC() const; 69 /** @returns the Size of the emitter */ 70 inline float getSize() const { return this->emitterSize; }; 71 /** @returns the emissionRate */ 72 inline float getEmissionRate() const { return this->emissionRate; }; 73 /** @returns the inherit-speed-factor */ 74 inline float getInheritSpeed() const { return this->inheritSpeed; }; 75 /** @returns the SpreadAngle of the emitter */ 76 inline float getSpread() const { return this->angle; }; 77 /** @returns the EmissionVelocity of the emitter */ 78 inline float getEmissionVelocity() const { return this->velocity; }; 79 /** @returns the EmissionMomentum of this emitter */ 80 inline float getEmissionMomentum() const { return this->momentum; }; 81 82 void debug() const; 83 28 virtual void emitParticles(unsigned int count) const; 84 29 85 30 private: 86 ParticleSystem* system; //!< The ParticleSystem this Emitter Emits into.31 void init(); 87 32 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. 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. 97 float momentum; //!< The Initial spped of the Rotation. 98 float momentumRandom; //!< The random variation of the Momentum. 33 private: 34 Vector emitterSize; //!< The size of the emitter (not for EMITTER_DOT). 99 35 100 float saveTime; //!< The time that was missing by the last Tick (otherwise there would be no emission when framefate is too big).101 36 }; 102 37 103 #endif /* _ PARTICLE_EMITTER_H */38 #endif /* _DOT_EMITTER_H */
Note: See TracChangeset
for help on using the changeset viewer.