Wavefront Obj format

Started by
7 comments, last by ArgusMaker 12 years, 3 months ago
Hello
I want to develop an OBJ importer class in DirectX. I know there already is one created by microsoft but it simply doesen't satisfy me since i tried it with lots of obj models and barely two result correctly loaded.
BUT there is still one thing about obj files that i don't understand.
When a new line begins with 'f' it means that a list of vertices ID defining a face will follow, so i expect to find three IDs
(eg: 1/1/1, 2/2/1, 3/3/1), instead, i find a variable number of indices, often greater than 3.
The point is, how should i consider the vertex indices when they are more than 3?
They are not supposed to be drawn with trianglestrip/fan/list method, i tried.
Advertisement
Each face should be a list of vertices defining the perimeter of the face. I believe a triangle fan could render them properly using the first vertex as central vertex.
Already tried with some obj models exported from sketchup.
It doesen't work. I'm starting to believe sketchup doesent export obj well.
Doesn't the obj file format support quads as well as triangles? I've seen cases where there were four indices per face, but never more than that (I'm not saying they don't exist, just that I have never seen them). I believe you can export your models with triangles only.
If you see an F command with more than three parameters then you have a polygon with more than three vertices (i.e. not a triangle). Just split it into multiple triangles or try to reexport them forcing triangles only.
Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.
I'm new myself, and was recently also going into OBJ import.

In used Maya to triangulate mesh, but you can do that in almost any app nowdays, so it would probably be best to triangulate and then import, i find it easier to work that way.
The obj format supports an arbitrary number of indices per face, so you will have to triangulate those is you want to completely support the .obj format.

f 1 2 3 4 5

Note that the first vertex is index 1, not 0.

http://netghost.narod.ru/gff/vendspec/waveobj/index.htm
for faces, you can have an arbitrary number of indices with the triplet v/vt/vn

f v/vt/vn v/vt/vn v/vt/vn v/vt/vn
v is the vertex index
vt is the texture index
vn is the vertex normal index
Ok, i forced sketchup to triangulate faces, now my importer works fine, thanks

This topic is closed to new replies.

Advertisement