More particles tweak + eye candy : add additive blending to materials.xml, now the nitro looks awesome

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7256 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-01-05 02:38:24 +00:00
parent ec3c1f76a0
commit c669a425e5
6 changed files with 35 additions and 10 deletions

View File

@ -16,7 +16,6 @@
<size min="0.22" <size min="0.22"
max="0.5" /> max="0.5" />
<!-- Doesn't seem to work -->
<color min="255 255 255" <color min="255 255 255"
max="255 255 255" /> max="255 255 255" />

View File

@ -16,11 +16,10 @@
<size min="0.2" <size min="0.2"
max="0.66" /> max="0.66" />
<!-- Doesn't seem to work -->
<color min="255 255 255" <color min="255 255 255"
max="255 255 255" /> max="255 255 255" />
<!-- How much time in milliseconds before the particle is fully faded out --> <!-- How much time in milliseconds before the particle is fully faded out -->
<fadeout time="1500" /> <fadeout time="900" />
</particles> </particles>

View File

@ -48,6 +48,7 @@ Material::Material(const XMLNode *node, int index)
throw std::runtime_error("No texture name specified in %s file\n"); throw std::runtime_error("No texture name specified in %s file\n");
} }
init(index); init(index);
bool b = false; bool b = false;
node->get("clampU", &b); if (b) m_clamp_tex |= UCLAMP; node->get("clampU", &b); if (b) m_clamp_tex |= UCLAMP;
b = false; b = false;
@ -60,6 +61,7 @@ Material::Material(const XMLNode *node, int index)
node->get("friction", &m_friction ); node->get("friction", &m_friction );
node->get("ignore", &m_ignore ); node->get("ignore", &m_ignore );
node->get("reset", &m_resetter ); node->get("reset", &m_resetter );
node->get("additive", &m_add );
node->get("max-speed", &m_max_speed_fraction); node->get("max-speed", &m_max_speed_fraction);
node->get("slowdown-time", &m_slowdown_time ); node->get("slowdown-time", &m_slowdown_time );
node->get("anisotropic", &m_anisotropic ); node->get("anisotropic", &m_anisotropic );
@ -135,6 +137,7 @@ void Material::init(unsigned int index)
m_friction = 1.0f; m_friction = 1.0f;
m_ignore = false; m_ignore = false;
m_resetter = false; m_resetter = false;
m_add = false;
m_max_speed_fraction = 1.0f; m_max_speed_fraction = 1.0f;
m_slowdown_time = 1.0f; m_slowdown_time = 1.0f;
m_sfx_name = ""; m_sfx_name = "";
@ -240,6 +243,8 @@ void Material::setSFXSpeed(SFXBase *sfx, float speed) const
*/ */
void Material::setMaterialProperties(video::SMaterial *m) const void Material::setMaterialProperties(video::SMaterial *m) const
{ {
int modes = 0;
if (m_alpha_testing) if (m_alpha_testing)
{ {
// Note: if EMT_TRANSPARENT_ALPHA_CHANNEL is used, you have to use // Note: if EMT_TRANSPARENT_ALPHA_CHANNEL is used, you have to use
@ -248,18 +253,33 @@ void Material::setMaterialProperties(video::SMaterial *m) const
// updates of the Z buffer of the material. Since the _REF // updates of the Z buffer of the material. Since the _REF
// approach is faster (and looks better imho), this is used for now. // approach is faster (and looks better imho), this is used for now.
m->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; m->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
modes++;
} }
else if (m_alpha_blending) if (m_alpha_blending)
{ {
m->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; m->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
modes++;
} }
else if (m_sphere_map) if (m_sphere_map)
{ {
m->MaterialType = video::EMT_SPHERE_MAP; m->MaterialType = video::EMT_SPHERE_MAP;
modes++;
} }
else if (m_lightmap) if (m_lightmap)
{ {
m->MaterialType = video::EMT_LIGHTMAP; m->MaterialType = video::EMT_LIGHTMAP;
modes++;
}
if (m_add)
{
m->MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
modes++;
}
if (modes > 1)
{
std::cerr << "[Material::setMaterialProperties] More than one main mode set for " << m_texname.c_str() << "\n";
} }
if (!m_lighting) if (!m_lighting)

View File

@ -49,6 +49,8 @@ private:
bool m_zipper; bool m_zipper;
bool m_resetter; bool m_resetter;
bool m_ignore; bool m_ignore;
bool m_add;
/** Texture clamp bitmask */ /** Texture clamp bitmask */
unsigned int m_clamp_tex; unsigned int m_clamp_tex;
bool m_lighting; bool m_lighting;

View File

@ -47,6 +47,7 @@ ParticleEmitter::ParticleEmitter(ParticleKind* type, core::vector3df position,
m_node->setName(debug_name.c_str()); m_node->setName(debug_name.c_str());
#endif #endif
if (parent != NULL) if (parent != NULL)
{ {
m_node->setParent(parent); m_node->setParent(parent);
@ -60,6 +61,8 @@ ParticleEmitter::ParticleEmitter(ParticleKind* type, core::vector3df position,
material->setMaterialProperties(&(m_node->getMaterial(0))); material->setMaterialProperties(&(m_node->getMaterial(0)));
m_node->setMaterialTexture(0, material->getTexture()); m_node->setMaterialTexture(0, material->getTexture());
printf("==== %s ====\n", material->getTexFname().c_str());
// FIXME: does the maxAngle param work at all?? // FIXME: does the maxAngle param work at all??
// FIXME: the min and max color params don't appear to work // FIXME: the min and max color params don't appear to work
m_emitter = m_node->createPointEmitter(core::vector3df(0.0f, 0.0f, 0.0f), // velocity in m/ms m_emitter = m_node->createPointEmitter(core::vector3df(0.0f, 0.0f, 0.0f), // velocity in m/ms

View File

@ -283,8 +283,10 @@ int XMLNode::get(const std::string &attribute, float *value) const
int XMLNode::get(const std::string &attribute, bool *value) const int XMLNode::get(const std::string &attribute, bool *value) const
{ {
std::string s; std::string s;
// FIXME: for some reason, missing attributes don't trigger that if???
if(!get(attribute, &s)) return 0; if(!get(attribute, &s)) return 0;
*value = s=="" || s[0]=='T' || s[0]=='t' || s[0]=='Y' || s[0]=='y' || *value = s[0]=='T' || s[0]=='t' || s[0]=='Y' || s[0]=='y' ||
s=="#t" || s =="#T"; s=="#t" || s =="#T";
return 1; return 1;
} // get(bool) } // get(bool)