Improve explosions. Fading still not working but needed.

Once fading works, maybe increase quantity for thicker start.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4348 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
mbjornstk
2009-12-24 01:00:47 +00:00
parent 5da301b8e1
commit 2f3523cd52

View File

@@ -29,32 +29,33 @@
Explosion::Explosion(const Vec3& coord, const int explosion_sound)
{
m_remaining_time = 1.5f;
m_remaining_time = 0.1f; // short emision time, explosion, not constant flame
m_node = irr_driver->addParticleNode();
m_node->setPosition(coord.toIrrVector());
Material *m = material_manager->getMaterial("explode.png");
m_node->setMaterialTexture(0, m->getTexture());
m->setMaterialProperties(&(m_node->getMaterial(0)));
//m->setMaterialProperties(SMaterial());
m_node->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);
m_node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
scene::IParticleEmitter* em = m_node->createPointEmitter();
em->setDirection(core::vector3df(0.0f,0.0013f,0.0f)); // velocity in m/ms(!!)
em->setMinParticlesPerSecond(5);
em->setMaxParticlesPerSecond(12);
em->setMinStartSize(core::dimension2df(0.6f, 0.6f));
em->setMaxStartSize(core::dimension2df(1.5f, 1.5f));
scene::IParticleEmitter* em = m_node->createSphereEmitter(core::vector3df(0.0f,0.0f,0.0f), 0.5f,
core::vector3df(0.0f,0.005f,0.0f), // velocity in m/ms
600, 900, // min max particles per sec
video::SColor(0, 0, 0, 0), video::SColor(0, 0, 0, 0), // min max colour
1000, 1500, // min max life ms
90, // max angle
core::dimension2df(0.3f, 0.3f), core::dimension2df(0.75f, 0.75f) // min max start size
);
m_node->setEmitter(em); // this grabs the emitter
em->drop(); // so we can drop it here without deleting it
scene::IParticleAffector* fade_out_affector = m_node->createFadeOutParticleAffector(video::SColor(0, 120, 0, 0), 1500 /* fade out time */);
scene::IParticleAffector* fade_out_affector = m_node->createFadeOutParticleAffector(video::SColor(0, 0, 0, 0), 10000 /* fade out time */);
m_node->addAffector(fade_out_affector); // same goes for the affector
fade_out_affector->drop();
scene::IParticleAffector* scale_affector = m_node->createScaleParticleAffector(core::dimension2df(2.0f, 2.0f));
scene::IParticleAffector* scale_affector = m_node->createScaleParticleAffector(core::dimension2df(3.0f, 3.0f));
m_node->addAffector(scale_affector); // same goes for the affector
scale_affector->drop();
//scene::IParticleAffector *paf =
// m_node->createGravityAffector(Vec3(0, 0, -5).toIrrVector());
//m_node->addAffector(paf);
@@ -88,7 +89,7 @@ void Explosion::update(float dt)
// Do nothing more if the animation is still playing
if (m_remaining_time>0) return;
// Otherwise check that the sfx has finished, otherwise the
// sfx will get aborted 'in the middle' when this explosion
// object is removed.