wavefront obj format

Member
Posts: 567
Joined: 2004.07
Post: #1
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

It's not magic, it's Ruby.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
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.
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #3
yes, that's what I decided to do.

It's not magic, it's Ruby.
Quote this message in a reply
Moderator
Posts: 3,571
Joined: 2003.06
Post: #4
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.
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #5
yea, I worked it out.

*throttles scanf*

It's not magic, it's Ruby.
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #6
uggh, I just gave up and used flex/bison. Much cleaner and much less stressful.

It's not magic, it's Ruby.
Quote this message in a reply
Moderator
Posts: 370
Joined: 2006.08
Post: #7
personally, I like .iv files, but *shrugs* different things work better for different people, I suppose Smile
-wyrmmage

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  reading wavefront-file in array bonanza 6 4,977 Sep 6, 2007 05:43 AM
Last Post: bonanza