Sign in to follow this  

Terrain Collision

Recommended Posts


I want to make terrain collision checking with primitives like a sphere and axis-aligned box. I'm in 3D by the way.
I've constructed my terrain from a heightmap and I have a method for checking if a point is below the terrain by transforming the point's position into a position in the terrains height array and then calculating the specific height on the terrain by using three height values and calculating the point within the triangle.

This worked fine for making spheres stay above the terrain. The problem is now I am trying to construct a collision detection system so I have it set up with spheres and AAboxes and now I want to add the terrain to this system. How would I go about this?

I'm also having trouble arranging this in my code. I have a baseCollision class and collisionSphere / collisionBoxAA classes. Would you suggest I have a collisionTerrain class maybe? Or have a collisionTriangle and somehow collision check against triangles individually?

Any links to websites or advice would be much appriciated

Share this post

Link to post
Share on other sites
You said you can actually calculate the point which the sphere/AABB is suppose to be @ to be ontop of the terrain, am I correct? If so exactly what kind of collision are you looking for?

like do you want to Check if Object A Collided with Terrain B (as in either it did or it didnt) or do you want to check, where the point of collision will be if any?

As for arranging your code the way I would do it is have a checkCollision method in your Terrain class with multiple overloads for the different type of Objects that you might be interested in interacting with the terrain like, Spheres, AABB, OBB, Rays (for picking of course), and then let your Scene Node handle the collision with any Objects that have been added/updated in the scene. I feel like I need a little bit more detail or a better explanation tho in order to truly help you.

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