My latest (failed) attempt at fixing MrIceBlock : allow setting material settings for untextured surfaces too. Committing because we might eventually see an interest in this

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4809 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-02-23 00:09:09 +00:00
parent a1d24a8433
commit 6577d770fb
4 changed files with 32 additions and 3 deletions

View File

@ -392,6 +392,7 @@ scene::IMesh *IrrDriver::getMesh(const std::string &filename)
scene::IAnimatedMesh *m = m_scene_manager->getMesh(filename.c_str());
if(!m) return NULL;
setAllMaterialFlags(m);
return m->getMesh(0);
} // getMesh
@ -410,8 +411,9 @@ void IrrDriver::setAllMaterialFlags(scene::IAnimatedMesh *mesh) const
for(unsigned int j=0; j<video::MATERIAL_MAX_TEXTURES; j++)
{
video::ITexture* t=irr_material.getTexture(j);
if(!t) continue;
material_manager->setAllMaterialFlags(t, mb);
if (!t) material_manager->setAllFlatMaterialFlags(mb);
else material_manager->setAllMaterialFlags(t, mb);
} // for j<MATERIAL_MAX_TEXTURES
material_manager->setAllUntexturedMaterialFlags(mb);
} // for i<getMeshBufferCount()

View File

@ -41,6 +41,29 @@ MaterialManager::MaterialManager()
// be moved into a separate function.
}
//-----------------------------------------------------------------------------
void MaterialManager::setAllFlatMaterialFlags(scene::IMeshBuffer *mb) const
{
video::SMaterial& material = mb->getMaterial();
//printf("=== I've got a flat material here! (%i, %i, %i) ==\n",
// material.AmbientColor.getRed(), material.AmbientColor.getGreen(), material.AmbientColor.getBlue());
if (material.AmbientColor.getAlpha() < 255)
{
//printf("---> AND IT's TRANSLUSCENT!!\n");
//m->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
material.MaterialType = video::EMT_SOLID;
material.ZWriteEnable = false;
material.setFlag(video::EMF_ZWRITE_ENABLE, false);
//material.setFlag(video::EMF_BACK_FACE_CULLING, false);
//material.Wireframe=true;
}
material.Shininess = 0.6f;
}
//-----------------------------------------------------------------------------
/** Searches for the material in the given texture, and calls a function
* in the material to set the irrlicht material flags.

View File

@ -43,7 +43,10 @@ public:
void reInit ();
void setAllMaterialFlags(video::ITexture* t,
scene::IMeshBuffer *mb) const;
void setAllUntexturedMaterialFlags(scene::IMeshBuffer *mb) const;
void setAllFlatMaterialFlags(scene::IMeshBuffer *mb) const;
int addEntity (Material *m);
Material *getMaterial (const std::string& t, bool is_full_path=false,
bool make_permanent=false);

View File

@ -420,7 +420,8 @@ bool Track::loadMainTrack(const XMLNode &root)
}
m_all_meshes.push_back(mesh);
scene::ISceneNode *scene_node = irr_driver->addMesh(mesh);
//scene::ISceneNode *scene_node = irr_driver->addMesh(mesh);
scene::ISceneNode *scene_node = irr_driver->addOctTree(mesh);
mesh->setHardwareMappingHint(scene::EHM_STATIC);
core::vector3df xyz(0,0,0);
track_node->getXYZ(&xyz);