🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

collision detection

Started by
8 comments, last by lunasol 24 years ago
Hi, i''m working on a simple viewer of a 3D scene. Is there a SIMPLE way to avoid that user can pass through the objects like a ghost? I have found some theorical links (on gamasutra) but some practical one will be very cool... Thanks for the reply working lunasol
Advertisement
The simplest way to do collision detection is to store all your objects in memory, set a radius for each one, then use the distance formula to test between the camera''s position and object origins. If the resulting distance is less than the radius for that object then you have a collision. It''s as realistic if the object doesn''t fit the radius well, but it''s easy and works well.

Morgan
There is no simple way of collision detection unless you already understand sphere to plane intersections.

------------------------
Captured Reality.
No, sphere/sphere collision detection is really easy (between objects), but the results are terrible. This should really only be a first step, but for beginners to do extremely simple collision detection it works, then you should do polygon/polygon or triangle/triangle collision detection if the two spheres collide, or whatever the hell more complex method you want to use. I think I left out the word ''not'' in the following sentance of my original post "It''s ___ as realistic" making it sound better than it is.

Morgan
Yeah you can always do iteration to check further collision. I agree that the Sphere/Sphere collision is one of the best way to know if an object is near, and when you know that you can always reduce the sphere to see if you''re going through or not.

If you are only building a simple "check the world you did", then simple sphere/sphere collision is perfect.

Unless you have squares

(( Moreover, Sphere Detection don''t require too much work from a CPU. All you need is calculate distance for object near the camera. You fix the distance, not too far, and check every single object with only one comparison per object. Polygon is much more work... ))
Now I know what I'm made of, and I'm afraid of it...
Sorry fr the lack in the argument,
is there anybody who could possibly explain me what is and how can I implement Sphere/Sphere collision detection ?

Thanks

Sphere-sphere collision detection is done something like this.

For every object you store the objects origin as a point in 3D space. You also define a radius for each object.

To test for a *possible* collison between the objects use pythagorus to calculate the distance between points, something like this.

distance = ((x1 - x2) * (y1 - y2) * (z1 - z2)) ^ 1/3


Thats the cube root of

(x1 - x2) * (y1 - y2) * (z1 - z2)

If this distance is less than or equal to the sum of two objects radii then you have a possible collison which should be tested using a better method.

You can get away without performing the cube root by comparing

(x1 - x2) * (y1 - y2) * (z1 - z2)

to

(radius1 * radius2) ^ 3

This should be a little faster on most machines.

It is also worth pointing out that this method is only really viable for object-object and object-camera tests. Use something like a sphere-plane test if you want to test for collison with the level geometry.

Regards,
Ralph Potter
ralph.potter@digital-magi.com, http://www.digital-magi.com



Edited by - digital-magi on June 2, 2000 4:42:58 AM
Regards,Ralph Potterralph.potter@digital-magi.com, http://www.digital-magi.com
thanks for the replies,

one question about sphere/sphere test :
let''s imaging that we have two cubes slightly separate. So slightly that the distance between the two cubes radii will be < 0 . In this case the two cubes seems to collide but they not really do!
And this effect will grow up with "parallelepipede" (what the english for this word?!) and all the object that doesn''t fit well the radius. Is there a way to avoid this with sphere/sphere test?

lunasol



That''s why bounding sphere collision detection isn''t very accurate, but it is very good for determining if you should do more accurate collision detection. If a collision is found using sphere/sphere collision detection then you can use polygon/polygon, line/plane, etc, collision detection to see if there is a true collision. I''d suggest you read some of the geometry docs on Paul Bourke''s site (http://www.swin.edu.au/astronomy/pbourke/). Hope that helps.

Morgan
Yep! i think this can help me...
There is a long time that i used to learn this topics at school (10 years ago at least...) Any doubt that i must refresh my memory!

thanks !

old (hum...) lunasol

This topic is closed to new replies.

Advertisement