Made explosions better-looking. Fade-out affector still seems buggy; at one point it worked, now no more

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4337 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-12-22 20:03:12 +00:00
parent 5434a1a376
commit 72c2b7a021
3 changed files with 28 additions and 15 deletions

View File

@ -77,6 +77,7 @@ ChallengeData::ChallengeData(const std::string& filename)
std::string s;
if(!root->get("name", &s) ) error("name");
std::cout << " // Challenge name = <" << s.c_str() << ">\n";
setName( _(s.c_str()) );
if(!root->get("id", &s) ) error("id");
@ -84,6 +85,7 @@ ChallengeData::ChallengeData(const std::string& filename)
if(!root->get("description", &s) ) error("description");
setChallengeDescription( _(s.c_str()) );
std::cout << " // Challenge description = <" << s.c_str() << ">\n";
if(!root->get("karts", &m_num_karts) ) error("karts");

View File

@ -35,21 +35,26 @@ Explosion::Explosion(const Vec3& coord, const int explosion_sound)
Material *m = material_manager->getMaterial("explode.png");
m_node->setMaterialTexture(0, m->getTexture());
m->setMaterialProperties(&(m_node->getMaterial(0)));
//m_node->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF);
//m->setMaterialProperties(SMaterial());
m_node->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);
scene::IParticleEmitter* em = m_node->createPointEmitter();
em->setDirection(core::vector3df(0.0f,0.0006f,0.0f)); // velocity in m/ms(!!)
em->setMinParticlesPerSecond(1);
em->setMaxParticlesPerSecond(5);
em->setMinStartSize(core::dimension2df(0.1f, 0.1f));
em->setMaxStartSize(core::dimension2df(0.5f, 0.5f));
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));
m_node->setEmitter(em); // this grabs the emitter
em->drop(); // so we can drop it here without deleting it
scene::IParticleAffector* paf = m_node->createFadeOutParticleAffector();
m_node->addAffector(paf); // same goes for the affector
paf->drop();
scene::IParticleAffector* fade_out_affector = m_node->createFadeOutParticleAffector(video::SColor(0, 120, 0, 0), 1500 /* 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));
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);
@ -82,14 +87,21 @@ void Explosion::update(float dt)
m_remaining_time -=dt;
// Do nothing more if the animation is still playing
if(m_remaining_time>0) return;
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.
if(m_explode_sound->getStatus() == SFXManager::SFX_PLAYING)
//if (m_explode_sound->getStatus() == SFXManager::SFX_PLAYING)
//{
// m_remaining_time = 0;
//}
//else
if (m_remaining_time > -1.5f)
{
m_remaining_time = 0;
// Stop the emitter and wait a little while for all particles to have time to fade out
m_node->getEmitter()->setMinParticlesPerSecond(0);
m_node->getEmitter()->setMaxParticlesPerSecond(0);
}
else
{

View File

@ -31,8 +31,7 @@ class Explosion
private:
SFXBase* m_explode_sound;
float m_remaining_time;
scene::IParticleSystemSceneNode
*m_node;
scene::IParticleSystemSceneNode *m_node;
public:
Explosion(const Vec3& coord, const int explosion_sound);