Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6826 in orxonox.OLD for trunk/src/lib/particles/box_emitter.cc


Ignore:
Timestamp:
Jan 29, 2006, 1:35:43 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: ok, the Cube Emitter works

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/particles/box_emitter.cc

    r6825 r6826  
    8181}
    8282
     83void BoxEmitter::setSize(float x, float y, float z)
     84{
     85  this->size = Vector (x,y,z);
     86}
     87
     88
    8389void BoxEmitter::emitParticles(unsigned int count) const
    8490{
    8591  Vector inheritVelocity = this->getVelocity() * this->inheritSpeed;
     92
     93  Vector xDir = this->getAbsDirX() * this->size.x;
     94  Vector yDir = this->getAbsDirY() * this->size.y;
     95  Vector zDir = this->getAbsDirZ() * this->size.z;
    8696
    8797  for (unsigned int i = 0; i < count; i++)
     
    92102    Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity;
    93103
    94     Vector extension = Vector(((float)rand()/RAND_MAX -.5)*this->size.x,
    95                               ((float)rand()/RAND_MAX -.5) *this->size.y,
    96                               ((float)rand()/RAND_MAX -.5) * this->size.z);
    97 
     104    Vector box = this->getAbsCoor() +
     105        xDir * ((float)rand()/RAND_MAX -.5) +
     106        yDir * ((float)rand()/RAND_MAX -.5) +
     107        zDir * ((float)rand()/RAND_MAX -.5);
    98108
    99109    // ROTATIONAL CALCULATION (this must not be done for all types of particles.)
     
    103113    Quaternion moment = Quaternion(this->momentum + this->momentumRandom, randDir);
    104114
    105     this->getSystem()->addParticle(this->getAbsCoor() + extension, velocityV, orient, moment);
     115    this->getSystem()->addParticle(box, velocityV, orient, moment);
    106116
    107117  }
Note: See TracChangeset for help on using the changeset viewer.