# moving a point on surface

This topic is 4992 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

How can I do a point walk on a 3D surface?for example a non-uniform ground, a montanhous terrain with many polygons on various orientations....Do you know how to do it?!?

##### Share on other sites
I'm also beginning with this and I had this problem some time ago. Maybe it's not the better solution but :(

I'm drawing only triangles.
I have a grid with the heights saved in a matrix and with this information I can calculate the plane that contains every triangle(and the normal vectors).
Then when the point is above this triangle giving the x and the z and with the plane's formula I can know the y coord.

But the grid confines the kind of terrain you can have(all the points equidistants) and surely there's a better way.

##### Share on other sites
That's a perfectly acceptable solution.

Another one is using bilinear interpolation.

Take the 4 points around the point on the regular grid, and interpolate between those 4 points to get the height.

For an arbitrary mesh, it's more difficult, and it depends what you want to do.

What I'd do is start with one triangle and a point on that triangle, and walk along the triangle plane, and the neighbouring triangle when the path crosses an edge.

##### Share on other sites
hmm....how is the plane's formula?!?

##### Share on other sites
Quote:
 Original post by oliiiThat's a perfectly acceptable solution. Another one is using bilinear interpolation. Take the 4 points around the point on the regular grid, and interpolate between those 4 points to get the height. For an arbitrary mesh, it's more difficult, and it depends what you want to do. What I'd do is start with one triangle and a point on that triangle, and walk along the triangle plane, and the neighbouring triangle when the path crosses an edge.

Umm!Thanks oliii I'm sure your solutions is smoother than mine. I must try it!
Quote:
 hmm....how is the plane's formula?!?

you can write a plane's formula like this
aX + bY + cZ + d = 0 or if you want
Y = -(aX + cZ + d)/b
where X,Y,Z are the coords of the points and the a,b,c,d are the constants that define the plain.
To find the constants you must solve a system imposing that 3 points are in the plain.

Let's say you have three points ( x1 , y1 ,z1),( x2 , y2 ,z2),( x3 , y3 ,z3) and you want to know the plane that contains the three, then you must impose:
a*x1 + b*y1 + c*z1 + d =0
a*x2 + b*y2 + c*z2 + d =0
a*x3 + b*y3 + c*z3 + d =0
Solve this and you will have a,b,c,d.But wait, three equations, four variables...yes you must impose some valor to one. For example b = 1 and find a,c,d by solving the system.

The trick is that if your points are equidistant you can write in a paper many of the operations and the result isn't too complicated.

/* As always forgive or better forget my english */

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 31
• 16
• 11
• 10
• 12
• ### Forum Statistics

• Total Topics
634118
• Total Posts
3015602
×