Page 1 of 1

Could not load mesh error

Posted: Fri Apr 06, 2007 9:47 pm
by Glazed Donuts
Hello, I am new to using Irrlicht. I downloaded and (I thought) I installed the program correctly by integrating it with my Microsoft Visual C++ (Express edition) program. I followed the "Hello World" example on the site exactly, but when I run the program, I get an error in the DOS prompt saying:

Code: Select all

Could not load mesh, because the file could not be opened: ../../media/sydney.md2
can anyone help me? Thanks.

Posted: Fri Apr 06, 2007 10:26 pm
by cowsarenotevil
Be sure the running directory of the program is the same as the project file.

Sorry, if you're doing this from scratch, that won't help. The file path is relative to the running directory of the program, so set it to point to irrlicht's media directory from wherever it is running.

Posted: Sat Apr 07, 2007 2:21 am
by Glazed Donuts
I don't understand that response. Do I need to have the media folder in the same folder as the program's EXE file?

This is how I have my code:

Code: Select all

#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

#pragma comment(lib, "Irrlicht.lib")

int main()
{

IrrlichtDevice *device = createDevice(EDT_SOFTWARE, dimension2d<s32>(512,384),16,false,false,false,0);

device->setWindowCaption(L"Hello World Program! - My first Irrlicht Program by me");

IVideoDriver*driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();

guienv->addStaticText(L"Hello World! This is the Irrlicht Software Engine!", rect<int>(10,10,200,22), true);

IAnimatedMesh* mesh = smgr->getMesh("C:\Documents and Settings\Knuckles\Desktop\irrlicht-1.3\media\sydney.md2");
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh);

if (node)
{
	node->setMaterialFlag(EMF_LIGHTING, false);
	node->setFrameLoop(0,310);
	node->setMaterialTexture(0, driver->getTexture("C:\Documents and Settings\Knuckles\Desktop\irrlicht-1.3\media\media\sydney.bmp"));
}

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;
}

The error still remains.

Posted: Sat Apr 07, 2007 2:02 pm
by belfegor
Dont use:
"C:\Documents and Settings\Knuckles\Desktop\irrlicht-1.3\media\sydney.md2"


use:

"C:\\Documents and Settings\\Knuckles\\Desktop\irrlicht-1.3\\media\\sydney.md2"

or use:

"C:/Documents and Settings/Knuckles/Desktop/irrlicht-1.3/media/sydney.md2"

first one is incorrect as it is used for special characters:

\n, \t, \a...(newline, tab, alarm...).

examples:

"media/model.md2" (folder "media" is in the same folder as .exe)

EDITED (10.apr): :oops:

"../media/model.md2" (folder "media" is one folder up from .exe)
"../../media/model.md2" (folder "media" is two folder up from .exe)

...

There is also function : setWorkingDirectory() (or something like that).

Posted: Sat Apr 07, 2007 5:47 pm
by Glazed Donuts
Thank you! it's working now!