PDA

View Full Version : well collision



JSoftware
15-02-2004, 02:57 PM
well well well...

i've got a bunch of triangles and a camera! i want to make some nice and simple sphere collision detection but as it is the first time i ever try collision detection programming i don't really know how to do that.. i'm not the big mathematic genius but i thought of a way to do it: (it sounded good in my ears)

check all triangles with following=

get nearest point inside the triangle
if the length from the camera to the point is 5 or under the move is invalid and i don't move that way!

is that the easiest way to do it? i just want it so easy as possible (just without bounding boxes which seems impossible to implement at this state) :roll:

Clootie
15-02-2004, 05:54 PM
Google for: "triangle+with+sphere+collision+detection" (http://www.google.com/search?sourceid=navclient&ie=UTF-8&oe=UTF-8&q=triangle+with+sphere+collision+detection).

If we look at your algo: when performing "get nearest point inside the triangle" - you have already got distance for each of 3 vertices to your sphere - so if any of these vertices is nearer to sphere - you got it!
But depending on count of triangles in you scene it's not best idea to check EVERY triangle agains sphere. So you'll have to use some kind of bounding boxes sometime in future anyway.

Ultra
15-02-2004, 11:18 PM
There's also an (c++) example on http://www.gametutorials.com on how to do a sphere-polygon collision.