Changeset 4690 in orxonox.OLD for orxonox/trunk/src/lib/particles/particle_emitter.cc
- Timestamp:
- Jun 24, 2005, 3:35:03 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/particles/particle_emitter.cc
r4639 r4690 113 113 114 114 115 /* these are Animation interfaces: so you can change spec values as you want */116 115 117 116 /** … … 212 211 213 212 /** 214 \brief sets the velocity of all particles emitted213 \brief sets the initial velocity of all particles emitted 215 214 \param velocity The starting velocity of the emitted particles 216 215 \param randomVelocity A random starting velocity, the +- randomness of this option … … 223 222 this->velocity = velocity; 224 223 this->randomVelocity = randomVelocity; 224 } 225 226 /** 227 \brief sets the initial Momentum of all particles emitted 228 \param momentum the new Momentum (just a float for being not too complicated). 229 \param randomMomentum variation from the given value. 230 */ 231 void ParticleEmitter::setEmissionMomentum(float momentum, float randomMomentum) 232 { 233 this->momentum = momentum; 234 this->momentumRandom = randomMomentum; 225 235 } 226 236 … … 233 243 you may want to use the animation class 234 244 */ 235 236 245 void ParticleEmitter::tick(float dt, ParticleSystem* system) 237 246 { … … 244 253 245 254 if (likely(count > 0)) 255 { 256 Vector inheritVelocity = this->getVelocity() * this->inheritSpeed; 257 for (int i = 0; i < count; i++) 258 // emmits from EMITTER_DOT, 246 259 { 247 Vector inheritVelocity = this->getVelocity() * this->inheritSpeed; 248 for (int i = 0; i < count; i++) 249 // emmits from EMITTER_DOT, 250 { 251 Vector randDir = Vector(rand()-RAND_MAX/2, rand()-RAND_MAX/2, rand()-RAND_MAX/2); 252 randDir.normalize(); 253 randDir = (this->getAbsDir()*Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->direction); 254 Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity; 260 Vector randDir = Vector(rand()-RAND_MAX/2, rand()-RAND_MAX/2, rand()-RAND_MAX/2); 261 randDir.normalize(); 262 randDir = (this->getAbsDir()*Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->direction); 263 Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity; 255 264 256 265 // this should spread the Particles evenly. if the Emitter is moved around quickly 257 Vector equalSpread = this->getVelocity() * rand()/RAND_MAX * dt; 258 Vector extension; // the Vector for different fields. 259 260 if (this->type & 2) 261 { 262 extension = Vector(this->emitterSize * ((float)rand()/RAND_MAX -.5), 0, this->emitterSize * ((float)rand()/RAND_MAX - .5)); 263 extension = this->getAbsDir().apply(extension); 264 } 265 else if (this->type & 8) 266 { 267 extension = Vector((float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5) * this->emitterSize; 268 } 269 270 system->addParticle(this->getAbsCoor() + extension - equalSpread, velocityV); 271 272 } 266 Vector equalSpread = this->getVelocity() * rand()/RAND_MAX * dt; 267 Vector extension; // the Vector for different fields. 268 269 if (this->type & 2) 270 { 271 extension = Vector(this->emitterSize * ((float)rand()/RAND_MAX -.5), 0, this->emitterSize * ((float)rand()/RAND_MAX - .5)); 272 extension = this->getAbsDir().apply(extension); 273 } 274 else if (this->type & 8) 275 { 276 extension = Vector((float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5) * this->emitterSize; 277 } 278 279 280 // ROTATIONAL CALCULATION (this must not be done for all types of particles.) 281 randDir = Vector(rand()-RAND_MAX/2, rand()-RAND_MAX/2, rand()-RAND_MAX/2); 282 randDir.normalize(); 283 Quaternion orient = Quaternion(M_PI, randDir); 284 Quaternion moment = Quaternion(this->momentum + this->momentumRandom, randDir); 285 286 system->addParticle(this->getAbsCoor() + extension - equalSpread, velocityV, orient, moment); 287 273 288 } 289 } 274 290 } 275 291 }
Note: See TracChangeset
for help on using the changeset viewer.