Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6873 in orxonox.OLD for trunk/src/lib/particles/plane_emitter.cc


Ignore:
Timestamp:
Jan 30, 2006, 10:43:00 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Emitter is emitting correctly

File:
1 copied

Legend:

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

    r6870 r6873  
    1616#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS
    1717
    18 #include "box_emitter.h"
     18#include "plane_emitter.h"
    1919
    2020#include "particle_system.h"
     
    2828
    2929
    30 CREATE_FACTORY(BoxEmitter, CL_BOX_EMITTER);
     30CREATE_FACTORY(PlaneEmitter, CL_PLANE_EMITTER);
    3131
    3232/**
    3333 *  standard constructor
    3434*/
    35 BoxEmitter::BoxEmitter(const Vector& size, float emissionRate, float velocity, float angle)
     35PlaneEmitter::PlaneEmitter(const Vector2D& size, float emissionRate, float velocity, float angle)
    3636    :  ParticleEmitter(emissionRate, velocity, angle)
    3737{
     
    4141
    4242/**
    43  *  constructs and loads a BoxEmitter from a XML-element
     43 *  constructs and loads a PlaneEmitter from a XML-element
    4444 * @param root the XML-element to load from
    4545*/
    46 BoxEmitter::BoxEmitter(const TiXmlElement* root)
     46PlaneEmitter::PlaneEmitter(const TiXmlElement* root)
    4747    : ParticleEmitter()
    4848{
     
    5858   removes the EmitterSystem from the ParticleEngine
    5959*/
    60 BoxEmitter::~BoxEmitter ()
     60PlaneEmitter::~PlaneEmitter ()
    6161{
    6262  this->setSystem(NULL);
     
    6666  @brief initializes default values of a ParitcleEmitter
    6767*/
    68 void BoxEmitter::init()
     68void PlaneEmitter::init()
    6969{
    70   this->setClassID(CL_BOX_EMITTER, "BoxEmitter");
    71   this->setSize(1.0f,1.0f,1.0f);
     70  this->setClassID(CL_PLANE_EMITTER, "PlaneEmitter");
     71  this->setSize(1.0f, 1.0f);
    7272}
    7373
    74 void BoxEmitter::loadParams(const TiXmlElement* root)
     74void PlaneEmitter::loadParams(const TiXmlElement* root)
    7575{
    7676  ParticleEmitter::loadParams(root);
    7777
    78   LoadParam(root, "size", this, BoxEmitter, setSize)
    79   .describe("The Size of the BoxEmitter: x, y, z")
    80   .defaultValues(3, 1.0f,1.0f,1.0f);
     78  LoadParam(root, "size", this, PlaneEmitter, setSize)
     79  .describe("The Size of the PlaneEmitter: x, y")
     80  .defaultValues(2, 1.0f,1.0f);
    8181}
    8282
    83 void BoxEmitter::setSize(float x, float y, float z)
     83void PlaneEmitter::setSize(float x, float y)
    8484{
    85   this->size = Vector (x,y,z);
     85  this->size = Vector2D(x, y);
    8686}
    8787
    8888
    89 void BoxEmitter::emitParticles(unsigned int count) const
     89void PlaneEmitter::emitParticles(unsigned int count) const
    9090{
    9191  Vector inheritVelocity = this->getVelocity() * this->inheritSpeed;
    9292
    9393  Vector xDir = this->getAbsDirX() * this->size.x;
    94   Vector yDir = this->getAbsDirY() * this->size.y;
    95   Vector zDir = this->getAbsDirZ() * this->size.z;
     94  Vector yDir = this->getAbsDirZ() * this->size.y;
     95  Vector zDir = this->getAbsDirY();
    9696
    9797  for (unsigned int i = 0; i < count; i++)
     
    9999    Vector randDir = Vector(rand()-RAND_MAX/2, rand()-RAND_MAX/2, rand()-RAND_MAX/2);
    100100    randDir.normalize();
    101     randDir = (Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->getAbsDirX());
     101    randDir = (Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(zDir);
    102102    Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity;
    103103
    104     Vector box = this->getAbsCoor() +
     104    Vector plane = this->getAbsCoor() +
    105105        xDir * ((float)rand()/RAND_MAX -.5) +
    106         yDir * ((float)rand()/RAND_MAX -.5) +
    107         zDir * ((float)rand()/RAND_MAX -.5);
     106        yDir * ((float)rand()/RAND_MAX -.5);
    108107
    109108    // ROTATIONAL CALCULATION (this must not be done for all types of particles.)
     
    113112    Quaternion moment = Quaternion(this->momentum + this->momentumRandom, randDir);
    114113
    115     this->getSystem()->addParticle(box, velocityV, orient, moment);
     114    this->getSystem()->addParticle(plane, velocityV, orient, moment);
    116115
    117116  }
Note: See TracChangeset for help on using the changeset viewer.