OBJ file translation

Hi,
I’m pretty new to OpenGL, so please bear with me!!!

I’m trying to figure out how to load an obj file into my program. I’ve been playing with this idea for a couple of hours now, and the only solution i have is to write custom routines to read the obj file and encapsulate the vertex data (v xval yval zval) and the normals (vn xnorm ynorm znorm) between a glBegin(); glEnd(); pair…

e.g.
glBegin(GL_TRIANGLES);
glNormal3f(-0.556971, 0.760480, 0.333847);
glVertex3f(-1.915925, 2.932206, 1.062864);
glNormal3f(-0.884029, 0.403707, 0.235612);
glVertex3f(-2.660180, 2.335078, 0.746116);
glNormal3f(-0.531439, 0.606457, 0.591423);
glVertex3f(-1.869035, 2.589165, 1.791945);
glNormal3f(-0.531439, 0.606457, 0.591423);

glEnd();

This doesnt even render correctly in GL_LINE_LOOP mode, so I have to perform another hack by reading 3 triplets of vertex coordinates(provided all mesh elements are triangles) and placing them between an glBegin(GL_LINE_LOOP); glEnd(); pair…

e.g.
glBegin(GL_LINE_LOOP);
glVertex3f(0.907787, -3.468165, 2.992616);
glVertex3f(0.930737, -3.371641, 2.946086);
glVertex3f(0.611883, -3.465947, 3.211004);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f(0.611883, -3.465947, 3.211004);
glVertex3f(0.930737, -3.371641, 2.946086);

glEnd();

If this sounds right it isnt because i have to detatch ALL of the faces (triangles) of the whole model before exporting to obj… that way i can guarantee that the model will be drawn correctly using glBegin(GL_TRIANGLES);

this isn’t what I want, it isn’t covenient and its a big optimization issue as well…

How can I load an obj file without having to detatch the faces and perform hacks???

As far as I understand it won’t work (using whole undetached mesh) with GL_TRIANGLE,GL_TRIANGLE_STRIP or other enumerated constants because normally a model is built (by an artist) in an order that doesnt have any relation to the order in which vertices are and should be connected.

e.g. an edge is added halfway between the two border edges (taking a quad plane for examplpe), so the two vertices of the new edge come last after the previous model state…

there must be a way of organizing vertices into a logical and sequential order. i just don’t know enough about geometry to know how…

the left part is all messed up because the mesh had not been separated into individual triangles, unlike the two rightmost images which are rendered correctly… (please note the model is © mario ucci aka loganarts).

I hope someone can help me!!! please!!! hehe!

cheers!!!