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:
parent
5434a1a376
commit
72c2b7a021
@ -77,6 +77,7 @@ ChallengeData::ChallengeData(const std::string& filename)
|
|||||||
|
|
||||||
std::string s;
|
std::string s;
|
||||||
if(!root->get("name", &s) ) error("name");
|
if(!root->get("name", &s) ) error("name");
|
||||||
|
std::cout << " // Challenge name = <" << s.c_str() << ">\n";
|
||||||
setName( _(s.c_str()) );
|
setName( _(s.c_str()) );
|
||||||
|
|
||||||
if(!root->get("id", &s) ) error("id");
|
if(!root->get("id", &s) ) error("id");
|
||||||
@ -84,6 +85,7 @@ ChallengeData::ChallengeData(const std::string& filename)
|
|||||||
|
|
||||||
if(!root->get("description", &s) ) error("description");
|
if(!root->get("description", &s) ) error("description");
|
||||||
setChallengeDescription( _(s.c_str()) );
|
setChallengeDescription( _(s.c_str()) );
|
||||||
|
std::cout << " // Challenge description = <" << s.c_str() << ">\n";
|
||||||
|
|
||||||
if(!root->get("karts", &m_num_karts) ) error("karts");
|
if(!root->get("karts", &m_num_karts) ) error("karts");
|
||||||
|
|
||||||
|
@ -35,20 +35,25 @@ Explosion::Explosion(const Vec3& coord, const int explosion_sound)
|
|||||||
Material *m = material_manager->getMaterial("explode.png");
|
Material *m = material_manager->getMaterial("explode.png");
|
||||||
m_node->setMaterialTexture(0, m->getTexture());
|
m_node->setMaterialTexture(0, m->getTexture());
|
||||||
m->setMaterialProperties(&(m_node->getMaterial(0)));
|
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();
|
scene::IParticleEmitter* em = m_node->createPointEmitter();
|
||||||
em->setDirection(core::vector3df(0.0f,0.0006f,0.0f)); // velocity in m/ms(!!)
|
em->setDirection(core::vector3df(0.0f,0.0013f,0.0f)); // velocity in m/ms(!!)
|
||||||
em->setMinParticlesPerSecond(1);
|
em->setMinParticlesPerSecond(5);
|
||||||
em->setMaxParticlesPerSecond(5);
|
em->setMaxParticlesPerSecond(12);
|
||||||
em->setMinStartSize(core::dimension2df(0.1f, 0.1f));
|
em->setMinStartSize(core::dimension2df(0.6f, 0.6f));
|
||||||
em->setMaxStartSize(core::dimension2df(0.5f, 0.5f));
|
em->setMaxStartSize(core::dimension2df(1.5f, 1.5f));
|
||||||
m_node->setEmitter(em); // this grabs the emitter
|
m_node->setEmitter(em); // this grabs the emitter
|
||||||
em->drop(); // so we can drop it here without deleting it
|
em->drop(); // so we can drop it here without deleting it
|
||||||
|
|
||||||
scene::IParticleAffector* paf = m_node->createFadeOutParticleAffector();
|
scene::IParticleAffector* fade_out_affector = m_node->createFadeOutParticleAffector(video::SColor(0, 120, 0, 0), 1500 /* fade out time */);
|
||||||
m_node->addAffector(paf); // same goes for the affector
|
m_node->addAffector(fade_out_affector); // same goes for the affector
|
||||||
paf->drop();
|
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 =
|
//scene::IParticleAffector *paf =
|
||||||
// m_node->createGravityAffector(Vec3(0, 0, -5).toIrrVector());
|
// m_node->createGravityAffector(Vec3(0, 0, -5).toIrrVector());
|
||||||
@ -82,14 +87,21 @@ void Explosion::update(float dt)
|
|||||||
m_remaining_time -=dt;
|
m_remaining_time -=dt;
|
||||||
|
|
||||||
// Do nothing more if the animation is still playing
|
// 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
|
// Otherwise check that the sfx has finished, otherwise the
|
||||||
// sfx will get aborted 'in the middle' when this explosion
|
// sfx will get aborted 'in the middle' when this explosion
|
||||||
// object is removed.
|
// 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
|
else
|
||||||
{
|
{
|
||||||
|
@ -31,8 +31,7 @@ class Explosion
|
|||||||
private:
|
private:
|
||||||
SFXBase* m_explode_sound;
|
SFXBase* m_explode_sound;
|
||||||
float m_remaining_time;
|
float m_remaining_time;
|
||||||
scene::IParticleSystemSceneNode
|
scene::IParticleSystemSceneNode *m_node;
|
||||||
*m_node;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Explosion(const Vec3& coord, const int explosion_sound);
|
Explosion(const Vec3& coord, const int explosion_sound);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user