Search code examples
openglwavefront

Displaying .obj files that are not all triangles or quads


I understand that there has to be some index magic to get an obj file into the correct vertex/index format for OpenGL, but consider the following .obj file:

# WaveFront *.obj file (generated by CINEMA 4D)

g Polygon
v -136.714894 0 -169.395745
v 134.53617 0 -224.953191
v 321.906383 0 -87.693617
v 358.944681 0 182.468085
v 49.565957 0 264.170213
v -340.425532 0 165.038298

f 6 5 4 3 2 1 

The face is not a triangle or quad, does this mean I'll have to do some sort of tessellation on the cpu or gpu? Would that be the standard method for dealing with that type of geometry description?

EDIT: In addition, is there a library that will do triangulation that is not restrictively licensed?


Solution

  • Hope they are planar polygons and triangulate via your preferred method.

    If they aren't planar then you might get away with PCAing a dimension off and triangulating the result.