Page 1 of 1

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

Posted: Wed Jun 23, 2010 2:04 pm
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.

Posted: Wed Jun 23, 2010 2:30 pm
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..

Posted: Wed Jun 23, 2010 3:56 pm
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).

Posted: Wed Jun 23, 2010 5:03 pm
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:

Posted: Wed Jun 23, 2010 5:45 pm
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:

Posted: Wed Jun 23, 2010 6:32 pm
by DtD
Like CuteAlien, check your working directory. http://irrlicht.sourceforge.net/docu/cl ... e521e66e61

Posted: Wed Jun 23, 2010 9:19 pm
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

Posted: Wed Jun 23, 2010 11:38 pm
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.

Similar Question

Posted: Tue Jun 29, 2010 3:51 pm
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.

Posted: Wed Jun 30, 2010 5:32 am
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).

Posted: Fri Jul 02, 2010 7:01 am
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).

Posted: Fri Jul 02, 2010 2:57 pm
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".