Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3933 in orxonox.OLD for orxonox/branches/particleEngine/src/lib


Ignore:
Timestamp:
Apr 23, 2005, 1:10:58 AM (20 years ago)
Author:
bensch
Message:

orxonox/branches/particleEngine: emitting 10000 particles a second …. without deleting anyone of them :)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/particleEngine/src/lib/graphics/particles/particle_emitter.cc

    r3932 r3933  
    3232   this->direction = direction;
    3333   this->setSpread(angle);
    34    this->emissionRate = emissionRate;
     34   this->setEmissionRate(emissionRate);
    3535   this->velocity = velocity;
    3636
     
    6767   \brief set the emission rate
    6868   \param sets the number of particles emitted per second
    69    \param random A random emissionRate, the +- randomness of this option
    7069
    7170   if you want to change the value of this variable during emission time (to make it more dynamic)
     
    7372*/
    7473void ParticleEmitter::setEmissionRate(float emissionRate)
    75 {}
     74{
     75  this->emissionRate = emissionRate;
     76}
    7677
    7778/**
     
    111112{
    112113  // saving the time
    113   float countF = (dt+this->saveTime) / emissionRate;
     114  float countF = (dt+this->saveTime) * this->emissionRate;
    114115  int count = (int)round(countF);
    115116  this->saveTime = countF - (float)count;
    116117
     118  printf( "%d::%f::emmit %f\n", count, countF, emissionRate);
     119
    117120  for (int i = 0; i <= count; i++)
    118121    // emmits from EMITTER_DOT,
    119     system->addParticle(this->getAbsCoor(), direction * velocity );
     122    {
     123      Vector randDir = Quaternion(Vector(random()-RAND_MAX/2, random()-RAND_MAX/2, random()-RAND_MAX/2), angle).apply(this->direction);
     124      randDir.normalize();
     125      system->addParticle(this->getAbsCoor(), randDir* velocity);
     126    }
    120127}
Note: See TracChangeset for help on using the changeset viewer.