Improvements to particle system, now fade out works as it should \o/

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7288 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2011-01-06 00:07:58 +00:00
parent 052a1664b3
commit cd850cf300
3 changed files with 20 additions and 6 deletions

View File

@@ -20,6 +20,6 @@
max="255 255 255" />
<!-- How much time in milliseconds before the particle is fully faded out -->
<fadeout time="1500" />
<fadeout time="1000" />
</particles>

View File

@@ -258,7 +258,14 @@ void Material::setMaterialProperties(video::SMaterial *m) const
}
if (m_alpha_blending)
{
m->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
//m->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
// EMT_TRANSPARENT_ALPHA_CHANNEL does include vertex color alpha into account, which
// messes up fading in/out effects. So we use the more customizable EMT_ONETEXTURE_BLEND instead
m->MaterialType = video::EMT_ONETEXTURE_BLEND ;
m->MaterialTypeParam = pack_texureBlendFunc(video::EBF_SRC_ALPHA, video::EBF_ONE_MINUS_SRC_ALPHA,
video::EMFN_MODULATE_1X, video::EAS_TEXTURE | video::EAS_VERTEX_COLOR);
modes++;
}
if (m_sphere_map)
@@ -273,7 +280,13 @@ void Material::setMaterialProperties(video::SMaterial *m) const
}
if (m_add)
{
m->MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
//m->MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
// EMT_TRANSPARENT_ADD_COLOR does include vertex color alpha into account, which
// messes up fading in/out effects. So we use the more customizable EMT_ONETEXTURE_BLEND instead
m->MaterialType = video::EMT_ONETEXTURE_BLEND ;
m->MaterialTypeParam = pack_texureBlendFunc(video::EBF_SRC_ALPHA, video::EBF_DST_ALPHA,
video::EMFN_MODULATE_1X, video::EAS_TEXTURE | video::EAS_VERTEX_COLOR);
modes++;
}

View File

@@ -54,11 +54,12 @@ ParticleEmitter::ParticleEmitter(ParticleKind* type, core::vector3df position,
}
m_node->setPosition(position);
//material->setMaterialProperties(&(m_node->getMaterial(0)));
material->setMaterialProperties(&(m_node->getMaterial(0)));
m_node->setMaterialTexture(0, material->getTexture());
m_node->getMaterial(0).MaterialType = video::EMT_ONETEXTURE_BLEND ;
m_node->getMaterial(0).MaterialTypeParam = pack_texureBlendFunc(video::EBF_SRC_ALPHA, video::EBF_ONE_MINUS_SRC_ALPHA);
//m_node->getMaterial(0).MaterialType = video::EMT_ONETEXTURE_BLEND ;
//m_node->getMaterial(0).MaterialTypeParam = pack_texureBlendFunc(video::EBF_SRC_ALPHA, video::EBF_ONE_MINUS_SRC_ALPHA,
// video::EMFN_MODULATE_1X, video::EAS_TEXTURE | video::EAS_VERTEX_COLOR);
m_node->getMaterial(0).ZWriteEnable = false; // disable z-buffer writes
switch (type->getShape())