From d4f9da2f3c19511b028da2569d7b6a8d1371e135 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 20 Jan 2013 21:37:11 +0000 Subject: Major overhaul of the particle system back-end, support multiple ejectors per particle system. --- src/render/renderext.cc | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) (limited to 'src/render/renderext.cc') diff --git a/src/render/renderext.cc b/src/render/renderext.cc index 1dc82f8..25e0cab 100644 --- a/src/render/renderext.cc +++ b/src/render/renderext.cc @@ -7,6 +7,7 @@ #include #include +#include "render/particlesystemscript.h" #include "math/functions.h" #include "core/application.h" #include "core/entity.h" @@ -39,7 +40,7 @@ RenderExt::RenderExt(core::Entity *entity) : core::Extension(core::Extension::Re if (entity->model()) { model::Model *model = entity->model(); - for (model::Model::Lights::iterator lit = model->lights().begin(); lit != model->lights().end(); lit++) { + for (model::Model::Lights::iterator lit = model->lights().begin(); lit != model->lights().end(); ++lit) { model::Light *light = (*lit); // load light texture @@ -48,7 +49,7 @@ RenderExt::RenderExt(core::Entity *entity) : core::Extension(core::Extension::Re light->set_texture(Textures::load(flarename.str())); } - for (model::Model::Flares::iterator flit = model->flares().begin(); flit != model->flares().end(); flit++) { + for (model::Model::Flares::iterator flit = model->flares().begin(); flit != model->flares().end(); ++flit) { model::Flare *flare = (*flit); // load flare texture @@ -57,30 +58,12 @@ RenderExt::RenderExt(core::Entity *entity) : core::Extension(core::Extension::Re flare->set_texture(Textures::load(flarename.str())); } - for (model::Model::ParticleSystems::const_iterator pit = model->particles().begin(); pit != model->particles().end(); pit++) { - // model attachment location tag - const model::Particles *particlesystem = (*pit); - + for (model::Model::ParticleSystems::const_iterator pit = model->particles().begin(); pit != model->particles().end(); ++pit) { // load particle systems - const ParticleScript *script = ParticleScript::load(particlesystem->script()); - while (script) { - if ( script->type() == render::ParticleScript::Trail) { - Trail *trail = new Trail(script, entity, particlesystem); - state_particles.push_back(trail); - - } else if (script->type() == render::ParticleScript::Jet) { - Jet *jet = new Jet(script, entity, particlesystem); - state_particles.push_back(jet); - - } else if (script->type() == render::ParticleScript::Spray) { - Spray *spray = new Spray(script, entity, particlesystem); - state_particles.push_back(spray); - - } else if (script->type() == render::ParticleScript::Flame) { - Flame *flame = new Flame(script, entity, particlesystem); - state_particles.push_back(flame); - } - script = script->next(); + const ParticleSystemScript *script = ParticleSystemScript::load((*pit)->script()); + if (script) { + ParticleSystem *ps = new ParticleSystem(script, entity, (*pit)); + state_particles.push_back(ps); } } @@ -181,9 +164,9 @@ void RenderExt::frame(float elapsed) if (!state_explosion) { // add explosion - const ParticleScript *script = ParticleScript::load("explosion"); + const ParticleSystemScript *script = ParticleSystemScript::load("explosion"); if (script) { - state_explosion = (ParticleSystem *) new Spray(script, entity(), 0); + state_explosion = new ParticleSystem(script, entity(), 0); state_particles.push_back(state_explosion); } } -- cgit v1.2.3