Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6825 in orxonox.OLD for trunk/src/lib/particles


Ignore:
Timestamp:
Jan 29, 2006, 1:07:01 PM (19 years ago)
Author:
bensch
Message:

trunk: new interface to ParticleEmitters

Location:
trunk/src/lib/particles
Files:
6 edited

Legend:

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

    r6823 r6825  
    3333 *  standard constructor
    3434*/
    35 BoxEmitter::BoxEmitter(const Vector& size)
     35BoxEmitter::BoxEmitter(const Vector& size, float emissionRate, float velocity, float angle)
     36    :  ParticleEmitter(emissionRate, velocity, angle)
    3637{
    3738  this->init();
     
    8889    Vector randDir = Vector(rand()-RAND_MAX/2, rand()-RAND_MAX/2, rand()-RAND_MAX/2);
    8990    randDir.normalize();
    90     randDir = (this->getAbsDir()*Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->direction);
     91    randDir = (Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->getAbsDirX());
    9192    Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity;
    9293
  • trunk/src/lib/particles/box_emitter.h

    r6823 r6825  
    99#include "particle_emitter.h"
    1010
     11#define BOX_EMITTER_DEFAULT_SIZE Vector(1.0f, 1.0f, 1.0f)
     12
    1113//! A class to handle an Emitter.
    1214class BoxEmitter : public ParticleEmitter
     
    1416  friend class ParticleSystem;
    1517public:
    16   BoxEmitter(const Vector& size);
     18  BoxEmitter(const Vector& size = BOX_EMITTER_DEFAULT_SIZE,
     19             float emissionRate = PARTICLE_EMITTER_DEFAULT_EMISSION_RATE,
     20             float velocity = PARTICLE_EMITTER_DEFAULT_VELOCITY,
     21             float angle = PARTICLE_EMITTER_DEFAULT_SPREAD);
    1722  BoxEmitter(const TiXmlElement* root);
    1823  virtual ~BoxEmitter();
     
    2328  void setSize(const Vector& size) { this->setSize(size.x, size.y, size.z); };
    2429
     30protected:
    2531  virtual void emitParticles(unsigned int count) const;
    2632
  • trunk/src/lib/particles/dot_emitter.cc

    r6822 r6825  
    3333 *  standard constructor
    3434*/
    35 DotEmitter::DotEmitter(const Vector& direction, float angle, float emissionRate,
    36                        float velocity)
    37   : ParticleEmitter(direction, angle, emissionRate, velocity)
     35DotEmitter::DotEmitter(float emissionRate, float velocity, float angle)
     36  : ParticleEmitter( emissionRate, velocity, angle)
    3837{
    3938  this->init();
     
    7978    Vector randDir = Vector(rand()-RAND_MAX/2, rand()-RAND_MAX/2, rand()-RAND_MAX/2);
    8079    randDir.normalize();
    81     randDir = (this->getAbsDir()*Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->direction);
     80    randDir = (Quaternion(angle + randomAngle *((float)rand()/RAND_MAX -.5), randDir)).apply(this->getAbsDirX());
    8281    Vector velocityV = randDir.getNormalized()*this->velocity + inheritVelocity;
    8382
  • trunk/src/lib/particles/dot_emitter.h

    r6823 r6825  
    1414  friend class ParticleSystem;
    1515public:
    16   DotEmitter(const Vector& direction, float angle = .5,
    17              float emissionRate = 1.0, float velocity = 1.0);
     16  DotEmitter(float emissionRate = 1.0, float velocity = 1.0, float angle = .5);
    1817  DotEmitter(const TiXmlElement* root);
    1918  virtual ~DotEmitter();
    2019
    21 
     20protected:
    2221  virtual void emitParticles(unsigned int count) const;
    2322
  • trunk/src/lib/particles/particle_emitter.cc

    r6822 r6825  
    2929 *  standard constructor
    3030*/
    31 ParticleEmitter::ParticleEmitter(const Vector& direction, float angle, float emissionRate,
    32                   float velocity)
     31ParticleEmitter::ParticleEmitter(float emissionRate, float velocity, float angle)
    3332{
    3433  this->setClassID(CL_PARTICLE_EMITTER, "ParticleEmitter");
     
    3837  this->setInheritSpeed(PARTICLE_EMITTER_DEFAULT_INHERIT_SPEED);
    3938  this->setEmissionMomentum(0);
    40   this->direction = direction;
    4139  this->setSpread(angle);
    4240  this->setEmissionRate(emissionRate);
     
    7876  LoadParam(root, "spread", this, ParticleEmitter, setSpread)
    7977    .describe("The angle the particles are emitted from (angle, deviation)");
    80 
    81 
    82   LoadParam(root, "emission-direction", this, ParticleEmitter, setDirection);
    8378}
    8479
  • trunk/src/lib/particles/particle_emitter.h

    r6822 r6825  
    1818#define PARTICLE_EMITTER_DEFAULT_INHERIT_SPEED     0.0
    1919#define PARTICLE_EMITTER_DEFAULT_SPREAD            M_PI
     20#define PARTICLE_EMITTER_DEFAULT_VELOCITY          1.0
    2021
    2122//! A class to handle an Emitter.
     
    2425  friend class ParticleSystem;
    2526public:
    26   ParticleEmitter(const Vector& direction = Vector(1.0,0.0,0.0) , float angle = .5,
    27                   float emissionRate = 1.0, float velocity = 1.0);
     27  ParticleEmitter(float emissionRate = PARTICLE_EMITTER_DEFAULT_EMISSION_RATE,
     28                  float velocity = PARTICLE_EMITTER_DEFAULT_VELOCITY,
     29                  float angle = PARTICLE_EMITTER_DEFAULT_SPREAD);
    2830  virtual ~ParticleEmitter();
    2931
     
    4547  void setEmissionMomentum(float momentum, float randomMomentum = 0.0);
    4648
    47   void setDirection(float x, float y, float z) { this->direction = Vector(x,y,z); }; //!< todo this should be done via PNODE
    48 
    4949  /** @returns the emissionRate */
    5050  inline float getEmissionRate() const { return this->emissionRate; };
     
    5858  inline float getEmissionMomentum() const { return this->momentum; };
    5959
    60   virtual void emitParticles(unsigned int count) const = 0;
    6160
    6261  void debug() const;
    6362
    6463protected:
     64  virtual void emitParticles(unsigned int count) const = 0;
    6565
     66protected:
    6667  float           inheritSpeed;      //!< How much speed the particle inherits from the Emitters speed.
    67   Vector          direction;         //!< emition direction.
    6868  float           angle;             //!< max angle from the direction of the emitter
    6969  float           randomAngle;       //!< random emission angle (angle +- angleRandom is the emitted angle.
Note: See TracChangeset for help on using the changeset viewer.