Jump to content
  • Advertisement
Sign in to follow this  
xissburg

moving a point on surface

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

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by oliii
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.


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 */


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!