- Timestamp:
- Jan 29, 2006, 1:07:01 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/particles/box_emitter.cc
r6823 r6825 33 33 * standard constructor 34 34 */ 35 BoxEmitter::BoxEmitter(const Vector& size) 35 BoxEmitter::BoxEmitter(const Vector& size, float emissionRate, float velocity, float angle) 36 : ParticleEmitter(emissionRate, velocity, angle) 36 37 { 37 38 this->init(); … … 88 89 Vector randDir = Vector(rand()-RAND_MAX/2, rand()-RAND_MAX/2, rand()-RAND_MAX/2); 89 90 randDir.normalize(); 90 randDir = ( this->getAbsDir()*Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->direction);91 randDir = (Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->getAbsDirX()); 91 92 Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity; 92 93 -
trunk/src/lib/particles/box_emitter.h
r6823 r6825 9 9 #include "particle_emitter.h" 10 10 11 #define BOX_EMITTER_DEFAULT_SIZE Vector(1.0f, 1.0f, 1.0f) 12 11 13 //! A class to handle an Emitter. 12 14 class BoxEmitter : public ParticleEmitter … … 14 16 friend class ParticleSystem; 15 17 public: 16 BoxEmitter(const Vector& size); 18 BoxEmitter(const Vector& size = BOX_EMITTER_DEFAULT_SIZE, 19 float emissionRate = PARTICLE_EMITTER_DEFAULT_EMISSION_RATE, 20 float velocity = PARTICLE_EMITTER_DEFAULT_VELOCITY, 21 float angle = PARTICLE_EMITTER_DEFAULT_SPREAD); 17 22 BoxEmitter(const TiXmlElement* root); 18 23 virtual ~BoxEmitter(); … … 23 28 void setSize(const Vector& size) { this->setSize(size.x, size.y, size.z); }; 24 29 30 protected: 25 31 virtual void emitParticles(unsigned int count) const; 26 32 -
trunk/src/lib/particles/dot_emitter.cc
r6822 r6825 33 33 * standard constructor 34 34 */ 35 DotEmitter::DotEmitter(const Vector& direction, float angle, float emissionRate, 36 float velocity) 37 : ParticleEmitter(direction, angle, emissionRate, velocity) 35 DotEmitter::DotEmitter(float emissionRate, float velocity, float angle) 36 : ParticleEmitter( emissionRate, velocity, angle) 38 37 { 39 38 this->init(); … … 79 78 Vector randDir = Vector(rand()-RAND_MAX/2, rand()-RAND_MAX/2, rand()-RAND_MAX/2); 80 79 randDir.normalize(); 81 randDir = ( this->getAbsDir()*Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->direction);80 randDir = (Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->getAbsDirX()); 82 81 Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity; 83 82 -
trunk/src/lib/particles/dot_emitter.h
r6823 r6825 14 14 friend class ParticleSystem; 15 15 public: 16 DotEmitter(const Vector& direction, float angle = .5, 17 float emissionRate = 1.0, float velocity = 1.0); 16 DotEmitter(float emissionRate = 1.0, float velocity = 1.0, float angle = .5); 18 17 DotEmitter(const TiXmlElement* root); 19 18 virtual ~DotEmitter(); 20 19 21 20 protected: 22 21 virtual void emitParticles(unsigned int count) const; 23 22 -
trunk/src/lib/particles/particle_emitter.cc
r6822 r6825 29 29 * standard constructor 30 30 */ 31 ParticleEmitter::ParticleEmitter(const Vector& direction, float angle, float emissionRate, 32 float velocity) 31 ParticleEmitter::ParticleEmitter(float emissionRate, float velocity, float angle) 33 32 { 34 33 this->setClassID(CL_PARTICLE_EMITTER, "ParticleEmitter"); … … 38 37 this->setInheritSpeed(PARTICLE_EMITTER_DEFAULT_INHERIT_SPEED); 39 38 this->setEmissionMomentum(0); 40 this->direction = direction;41 39 this->setSpread(angle); 42 40 this->setEmissionRate(emissionRate); … … 78 76 LoadParam(root, "spread", this, ParticleEmitter, setSpread) 79 77 .describe("The angle the particles are emitted from (angle, deviation)"); 80 81 82 LoadParam(root, "emission-direction", this, ParticleEmitter, setDirection);83 78 } 84 79 -
trunk/src/lib/particles/particle_emitter.h
r6822 r6825 18 18 #define PARTICLE_EMITTER_DEFAULT_INHERIT_SPEED 0.0 19 19 #define PARTICLE_EMITTER_DEFAULT_SPREAD M_PI 20 #define PARTICLE_EMITTER_DEFAULT_VELOCITY 1.0 20 21 21 22 //! A class to handle an Emitter. … … 24 25 friend class ParticleSystem; 25 26 public: 26 ParticleEmitter(const Vector& direction = Vector(1.0,0.0,0.0) , float angle = .5, 27 float emissionRate = 1.0, float velocity = 1.0); 27 ParticleEmitter(float emissionRate = PARTICLE_EMITTER_DEFAULT_EMISSION_RATE, 28 float velocity = PARTICLE_EMITTER_DEFAULT_VELOCITY, 29 float angle = PARTICLE_EMITTER_DEFAULT_SPREAD); 28 30 virtual ~ParticleEmitter(); 29 31 … … 45 47 void setEmissionMomentum(float momentum, float randomMomentum = 0.0); 46 48 47 void setDirection(float x, float y, float z) { this->direction = Vector(x,y,z); }; //!< todo this should be done via PNODE48 49 49 /** @returns the emissionRate */ 50 50 inline float getEmissionRate() const { return this->emissionRate; }; … … 58 58 inline float getEmissionMomentum() const { return this->momentum; }; 59 59 60 virtual void emitParticles(unsigned int count) const = 0;61 60 62 61 void debug() const; 63 62 64 63 protected: 64 virtual void emitParticles(unsigned int count) const = 0; 65 65 66 protected: 66 67 float inheritSpeed; //!< How much speed the particle inherits from the Emitters speed. 67 Vector direction; //!< emition direction.68 68 float angle; //!< max angle from the direction of the emitter 69 69 float randomAngle; //!< random emission angle (angle +- angleRandom is the emitted angle. -
trunk/src/world_entities/projectiles/bomb.cc
r6822 r6825 50 50 this->lifeSpan = 15; 51 51 52 this->emitter = new DotEmitter( Vector(0,1,0), M_2_PI, 100, 5);52 this->emitter = new DotEmitter(100, 5, M_2_PI); 53 53 this->emitter->setParent(this); 54 54 this->emitter->setSpread(M_PI, M_PI); -
trunk/src/world_entities/projectiles/guided_missile.cc
r6822 r6825 46 46 this->maxVelocity = 75; 47 47 48 this->emitter = new DotEmitter( Vector(0,1,0), M_2_PI, 100, 5);48 this->emitter = new DotEmitter(100, 5, M_2_PI); 49 49 this->emitter->setParent(this); 50 50 this->emitter->setSpread(M_PI, M_PI); -
trunk/src/world_entities/projectiles/hyperblast.cc
r6822 r6825 47 47 this->size = 4.0; 48 48 49 this->emitter = new DotEmitter( Vector(0,1,0), M_2_PI, 100, 5);49 this->emitter = new DotEmitter(100, 5, M_2_PI); 50 50 this->emitter->setParent(this); 51 51 this->emitter->setSpread(M_PI, M_PI); -
trunk/src/world_entities/projectiles/laser.cc
r6822 r6825 48 48 this->lifeSpan = 5.0; 49 49 50 this->emitter = new DotEmitter( Vector(0,1,0), M_2_PI, 100, 5);50 this->emitter = new DotEmitter(100, 5, M_2_PI); 51 51 this->emitter->setParent(this); 52 52 this->emitter->setSpread(M_PI, M_PI); -
trunk/src/world_entities/projectiles/rocket.cc
r6822 r6825 45 45 this->lifeSpan = 5; 46 46 47 this->emitter = new DotEmitter( Vector(0,1,0), M_2_PI, 100, 5);47 this->emitter = new DotEmitter(100, 5, M_2_PI); 48 48 this->emitter->setParent(this); 49 49 this->emitter->setSpread(M_PI, M_PI); -
trunk/src/world_entities/projectiles/test_bullet.cc
r6822 r6825 45 45 this->lifeSpan = 2; 46 46 47 this->emitter = new DotEmitter( Vector(0,1,0), M_2_PI, 100, 5);47 this->emitter = new DotEmitter(100, 5, M_2_PI); 48 48 this->emitter->setParent(this); 49 49 this->emitter->setSpread(M_PI, M_PI); -
trunk/src/world_entities/space_ships/space_ship.cc
r6822 r6825 205 205 dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false); 206 206 207 this->burstEmitter = new DotEmitter( Vector(1,0,0), .01, 200, 0.0);207 this->burstEmitter = new DotEmitter(200, 0.0, .01); 208 208 this->burstEmitter->setParent(this); 209 209 this->burstEmitter->setRelCoor(-1, .5, 0);
Note: See TracChangeset
for help on using the changeset viewer.