Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Taulin

Collision Detection: Spheres/Boxes/etc

This topic is 6928 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here is a question of personal taste: I just read a book that starts off explaining using axis aligned bounding boxes. Then explains how to iterate through all the polygons finding a seperating plane to test for a more detailed collision if the bounding boxes touch. First this sounds slow and expensive. Is this method common? But then for the examples constructs bounding spheres for every polygon ( plus one big one for the whole model ). I guess this would be OK as long as your model had small polygons. The big question is, after the initial test that two objects MIGHT collide, what methods has everyone here implemented for detailed testing? I.E. finding the seperating plane, speres, etc. -------------- My opinions do not reflect the porn industry in any way.

Share this post


Link to post
Share on other sites
Advertisement
First off, if your objects are stored in a list, your gonna have to iterate through the list to see if any object collides with any other, whether you use bounding boxes or spheres. I used the axis aligned boxes sinces it involves simpilar calculations than a sphere. Whether you use a sphere or a rectangle depends on the shape, since somes shapes are suited well for one method and not for the other.

Share this post


Link to post
Share on other sites
this was the way that a computer proffessor suggested me:
first check the bounding boxes, if u see they collide, then sends the two boxes into a recursive function:
the recursive function break each bounding box into 4 similar boxes (like cutting it in half horizontally, then vertivally) and then check if that box contains a piece of the original shape (clip it). if true then check if it collides with any small boxes of the other shape. if they collide, then send the two new boxes back to the recursive function and keep checking until u reach the level of accuracy that u wanted to reach.
i found this way prettu confusing and kinda hard to deploy, so i never coded it. instead, u can just use simple math formulas to see if 2 objects collide or not. for example to see if a line and a circle collide, just get the shortest distance from the line to the centre of the circle (arr, i forgot the formula) and check if the distance is greater than or equal to the radius. i''m pretty sure u can find the ways for other shapes yourself. no need to write them down here

ahhh, i''m not gonna go through all that and revise my message

- pouya

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!