PDA

View Full Version : Writing .obj importer, please advise.



RobertSI
11-02-2001, 03:26 AM
I am trying to write an .obj file importer.
I have no problem parsing the file. The problem is using the FACE data. As I understand it OpenGL uses:
glBegin(_);
glVertex3f(_,_,_);
glEnd();
This works fine for GL_POINTS, but I know that the FACE data has to be used for the other GL konstants.
Can anybody interpet:
f 1/1/1 2/2/2 4/3/3/ 3/3/4
I know what a FACE is just don't know how to incorperate into 'C' source.
Thanks in advance.

Rob The Bloke
11-02-2001, 03:58 AM
Each vertex in the file is assigned a unique number Identifying it, the first vertex listd is number 1, second is number 2 etc..

No matter how may surfaces there are, all vertices will be numbered incremetally. This is done for the whole file, not just the surfaces!

The normals and texturing co-ords are numbred in exactly the same way.

a face is represented as :

f 1/1/1 2/2/2 3/3/3

each vertex is represented by a block ( eg , 1/1/1 is one vertex). In the example above, we have a triangle, each block of three numbers corresponds to one of the vertices :

better represented as :

f v1/t1/n1 v2/t2/n2 v3/t3/n3

to make the triangle, we have to use vertex 1, tex coord 1 & normal 1 for the first vertex, and so on for the other vertices.

The idea is to minimise the file size by reusing data (most stuff is shared by a number of polygons)

Hope that makes sense

Allan Walton
11-02-2001, 04:24 AM
Try here for more info on the .obj format
http://astronomy.swin.edu.au/pbourke/3dformats/obj/

Cheers

Allan