GliTch 122 Report post Posted January 16, 2002 I created a terrain and I''m trying to make my character to walk on it. my idea is to 1. Determine which tile my chracter is on 2. Determine which of the two triangle its on. 3. Calculate the height. Now my problem is on 3. How do i calculate the height? is my idea the right way of doing it or is there easier way of doing it? 0 Share this post Link to post Share on other sites

krez 443 Report post Posted January 16, 2002 you have to find out where in the triangle the character is, and get the height at that point (there was a post here earlier that went into detail about how to do this)... you might be able to just average the heights of the 3 corners of the triangle (or the 4 corners of the tile) and use that; it isn''t nearly as accurate but it might work out if your terrain isn''t very "bumpy"... that''d be faster, and it might look ok (i never tried any of this, so sorry if i am completely wrong)... --- krez (krezisback@aol.com) 0 Share this post Link to post Share on other sites

BS-er 181 Report post Posted January 16, 2002 I recently came through the same issue. My approach worked perfectly, giving the exact hight on a given terrain triangle. here's my approach:I have a 2D matrix of floats for height values of every terrain vertex. Since I know the distance between each vertex, I only need the height (y axis).Let's say my x, z coordinates are 24,25, and each vertex is 10 meters apart along the axis.What I determine is that I'm 4 meters beyond the 20,20 vertex in the x direction, and 5 meters beyond that vertex in the z direction. I'm also on the lower triangle of that square, because 4 + 5 < 10.Lets now say that the vertex at 20,20 is 50 meters high. let's say the vertex at 30,20 (10 meters in the x direction) is 60 meters high, and the vertex at 20,30 (10 meters in the z direction) is 70 meters high.I use the follwing formula to get my height:y = 50 + (60 - 50) * (4/10) + (70 - 50) * (5/10).Now lets say my x,z position is 26,27. this puts me 6 meters beyond the 20,20 vertex in the x direction, and 7 meters beyond that vertex in the z direction. I'm on the upper triangle of that square, because 6 + 7 > 10.Since I'm on the upper triangle of the square, I need to use the vertex at 30,30. Let's say it has a height of 80.so my height is:y = 80 + (70 - 80) * ((10 - 6)/10) + (60 - 80) * ((10 - 7)/10). y=70 y=80+---------+---------+---------+| | | || | | || | | || | |y=50 |y=60+---------+---------+---------+| | | || | | || | | || | | | ^+---------+---------+---------+ || | | | z| | | || | | || | | |+---------+---------+---------+ x -> Each number 10 in the equation is basically representing the distances between terrain vertices.I can post my algorithm in C++ if you like, but there's some translations in it that might throw you off. See if this helps first. Value of good ideas: 10 cents per dozen.Implementation of the good ideas: Priceless.The Battlezone Launch PadEdited by - BS-er on January 16, 2002 10:50:44 PM 0 Share this post Link to post Share on other sites