From 9c8ba427503cbf73f0263495a791656b905c2efc Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Wed, 24 Oct 2012 22:10:05 +0300 Subject: [PATCH] Get the mesh working through the memory cache properly. Most credit goes to celeron55 for the help on this code Get the texture from memory as well Add .x to the list of supported formats Update LUA API documentation --- doc/lua_api.txt | 3 ++- src/client.cpp | 24 ++++++++++++++---------- src/content_cao.cpp | 13 +++++++++++-- src/server.cpp | 2 +- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 500b514d..84c86061 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -1227,8 +1227,9 @@ Object Properties physical = true, weight = 5, collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, - visual = "cube"/"sprite"/"upright_sprite", + visual = "cube"/"sprite"/"upright_sprite"/"mesh", visual_size = {x=1, y=1}, + mesh = "model", textures = {}, -- number of required textures depends on visual spritediv = {x=1, y=1}, initial_sprite_basepos = {x=0, y=0}, diff --git a/src/client.cpp b/src/client.cpp index 504297a6..7f542174 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -41,6 +41,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "sound.h" #include "util/string.h" #include "hex.h" +#include "IMeshCache.h" static std::string getMediaCacheDir() { @@ -820,8 +821,8 @@ bool Client::loadMedia(const std::string &data, const std::string &filename) name = removeStringEnd(filename, image_ext); if(name != "") { - verbosestream<<"Client: Attempting to load image " - <<"file \""<getFileSystem(); video::IVideoDriver *vdrv = m_device->getVideoDriver(); @@ -854,28 +855,31 @@ bool Client::loadMedia(const std::string &data, const std::string &filename) name = removeStringEnd(filename, sound_ext); if(name != "") { - verbosestream<<"Client: Attempting to load sound " - <<"file \""<loadSoundData(name, data); return true; } const char *model_ext[] = { - ".b3d", ".md2", ".obj", + ".x", ".b3d", ".md2", ".obj", NULL }; name = removeStringEnd(filename, model_ext); if(name != "") { verbosestream<<"Client: Storing model into Irrlicht: " - <<"file \""<getFileSystem(); - - // Create an irrlicht memory file - io::IReadFile *rfile = irrfs->createMemoryReadFile(*data_rw, data_rw.getSize(), filename.c_str(), true); + io::IReadFile *rfile = irrfs->createMemoryReadFile( + *data_rw, data_rw.getSize(), filename.c_str()); assert(rfile); - //rfile->drop(); + + scene::ISceneManager *smgr = m_device->getSceneManager(); + scene::IAnimatedMesh *mesh = smgr->getMesh(rfile); + smgr->getMeshCache()->addMesh(filename.c_str(), mesh); + return true; } diff --git a/src/content_cao.cpp b/src/content_cao.cpp index b3c0370b..cd822cb3 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -979,6 +979,8 @@ public: updateTexturePos(); + updateAnimations(); + if(m_reset_textures_timer >= 0){ m_reset_textures_timer -= dtime; if(m_reset_textures_timer <= 0){ @@ -1066,8 +1068,7 @@ public: if(texturestring == "") continue; // Empty texture string means don't modify that material texturestring += mod; - video::IVideoDriver* driver = m_animated_meshnode->getSceneManager()->getVideoDriver(); - video::ITexture* texture = driver->getTexture(texturestring.c_str()); + video::ITexture* texture = tsrc->getTextureRaw(texturestring); if(!texture) { errorstream<<"GenericCAO::updateTextures(): Could not load texture "<setFrameLoop(0, 50); + } + void processMessage(const std::string &data) { //infostream<<"GenericCAO: Got message"<