Pregunta

I have been working on some 3d stuff in relation to android, specifically opengl ES 2.0. In my learning path all (most) of the examples show you how to take an obj file (wavefront .obj) and rip the vertices out of it. Upon further reading though, you find that both the obj file and a few other file types (popular ones at that) decided to "go their own way" even though most 3d libs cant support independently indexed meshes (seperate index for vertices, normals and texture coords) these file types used multiple indexed meshes anyways.

So anyways here's my question:

I read in one place that some of the file types out there that exist provide easy import into opengl (i.e. without all of the crazy shuffle electric slide harlem shake stuff i have to do to the data in an obj file). Does anyone know some file types (opengl / friendly) that supports a single index for indexed drawing?

¿Fue útil?

Solución

Try looking at Quake's MD2 format (good tutorial here) http://tfc.duke.free.fr/old/models/md2.htm which is designed specifically to be loaded into OpenGL. It is a nice thing to learn however it is a little old.

By contrast, the OBJ format is still going strong and it has a lot going for it (simplicity, wide support). It looks like you're on the right path as you seem to understand that the format has separate indices for vertices, normals and texture coords, and thus has a requirment for you to create a separate index buffer for your Vertex Arrays.

The trick to get it to work well is to use a fast hashtable solution to store/retrieve the 'vert/norm/tex' face descriptions. (My first attempt at an OBJ importer took 7 seconds to read a 10000 face object, now it's down to 0.5 seconds - and can probably still be improved! Good luck!

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top