[fixed]Wavefront obj import crashes program

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Brumm
Posts: 8
Joined: Fri Mar 19, 2010 12:19 am
Location: Austria

[fixed]Wavefront obj import crashes program

Post by Brumm »

Code: Select all

 int main(){
	ISceneManager* sMgr = NULL;
	IVideoDriver* vDrv = NULL;

	ITexture* skyBoxTex = NULL;
	IMesh* ufoGeom = NULL;
	IMeshSceneNode* ufoInstance = NULL;

	IrrlichtDevice* gameWindow = createDevice(EDT_DIRECT3D9, dimension2d<u32>(800,600),16,false,false,false,NULL);
	if(!gameWindow)
		return 0;

	sMgr = gameWindow->getSceneManager();
	vDrv = gameWindow->getVideoDriver();
	if(!sMgr || !vDrv){
		gameWindow->drop();
		return 0;
	}

	skyBoxTex = vDrv->getTexture("uglySky.png");
	ufoGeom = sMgr->getMesh("ufo1.obj");
 /* +++ T H I S LINE  WONT WORK ! ++  */
/* ... */
There was no problem when I imported the same model as a .3ds mesh, and finally everything worked fine with my program.
But when I tried to import the same Mesh (when in .obj format) the program crashes and Windows wants to search a solution for the problem.
I tested whether the .OBJ File contains wrong data (perhaps the export tool failed?) but all of these: C4D, Wings3D, Anim8or could import the .obj-Mesh without any problems.
Is it generally better to use the .3ds format instead of .obj? Do your irrlicht-programs crash too, when you try to import any .obj Meshes? (I usually prefered to export .OBJ - until today ...)
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

Odd, I've never had this happen before. Have you tried opening it up with the meshviewer example? If it still doesn't work, perhaps you can sends us the problematic file so we can find a solution?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Does that .obj also crash the meshviewer (from the examples)? In that case it would be nice if you could upload the model somewhere so we can test it.
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
Brumm
Posts: 8
Joined: Fri Mar 19, 2010 12:19 am
Location: Austria

Post by Brumm »

Thx for the reply.
MeshViewer crashes too, when I try to open this .obj file:
https://www.qdrive.net/en/download/shar ... 9LxnXxXxbC
But it worked fine when I converted the model to .3ds (which format I will use in the future), so this isn't a problem any longer.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

I can't reproduce it here. Which Irrlicht version do you use? Also please tell us operating system, compiler and which renderer you use.

And please take a look at the console output if there are any warnings or errors.

Thanks.
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
Brumm
Posts: 8
Joined: Fri Mar 19, 2010 12:19 am
Location: Austria

win7

Post by Brumm »

Version: Irrlicht 1.7.1
OS: Windows 7
Compiler: VC++ 2008 Express
Render: D3D9 / D3D8 / OpenGL -> doesn't really matter, MeshViewer will always crash
I tried of course 'Run as admin' as well as 'Compatibility Mode XP' -> didn't help.
If you can't reproduce the crash of the MeshViewer program (that is - you are able to import the .obj-mesh successfully??) on your machine - I'm sure that this is Windows 7's fault, and not so much a bug with the .obj importer of Irrlicht. I'll keep playing around with compatibility settings until importing .OBJ files with Irrlicht will work on my machine, too. (And if this doesn't happen I'll just use the .3ds format which seems to work fine with Irrlicht + Windows 7).

(Btw I do not even get the dialog from which I could choose 'Debug the program', when the crash happens. The only thing that happens is: 'MeshViewer doesn't work any longer.' This has changed with Windows 7 too. With Win7's predecessors I could at least choose to open the VC++ IDE and search the line of code that caused the program crash.)

Thanks for your efforts, Irrlicht is a great tool and only due to Irrlicht I see a realistic chance now to program some 3d applications in the future (within a reasonable time).
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

OK, I could reproduce it with VS. COBJMeshFileLoader::copyWord did overwrite memory when the input numbers where to long due to using the wrong index variable when writing the closing 0.

It is fixed now in the 1.7 branch in svn. Thanks for the info and the test-case.

Edit: As a workaround you can reduce the decimal places of the color values in the mtl 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
Brumm
Posts: 8
Joined: Fri Mar 19, 2010 12:19 am
Location: Austria

Post by Brumm »

Big thanks for this tip. I didn't know that the wings3d exporter writes floats with too many digits to the .mtl file. Thanks :)
Post Reply