Jump to content
  • Advertisement
Sign in to follow this  
FeanorLobelia

Calculating index buffers via an algorithm?

This topic is 3717 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

Hi, after abandoning the DirectX format (which I incidentally found very convenient, very readable - good for animation and easy to transfer to binary - but blighted by its fast ageing fixed function legacy) I decided to construct my own mesh format. However I don't have the index buffer output from the modeler - and I'm not sure how to get it from the vertex buffer. Any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
Assuming the vertex buffer contains all triangles in the right order


X1,Y1,Z1,X2,Y2,Z2,X1,Y1,Z1,X2,Y2,Z2 ....


the index buffer would look like this:


0,1,2,3,4,5 ....


However, you can optimize this by checking for redundant vertices. For each new vertex you check whether it is already there (possibly using some fast look-up table to be able to find vertices close to a given position quickly). If true, you can reuse this vertex index in the index buffer.

Hope this helps.

Alexander

Share this post


Link to post
Share on other sites
Thanks very much! The problem is that I don't have my triangles in the right order - I just have a list of vertices without specification as to when they're drawn. So I suppose I have to get that information, somehow - is there a way to calculate that?

Share this post


Link to post
Share on other sites
Given an arbitrary set of vertices, there is no way to determine what polygons should be stretched across them. You either need multiple sets of vertices with a polygonization assumption overlaid on each set (ie triangle strip), or the actual vertex list and index lists.

Share this post


Link to post
Share on other sites
I asked same thing times ago, and Buckeye found a very good solution.
http://www.gamedev.net/community/forums/topic.asp?topic_id=491501

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!