OBJ conventions

I have been improving my engine to use larger models but I have seen some with strange data inside.

It was my understanding that the face elements at the end of the file should consist of three sets of data containing, Indices , texture coords and normals. But i found a teapot example with face data in this format.

f 7771/8201 7770/8200 7758/8187 7759/8188 

I know it’s the indices and texture data but why is there 4 sets of data??

For that face you have shown; the face is a quad, as their is 4 vertices per face.

if it was a triangle, their would be 3.

You will need to write some code to triangulate the faces or load it into blender and export it with the triangulate checkbox on.

You can manipulate this to turn quadrilaterals to triangles:

int[] vertexIndicesRectangle = new int[]{1, 2, 3, 4}

int[] vertexIndicesTriangle1 = new int[]{vertexIndicesRectangle[0], vertexIndicesRectangle[1], vertexIndicesRectangle[2]}
int[] vertexIndicesTriangle2 = new int[]{vertexIndicesRectangle[2], vertexIndicesRectangle[3], vertexIndicesRectangle[0]}

Ahh okay, thanks. I was not sure…I exported that model on a different pc so my settings must be different, thanks!

This is a highly unlikely pattern.

Use {0,1,2}, {2,3,0} as mappings.

I was just showing the exact indices coming from another array so OP gets a good idea.

And I was just saying that your indirection layer is highly unlikely to be correct.
You create two triangles that partially overlap and do not fill the whole quad.

Read that wrong, whoops! Fixing it now. Thanks!

it’s only important to create two triangles with the correct winding, CW or CCW - whatever your GL is set to.

something i learned about importing quads is importance of the information.

once transformed into triangles it’s still interesting to know which triangle belongs to a quad.

when generating normals and the quad wasn’t perfectly flat.
when processing the mesh; subdivision or smoothing. iterating over vertex-neighbour-edges, that extra edge needs special attention.

o/