Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jan 29, 2006, 2:20:46 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: BoxEmitter

File:
1 copied

Legend:

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

    r6822 r6823  
    1616#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS
    1717
    18 #include "dot_emitter.h"
     18#include "box_emitter.h"
    1919
    2020#include "particle_system.h"
     
    2828
    2929
    30 CREATE_FACTORY(DotEmitter, CL_DOT_EMITTER);
     30CREATE_FACTORY(BoxEmitter, CL_BOX_EMITTER);
    3131
    3232/**
    3333 *  standard constructor
    3434*/
    35 DotEmitter::DotEmitter(const Vector& direction, float angle, float emissionRate,
    36                        float velocity)
    37   : ParticleEmitter(direction, angle, emissionRate, velocity)
     35BoxEmitter::BoxEmitter(const Vector& size)
    3836{
    3937  this->init();
     38  this->setSize(size);
    4039}
    4140
    4241/**
    43  *  constructs and loads a DotEmitter from a XML-element
     42 *  constructs and loads a BoxEmitter from a XML-element
    4443 * @param root the XML-element to load from
    4544*/
    46 DotEmitter::DotEmitter(const TiXmlElement* root)
    47   : ParticleEmitter()
     45BoxEmitter::BoxEmitter(const TiXmlElement* root)
     46    : ParticleEmitter()
    4847{
    4948  this->init();
    5049
    51    if (root != NULL)
    52      this->loadParams(root);
     50  if (root != NULL)
     51    this->loadParams(root);
    5352}
    5453
     
    5857   removes the EmitterSystem from the ParticleEngine
    5958*/
    60 DotEmitter::~DotEmitter ()
     59BoxEmitter::~BoxEmitter ()
    6160{
    6261  this->setSystem(NULL);
     
    6665  @brief initializes default values of a ParitcleEmitter
    6766*/
    68 void DotEmitter::init()
     67void BoxEmitter::init()
    6968{
    70   this->setClassID(CL_DOT_EMITTER, "DotEmitter");
     69  this->setClassID(CL_BOX_EMITTER, "BoxEmitter");
     70  this->setSize(1.0f,1.0f,1.0f);
    7171}
    7272
    73 void DotEmitter::emitParticles(unsigned int count) const
     73void BoxEmitter::loadParams(const TiXmlElement* root)
     74{
     75  ParticleEmitter::loadParams(root);
     76
     77  LoadParam(root, "size", this, BoxEmitter, setSize)
     78  .describe("The Size of the BoxEmitter: x, y, z")
     79  .defaultValues(3, 1.0f,1.0f,1.0f);
     80}
     81
     82void BoxEmitter::emitParticles(unsigned int count) const
    7483{
    7584  Vector inheritVelocity = this->getVelocity() * this->inheritSpeed;
     
    8291    Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity;
    8392
     93    Vector extension = Vector(((float)rand()/RAND_MAX -.5)*this->size.x,
     94                              ((float)rand()/RAND_MAX -.5) *this->size.y,
     95                              ((float)rand()/RAND_MAX -.5) * this->size.z);
     96
     97
    8498    // ROTATIONAL CALCULATION (this must not be done for all types of particles.)
    8599    randDir = Vector(rand()-RAND_MAX/2, rand()-RAND_MAX/2, rand()-RAND_MAX/2);
     
    88102    Quaternion moment = Quaternion(this->momentum + this->momentumRandom, randDir);
    89103
    90     this->getSystem()->addParticle(this->getAbsCoor(), velocityV, orient, moment);
     104    this->getSystem()->addParticle(this->getAbsCoor() + extension, velocityV, orient, moment);
    91105
    92106  }
Note: See TracChangeset for help on using the changeset viewer.