Fix billboard text
This commit is contained in:
parent
3a5ec83ae9
commit
d47faaaa89
@ -377,6 +377,7 @@ public:
|
|||||||
float getZipperMinSpeed() const { return m_zipper_min_speed; }
|
float getZipperMinSpeed() const { return m_zipper_min_speed; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
ShaderType getShaderType() const { return m_shader_type; }
|
ShaderType getShaderType() const { return m_shader_type; }
|
||||||
|
void setShaderType(ShaderType st) { m_shader_type = st; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** True if this texture should have the U coordinates mirrored. */
|
/** True if this texture should have the U coordinates mirrored. */
|
||||||
char getMirrorAxisInReverse() const { return m_mirror_axis_when_reverse; }
|
char getMirrorAxisInReverse() const { return m_mirror_axis_when_reverse; }
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "config/user_config.hpp"
|
#include "config/user_config.hpp"
|
||||||
#include "graphics/material.hpp"
|
#include "graphics/material.hpp"
|
||||||
|
#include "graphics/shaders.hpp"
|
||||||
#include "io/file_manager.hpp"
|
#include "io/file_manager.hpp"
|
||||||
#include "io/xml_node.hpp"
|
#include "io/xml_node.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
@ -40,7 +41,6 @@ MaterialManager::MaterialManager()
|
|||||||
{
|
{
|
||||||
/* Create list - and default material zero */
|
/* Create list - and default material zero */
|
||||||
|
|
||||||
m_default_material = NULL;
|
|
||||||
m_materials.reserve(256);
|
m_materials.reserve(256);
|
||||||
// We can't call init/loadMaterial here, since the global variable
|
// We can't call init/loadMaterial here, since the global variable
|
||||||
// material_manager has not yet been initialised, and
|
// material_manager has not yet been initialised, and
|
||||||
@ -67,7 +67,7 @@ Material* MaterialManager::getMaterialFor(video::ITexture* t,
|
|||||||
scene::IMeshBuffer *mb)
|
scene::IMeshBuffer *mb)
|
||||||
{
|
{
|
||||||
if (t == NULL)
|
if (t == NULL)
|
||||||
return m_default_material;
|
return getDefaultMaterial(mb->getMaterial().MaterialType);
|
||||||
|
|
||||||
core::stringc img_path = core::stringc(t->getName());
|
core::stringc img_path = core::stringc(t->getName());
|
||||||
const std::string image = StringUtils::getBasename(img_path.c_str());
|
const std::string image = StringUtils::getBasename(img_path.c_str());
|
||||||
@ -92,7 +92,8 @@ Material* MaterialManager::getMaterialFor(video::ITexture* t,
|
|||||||
}
|
}
|
||||||
} // for i
|
} // for i
|
||||||
}
|
}
|
||||||
return m_default_material;
|
|
||||||
|
return getDefaultMaterial(mb->getMaterial().MaterialType);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -111,53 +112,39 @@ void MaterialManager::setAllMaterialFlags(video::ITexture* t,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_default_material == NULL)
|
Material* default_material = getDefaultMaterial(mb->getMaterial().MaterialType);
|
||||||
m_default_material = new Material("", false, false, false);
|
default_material->setMaterialProperties(&(mb->getMaterial()), mb);
|
||||||
m_default_material->setMaterialProperties(&(mb->getMaterial()), mb);
|
|
||||||
|
|
||||||
/*
|
|
||||||
// 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
|
} // setAllMaterialFlags
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Material* MaterialManager::getDefaultMaterial(video::E_MATERIAL_TYPE shader_type)
|
||||||
|
{
|
||||||
|
auto it = m_default_materials.find(shader_type);
|
||||||
|
if (it == m_default_materials.end())
|
||||||
|
{
|
||||||
|
Material* default_material = new Material("", false, false, false);
|
||||||
|
|
||||||
|
// TODO: workaround, should not hardcode these material types here?
|
||||||
|
// Try to find a cleaner way
|
||||||
|
if (shader_type == Shaders::getShader(ShaderType::ES_OBJECT_UNLIT))
|
||||||
|
default_material->setShaderType(Material::SHADERTYPE_SOLID_UNLIT);
|
||||||
|
else if (shader_type == Shaders::getShader(ShaderType::ES_OBJECTPASS_REF))
|
||||||
|
default_material->setShaderType(Material::SHADERTYPE_ALPHA_TEST);
|
||||||
|
else if (shader_type == Shaders::getShader(ShaderType::ES_OBJECTPASS))
|
||||||
|
default_material->setShaderType(Material::SHADERTYPE_ALPHA_BLEND);
|
||||||
|
|
||||||
|
m_default_materials[shader_type] = default_material;
|
||||||
|
return default_material;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void MaterialManager::adjustForFog(video::ITexture* t,
|
void MaterialManager::adjustForFog(video::ITexture* t,
|
||||||
scene::IMeshBuffer *mb,
|
scene::IMeshBuffer *mb,
|
||||||
scene::ISceneNode* parent,
|
scene::ISceneNode* parent,
|
||||||
@ -191,9 +178,8 @@ void MaterialManager::setAllUntexturedMaterialFlags(scene::IMeshBuffer *mb)
|
|||||||
material.MaterialType = irr::video::EMT_SOLID;
|
material.MaterialType = irr::video::EMT_SOLID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_default_material == NULL)
|
Material* default_material = getDefaultMaterial(mb->getMaterial().MaterialType);
|
||||||
m_default_material = new Material("", false, false, false);
|
default_material->setMaterialProperties(&(mb->getMaterial()), mb);
|
||||||
m_default_material->setMaterialProperties(&(mb->getMaterial()), mb);
|
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
int MaterialManager::addEntity(Material *m)
|
int MaterialManager::addEntity(Material *m)
|
||||||
|
@ -24,13 +24,14 @@
|
|||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
{
|
{
|
||||||
namespace video { class ITexture; }
|
namespace video { class ITexture; enum E_MATERIAL_TYPE; }
|
||||||
namespace scene { class IMeshBuffer; class ISceneNode; }
|
namespace scene { class IMeshBuffer; class ISceneNode; }
|
||||||
}
|
}
|
||||||
using namespace irr;
|
using namespace irr;
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
class Material;
|
class Material;
|
||||||
class XMLReader;
|
class XMLReader;
|
||||||
@ -48,7 +49,8 @@ private:
|
|||||||
|
|
||||||
std::vector<Material*> m_materials;
|
std::vector<Material*> m_materials;
|
||||||
|
|
||||||
Material* m_default_material;
|
std::map<video::E_MATERIAL_TYPE, Material*> m_default_materials;
|
||||||
|
Material* getDefaultMaterial(video::E_MATERIAL_TYPE material_type);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MaterialManager();
|
MaterialManager();
|
||||||
|
Loading…
Reference in New Issue
Block a user