Fix weird opaque particles
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7325 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
6db2b6a49e
commit
47add64448
@ -46,10 +46,15 @@ Material::Material(const XMLNode *node, int index)
|
||||
node->get("name", &m_texname);
|
||||
if (m_texname=="")
|
||||
{
|
||||
throw std::runtime_error("No texture name specified in %s file\n");
|
||||
}
|
||||
throw std::runtime_error("[Material] No texture name specified in file\n");
|
||||
}
|
||||
init(index);
|
||||
|
||||
if (m_texname == "smoke.png")
|
||||
{
|
||||
printf("breakpoint here\n");
|
||||
}
|
||||
|
||||
bool b = false;
|
||||
node->get("clampU", &b); if (b) m_clamp_tex |= UCLAMP;
|
||||
b = false;
|
||||
|
@ -133,6 +133,9 @@ public:
|
||||
const std::string&
|
||||
getTexFname () const { return m_texname; }
|
||||
int getIndex () const { return m_index; }
|
||||
|
||||
bool isTransparent () const { return m_alpha_testing || m_alpha_blending || m_add; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the fraction of maximum speed on this material. */
|
||||
float getMaxSpeedFraction() const { return m_max_speed_fraction; }
|
||||
|
@ -229,3 +229,15 @@ Material *MaterialManager::getMaterial(const std::string& fname,
|
||||
return m ;
|
||||
} // getMaterial
|
||||
|
||||
|
||||
bool MaterialManager::hasMaterial(const std::string& fname)
|
||||
{
|
||||
std::string basename=StringUtils::getBasename(fname);
|
||||
|
||||
// Search backward so that temporary (track) textures are found first
|
||||
for(int i = (int)m_materials.size()-1; i>=0; i-- )
|
||||
{
|
||||
if(m_materials[i]->getTexFname()==basename) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -58,6 +58,8 @@ public:
|
||||
void addSharedMaterial(const std::string& filename);
|
||||
bool pushTempMaterial (const std::string& filename);
|
||||
void popTempMaterial ();
|
||||
|
||||
bool hasMaterial(const std::string& fname);
|
||||
};
|
||||
|
||||
extern MaterialManager *material_manager;
|
||||
|
@ -30,6 +30,7 @@ ParticleEmitter::ParticleEmitter(const ParticleKind* type, core::vector3df posit
|
||||
scene::ISceneNode* parent) : m_position(position)
|
||||
{
|
||||
m_node = NULL;
|
||||
m_particle_type = NULL;
|
||||
m_parent = parent;
|
||||
setParticleType(type);
|
||||
|
||||
@ -81,7 +82,7 @@ void ParticleEmitter::setPosition(core::vector3df pos)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ParticleEmitter::setParticleType(const ParticleKind* type)
|
||||
{
|
||||
{
|
||||
if (m_particle_type == type) return; // already the right type
|
||||
|
||||
if (m_node != NULL)
|
||||
@ -116,11 +117,13 @@ void ParticleEmitter::setParticleType(const ParticleKind* type)
|
||||
m_node->setName(debug_name.c_str());
|
||||
#endif
|
||||
|
||||
video::SMaterial& mat0 = m_node->getMaterial(0);
|
||||
|
||||
m_node->setPosition(m_position);
|
||||
material->setMaterialProperties(&(m_node->getMaterial(0)));
|
||||
material->setMaterialProperties(&mat0);
|
||||
m_node->setMaterialTexture(0, material->getTexture());
|
||||
|
||||
m_node->getMaterial(0).ZWriteEnable = false; // disable z-buffer writes
|
||||
mat0.ZWriteEnable = !material->isTransparent(); // disable z-buffer writes if material is transparent
|
||||
|
||||
switch (type->getShape())
|
||||
{
|
||||
|
@ -120,10 +120,17 @@ ParticleKind::ParticleKind(const std::string file) : m_min_start_color(255,255,2
|
||||
throw std::runtime_error("[ParticleKind] <material> tag has invalid 'file' attribute");
|
||||
}
|
||||
|
||||
m_material = material_manager->getMaterial(materialFile);
|
||||
if (m_material->getTexture() == NULL)
|
||||
if (material_manager->hasMaterial(materialFile))
|
||||
{
|
||||
throw std::runtime_error("[ParticleKind] Cannot locate file " + materialFile);
|
||||
m_material = material_manager->getMaterial(materialFile);
|
||||
if (m_material->getTexture() == NULL)
|
||||
{
|
||||
throw std::runtime_error("[ParticleKind] Cannot locate file " + materialFile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "[ParticleKind] WARNING: particle image '%s' does not appear in the list of currently known materials, it will be opaque", materialFile.c_str());
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user