Sign in to follow this  
EngineCoder

Mesh structure question

Recommended Posts

EngineCoder    246
I've coded several engines for over 10 years but never thought of this: Why the number of normals/texture coordinates/vertices aren't always equal? For example, I made a cube in Blender and saved it as COLLADA .dae and it has 8 vertices and 6 normals. OBJ format also has this feature, but for example .3ds always has the same number of coordinates. Doesn't VBO require the same length for vertex/texture coordinate/normal buffer? [Edited by - EngineCoder on May 3, 2009 5:50:08 AM]

Share this post


Link to post
Share on other sites
Jason Z    6434
You could think of those normal vectors in the same way that a indexed draw call works - you only have six unique faces on a cube, and each vertex just references the appropriate vector.

It is actually quite common for DCC tools to use different formats than what is used by the rendering APIs. As you mentioned, the vertex structures typically have a list of attributes that are stored with each vertex. Most file loaders convert from the DCC format to the rendering format at loading time, or the files are pre-converted to the engine's native format before hand.

Share this post


Link to post
Share on other sites
AndyFirth    162
some hardware actually uses vertex info in this format... gamecube for instance individually indexes each vertex attribute from unique buffers.

Share this post


Link to post
Share on other sites
CPPNick    100
http://www.gamedev.net/community/forums/topic.asp?topic_id=464065

the above post is about Milkshape's Ascii Mesh format if you want to see how the normals are referenced.

if you have a flat 10x10 segmented square plane, its easier to store one normal and simply reference it, than to store 100 copies of the same one. Normals don't actually stick out of the center of a face, they start at (0,0,0) and act as an indication of direction. Also, in smooth shading, a normal is created that would be the average of the normals of all faces in the same smoothing group that share the the vertex with the normal in question.

Share this post


Link to post
Share on other sites
EngineCoder    246
Thanks, your replies explained it to me. If I got it right, basically I have to use {vertex/vertex normal/texture coordinate} arrays of the same length in my engine and do the conversion to that format when I import meshes from files.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this