Changeset 4597 in orxonox.OLD for orxonox/trunk/src/lib/particles/particle_emitter.cc
- Timestamp:
- Jun 11, 2005, 12:55:48 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/particles/particle_emitter.cc
r4496 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 31 31 \brief standard constructor 32 32 */ 33 ParticleEmitter::ParticleEmitter(const Vector& direction, float angle, float emissionRate, 34 float velocity) 35 { 33 ParticleEmitter::ParticleEmitter(const Vector& direction, float angle, float emissionRate, 34 float velocity) 35 { 36 this->setClassID(CL_PARTICLE_EMITTER, "ParticleEmitter"); 36 37 this->type = EMITTER_DOT; 37 38 this->emitterSize = 1.0; … … 64 65 removes the EmitterSystem from the ParticleEngine 65 66 */ 66 ParticleEmitter::~ParticleEmitter () 67 ParticleEmitter::~ParticleEmitter () 67 68 { 68 69 ParticleEngine::getInstance()->removeEmitter(this); … … 91 92 LoadParam<ParticleEmitter>(root, "emission-velocity", this, &ParticleEmitter::setEmissionVelocity) 92 93 .describe("How fast the particles are emittet (their initial speed)"); 93 94 94 95 LoadParam<ParticleEmitter>(root, "spread", this, &ParticleEmitter::setSpread) 95 96 .describe("The angle the particles are emitted from (angle, deviation)"); … … 224 225 float count = (dt+this->saveTime) * this->emissionRate; 225 226 this->saveTime = modff(count, &count) / this->emissionRate; 226 PRINTF(5)("emitting %f particles, saving %f seconds for the next round\n", count, this->saveTime); 227 227 PRINTF(5)("emitting %f particles, saving %f seconds for the next round\n", count, this->saveTime); 228 228 229 if (likely(count > 0)) 229 230 { 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 231 Vector inheritVelocity = this->getVelocity() * this->inheritSpeed; 232 for (int i = 0; i < count; i++) 233 // emmits from EMITTER_DOT, 234 { 235 Vector randDir = Vector(rand()-RAND_MAX/2, rand()-RAND_MAX/2, rand()-RAND_MAX/2); 236 randDir.normalize(); 237 randDir = (this->getAbsDir()*Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->direction); 238 Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity; 239 240 // this should spread the Particles evenly. if the Emitter is moved around quickly 241 Vector equalSpread = this->getVelocity() * rand()/RAND_MAX * dt; 242 Vector extension; // the Vector for different fields. 243 244 if (this->type & 2) 245 { 246 extension = Vector(this->emitterSize * ((float)rand()/RAND_MAX -.5), 0, this->emitterSize * ((float)rand()/RAND_MAX - .5)); 247 extension = this->getAbsDir().apply(extension); 248 } 249 else if (this->type & 8) 250 { 251 extension = Vector((float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5) * this->emitterSize; 252 } 253 254 system->addParticle(this->getAbsCoor() + extension - equalSpread, velocityV); 255 256 } 256 257 } 257 258 }
Note: See TracChangeset
for help on using the changeset viewer.