Add support for full particle emitters anywhere in track

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7568 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-01-31 02:27:19 +00:00
parent 491de4a805
commit ab5c3b43d7
2 changed files with 18 additions and 32 deletions

View File

@ -132,6 +132,8 @@ void Track::cleanup()
irr_driver->removeNode(m_all_nodes[i]);
}
m_all_nodes.clear();
m_all_emitters.clearAndDeleteAll();
if (m_sky_particles_emitter) delete m_sky_particles_emitter;
m_sky_particles_emitter = NULL;
@ -831,41 +833,21 @@ void Track::loadTrackModel(World* parent, unsigned int mode_id)
}
else if (name=="particle-emitter")
{
// based on http://irrlicht.sourceforge.net/tut008.html
std::string path;
std::vector<float> emitter_origin;
scene::ISceneManager* smgr = irr_driver->getSceneManager();
node->get("texture", &path);
irr::core::vector3df emitter_origin;
node->get("kind", &path);
node->get("origin", &emitter_origin);
video::ITexture* particle_texture_load;
particle_texture_load = irr_driver->getTexture(path);
scene::IParticleSystemSceneNode* ps = smgr->addParticleSystemSceneNode(false);
scene::IParticleEmitter* em = ps->createBoxEmitter(
core::aabbox3d<f32>(-2,0,-2,2,1,2), // emitter size
core::vector3df(0.0f,0.06f,0.0f), // initial direction
2,3, // emit rate
video::SColor(0,255,255,255), // darkest color
video::SColor(0,255,255,255), // brightest color
800,2000,0, // min and max age, angle
core::dimension2df(1.f,1.f), // min size
core::dimension2df(2.f,2.f)); // max size
ps->setEmitter(em);
em->drop();
scene::IParticleAffector* paf = ps->createFadeOutParticleAffector();
ps->addAffector(paf);
paf->drop();
ps->setPosition(core::vector3df(emitter_origin[0], emitter_origin[2], emitter_origin[1] ));
ps->setScale(core::vector3df(1,1,1));
ps->setMaterialFlag(video::EMF_LIGHTING, false);
ps->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
ps->setMaterialTexture(0, particle_texture_load);
ps->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);
try
{
ParticleKind* kind = ParticleKindManager::get()->getParticles( path.c_str() );
ParticleEmitter* emitter = new ParticleEmitter( kind, emitter_origin );
m_all_emitters.push_back(emitter);
}
catch (std::runtime_error& e)
{
fprintf(stderr, "[Track] WARNING: Could not load particles '%s'; cause :\n %s", path.c_str(), e.what());
}
}
else if(name=="sun")
{

View File

@ -27,11 +27,14 @@
using namespace irr;
#include "LinearMath/btTransform.h"
#include "audio/music_information.hpp"
#include "graphics/material.hpp"
#include "graphics/particle_emitter.hpp"
#include "items/item.hpp"
#include "tracks/quad_graph.hpp"
#include "utils/vec3.hpp"
#include "utils/ptr_vector.hpp"
class AnimationManager;
class BezierCurve;
@ -69,6 +72,7 @@ private:
std::vector<std::string> m_groups;
std::vector<scene::ISceneNode*> m_all_nodes;
std::vector<scene::IMesh*> m_all_meshes;
ptr_vector<ParticleEmitter> m_all_emitters;
scene::ILightSceneNode *m_sun;
TriangleMesh* m_track_mesh;
/** Minimum coordinates of this track. */