Sign in to follow this  
Kaze

box collision detection

Recommended Posts

Kaze    948
is it possible to detect collisions between two rotated boxes in 3d space the same way you would detect it between two unrotated cubes by applying the transformation matrix to its points or is a more complex method needed.

Share this post


Link to post
Share on other sites
mrcheesewheel    325
If the boxes are both in the same orientation, then in their local frame or reference it's a simple axis aligned box collision test, ie do what you suggested and it's reduced to the previous case. If they are not in the same orientation, then you'll need a different method... You could probably be clever and rotate both so as one was axis aligned, then check for vertices penetrating, then edges, then faces (you must cover all of these to cover all possible collision cases, eg a box in a box). If you know more about the possible states the boxes can be in you can try less options. You can also do this in the unrotated frame of reference which may or may not be advantageous. I suggest checking vertices then edges then faces as that reflects the computational cost of each and if you simply want a boolean result... you'll most likely get it faster. If you need more specific details skip straight to face/face collision checks.
Hope this helps,

Dan

Share this post


Link to post
Share on other sites
jyk    2094
Quote:
Original post by mrcheesewheel
You could probably be clever and rotate both so as one was axis aligned, then check for vertices penetrating, then edges, then faces (you must cover all of these to cover all possible collision cases, eg a box in a box).
As far as I am aware at least, the most straightforward and efficient (or at least most commonly used) method for testing for intersection between oriented boxes is the separating axis test (SAT), which can be optimized to take advantage of the regularity of the box shape (i.e. multiple parallel faces and edges, etc.).

The algorithm for OBB SAT intersection is well documented, so you should be able to find plenty of references online (in fact, I believe it's covered in one of the articles in the 'collision detection' section here on GDNet).

Share this post


Link to post
Share on other sites
Kaze    948
I tried a separating axis test tutorial a while ago but i couldn't wrap me head around it, now I'm not sure if I want to try it again or use ode even though my game doesn't need any physics.

For boxes I'm able to detect if a point is inside it so i wonder if its possible to try to detect the spot where if there is a collision its going to happen and test that point.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this