From 0a020dbcc848ae2debec664846e08bd097d70320 Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Tue, 23 Oct 2012 20:03:06 +0300 Subject: Properly read the mesh from LUA. Players can now be set to meshes using the following test script: function switch_player_visual() prop = { mesh="player.obj", texture="player.png", visual="mesh", } for _, obj in pairs(minetest.get_connected_players()) do obj:set_properties(prop) end minetest.after(1.0, switch_player_visual) end minetest.after(1.0, switch_player_visual) --- src/content_cao.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/content_cao.cpp') diff --git a/src/content_cao.cpp b/src/content_cao.cpp index e177fa15c..985f3cbbd 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -802,14 +802,18 @@ public: else if(m_prop.visual == "mesh"){ infostream<<"GenericCAO::addToScene(): mesh"<getMesh(m_prop.mesh.c_str()); - m_animated_meshnode = smgr->addAnimatedMeshSceneNode(mesh, NULL); - mesh->drop(); - - m_animated_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_animated_meshnode->getMesh(), video::SColor(255,li,li,li)); + if(mesh) + { + m_animated_meshnode = smgr->addAnimatedMeshSceneNode(mesh, NULL); + + m_animated_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_animated_meshnode->getMesh(), video::SColor(255,li,li,li)); + } + else + errorstream<<"GenericCAO::addToScene(): Could not load mesh "<