Collision detection......

SYS49152 101 Dec 31, 2004 at 08:58

hello all….

i have atm my terrain as a simply layer and combined with real data that was created in a modelling programm for mountains.

something like this:

the player should be able to run on the mountains.
so i wonder what kind of collision detection normaly people implement for this kind of data.

my first attempt is to scan the object. i have a simply copy of the modell in memory. but if the mountains get more complex more time is needed to find the triangle the player is on.

i have 2 ideas atm but i dont know if someone would do this way.

  1. divide the modell in different parts. ( somekind of patches ) inside the modelling programm and then save as single modells.

  2. using an octree for the modell ( mountains )

  • Andy

1 Reply

Please log in or register to post a reply.

Smokey_ 101 Jan 13, 2005 at 12:51

The simplest and cheapest way if you just want the player to be able to walk on the terrain would be to find what triangle the player is on, given their x/z coordinates. (If your terrain is simply a uniform grid, this should be quite trivial)

Then given the distance between the triangles point’s and the player’s position, LERP between the three points of the triangle. This will give you the point on the terrain where the user should be…

However if the terrain overlaps itself in some cases (eg: caves…), or you want more complex physics, you’d best go the whole way and implement some rigid body dynamics…

I hope this helped… :)