#### Archived

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.

## 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 on other sites

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

http://members.xoom.com/myBollux

##### 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

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 9
• 19
• 20
• 14
• 14
• ### Forum Statistics

• Total Topics
633382
• Total Posts
3011581
• ### Who's Online (See full list)

There are no registered users currently online

×