1
votes

I have successfully created an object loader in java that loads in vertices, indices, texture-coordinates and normals. The object loader, reads in from Wavefont OBJ files.

It is relatively simple, however as soon as I try to load in a more complex file with texture-coordinate indices, and normal indices, I have no idea what to do with these extra sets of index's? I could not find any opengl (or in this case opengl es 1.1) methods to parse the texture and normal indices too. This has not only been bugging me in opengl for android but also previously did in webgl, so any help would be much appreciated. It is rather annoying that there are so many tutorials that talk about how to load vertices, indices, texture coords and normals but I am yet to see one (for opengl es) where they load in texture and normal indices.

Do I have to reorder or rebuild the texture coords / normal arrays based on indices? or some function im missing or?

1

1 Answers

2
votes

but I am yet to see one (for opengl es) where they load in texture and normal indices.

There's a reason for that: you can't. This is generally why the Wavefront OBJ format is bad for loading into OpenGL/D3D applications.

Each vertex, each combination of position/normal/texCoord/etc data, must be unique. If you are doing index rendering, each index refers to a specific combination of position/normal/texCoord/etc.

In short, you can use only one index to render with. That index indexes into all of the attribute arrays simultaneously. So if your data indexes different attributes with different index lists, you must convert your data to do things correctly. The best way to do this is via some kind of off-line tool.