Sign in to follow this  
calicojack

Heightmap and collision problem

Recommended Posts

I have a height map which I do collision detection and correction with. All triangles are right triangles. I find the triangle based on the x/z of the player's character and adjust the player's elevation to the highest point of that triangle. Herein lies the problem. Since the model can sometimes hang off the triangle, how do you avoid clipping with the neighboring triangles if the current triangle is lower than its neighbors? How do you avoid floating if your current triangle is higher than its neighbors? I see a few solutions to this, but none sit well with me. 1) Do collision detection for the four bottom points of the model (bounding box collisions). This is not right if the current triangle you are located on is lower or higher than the neighboring triangles. The model will clip through the higher edges of the triangles and it will float above the lower edges. 2) Position the model on the same plane (angle) of the current triangle. When the model hangs off the triangle, the neighboring triangles could be higher (which will clip) or lower (which will make the model appear to float). 3) Use larger triangles for the maps. This is sweeping the problem under the rug and could lose detail/realism on the map. I appreciate any feedback. Attached are three screenshots. Top Free Image Hosting at www.ImageShack.us Below Map 1 Free Image Hosting at www.ImageShack.us Below Map 2 Free Image Hosting at www.ImageShack.us

Share this post


Link to post
Share on other sites
You're heading in the right direction with the first solution. Instead of positioning at the highest point in the triangle you need to find the exact hight within the triangle.
First position your model above the terrain then cast rays down from each corner of the model then position the height at each corner to the terrain height where the ray intersects.
A much better discription is here
http://www.toymaker.info/Games/html/terrain_follow.html

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this