Changeset 4690 in orxonox.OLD for orxonox/trunk/src/lib
- Timestamp:
- Jun 24, 2005, 3:35:03 PM (19 years ago)
- Location:
- orxonox/trunk/src/lib/particles
- Files:
-
- 4 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 } -
orxonox/trunk/src/lib/particles/particle_emitter.h
r4639 r4690 46 46 void setSpread(float angle, float randomAngle = 0.0); 47 47 void setEmissionVelocity(float velocity, float randomVelocity = 0.0); 48 void setEmissionMomentum(float momentum, float randomMomentum = 0.0); 48 49 49 50 /** \returns the type of the emitter */ … … 61 62 /** \returns the EmissionVelocity of the emitter */ 62 63 inline float getEmissionVelocity(void) const { return this->velocity; }; 64 /** \returns the EmissionMomentum of this emitter */ 65 inline float getEmissionMomentum(void) const { return this->momentum; }; 63 66 64 67 void debug(void) const; 65 68 66 67 69 private: 68 EMITTER_TYPE type; //!< The type of emitter this is 69 float emitterSize; //!< The size of the emitter (not for EMITTER_DOT) 70 float inheritSpeed; //!< How much speed the particle inherits from the Emitters speed \todo move this to the emitter71 Vector direction; //!< emition direction 70 EMITTER_TYPE type; //!< The type of emitter this is. 71 float emitterSize; //!< The size of the emitter (not for EMITTER_DOT). 72 float inheritSpeed; //!< How much speed the particle inherits from the Emitters speed. 73 Vector direction; //!< emition direction. 72 74 float angle; //!< max angle from the direction of the emitter 73 75 float randomAngle; //!< random emission angle (angle +- angleRandom is the emitted angle. … … 75 77 float velocity; //!< the initial speed of a Particles. 76 78 float randomVelocity; //!< the random variation from the initial Speed. 79 float momentum; //!< The Initial spped of the Rotation. 80 float momentumRandom; //!< The random variation of the Momentum. 77 81 78 82 float saveTime; //!< The time that was missing by the last Tick (otherwise there would be no emission when framefate is too big). -
orxonox/trunk/src/lib/particles/particle_system.cc
r4687 r4690 485 485 /** 486 486 \brief adds a new Particle to the System 487 \param position the position where the particle gets emitted. 488 \param velocity the Starting velocity of the particle. 487 \param position the initial position, where the particle gets emitted. 488 \param velocity the initial velocity of the particle. 489 \param orientation the initial orientation of the Paritcle. 490 \param momentum the initial momentum of the Particle (the speed of its rotation). 489 491 \param data some more data given by the emitter 490 492 */ 491 void ParticleSystem::addParticle(const Vector& position, const Vector& velocity, unsigned int data)493 void ParticleSystem::addParticle(const Vector& position, const Vector& velocity, const Quaternion& orientation, const Quaternion& momentum, unsigned int data) 492 494 { 493 495 if (this->count <= this->maxCount) … … 530 532 particles->velocity = velocity; 531 533 532 particles->orientation = Quaternion(.4, velocity.getNormalized());533 particles->momentum = Quaternion(.4, velocity.getNormalized());534 particles->orientation = orientation; 535 particles->momentum = momentum; 534 536 535 537 // particle->rotation = ; //! \todo rotation is once again something to be done. -
orxonox/trunk/src/lib/particles/particle_system.h
r4687 r4690 109 109 virtual void tickPhys(float dt) {}; 110 110 111 void addParticle(const Vector& position, const Vector& velocity, unsigned int data = 0);111 void addParticle(const Vector& position, const Vector& velocity, const Quaternion& orientation, const Quaternion& momentum, unsigned int data = 0); 112 112 113 113 virtual void tick(float dt);
Note: See TracChangeset
for help on using the changeset viewer.