# Calculating index buffers via an algorithm?

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

## 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 on other sites
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 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 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 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

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633661
• Total Posts
3013227
×