Changeset 4338 in orxonox.OLD for orxonox/trunk/src/lib/graphics/particles/particle_emitter.cc
- Timestamp:
- May 27, 2005, 9:16:53 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/particles/particle_emitter.cc
r4320 r4338 31 31 { 32 32 this->setClassID(CL_PARTICLE_EMITTER, "ParticleEmitter"); 33 34 this->type = EMITTER_DOT; 35 this->emitterSize = 1.0; 33 36 this->direction = direction; 34 37 this->setSpread(angle); 35 38 this->setEmissionRate(emissionRate); 36 this->set Velocity(velocity);39 this->setEmissionVelocity(velocity); 37 40 38 41 this->saveTime = 0.0; … … 50 53 { 51 54 ParticleEngine::getInstance()->removeEmitter(this); 52 53 55 } 54 56 … … 71 73 72 74 /** 75 \param type the new Type of this emitter 76 */ 77 void ParticleEmitter::setType(EMITTER_TYPE type) 78 { 79 this->type = type; 80 } 81 82 void ParticleEmitter::setSize(float emitterSize) 83 { 84 if (emitterSize > 0.0) 85 this->emitterSize = emitterSize; 86 else 87 emitterSize = 0.0; 88 } 89 90 /** 73 91 \brief set the emission rate 74 92 \param sets the number of particles emitted per second … … 79 97 void ParticleEmitter::setEmissionRate(float emissionRate) 80 98 { 81 this->emissionRate = emissionRate; 99 if (emissionRate > 0.0) 100 this->emissionRate = emissionRate; 101 else 102 this->emissionRate = 0.0; 82 103 } 83 104 … … 104 125 you may want to use the animation class 105 126 */ 106 void ParticleEmitter::set Velocity(float velocity, float randomVelocity)127 void ParticleEmitter::setEmissionVelocity(float velocity, float randomVelocity) 107 128 { 108 129 this->velocity = velocity; … … 139 160 140 161 // this should spread the Particles evenly. if the Emitter is moved around quickly 141 Vector equalSpread = this->getVelocity() * random()/RAND_MAX * dt; 162 Vector equalSpread = this->getVelocity() * rand()/RAND_MAX * dt; 163 Vector extension; // the Vector for different fields. 142 164 143 system->addParticle(this->getAbsCoor() - equalSpread, velocityV); 165 if (this->type & 2) 166 { 167 extension = Vector(this->emitterSize * ((float)rand()/RAND_MAX -.5), 0, this->emitterSize * ((float)rand()/RAND_MAX - .5)); 168 extension = this->getAbsDir().apply(extension); 169 } 170 else if (this->type & 8) 171 { 172 extension = Vector((float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5) * this->emitterSize; 173 } 174 175 system->addParticle(this->getAbsCoor() + extension - equalSpread, velocityV); 176 144 177 } 145 178 }
Note: See TracChangeset
for help on using the changeset viewer.