mirror of
https://github.com/edubart/otclient.git
synced 2025-12-21 07:57:12 +01:00
particles from file
This commit is contained in:
38
src/framework/graphics/particlemanager.cpp
Normal file
38
src/framework/graphics/particlemanager.cpp
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user