Terrain engine question

Started by
1 comment, last by mars_888 23 years, 3 months ago
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?
Prosser: But the plans were on display.Arthur Dent: On display? I eventually had to go down to the cellar.Prosser: That's the display department.Arthur Dent: With a torch.Prosser: The lights had probably gone.Arthur Dent: So had the stairs.Prosser: But you did see the notice, didn't you?Arthur Dent: Oh, yes. It was on display in the bottom of a locked filing cabinet stuck in a disused lavatory with a sign outside the door saying "Beware of the Leopard." Ever thought of going into advertising?
Advertisement
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

http://members.xoom.com/myBollux
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
Prosser: But the plans were on display.Arthur Dent: On display? I eventually had to go down to the cellar.Prosser: That's the display department.Arthur Dent: With a torch.Prosser: The lights had probably gone.Arthur Dent: So had the stairs.Prosser: But you did see the notice, didn't you?Arthur Dent: Oh, yes. It was on display in the bottom of a locked filing cabinet stuck in a disused lavatory with a sign outside the door saying "Beware of the Leopard." Ever thought of going into advertising?

This topic is closed to new replies.

Advertisement