diff --git a/src/content_cao.cpp b/src/content_cao.cpp index ca891a0..34a5e61 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -1369,7 +1369,21 @@ public: u8 li = m_last_light; setMeshColor(m_meshnode->getMesh(), video::SColor(255,li,li,li)); } - } else { + } + else if(m_prop.visual == "file") + { + scene::IMesh *mesh = createMeshFromFile(m_prop.meshfile, v3f(BS,BS,BS), smgr); + m_meshnode = smgr->addMeshSceneNode(mesh, NULL); + mesh->drop(); + + m_meshnode->setScale(v3f(m_prop.visual_size.X, + m_prop.visual_size.Y, + m_prop.visual_size.X)); + u8 li = m_last_light; + setMeshColor(m_meshnode->getMesh(), video::SColor(255,li,li,li)); + } + else + { infostream<<"GenericCAO::addToScene(): \""<getMesh(filename.c_str())); + scaleMesh(anim_mesh, scale); // also recalculates bounding box + return anim_mesh; +} + static scene::IAnimatedMesh* extrudeARGB(u32 twidth, u32 theight, u8 *data) { const s32 argb_wstep = 4 * twidth; diff --git a/src/mesh.h b/src/mesh.h index 5716623..c6b717d 100644 --- a/src/mesh.h +++ b/src/mesh.h @@ -32,6 +32,11 @@ with this program; if not, write to the Free Software Foundation, Inc., */ scene::IAnimatedMesh* createCubeMesh(v3f scale); +/* + Create a mesh from a file. +*/ +scene::IAnimatedMesh* createMeshFromFile(std::string filename, v3f scale, scene::ISceneManager* smgr); + /* Create a new extruded mesh from a texture. Maximum bounding box is (+-scale.X/2, +-scale.Y/2, +-scale.Z). diff --git a/src/object_properties.cpp b/src/object_properties.cpp index 3043b1a..5563b02 100644 --- a/src/object_properties.cpp +++ b/src/object_properties.cpp @@ -34,7 +34,8 @@ ObjectProperties::ObjectProperties(): initial_sprite_basepos(0,0), is_visible(true), makes_footstep_sound(false), - automatic_rotate(0) + automatic_rotate(0), + meshfile() { textures.push_back("unknown_object.png"); textures_3d.push_back("unknown_object.png"); @@ -48,6 +49,7 @@ std::string ObjectProperties::dump() os<<", weight="<is_visible); getboolfield(L, -1, "makes_footstep_sound", prop->makes_footstep_sound); getfloatfield(L, -1, "automatic_rotate", prop->automatic_rotate); + getstringfield(L, -1, "meshfile", prop->meshfile); } /* diff --git a/src/server.cpp b/src/server.cpp index 696fa5d..4bfb3c5 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -4094,6 +4094,7 @@ void Server::fillMediaCache() paths.push_back(mod.path + DIR_DELIM + "textures"); paths.push_back(mod.path + DIR_DELIM + "sounds"); paths.push_back(mod.path + DIR_DELIM + "media"); + paths.push_back(mod.path + DIR_DELIM + "meshes"); } // Collect media file information from paths into cache