Advertisement

Working Colision in 3D

Started by June 12, 2002 09:35 AM
9 comments, last by Kern 22 years, 8 months ago
Hi, I''m making a simple racing game and I created a system of colision but I just can''t get it to work properly no matter what I try. I first tried a system that checked the position(after movement) and if inside any polygon you get pushed back. But it couldn''t work properly because if you go fast enough you can go through a polygon. (I abandoned this technique) So I tried to create a system that works on the path of the vehicule. It doesnt work properly because I''m able to find the closest points between a line and a polygon and use it to deviate the path, but that point isn''t the first point of contact so sometimes the sphere is still coliding at the end of a frame. I would like to know if anyone has a system that works without flaw(like going through walls) or if anyone uses a similar system to mine? I also tought of making a bubble around the polygon and trying to detect the point of entry of a ray(path). But I can''t figure out how to detect those colision and get that colision point. If anyone knows how to find the first point of contact between a sphere and a polygon or a polygon bubble and a ray I would realy apreciate the help. Of course if you have a better system I would like to hear about it. Thanks for reading.
Have you thought about using bounding boxes inside some sort of quad tree?

Lemme xplain, every object gets one or more cubes around it (depending on the speed you want the game to run and the precision factor)

Put all these boxes inside a tree, subdivide the tree a few times.

Check out in which tree your currently driving, test the pre-movement car position and the post-movement car position with all the objects in the tree.

If an object is between the pre-movement and post-movement position, you''ve got a winner

Hope it helps

-- Divide
Advertisement
I already use an Octree that gets the Polygon Index of all the Polygon that could colide with the vehicle. But that is beside the point.

The test of "is there something in between the start and end point" is something that I already try to do and that doesn''t work well enough. Also my colision between two vehicle or a vehicle and an obstacle other than the terrain mesh works well enough.

It doesnt work well because I use the point of colision between the path and the polygon itself. that means that the vehicle is at that point well inside the polygon.

I evaluate that the best thing would be a system that never lets the vehicle gets into a polygon, because it would then never be intersecting a polygon at the end of a frame(that causes big problems with the physics) and a system that pushes the vehicle outside of the polygon when a colision is detected will push it in an other polygon very often.(it also make angles smaller then 90 degree between polygon a major problem)

Thanks for your response it helped clarify the problem.
I''m presently developing a system that involves making a simple polygonal shell around the polygon and reflecting a ray on that.

In theory it should work but... "in theory communism works".
It would limit collision to sphere or points...
and it will slow the test down that''s certain.

If anyone knows an other system that works fine please let me know.
If your problem is that objects are passing through each other and you need exact contact points then you should look at doing time dependent collision detection.

Basicly, you take a line segment and a point.
The position of the point is p0 + v0*t.
The position of the endpoints of the line segment are p1 + v1*t and p2 + v2*t.
You solve for when the line segments p1p0 and p1p2 are colinear.
You get a quadratic equation in t, which you can solve using everyone''s favourite high-school formula.
Substitute t back in to the positions and then test whether the point of collision is between p1 and p2.

This method is a little slower than non-time dependent ones. You should do an initial check to see if a collision occurs before finding the exact contact point.



"Math is hard" -Barbie
"Math is hard" -Barbie
Adding rotational speed becomes then even a bit more difficult...!

Good luck!
Advertisement
Well thanks for your reply Pragma. Unfortunately I can already find the point of contact between two lines, what i''m looking for is the point(on the path) where a sphere that is traveling on that path collides with a polygon.

I think that an equation that would find the point of colision between a ray and a sphere sould help solve this puzzle...
hey , i have the equations somewhere as i remember, if i look for them i''m shoore i''ll find them , if you''re interseted you can mail me at mm_cristi@yahoo.com , i don''t know if i''ll enter this page soon again .
You can also have a look at Solid. It''s a general collision detection engine that has worked pretty well for me in the past. With a little adjusting you can transform it into a ''swept volume'' collision detection lib fairly easy (which eliminates objects going through other objects)

here''s the link:
http://www.win.tue.nl/~gino/solid/

Cheers!
Nick

Thanks NickWaanders, that''s a very interesting link and engine. I need to study and understand it. Too bad version 3 is not free. I don''t know if I could transform it like you say but it''s worth a try.

Thanks again.

This topic is closed to new replies.

Advertisement