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:
parent
491de4a805
commit
ab5c3b43d7
@ -133,6 +133,8 @@ void Track::cleanup()
|
|||||||
}
|
}
|
||||||
m_all_nodes.clear();
|
m_all_nodes.clear();
|
||||||
|
|
||||||
|
m_all_emitters.clearAndDeleteAll();
|
||||||
|
|
||||||
if (m_sky_particles_emitter) delete m_sky_particles_emitter;
|
if (m_sky_particles_emitter) delete m_sky_particles_emitter;
|
||||||
m_sky_particles_emitter = NULL;
|
m_sky_particles_emitter = NULL;
|
||||||
|
|
||||||
@ -831,41 +833,21 @@ void Track::loadTrackModel(World* parent, unsigned int mode_id)
|
|||||||
}
|
}
|
||||||
else if (name=="particle-emitter")
|
else if (name=="particle-emitter")
|
||||||
{
|
{
|
||||||
// based on http://irrlicht.sourceforge.net/tut008.html
|
|
||||||
std::string path;
|
std::string path;
|
||||||
std::vector<float> emitter_origin;
|
irr::core::vector3df emitter_origin;
|
||||||
scene::ISceneManager* smgr = irr_driver->getSceneManager();
|
node->get("kind", &path);
|
||||||
node->get("texture", &path);
|
|
||||||
node->get("origin", &emitter_origin);
|
node->get("origin", &emitter_origin);
|
||||||
video::ITexture* particle_texture_load;
|
|
||||||
particle_texture_load = irr_driver->getTexture(path);
|
|
||||||
|
|
||||||
scene::IParticleSystemSceneNode* ps = smgr->addParticleSystemSceneNode(false);
|
try
|
||||||
|
{
|
||||||
scene::IParticleEmitter* em = ps->createBoxEmitter(
|
ParticleKind* kind = ParticleKindManager::get()->getParticles( path.c_str() );
|
||||||
core::aabbox3d<f32>(-2,0,-2,2,1,2), // emitter size
|
ParticleEmitter* emitter = new ParticleEmitter( kind, emitter_origin );
|
||||||
core::vector3df(0.0f,0.06f,0.0f), // initial direction
|
m_all_emitters.push_back(emitter);
|
||||||
2,3, // emit rate
|
}
|
||||||
video::SColor(0,255,255,255), // darkest color
|
catch (std::runtime_error& e)
|
||||||
video::SColor(0,255,255,255), // brightest color
|
{
|
||||||
800,2000,0, // min and max age, angle
|
fprintf(stderr, "[Track] WARNING: Could not load particles '%s'; cause :\n %s", path.c_str(), e.what());
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
else if(name=="sun")
|
else if(name=="sun")
|
||||||
{
|
{
|
||||||
|
@ -27,11 +27,14 @@
|
|||||||
using namespace irr;
|
using namespace irr;
|
||||||
|
|
||||||
#include "LinearMath/btTransform.h"
|
#include "LinearMath/btTransform.h"
|
||||||
|
|
||||||
#include "audio/music_information.hpp"
|
#include "audio/music_information.hpp"
|
||||||
#include "graphics/material.hpp"
|
#include "graphics/material.hpp"
|
||||||
|
#include "graphics/particle_emitter.hpp"
|
||||||
#include "items/item.hpp"
|
#include "items/item.hpp"
|
||||||
#include "tracks/quad_graph.hpp"
|
#include "tracks/quad_graph.hpp"
|
||||||
#include "utils/vec3.hpp"
|
#include "utils/vec3.hpp"
|
||||||
|
#include "utils/ptr_vector.hpp"
|
||||||
|
|
||||||
class AnimationManager;
|
class AnimationManager;
|
||||||
class BezierCurve;
|
class BezierCurve;
|
||||||
@ -69,6 +72,7 @@ private:
|
|||||||
std::vector<std::string> m_groups;
|
std::vector<std::string> m_groups;
|
||||||
std::vector<scene::ISceneNode*> m_all_nodes;
|
std::vector<scene::ISceneNode*> m_all_nodes;
|
||||||
std::vector<scene::IMesh*> m_all_meshes;
|
std::vector<scene::IMesh*> m_all_meshes;
|
||||||
|
ptr_vector<ParticleEmitter> m_all_emitters;
|
||||||
scene::ILightSceneNode *m_sun;
|
scene::ILightSceneNode *m_sun;
|
||||||
TriangleMesh* m_track_mesh;
|
TriangleMesh* m_track_mesh;
|
||||||
/** Minimum coordinates of this track. */
|
/** Minimum coordinates of this track. */
|
||||||
|
Loading…
Reference in New Issue
Block a user