Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 23, 2005, 3:30:45 AM (19 years ago)
Author:
bensch
Message:

orxonox/branches/particleEngine: spread works, and many other functions implemented

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/particleEngine/src/lib/graphics/particles/particle_emitter.cc

    r3934 r3935  
    1919
    2020#include "particle_system.h"
     21#include "particle_engine.h"
    2122
    2223using namespace std;
     
    3334   this->setSpread(angle);
    3435   this->setEmissionRate(emissionRate);
    35    this->velocity = velocity;
     36   this->setVelocity(velocity);
    3637
    3738   this->saveTime = 0.0;
     39
     40   ParticleEngine::getInstance()->addEmitter(this);
    3841}
    3942
     
    4548*/
    4649ParticleEmitter::~ParticleEmitter ()
    47 {}
     50{
     51   ParticleEngine::getInstance()->removeEmitter(this);
     52 
     53}
    4854
    4955
     
    8591*/
    8692void ParticleEmitter::setSpread(float angle, float randomAngle)
    87 {}
    88 
    89 
    90 
     93{
     94  this->angle = angle;
     95  this->randomAngle = randomAngle;
     96}
    9197
    9298/**
     
    98104   you may want to use the animation class
    99105*/
    100 void ParticleEmitter::setVelocity(float velocity, float random)
    101 {}
     106void ParticleEmitter::setVelocity(float velocity, float randomVelocity)
     107{
     108  this->velocity = velocity;
     109  this->randomVelocity = randomVelocity;
     110}
    102111
    103112/**
     
    116125  this->saveTime /= this->emissionRate;
    117126
     127
    118128  for (int i = 0; i <= count; i++)
    119129    // emmits from EMITTER_DOT,
    120130    {
    121       Vector randDir = Quaternion(Vector(random()-RAND_MAX/2, random()-RAND_MAX/2, random()-RAND_MAX/2), angle).apply(this->direction);
     131      Vector randDir = Vector(random()-RAND_MAX/2, random()-RAND_MAX/2, random()-RAND_MAX/2);
     132      randDir.normalize();
     133      randDir = Quaternion(angle + randomAngle *((float)random()/RAND_MAX -.5), randDir).apply(this->direction);
    122134      randDir.normalize();
    123135      system->addParticle(this->getAbsCoor(), randDir* velocity);
Note: See TracChangeset for help on using the changeset viewer.