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,38 @@
#include "particlemanager.h"
#include <framework/core/resourcemanager.h>
#include <framework/otml/otml.h>
ParticleManager g_particleManager;
bool ParticleManager::load(const std::string& filename)
{
if(!g_resources.fileExists(filename))
return false;
try {
OTMLDocumentPtr doc = OTMLDocument::parse(filename);
for(const OTMLNodePtr& node : doc->children()) {
if(node->tag() == "ParticleSystem") {
ParticleSystemPtr particleSystem = ParticleSystemPtr(new ParticleSystem);
particleSystem->load(node);
m_particlesSystems.push_back(particleSystem);
}
}
return true;
} catch(Exception& e) {
logError("could not load particles: ", e.what());
return false;
}
}
void ParticleManager::render()
{
for(auto it = m_particlesSystems.begin(), end = m_particlesSystems.end(); it != end; ++it)
(*it)->render();
}
void ParticleManager::update()
{
for(auto it = m_particlesSystems.begin(), end = m_particlesSystems.end(); it != end; ++it)
(*it)->update();
}