return &m_particle_manager;
}
-scene::IAnimatedMesh* Client::getMesh(const std::string &filename)
+scene::IAnimatedMesh* Client::getMesh(const std::string &filename, bool cache)
{
StringMap::const_iterator it = m_mesh_data.find(filename);
if (it == m_mesh_data.end()) {
scene::IAnimatedMesh *mesh = RenderingEngine::get_scene_manager()->getMesh(rfile);
rfile->drop();
- // NOTE: By playing with Irrlicht refcounts, maybe we could cache a bunch
- // of uniquely named instances and re-use them
mesh->grab();
- RenderingEngine::get_mesh_cache()->removeMesh(mesh);
+ if (!cache)
+ RenderingEngine::get_mesh_cache()->removeMesh(mesh);
return mesh;
}
virtual ParticleManager* getParticleManager();
bool checkLocalPrivilege(const std::string &priv)
{ return checkPrivilege(priv); }
- virtual scene::IAnimatedMesh* getMesh(const std::string &filename);
+ virtual scene::IAnimatedMesh* getMesh(const std::string &filename, bool cache = false);
const std::string* getModFile(const std::string &filename);
virtual std::string getModStoragePath() const;
}
else if(m_prop.visual == "mesh") {
infostream<<"GenericCAO::addToScene(): mesh"<<std::endl;
- scene::IAnimatedMesh *mesh = m_client->getMesh(m_prop.mesh);
+ scene::IAnimatedMesh *mesh = m_client->getMesh(m_prop.mesh, true);
if(mesh)
{
m_animated_meshnode = RenderingEngine::get_scene_manager()->
m_prop.visual_size.Y,
m_prop.visual_size.X));
u8 li = m_last_light;
+
+ // set vertex colors to ensure alpha is set
setMeshColor(m_animated_meshnode->getMesh(), video::SColor(255,li,li,li));
+ setAnimatedMeshColor(m_animated_meshnode, video::SColor(255,li,li,li));
+
bool backface_culling = m_prop.backface_culling;
if (m_is_player)
backface_culling = false;
- m_animated_meshnode->setMaterialFlag(video::EMF_LIGHTING, false);
+ m_animated_meshnode->setMaterialFlag(video::EMF_LIGHTING, true);
m_animated_meshnode->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
m_animated_meshnode->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF);
m_animated_meshnode->setMaterialFlag(video::EMF_FOG_ENABLE, true);
if (m_meshnode) {
setMeshColor(m_meshnode->getMesh(), color);
} else if (m_animated_meshnode) {
- setMeshColor(m_animated_meshnode->getMesh(), color);
+ setAnimatedMeshColor(m_animated_meshnode, color);
} else if (m_wield_meshnode) {
m_wield_meshnode->setColor(color);
} else if (m_spritenode) {
// Set material flags and texture
video::SMaterial& material = m_animated_meshnode->getMaterial(i);
material.TextureLayer[0].Texture = texture;
- material.setFlag(video::EMF_LIGHTING, false);
+ material.setFlag(video::EMF_LIGHTING, true);
material.setFlag(video::EMF_BILINEAR_FILTER, false);
// don't filter low-res textures, makes them look blurry
#include <iostream>
#include <IAnimatedMesh.h>
#include <SAnimatedMesh.h>
+#include <IAnimatedMeshSceneNode.h>
// In Irrlicht 1.8 the signature of ITexture::lock was changed from
// (bool, u32) to (E_TEXTURE_LOCK_MODE, u32).
((video::S3DVertex *) (vertices + i * stride))->Color = color;
}
+void setAnimatedMeshColor(scene::IAnimatedMeshSceneNode *node, const video::SColor &color)
+{
+ for (u32 i = 0; i < node->getMaterialCount(); ++i) {
+ node->getMaterial(i).EmissiveColor = color;
+ }
+}
+
void setMeshColor(scene::IMesh *mesh, const video::SColor &color)
{
if (mesh == NULL)