ObjLoader crashes on some Blender models--easy fix

Any community contributions to libgdx go here! Some may get included in the core API when permission is granted.

ObjLoader crashes on some Blender models--easy fix

Postby tenfour04 » Sat Nov 12, 2011 6:18 pm

I made a model in Blender and exported it as a Wavefront Obj. The model loads fine if I don't triangulate it, but then half of each quad is missing. When I triangulated the model, it kept crashing the ObjLoader with "Unable to parse int...".

It took me a while to figure out what was wrong. For some reason, Blender sometimes adds a carriage return to the end of each face line. I don't know exactly what cases result in the carriage return, but it always happens when I triangulate my model. And it's not easy to diagnose, because the carriage return is invisible in Notepad and various other text editors.

So to avoid others running into this pitfall, can a String.replace('\r', '\n') line be added to the ObjLoader? This fixed it for me.
tenfour04
 
Posts: 1235
Joined: Sat Jun 18, 2011 3:24 pm

Re: ObjLoader crashes on some Blender models--easy fix

Postby radioking » Tue Nov 15, 2011 1:33 pm

How many verts and faces do you have in your Model file?
Please "give sth. back" to community and contribute your knowledge to our libgdx-users project community wiki:
http://code.google.com/p/libgdx-users/
Please see Mario's note on User Wiki 2.0: http://www.badlogicgames.com/wordpress/?p=2411
radioking
 
Posts: 284
Joined: Wed Aug 03, 2011 10:28 am

Re: ObjLoader crashes on some Blender models--easy fix

Postby tenfour04 » Wed Nov 16, 2011 3:02 am

It's a half-pipe formed from 16 quads. So 34 vertices and 32 triangles.

http://imageshack.us/photo/my-images/528/halfpipe.jpg/

Here is the Blender file and both versions of the model file.
Attachments
halfpipe.zip
(69.81 KiB) Downloaded 355 times
tenfour04
 
Posts: 1235
Joined: Sat Jun 18, 2011 3:24 pm


Return to Libgdx Contributions

Who is online

Users browsing this forum: No registered users and 1 guest