Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6825 in orxonox.OLD for trunk


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

trunk: new interface to ParticleEmitters

Location:
trunk/src
Files:
13 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.
  • trunk/src/world_entities/projectiles/bomb.cc

    r6822 r6825  
    5050  this->lifeSpan = 15;
    5151
    52   this->emitter = new DotEmitter(Vector(0,1,0), M_2_PI, 100, 5);
     52  this->emitter = new DotEmitter(100, 5, M_2_PI);
    5353  this->emitter->setParent(this);
    5454  this->emitter->setSpread(M_PI, M_PI);
  • trunk/src/world_entities/projectiles/guided_missile.cc

    r6822 r6825  
    4646  this->maxVelocity = 75;
    4747
    48   this->emitter = new DotEmitter(Vector(0,1,0), M_2_PI, 100, 5);
     48  this->emitter = new DotEmitter(100, 5, M_2_PI);
    4949  this->emitter->setParent(this);
    5050  this->emitter->setSpread(M_PI, M_PI);
  • trunk/src/world_entities/projectiles/hyperblast.cc

    r6822 r6825  
    4747  this->size = 4.0;
    4848
    49   this->emitter = new DotEmitter(Vector(0,1,0), M_2_PI, 100, 5);
     49  this->emitter = new DotEmitter(100, 5, M_2_PI);
    5050  this->emitter->setParent(this);
    5151  this->emitter->setSpread(M_PI, M_PI);
  • trunk/src/world_entities/projectiles/laser.cc

    r6822 r6825  
    4848  this->lifeSpan = 5.0;
    4949
    50   this->emitter = new DotEmitter(Vector(0,1,0), M_2_PI, 100, 5);
     50  this->emitter = new DotEmitter(100, 5, M_2_PI);
    5151  this->emitter->setParent(this);
    5252  this->emitter->setSpread(M_PI, M_PI);
  • trunk/src/world_entities/projectiles/rocket.cc

    r6822 r6825  
    4545  this->lifeSpan = 5;
    4646
    47   this->emitter = new DotEmitter(Vector(0,1,0), M_2_PI, 100, 5);
     47  this->emitter = new DotEmitter(100, 5, M_2_PI);
    4848  this->emitter->setParent(this);
    4949  this->emitter->setSpread(M_PI, M_PI);
  • trunk/src/world_entities/projectiles/test_bullet.cc

    r6822 r6825  
    4545  this->lifeSpan = 2;
    4646
    47   this->emitter = new DotEmitter(Vector(0,1,0), M_2_PI, 100, 5);
     47  this->emitter = new DotEmitter(100, 5, M_2_PI);
    4848  this->emitter->setParent(this);
    4949  this->emitter->setSpread(M_PI, M_PI);
  • trunk/src/world_entities/space_ships/space_ship.cc

    r6822 r6825  
    205205  dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false);
    206206
    207   this->burstEmitter = new DotEmitter(Vector(1,0,0), .01, 200, 0.0);
     207  this->burstEmitter = new DotEmitter(200, 0.0, .01);
    208208  this->burstEmitter->setParent(this);
    209209  this->burstEmitter->setRelCoor(-1, .5, 0);
Note: See TracChangeset for help on using the changeset viewer.