particles from file

This commit is contained in:
Henrique Santiago
2011-12-15 16:20:09 -02:00
parent 24022317be
commit f67770ed00
11 changed files with 174 additions and 326 deletions

View File

@@ -0,0 +1,32 @@
#include "particlesystem.h"
bool ParticleSystem::load(const OTMLNodePtr& node)
{
for(const OTMLNodePtr& childNode : node->children()) {
if(childNode->tag() == "Emitter") {
ParticleEmitterPtr emitter = ParticleEmitterPtr(new ParticleEmitter);
emitter->load(childNode);
m_emitters.push_back(emitter);
}
}
return true;
}
void ParticleSystem::render()
{
for(auto it = m_emitters.begin(), end = m_emitters.end(); it != end; ++it)
(*it)->render();
}
void ParticleSystem::update()
{
for(auto it = m_emitters.begin(), end = m_emitters.end(); it != end;) {
const ParticleEmitterPtr& emitter = *it;
if(emitter->hasFinished()) {
it = m_emitters.erase(it);
continue;
}
emitter->update();
++it;
}
}