Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jan 19, 2006, 1:50:39 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: particle_system is now loaded differently

ParticleEngine is NOT needed anymore, this is faster and better

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

Legend:

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

    r5654 r6612  
    309309{
    310310  // ticks all the ParticleSystems
     311//   tIterator<ParticleSystem>* tmpIt = systemList->getIterator();
     312//   ParticleSystem* tmpSys = tmpIt->firstElement();
     313//   while(tmpSys)
     314//     {
     315//       tmpSys->tick(dt);
     316//       tmpSys = tmpIt->nextElement();
     317//     }
     318//   delete tmpIt;
     319
     320  // add new Particles to each System connected to an Emitter.
     321  tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
     322  ParticleConnection* tmpConnection = tmpConIt->firstElement();
     323  while(tmpConnection)
     324    {
     325      tmpConnection->emitter->tick(dt, tmpConnection->system);
     326      tmpConnection = tmpConIt->nextElement();
     327    }
     328  delete tmpConIt;
     329}
     330
     331/**
     332 *  draws all the systems and their Particles.
     333*/
     334void ParticleEngine::draw() const
     335{
     336  /*
    311337  tIterator<ParticleSystem>* tmpIt = systemList->getIterator();
    312338  ParticleSystem* tmpSys = tmpIt->firstElement();
    313339  while(tmpSys)
    314340    {
    315       tmpSys->tick(dt);
    316       tmpSys = tmpIt->nextElement();
    317     }
    318   delete tmpIt;
    319 
    320   // add new Particles to each System connected to an Emitter.
    321   tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
    322   ParticleConnection* tmpConnection = tmpConIt->firstElement();
    323   while(tmpConnection)
    324     {
    325       tmpConnection->emitter->tick(dt, tmpConnection->system);
    326       tmpConnection = tmpConIt->nextElement();
    327     }
    328   delete tmpConIt;
    329 }
    330 
    331 /**
    332  *  draws all the systems and their Particles.
    333 */
    334 void ParticleEngine::draw() const
    335 {
    336   tIterator<ParticleSystem>* tmpIt = systemList->getIterator();
    337   ParticleSystem* tmpSys = tmpIt->firstElement();
    338   while(tmpSys)
    339     {
    340341      tmpSys->draw();
    341342      tmpSys = tmpIt->nextElement();
    342343    }
    343   delete tmpIt;
     344  delete tmpIt;*/
    344345
    345346}
  • trunk/src/lib/particles/particle_system.cc

    r6512 r6612  
    3131
    3232#include "parser/tinyxml/tinyxml.h"
     33#include <algorithm>
     34
    3335
    3436CREATE_FACTORY(ParticleSystem, CL_PARTICLE_SYSTEM);
     
    107109  this->setType(PARTICLE_DEFAULT_TYPE, 1);
    108110  ParticleEngine::getInstance()->addSystem(this);
     111
     112  this->toList(OM_ENVIRON);
    109113}
    110114
     
    132136
    133137  LoadParam(root, "texture", this, ParticleSystem, setMaterialTexture);
     138  LoadParamXML(root, "emitter", this, ParticleSystem, addEmitterXML);
    134139
    135140  LOAD_PARAM_START_CYCLE(root, element);
     
    147152  }
    148153  LOAD_PARAM_END_CYCLE(element);
    149 
    150154}
    151155
     
    288292  this->colorAnim[2].changeEntry(lifeCycleTime, blue);
    289293  this->colorAnim[3].changeEntry(lifeCycleTime, alpha);
     294}
     295
     296
     297void ParticleSystem::addEmitter(ParticleEmitter* emitter)
     298{
     299  this->emitters.push_back(emitter);
     300}
     301
     302void ParticleSystem::addEmitterXML(const TiXmlElement* emitterRoot)
     303{
     304  ParticleEmitter* emitter = new ParticleEmitter(emitterRoot);
     305  this->addEmitter(emitter);
     306}
     307
     308
     309void ParticleSystem::removeEmitter(ParticleEmitter* emitter)
     310{
     311  std::list<ParticleEmitter*>::iterator it = std::find(this->emitters.begin(), this->emitters.end(), emitter);
     312  if (it != this->emitters.end())
     313    this->emitters.erase(it);
    290314}
    291315
     
    357381        }
    358382    }
     383
     384    std::list<ParticleEmitter*>::iterator emitter;
     385    for (emitter = this->emitters.begin(); emitter != this->emitters.end(); emitter++)
     386      (*emitter)->tick(dt, this);
    359387}
    360388
  • trunk/src/lib/particles/particle_system.h

    r6512 r6612  
    1212#include "glincl.h"
    1313#include "vector.h"
     14#include <list>
    1415
    1516#include "quick_animation.h"
     
    107108  virtual unsigned int getFaceCount() const;
    108109
     110  void addEmitter(ParticleEmitter* emitter);
     111  void addEmitterXML(const TiXmlElement* emitterRoot);
     112  void removeEmitter(ParticleEmitter* emitter);
    109113
    110114  virtual void applyField(Field* field);
     
    136140  GLuint            dialectCount;        //!< How many different types of particles are there in the Particle System
    137141
     142  std::list<ParticleEmitter*> emitters;  //!< The Emitters that do emit into this System.
     143
    138144  // per particle attributes
    139145  QuickAnimation    radiusAnim;          //!< Animation of the radius
Note: See TracChangeset for help on using the changeset viewer.