Could not load mesh, because file could not be opened: ...

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
marchacley
Posts: 10
Joined: Sun Jun 20, 2010 1:47 pm

Could not load mesh, because file could not be opened: ...

Post by marchacley »

Hi pepole!
I'm riting because I have a problem opening any file in Irrlicht.

I pass you the code:

Code: Select all

#include <IRR/irrlicht.h>

int main(void)
{
    irr::IrrlichtDevice *device = irr::createDevice (irr::video::EDT_OPENGL, irr::core::dimension2d<irr::u32>(800,600), 32,false,true,false,0);
    irr::video::IVideoDriver* driver = device->getVideoDriver ();
    irr::scene::ISceneManager *sceneManager = device->getSceneManager ();

    irr::scene::ICameraSceneNode *camera = sceneManager->addCameraSceneNodeFPS (0,80.0f,0.2f);

    irr::scene::IAnimatedMesh *gun = sceneManager->getMesh("gun.md2");
    irr::scene::IMeshSceneNode *Ngun = sceneManager->addMeshSceneNode(gun->getMesh(0));

    while (device->run ())
    {
        driver->beginScene (true, true,
            irr::video::SColor (255,100,100,255));
        sceneManager->drawAll ();
        driver->endScene ();
    }
    device->drop ();
    return 0;
}
In fact, the window opens but it closes immediately, and the console says:

Irrlicht Engine Version 1.7.1
microsoft Windows XP Professional Service Pack (Build 2600)
Using renderer: OpenGL 1.1.0
GDI generic: Microsoft Corporation
OpenGL driver version is not 1.2 or better
Failed to load OpenGL's multitexture extension, proceeding without.
GLSL not availaible.
Could not load mesh, because file could not be opened : gun.md2


Process returned -1073741819 (0xC0000005) execution time : 0.125
Press any key to continue.


Is it because OpenGL version is under 1.2 ?
Or his texture extension ?

I dont know, please help me!!

Thanks for reading.
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Post by ent1ty »

that GLSl stuff should not matter when loading just a simple model, and try the loading like this

Code: Select all

irr::scene::IMesh *gun = sceneManager->getMesh("gun.md2"); 
irr::scene::IMeshSceneNode *Ngun = sceneManager->addMeshSceneNode(gun);
but the problem is that it can not find the file..
irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps

Step back! I have a void pointer, and I'm not afraid to use it!
CuteAlien
Admin
Posts: 9670
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

I suppose gun.md2 is not in your working directory. When starting the executable the working directory is by default the same folder as your binary. When starting from within an IDE you can set the working directory in your IDE (by default it's usually the folder of your project file).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
marchacley
Posts: 10
Joined: Sun Jun 20, 2010 1:47 pm

Post by marchacley »

gun.md2 is in : /path/My project name
That is with my CPP's and H's.

I also put it with the EXE. :wink:


And I forgot, gun.md2 is an animation, so I replace :

Code: Select all

 irr::scene::IMesh *gun = sceneManager->getMesh("gun.md2");
    irr::scene::IMeshSceneNode *Ngun = sceneManager->addMeshSceneNode(gun);
by :

Code: Select all

 irr::scene::IAnimatedMesh *gun = sceneManager->getMesh("gun.md2");
    irr::scene::IAnimatedMeshSceneNode *Ngun = sceneManager->addAnimatedMeshSceneNode(gun);
:D

But it dosn't work yet... :cry:
marchacley
Posts: 10
Joined: Sun Jun 20, 2010 1:47 pm

Post by marchacley »

nobody? :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry:
DtD
Posts: 264
Joined: Mon Aug 11, 2008 7:05 am
Location: Kansas
Contact:

Post by DtD »

Like CuteAlien, check your working directory. http://irrlicht.sourceforge.net/docu/cl ... e521e66e61
neil_123
Posts: 67
Joined: Wed Apr 07, 2010 8:50 pm

Post by neil_123 »

Instead of

irr::scene::IMesh *gun = sceneManager->getMesh("gun.md2");

Have you tried specifying the full path of the file gun.md2?

something like,

C:\myDir\gun.md2

or

/home/laeeq/media/gun.md2
CuteAlien
Admin
Posts: 9670
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Test if the file loads in the meshviewer example. Although the error rather sounds like a problem with the working directory. Maybe you mistyped it? Copy-paste the filename into the sources to be sure it's correct.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
starsgt
Posts: 19
Joined: Tue Jun 29, 2010 3:49 pm

Similar Question

Post by starsgt »

I am able to load my meshes with no problem, but I'm just curious how the tutorials keep getting away with writing file paths like:

(/../../Sydney.bmp) for example.
Brainsaw
Posts: 1176
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

Those relative file paths are no problem, as long as the working directory you have set in your IDE is correct.

You can try to run the compiled program from the Windows Explorer. If it works the settings of your IDE seem to be wrong, if it doesn't work you have an error in the file loading itself (e.g. an invalid path).
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
CuteAlien
Admin
Posts: 9670
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Also please note that it's "../../Sydney.bmp" (no slash at start) and not "/../../Sydney". That is a big difference. The one is a path relative to the current folder, while the other is at least on Unix-systems an absolute path starting at root (and I don't even know how Windows would handle that one).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Buck1000
Posts: 93
Joined: Sun Dec 14, 2008 8:02 pm
Location: Seattle, WA

Post by Buck1000 »

What IDE are you using? I had the same problem when I first started using Code::Blocks. I had to go in and change the execution directory for my project, you might have to do the same. Check to see if its what you want.

And, when you specify directory changes like "..\..\..\" in C++, you have too use 2 slashes. So, ".\Media\gun.md2" would look like ".\\Media\\gun.md2".
Post Reply