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},
#include "sound.h"
#include "util/string.h"
#include "hex.h"
+#include "IMeshCache.h"
static std::string getMediaCacheDir()
{
name = removeStringEnd(filename, image_ext);
if(name != "")
{
- verbosestream<<"Client: Attempting to load image "
- <<"file \""<<filename<<"\""<<std::endl;
+ verbosestream<<"Client: Storing image into Irrlicht: "
+ <<"\""<<filename<<"\""<<std::endl;
io::IFileSystem *irrfs = m_device->getFileSystem();
video::IVideoDriver *vdrv = m_device->getVideoDriver();
name = removeStringEnd(filename, sound_ext);
if(name != "")
{
- verbosestream<<"Client: Attempting to load sound "
- <<"file \""<<filename<<"\""<<std::endl;
+ verbosestream<<"Client: Storing sound into Irrlicht: "
+ <<"\""<<filename<<"\""<<std::endl;
m_sound->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 \""<<filename<<"\""<<std::endl;
+ <<"\""<<filename<<"\""<<std::endl;
io::IFileSystem *irrfs = m_device->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;
}
updateTexturePos();
+ updateAnimations();
+
if(m_reset_textures_timer >= 0){
m_reset_textures_timer -= dtime;
if(m_reset_textures_timer <= 0){
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 "<<texturestring<<std::endl;
}
}
+ void updateAnimations()
+ {
+ if(!m_animated_meshnode)
+ return;
+
+ m_animated_meshnode->setFrameLoop(0, 50);
+ }
+
void processMessage(const std::string &data)
{
//infostream<<"GenericCAO: Got message"<<std::endl;
".png", ".jpg", ".bmp", ".tga",
".pcx", ".ppm", ".psd", ".wal", ".rgb",
".ogg",
- ".b3d", ".md2", ".obj",
+ ".x", ".b3d", ".md2", ".obj",
NULL
};
if(removeStringEnd(filename, supported_ext) == ""){