Question

Are the amounts of v, vn and vt same in an .obj model ? I ask it because i can only use one index per draw so i have that to use VBO

struct VertexCoord
{
float x,y,z,w;
float nx,ny,nz;
float u,v;
};

so i can use one index for all buffers by striding offsets.

Was it helpful?

Solution

no, the number of v, vt, vn can be different.

notice that there is a list of "v", then list of "vt", "vn", etc...

At the end there is a list of faces: 1/2/3, 4/5/4, etc. Faces index vertex pos, texture coords, normals, but since those indexes are not related to each other this also means that num of vers can be different.

Only when the list of faces looks like "1/1/1", "4/4/4" we would have the same about of attributes.

This is a bit tricky to explain, but I hope you get the point :)

So in general you cannot directly map obj data into your VBO structure. In OpenGL you can use indexed geometry of course, but that means one index per all attribs for particular vertex. You cannot index position, texture coords separately. You have to somehow rearrange the data.

here are some links:

http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Tutorial_Load_OBJ

http://xiangchen.wordpress.com/2010/05/04/loading-a-obj-file-in-opengl/

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