Jump to content
  • Advertisement
Sign in to follow this  
ArgusMaker

Wavefront Obj format

This topic is 2538 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Already tried with some obj models exported from sketchup.
It doesen't work. I'm starting to believe sketchup doesent export obj well.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!