Sign in to follow this  
a128

Heightmap from Triangles

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 this post


Link to post
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 this post


Link to post
Share on other sites
This tutorial might have what you want I think:
http://www.videotutorialsrock.com/opengl_tutorial/blockhead/home.php

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

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this