Jump to content
  • Advertisement
Sign in to follow this  
a128

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.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!