I'm sorry for bumping such an old post but I am suffering a similar problem but unfortunately I'm an irrlicht dummy and can't really understand to much about some of the code you have up there.
I am trying to use bin2h to do this exact thing but I don't know how to put the file into practice from the point of getting it in there... It isn't like your code really. But this is the code I'm trying.
Code: Select all
#include <irrlicht.h>
#include "BuildInSydneyModel.h"
#include "BuildInSydneyTexture.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
IReadFile* file;
IReadFile* file2;
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#endif
int main()
{
IrrlichtDevice *device =
#ifdef _IRR_OSX_PLATFORM_
createDevice( video::EDT_OPENGL, dimension2d<s32>(640, 480), 16,
false, false, false, 0);
#else
createDevice( video::EDT_SOFTWARE, dimension2d<s32>(640, 480), 16,
false, false, false, 0);
#endif
device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
const c8* filename2 = "sydneyModel";
const c8* filename = "sydneyModelTexture";
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
rect<s32>(10,10,260,22), true);
file = device->getFileSystem()->createMemoryReadFile(mySydneyTextureData, mySydneyTextureData_size, filename, false);
file2 = device->getFileSystem()->createMemoryReadFile(mySydneyModelData, mySydneyModelData_size, filename2, false);
IAnimatedMesh* mesh = smgr->getMesh(file2);
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation ( scene::EMAT_STAND );
node->setMaterialTexture( 0, driver->getTexture(file) );
}
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
and I keep getting this in the commandline area...
Code: Select all
MD2 Loader: Wrong file header: sydneyModel
Could not load mesh, wrong file format seems to be unsupported: sydneyModel
As a little explanation, the name shouldn't really matter because I'm not trying to use the actual file as the memory but a header file that contains data from the bin2h exported header, with a few minor edits.
Also I have tried so many different names that I think it all leads back to it not being read right.
Maybe perhaps it isn't being read right because I am not doing something right in the header, I guess I'll try to store the data into memory from the file itself.