Changeset 6619 in orxonox.OLD for trunk/src/lib/particles
- Timestamp:
- Jan 19, 2006, 6:23:56 PM (19 years ago)
- Location:
- trunk/src/lib/particles
- Files:
-
- 1 added
- 4 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/particles/Makefile.am
r5463 r6619 4 4 noinst_LIBRARIES = libORXparticles.a 5 5 6 libORXparticles_a_SOURCES = particle_engine.cc \ 7 particle_emitter.cc \ 6 libORXparticles_a_SOURCES = particle_emitter.cc \ 8 7 particle_system.cc \ 9 8 quick_animation.cc 10 9 11 10 12 noinst_HEADERS= particle_engine.h \ 13 particle_emitter.h \ 11 noinst_HEADERS= particle_emitter.h \ 14 12 particle_system.h \ 15 13 quick_animation.h -
trunk/src/lib/particles/particle_emitter.cc
r6512 r6619 19 19 20 20 #include "particle_system.h" 21 #include "particle_engine.h"22 21 23 22 #include "load_param.h" … … 44 43 this->setEmissionVelocity(velocity); 45 44 46 ParticleEngine::getInstance()->addEmitter(this);47 45 } 48 46 … … 57 55 if (root != NULL) 58 56 this->loadParams(root); 59 60 ParticleEngine::getInstance()->addEmitter(this);61 57 } 62 58 … … 68 64 ParticleEmitter::~ParticleEmitter () 69 65 { 70 ParticleEngine::getInstance()->removeEmitter(this);71 66 } 72 67 … … 84 79 this->setSize(PARTICLE_EMITTER_DEFAULT_SIZE); 85 80 81 this->system = NULL; 82 86 83 this->saveTime = 0.0; 87 84 } … … 118 115 119 116 LoadParam(root, "emission-direction", this, ParticleEmitter, setDirection); 117 } 118 119 void ParticleEmitter::setSystem(ParticleSystem* system) 120 { 121 if (system != NULL) 122 system->addEmitter(this); 123 else if (this->system != NULL) 124 this->system->removeEmitter(this); 125 this->system = system; 120 126 } 121 127 -
trunk/src/lib/particles/particle_emitter.h
r6512 r6619 21 21 22 22 //! The form of the Emitter to emit from 23 23 typedef enum EMITTER_TYPE 24 24 { 25 25 EMITTER_DOT = 1, … … 30 30 31 31 //! A class to handle an Emitter. 32 class ParticleEmitter : public PNode { 33 34 public: 32 class ParticleEmitter : public PNode 33 { 34 friend class ParticleSystem; 35 public: 35 36 ParticleEmitter(const Vector& direction, float angle = .5, 36 37 float emissionRate = 1.0, float velocity = 1.0); … … 46 47 void tick(float dt, ParticleSystem* system); 47 48 49 void setSystem(ParticleSystem* system); 50 ParticleSystem* getSystem() const { return this->system; }; 51 48 52 /* controlling the behavour: these can be used as Animation interfaces */ 49 53 void setType(EMITTER_TYPE type); … … 56 60 void setEmissionMomentum(float momentum, float randomMomentum = 0.0); 57 61 58 void setDirection(float x, float y, float z) { this->direction = Vector(x,y,z); }; //!< todo this should be done via PNODE 62 void setDirection(float x, float y, float z) { this->direction = Vector(x,y,z); } 63 ; //!< todo this should be done via PNODE 59 64 60 65 /** @returns the type of the emitter */ … … 77 82 void debug() const; 78 83 79 private: 84 85 private: 86 ParticleSystem* system; //!< The ParticleSystem this Emitter Emits into. 87 80 88 EMITTER_TYPE type; //!< The type of emitter this is. 81 89 float emitterSize; //!< The size of the emitter (not for EMITTER_DOT). -
trunk/src/lib/particles/particle_system.cc
r6612 r6619 19 19 20 20 #include "particle_emitter.h" 21 #include "particle_engine.h"22 21 23 22 #include "field.h" … … 69 68 ParticleSystem::~ParticleSystem() 70 69 { 71 // delete what has to be deleted here72 ParticleEngine::getInstance()->removeSystem(this);73 74 70 // deleting all the living Particles 75 71 while (this->particles) … … 108 104 this->glID = NULL; 109 105 this->setType(PARTICLE_DEFAULT_TYPE, 1); 110 ParticleEngine::getInstance()->addSystem(this);111 106 112 107 this->toList(OM_ENVIRON); … … 297 292 void ParticleSystem::addEmitter(ParticleEmitter* emitter) 298 293 { 294 assert (emitter != NULL); 295 if (emitter->getSystem() != NULL) 296 emitter->getSystem()->removeEmitter(emitter); 299 297 this->emitters.push_back(emitter); 300 298 }
Note: See TracChangeset
for help on using the changeset viewer.