Jump to content
  • Advertisement
Sign in to follow this  
lexs

OpenGL OBJ to indexed VBO

This topic is 3714 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having problems wrapping my head around on how to convert a OBJ file to a indexed interleaved VBO as OBJ uses separate indexes for vertex, normal, texcoords instead of just 1 for all as OpenGL. Now i only use the vertices and it loads and works great, but i need help on how to get vertex, normal and texcoords (using a single index).

Share this post


Link to post
Share on other sites
Advertisement
I'm afraid you will have to do a little more work in your Obj loading routines.
(Or of course, you could search for some Obj tool or source).
Anyway ... given a simple model that consists of a Vertex, tex coords and normals and a face index set you need to parse this into a vertex_array_friendly format.

The trick is to understand that the Obj file format is an optimized for storage format and not optimized for rendering. So - with that in mind you should essentially:

read the list of vertex coords and store in a temp vertex list
Do the same for the texture and normals
Then read each face in turn (and each face will have a set of indexes into the vertex, texture and normal temp lists). Use these indexes to obtain the corresponding vertex from the temp vertex list, the face-texture index to read the texture-coord from the temp texture list and so on for all the attributes. Finally, store the result into the Final_array_list and record the index in the final_index_list

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!