Sign in to follow this  
amadeus12

how to parse obj file?

Recommended Posts

I made .OBJ file parser.

but something wierd happened.

in OBJ file, there're 254 vertices.

but in face section, it indicate 258th vertex.

I attach file here.

 

Share this post


Link to post
Share on other sites

There's a plane-object with 4 vertices at the beginning of the file:

o Plane.001
v -55.848103 -0.456518 59.626743
v 60.802990 -0.456518 59.626743
v -55.848103 -0.456518 -57.024349
v 60.802990 -0.456518 -57.024349
vn 0.0000 1.0000 0.0000

With that, there are actually just 258 vertices.

Share this post


Link to post
Share on other sites
I think that's plane not part of rock model..

Doesn't matter. See Wavefront Object specs pdf: https://www.cs.utah.edu/~boulos/cs3505/obj_spec.pdf

Referencing vertex data

For all elements, reference numbers are used to identify geometric vertices, texture vertices, vertex normals, and parameter space vertices. Each of these types of vertices is numbered separately, starting with 1. This means that the first geometric vertex in the file is 1, the second is 2, and so on. The first texture vertex in the file is 1, the second is 2, and so on. The numbering continues sequentially throughout the entire file. Frequently, files have multiple lists of vertex data. This numbering sequence continues even when vertex data is separated by other data.

In addition to counting vertices down from the top of the first list in the file, you can also count vertices back up the list from an element’s position in the file. When you count up the list from an element, the reference numbers are negative. A reference number of -1 indicates the vertex immediately above the element. A reference number of -2 indicates two references above and so on.

 

Edited by vstrakh

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this