#### Archived

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

# Height map to triangle strip

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

## Recommended Posts

I have a two dimensional array for my height map, the question is how can I put that into a triangle list or triangle strip?

##### Share on other sites
Let's say you have a 64x64 pixel heightmap. That means you have 64 pixels per row and 64 pixels per column. Each pixel is a vertex, obviously. 4 vertices make up a square, so that means you have 63x63 squares in your heightmap. Each square is made up of 2 triangles. With all that information, you can lay out the heightmap as a series of triangles, like this:

0--2--4| /| /||/ |/ |1--3--5

which is a very straighforward triangle strip: 012345
t1=012
t2=213
t3=234
t4=435
etc...

Hope that helps...

[edited by - fizban75 on March 17, 2003 8:18:14 PM]

##### Share on other sites
I was thinking something like that myself but what happens when I reach the end of the row? Do I have another strip going:

1--3--5
| /| /|
|/ |/ |
6--8--10

so that I have 63 strips in total?
like so:

---------
---------
---------
---------

sorry if I sound confusing.

##### Share on other sites
Yeah, one way is to do the next row the same as the prior one, so that you''d have 63 triangle strips all running left to right. The other way, which allows you to have only one triangle strip covering the whole terrain, is to reverse the direction of traversal every other row. Row 1 would be left to right, row 2 would be right to left, etc. The only thing here is that you have to be careful of your winding. That one takes a bit of thought, but that''s the only other solution if you want just one triangle strip. Of course, you''ll probably then divide up the terrain into a quad or octree, and use separate index arrays drawing separate triangle strips for each leaf-node.

##### Share on other sites
Thanks fizban75.

quote:
Of course, you''ll probably then divide up the terrain into a quad or octree, and use separate index arrays drawing separate triangle strips for each leaf-node.

He he. Well, not just yet anyway I''ll take it one step at a time.

##### Share on other sites
You that it is possible to make the terrain just one large strip... I was trying to draw this on paper, but couldn''t really get it figured out. It seemed that no matter what I did, every othre row would have back facing tris or at least every other triangle would be facing the wrong way.

Thanx

Dwiel

P.S. sorry for bringing this thread back, but it seemed apropriet SP?