Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 11, 2005, 12:55:48 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: setClassID implemented in all files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/particles/particle_emitter.cc

    r4496 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    3131   \brief standard constructor
    3232*/
    33 ParticleEmitter::ParticleEmitter(const Vector& direction, float angle, float emissionRate,
    34                   float velocity)
    35 {
     33ParticleEmitter::ParticleEmitter(const Vector& direction, float angle, float emissionRate,
     34                  float velocity)
     35{
     36  this->setClassID(CL_PARTICLE_EMITTER, "ParticleEmitter");
    3637  this->type = EMITTER_DOT;
    3738  this->emitterSize = 1.0;
     
    6465   removes the EmitterSystem from the ParticleEngine
    6566*/
    66 ParticleEmitter::~ParticleEmitter () 
     67ParticleEmitter::~ParticleEmitter ()
    6768{
    6869  ParticleEngine::getInstance()->removeEmitter(this);
     
    9192  LoadParam<ParticleEmitter>(root, "emission-velocity", this, &ParticleEmitter::setEmissionVelocity)
    9293    .describe("How fast the particles are emittet (their initial speed)");
    93  
     94
    9495  LoadParam<ParticleEmitter>(root, "spread", this, &ParticleEmitter::setSpread)
    9596    .describe("The angle the particles are emitted from (angle, deviation)");
     
    224225    float count = (dt+this->saveTime) * this->emissionRate;
    225226    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
    228229    if (likely(count > 0))
    229230      {
    230         Vector inheritVelocity = this->getVelocity() * this->inheritSpeed;
    231         for (int i = 0; i < count; i++)
    232           // emmits from EMITTER_DOT,
    233           {
    234             Vector randDir = Vector(rand()-RAND_MAX/2, rand()-RAND_MAX/2, rand()-RAND_MAX/2);
    235             randDir.normalize();
    236             randDir = (this->getAbsDir()*Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->direction);
    237             Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity;
    238 
    239             // this should spread the Particles evenly. if the Emitter is moved around quickly
    240             Vector equalSpread = this->getVelocity() * rand()/RAND_MAX * dt;
    241             Vector extension; // the Vector for different fields.
    242 
    243             if (this->type & 2)
    244               {
    245                 extension = Vector(this->emitterSize * ((float)rand()/RAND_MAX -.5), 0, this->emitterSize * ((float)rand()/RAND_MAX - .5));
    246                 extension = this->getAbsDir().apply(extension);
    247               }
    248             else if (this->type & 8)
    249               {
    250                 extension = Vector((float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5, (float)rand()/RAND_MAX -.5) * this->emitterSize;
    251               }
    252 
    253             system->addParticle(this->getAbsCoor() + extension - equalSpread, velocityV);
    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          }
    256257      }
    257258  }
Note: See TracChangeset for help on using the changeset viewer.