iDevGames Forums
wavefront obj format - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: wavefront obj format (/thread-3114.html)



wavefront obj format - Duane - Aug 7, 2007 07:04 AM

I'm writing a program to read these suckers in, but I have a small question that the spec I use ( http://www.martinreddy.net/gfx/3d/OBJ.spec , the best one I could find) doesn't say how many vertices are allowed for every face. I've never seen a five-sided polygon in an obj file before, but I want this to be complete. Rasp


wavefront obj format - ThemsAllTook - Aug 7, 2007 07:14 AM

Nayr Wrote:I've never seen a five-sided polygon in an obj file before
I have. .obj allows for an arbitrary number of vertices per face. A lot of .obj loaders seem to triangulate their models as they load them to deal with this.


wavefront obj format - Duane - Aug 7, 2007 08:17 AM

yes, that's what I decided to do.


wavefront obj format - AnotherJake - Aug 7, 2007 08:19 AM

Nayr Wrote:I'm writing a program to read these suckers in, but I have a small question that the spec I use ( http://www.martinreddy.net/gfx/3d/OBJ.spec , the best one I could find) doesn't say how many vertices are allowed for every face. I've never seen a five-sided polygon in an obj file before, but I want this to be complete. Rasp

Well you're in for a little bit of work then, because I've seen obj files with some faces having way more than five vertices. Go to TurboSquid and download a few models to test with to see what I mean! To make matters worse, I believe the spec says that all faces are to be convex, but I've seen 'em concave too. There are a lot of programs out there which export .obj files and don't even bother to error check their own crap. I'm convinced that many users at TurboSquid don't even test their own .obj files and just assume they output correctly. IOW, there are a lot of junk obj files out there! But there are many that I've stumbled across which aren't junk and just have n-sided complex polygons which can be tessellated and work fine after that.

The solution I found is to use GLUTessellate. It takes some serious thinking and messing around to figure out how to use it without drawing display lists like all the examples out there, but it's not hard once you get it figured out. Even the Red Book is somewhat misleading on it so you have to read extra carefully. Additionally, in the tessCombineCallback, apparently the OS X implementation doesn't follow the spec in that I've received nil values for vertex data in indicies 2 and 3 (3 and 4 out of 4). Plus the spec says you should release malloc'ed data from the combiner yourself, but apparently the OS X implementation does it for you since I get a double free error if I do that. Other than that it has worked as advertised.


wavefront obj format - Duane - Aug 7, 2007 10:47 AM

yea, I worked it out.

*throttles scanf*


wavefront obj format - Duane - Aug 9, 2007 10:20 AM

uggh, I just gave up and used flex/bison. Much cleaner and much less stressful.


wavefront obj format - wyrmmage - Aug 9, 2007 09:59 PM

personally, I like .iv files, but *shrugs* different things work better for different people, I suppose Smile
-wyrmmage