dmitriyd 100 Report post Posted June 5, 2009 I have my world with vertices (V[0], V[1] , V[2]) and respective normal (normal), my player's position is (position), can anyone describe me an algoritm to "find height" from player postition to the ground ? I have used plane distance ecuation: Ax+Bx+Cx+D = 0, but I just confussed with that... _O_ | / \ --- | | h | | --------------------- 0 Share this post Link to post Share on other sites
grhodes_at_work 1385 Report post Posted June 5, 2009 Your plane equation is wrong. Should be:Ax + By + Cz + D = 0Do you know how to compute the plane equation for your ground plane?So, to find the height, let's say your player is at some point, say, <45, 100, 115>. To find the "height" above the ground, do the following. I am assuming that your "up" direction is positive Z.1) Compute the ground elevation, the ground's Z value, at the player's xy location. Solving algebraically:z_ground_below_player = -(D +Ax +By) / C;You know everything on the right-hand-side, so can solve for z2) The "height" above terrain is:height_above_ground = z_player - z_ground_below_playerOr, in this case:height_above_ground = 115 + ((D + Ax + By) / C);Hope that helps! 0 Share this post Link to post Share on other sites
dmitriyd 100 Report post Posted June 5, 2009 I dont need to compute the ground normals to do that ?How do I compute A ,B C and D of plane ecuation? Can you help me? 0 Share this post Link to post Share on other sites
grhodes_at_work 1385 Report post Posted June 5, 2009 Actually, for the plane equation, you do need a normal. So, the A, B, and C are the plane normal = (A,B,C). If the ground is horizontal and positive Z is "up", then (A,B,C) = (0,0,1). If the ground is sloped, then you have to have the ground defined in some way that you know the slope.To find D, you have to know a point that is on the plane. So, if, say, positive Z is up and the ground is at z = 15, then the point (0,0,15) is on the plane and so:Ax+By+Cz+D = 0 = 0x+0y+1z+D = z+DSo, then z+D = 0 and D = -z, orD = -15That gives you a final equation of::0x+0y+1z-15 = 0, or z = 15 for all xy. This makes sense for a horizontal ground plane, that z is the same no matter what xy you are at. If you have a sloped ground then (A,B,C) will be different and it will be a bit more interesting. 0 Share this post Link to post Share on other sites
dmitriyd 100 Report post Posted June 5, 2009 Thank you very much, here is my mail: programar3d@yahoo.com.ar 0 Share this post Link to post Share on other sites