Archived

This topic is now archived and is closed to further replies.

billybob

how would i set up an index buffer for a triangle strip?

Recommended Posts

i have this terrain, it could be 256 strips of 256 triangles instead of 256*256 triangle lists. i imagine this would increase fps quite a bit, how would i go about setting up the index buffer for this? like would it be this: i1 = vert1 \ i2 = vert2 | -first triangle i3 = vert3/ i4 = vert2\ i5 = vert3| -second? i6 = vert4/ i4 = vert4\ i5 = vert3| -third? i6 = vert5/ but it seems that this method is defeating the purpose of a triangle fan, as i''m still passing three verts per triangle. is there a good example i can look at for this?

Share this post


Link to post
Share on other sites
I''m using strips for an animation like this, but it
should also work for terrain.
Say I have a just two terrain blocks(4 triangles)

V2 V4 V6
|\ |\ |
| \ | \ |
| \ | \ |
| \| \|
V1 V3 V5

The indices would be as follows

i(1)= V1
i(2)= V2 <-- Triangle 1
i(3)= V3

i(4)= V4 <-- Triangle 2
i(5)= V5 <-- Triangle 3
i(6)= V6 <-- Triangle 4

The system will automatically use the 2 previous indices
from the second triangle onwards, thus, you send only
''1'' index per triangle (or 1 vertex).


Hope this helps.

Share this post


Link to post
Share on other sites
now, would 256 calls to this be faster or slower than a call to a indexed triangle list? that is what i'm already doing, indexed triangles.

[edited by - billybob on July 28, 2002 5:02:45 PM]

Share this post


Link to post
Share on other sites
It''s possible to draw the whole terrian in one DrawPrimitive call and still use an indexed triangle strip, if you don''t mind turning of back-face culling, and wasting 1 triangle per column. That is how my terrian engine works anyway. It''s difficult to describe... it looks like this

|/|\|
|/|\|
|/|\|
|/|\|

First you go down, then, as you move across, you must move across 2 vertices (here a triangle is wasted) and then draw the strip going upwards with the diagonals going the opposite way. When you get to the top, again, move across 2 vertices, and you are back in a position to start the downwards strip again. Notice you cant use back face culling because the triangles faces opposite ways in each column. This usually isn''t a big deal with terrian (since you''re rarely underneath it). It''s an awkward algorithm to implement, and may not even bring you must of a speed increase, but I do promise it''s possible and it works.

Share this post


Link to post
Share on other sites