Could not load mesh error

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Glazed Donuts
Posts: 3
Joined: Fri Apr 06, 2007 9:43 pm

Could not load mesh error

Post 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.
cowsarenotevil
Posts: 19
Joined: Fri Nov 18, 2005 4:14 pm

Post 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.
Glazed Donuts
Posts: 3
Joined: Fri Apr 06, 2007 9:43 pm

Post 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.
belfegor
Posts: 383
Joined: Mon Sep 18, 2006 7:22 pm
Location: Serbia

Post 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).
Last edited by belfegor on Tue Apr 10, 2007 10:37 am, edited 1 time in total.
Small FPS demo made using Irrlicht&NewtonDEMO
InfoHERE
Its at very early stage but i think im crazy enough to finish it all alone.
Glazed Donuts
Posts: 3
Joined: Fri Apr 06, 2007 9:43 pm

Post by Glazed Donuts »

Thank you! it's working now!
Post Reply