//----------------------------------------------------------------------------- Material* MaterialManager::getMaterialFor(video::ITexture* t, video::E_MATERIAL_TYPE material_type) { if (t == NULL) return getDefaultSPMaterial("solid"); Material* m = getMaterialFor(t); if (m != NULL) return m; return getDefaultSPMaterial("solid"); }
/** Searches for the material in the given texture, and calls a function * in the material to set the irrlicht material flags. * \param t Pointer to the texture. * \param mb Pointer to the mesh buffer. */ void MaterialManager::setAllMaterialFlags(video::ITexture* t, scene::IMeshBuffer *mb) { Material* mat = getMaterialFor(t, mb); if (mat != NULL) { mat->setMaterialProperties(&(mb->getMaterial()), mb); return; } Material* default_material = getDefaultMaterial(mb->getMaterial().MaterialType); default_material->setMaterialProperties(&(mb->getMaterial()), mb); } // setAllMaterialFlags
/** Searches for the material in the given texture, and calls a function * in the material to set the irrlicht material flags. * \param t Pointer to the texture. * \param mb Pointer to the mesh buffer. */ void MaterialManager::setAllMaterialFlags(video::ITexture* t, scene::IMeshBuffer *mb) { Material* mat = getMaterialFor(t, mb); if (mat != NULL) { mat->setMaterialProperties(&(mb->getMaterial()), mb); return; } // This material does not appear in materials.xml. Set some common flags... if (UserConfigParams::m_anisotropic > 0) { for (u32 i=0; i<video::MATERIAL_MAX_TEXTURES; ++i) { mb->getMaterial().TextureLayer[i].AnisotropicFilter = UserConfigParams::m_anisotropic; } } else if (UserConfigParams::m_trilinear) { mb->getMaterial().setFlag(video::EMF_TRILINEAR_FILTER, true); } mb->getMaterial().ColorMaterial = video::ECM_DIFFUSE_AND_AMBIENT; if (World::getWorld() != NULL) { mb->getMaterial().FogEnable = World::getWorld()->isFogEnabled(); } // Modify lightmap materials so that vertex colors are taken into account. // But disable lighting because we assume all lighting is already part // of the lightmap if (mb->getMaterial().MaterialType == video::EMT_LIGHTMAP) { mb->getMaterial().MaterialType = video::EMT_LIGHTMAP_LIGHTING; mb->getMaterial().AmbientColor = video::SColor(255, 255, 255, 255); mb->getMaterial().DiffuseColor = video::SColor(255, 255, 255, 255); mb->getMaterial().EmissiveColor = video::SColor(255, 255, 255, 255); mb->getMaterial().SpecularColor = video::SColor(255, 255, 255, 255); } //if (UserConfigParams::m_fullscreen_antialiasing) // mb->getMaterial().AntiAliasing = video::EAAM_LINE_SMOOTH; } // setAllMaterialFlags
Material* MaterialManager::getMaterialFor(video::ITexture* t, scene::IMeshBuffer *mb) { return getMaterialFor(t, mb->getMaterial().MaterialType); }