Advertisement

Box/Tri collision - anybody?

Started by July 31, 2000 07:05 PM
4 comments, last by IDC 24 years, 4 months ago
Can some kind soul help me out here, trying to come up with a robust fast box/tri collision test is driving me nuts. Sphere/Triangle I''ve done, but it''s a little too inaccurate for my tastes, and when I want to do Sphere/Sphere testing(for objects hitting objects), it''s far too inaccurate. I''ve seen the odd example on the ''net, like in graphics gems or magic, but I still can''t figure out a proper no-mess non-cube non-axis aligned box/triangle test which will simply return a hit/miss result. Somebody has to have done this - it''s very commonly used. If anybody can help me out here, I would be very grateful!
well, my box/wall collision detector/resolver went something like this:

checkcollisions()
{
for (# boxes to check)
for (# walls to check against)[j]
for ( # corners of the box)[k]
{
test if corner violates the plane
designated by the wall for loop[j]
if(violated)
assign collision corner[k]
assign collision normal of plane[j]
assign object colliding <br> return colliding<br> }<br>return clear;<br>}<br><br>the values assigned by this detection function are passed to the resolver for calculating the impulse factor caused by the collision, and thereby reassigning velocities, etc.<br><br>this is basically how chris hecker did his collision detector/resolver in his game developer articles.<br><br>a2k<br> <br> </i>
------------------General Equation, this is Private Function reporting for duty, sir!a2k
Advertisement
Thanks, I can do planes, but properly checking triangles which can be of any orientation or size is what''s causing me grief.
There are some ways, like defining the box from 12 triangles, then checking, or doing a line/tri check from every line needed to define the bbox, but it''s too slow. I couldn''t just see if the 3 triangle points are within the box either, as the triangle may intersect the box while all the points are outside. Nor can I do line/plane checks, because the triangle can intersect the box when there are no edges intersecting.

Very messy stuff :-(
Hey man, don''t give up. I''m working on it. I''ll let you know when I''ve got it working.

www.gameprojects.com - Share Your Games and Other Projects
About sphere/sphere - collision:

You only have to test if the distance of the centers of the spheres is < r1 + r2.


bool collision(...)
{
if ((r1 + r2)*(r1 + r2) > (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) + (z2-z1)*(z2-z1)) return true;return false;
}


GA
Visit our homepage: www.rarebyte.de.stGA
um, last i checked, he''s not looking for sphere-sphere collision.

a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k

This topic is closed to new replies.

Advertisement