4

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?

grivescorbett
  • 1,605
  • 1
  • 21
  • 29

2 Answers2

2

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.

genpfault
  • 51,148
  • 11
  • 85
  • 139
  • Right, I'm realizing that when the points are not coplanar it isn't clear. I even tried making a shape in Cinema 4D, exporting to OBJ, importing in Blender, and they interpreted them differently. – grivescorbett Aug 15 '12 at 04:59
0

It depends on your polygon. OpenGL does have a function for drawing polygons rather than quads or tris or strips and such. However, the polygon needs to be a convex polygon. Otherwise you'll need to tessellate.

If you're using fixed function, it's "glBegin(GL_POLYGON)"

zero298
  • 25,467
  • 10
  • 75
  • 100
  • 2
    @grivescorbett: No, it's [*removed* in the core profile](http://www.opengl.org/wiki/Core_And_Compatibility_in_Contexts). "Deprecated" means "subject to removal in the future." Removed means removed. – Nicol Bolas Aug 15 '12 at 01:02
  • 1
    `GL_POLYGON` is only valid for convex polygons. The OBJ spec makes no such restriction. – genpfault Aug 15 '12 at 04:26