Jump to content
  • Advertisement


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


Terrain engine question

This topic is 6517 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

This might be a simple question but I was wondering what would be the best wat to get the height and normal vector from a given point from a terrain. Say you would use a simple height map to represent the terrain: float heightMap[100][100]; // for example. and the same for the vertex normals. and each cell would have a certain distance between it (say 10 world units) so the whole terrain would be 1000 x 1000 world units. Then you would know the height and normal vector on each of the vertices, but what if you would want to know the height(or normal vector) interpolated somewhere between the vertices (at (12.73, 30.12) for example). What would be the most efficient way to calculate that?

Share this post

Link to post
Share on other sites
depends if your terrain is made up of triangles or quads

find the triangle/quad that the point belongs to.
take 3 points from that shape and u can work out the normal.

u wanna know the height(y) of the point + u already know x,z

just use the plane equation Ax+By+Cz+D=0

note of course this only accurate if you''re using flat polygons. if youre using the points to make a curved surface eg bezier patch etc then that requires a bit more math


Share this post

Link to post
Share on other sites
I'm using flat triangles for the terrain.
I was allready thinking about doing the height in this way, though I thought there would be a more efficient way of doing it

About the interpolation of ther normals though... The point is that if you just calculate the normal of the face and you use it to position an object like a vehicle. Once you start moving across the terrain with the vehicle the transition isn't nice and smooth.

I was thinking about taking the triangle and the intersection point. Then calculating the averaged normal by using the distance from the intersection point to the other 3 vertices. Basically calculating a weighted average from the vertex normals of the terrain.

Edited by - mars_888 on January 15, 2001 9:13:04 AM

Share this post

Link to post
Share on other sites

  • 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!