Question

I'm developing an Android application with OpenGL ES 2.0.

I want to load an export made with Blender 2.49b in Wavefront OBJ format. I have identified verxtex position, normal and texture.

I want to use glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) to draw my mesh but I don't know how I can obtain the last parameter, indices, from a Wavefront OBJ file.

Are faces the 'indices' that I'm looking for?

I've found this on a forum: faces = indices starting with 1!

What is the meaning of 'starting with 1!'?

Thanks.

Was it helpful?

Solution

It means the first index is 1 instead of zero. Java/C arrays/collections use zero based indicies and the first element starts with zero. Wavefront OBJ format indexes start with 1.

faces are made up for 3 values v/vt/vn which are indexes. The indexes are not specified directly in the file format. Instead it's the order in which the v, vt, vn elements occur in the file. So as you are parsing the file you have to keep track of how many vertexes, vertex texture, and vertex normals you have encountered.

For all the details on the format you'll want to consult the spec.

http://www.martinreddy.net/gfx/3d/OBJ.spec

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top