# Heightmap from Triangles

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

## Recommended Posts

For a racing game I used 2D Sectors and 3D Triangles to gather the height of the terrain (HOT), works nice but is slow because I have to 1) test the position if it's inside the triangle 2) Compute (interpolate) the HOT Then I came up with the idea to use the height of the drivelines...but that will not work if you have some tilted sectors Maybe a heightmap[x][z] would work ...but I wan't to generate the heightmap from my triangles any ideas how to do that

##### Share on other sites
select your heightmap's grid resolution, then step in x-z plane at that resolution in the world; ray-cast straight downward (from some very high ray-origin) and compute the intersection with your triangles; use the intersected position's y value as your height for that cell, advance to next cell in heightmap...

##### Share on other sites
This tutorial might have what you want I think:

[Edited by - Tenac on May 14, 2008 8:49:10 PM]

##### Share on other sites
There is an excellent digression of this problem in the following book by Frank D Luna:

"Introduction to 3D Game Programming with DirectX 9.0"

I also think that this book has increased substantially in size in its latest edition, with more topics on pixel and vertex shaders.

Anyway, it sorted me out beautifully (once I re-wrote Frank's code in a slightly better format) and he also gives tips on how to cheaply pre-light the terrain. Something that emeyex was pertaining to.

In any case, check it out if you can!

1. 1
2. 2
3. 3
Rutin
22
4. 4
JoeJ
17
5. 5

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631774
• Total Posts
3002297
×