Changeset 6623 in orxonox.OLD for trunk/src/lib/particles/particle_system.cc
- Timestamp:
- Jan 20, 2006, 12:54:20 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/particles/particle_system.cc
r6621 r6623 44 44 45 45 this->setMaxCount(maxCount); 46 }47 48 /**49 * @brief creates a Particle System out of a XML-element50 * @param root: the XML-element to load from51 */52 ParticleSystem::ParticleSystem(const TiXmlElement* root)53 {54 this->init();55 56 this->loadParams(root);57 46 } 58 47 … … 78 67 } 79 68 80 if (this->material) 81 delete this->material; 69 while(!this->emitters.empty()) 70 { 71 this->removeEmitter(this->emitters.front()); 72 } 73 82 74 } 83 75 … … 89 81 this->setClassID(CL_PARTICLE_SYSTEM, "ParticleSystem"); 90 82 91 this->material = NULL;92 83 this->setMaxCount(PARTICLE_DEFAULT_MAX_COUNT); 93 84 this->count = 0; … … 96 87 this->setConserve(1); 97 88 this->setLifeSpan(1); 98 this->glID = NULL;99 89 100 90 this->toList(OM_ENVIRON); … … 120 110 .describe("sets the Conserve factor of the Particles (1.0: they keep all their energy, 0.0:they keep no energy)"); 121 111 122 LoadParam(root, "texture", this, ParticleSystem, setMaterialTexture); 123 LoadParamXML(root, "emitter", this, ParticleSystem, addEmitterXML); 112 LoadParamXML(root, "emitters", this, ParticleSystem, loadEmitters); 124 113 125 114 LOAD_PARAM_START_CYCLE(root, element); … … 140 129 141 130 /** 131 * @brief loads the Emitters from An XML-Root 132 * @param root the XML-Element to load all emitters from 133 */ 134 void ParticleSystem::loadEmitters(const TiXmlElement* root) 135 { 136 LOAD_PARAM_START_CYCLE(root, element); 137 { 138 BaseObject* emitter = Factory::fabricate(element); 139 if (emitter->isA(CL_PARTICLE_EMITTER)) 140 this->addEmitter(dynamic_cast<ParticleEmitter*>(emitter)); 141 else 142 { 143 PRINTF(2)("Tried to load an Element of type '%s' that should be a ParticleEmitter onto '%s::%s'.\n", 144 emitter->getClassName(), this->getClassName(), this->getName()); 145 delete emitter; 146 } 147 } 148 LOAD_PARAM_END_CYCLE(element); 149 } 150 151 /** 142 152 * @param maxCount the maximum count of particles that can be emitted 143 153 */ … … 148 158 149 159 // setting properties 150 /**151 * sets the material to an external material152 * @param material: the material to set this material to.153 154 !! important if the extern material gets deleted it MUST be unregistered here or segfault !!155 */156 void ParticleSystem::setMaterial(Material* material)157 {158 this->material = material;159 }160 161 void ParticleSystem::setMaterialTexture(const char* textureFile)162 {163 if (this->material != NULL)164 this->material->setDiffuseMap(textureFile);165 }166 167 160 /** 168 161 * Sets the lifespan of newly created particles … … 237 230 emitter->getSystem()->removeEmitter(emitter); 238 231 this->emitters.push_back(emitter); 239 }240 241 void ParticleSystem::addEmitterXML(const TiXmlElement* emitterRoot)242 {243 ParticleEmitter* emitter = new ParticleEmitter(emitterRoot);244 this->addEmitter(emitter);245 232 } 246 233
Note: See TracChangeset
for help on using the changeset viewer.