Hi, I'm trying to detect a collision of 2 boxes.
I can handle the min and max vector of both boxes but it is not "very" usefull because it doesn't change with the box rotation. Any idea of what can I do?
Thanks.
Collision between 2 boxes
-
- Posts: 861
- Joined: Sun Jul 03, 2005 4:06 pm
- Location: Kirkland, WA
Re: Collision between 2 boxes
You can use the Separating Axes Theorem (SAT) to detect overlap between two boxes. Get Christer Ericson's book "Realtime Collision Detection" for a good explanation.
http://en.wikipedia.org/wiki/Separating_axis_theorem
http://realtimecollisiondetection.net/p ... al_SAT.ppt
Cheers,
-Dirk
http://en.wikipedia.org/wiki/Separating_axis_theorem
http://realtimecollisiondetection.net/p ... al_SAT.ppt
Cheers,
-Dirk
-
- Posts: 5
- Joined: Tue Sep 15, 2009 9:29 pm
Re: Collision between 2 boxes
Hello, I'm friend of xema25, we pretend detect collisions between two collision objects, you know have a way to use a callback function for collisions? or any method to get the contact point and the forces?
Thanks.
Tony.
Thanks.
Tony.
-
- Posts: 91
- Joined: Wed Jun 10, 2009 4:01 am
Re: Collision between 2 boxes
To Get Contact Point and Normal when use SAT see Erin's GDC ppt, I forget whether is 2006 or 2007 GDC
-
- Posts: 91
- Joined: Wed Jun 10, 2009 4:01 am
Re: Collision between 2 boxes
The Process is something like this ,first find the seperate axis which has the minimum overlap ,then this axis is the contact normal,then according to the feature which form this axis(poins&poins,edge&edge,face&face),you can get the contact point for example in point&point case the contact point is the 2 points while in face-face you may need to project the 2 face to the seperate plane and do 2d polygon clip to get all the contact point,I am not very familiar with SAT, so if I am wrong Dirk could correct me
-
- Posts: 2
- Joined: Mon Nov 09, 2009 9:23 am
Re: Collision between 2 boxes
Is there any example or demo where I can see it? I thinks it is something very basic and I can't find any way to do it without a very complex mathematic use.
Thanks and sorry for my english
Thanks and sorry for my english
-
- Posts: 861
- Joined: Sun Jul 03, 2005 4:06 pm
- Location: Kirkland, WA
Re: Collision between 2 boxes
In order to build the contact information you keep track of the axis of minimum penetration. If this axis comes from a face you clip the most incident face polygon against the side plane of the reference face. If the axis comes from an edge pair you could e.g. use the center of closest points of the supporting edges.
The ODE has a full example implementation of this. Look at dBoxBox. You can also look at Box2D for a 2D version. This is easier to grasp and straght forward to port to 3D. For the edge cases you have to look at the ODE or maybe Open Tissue. Finally are presentations by Erin Catto which should also be helpful. Check the GDC 2007 - 2009 presentations: http://www.gphysics.com/downloads
The ODE has a full example implementation of this. Look at dBoxBox. You can also look at Box2D for a 2D version. This is easier to grasp and straght forward to port to 3D. For the edge cases you have to look at the ODE or maybe Open Tissue. Finally are presentations by Erin Catto which should also be helpful. Check the GDC 2007 - 2009 presentations: http://www.gphysics.com/downloads
-
- Posts: 10
- Joined: Fri Nov 13, 2009 4:36 pm
Re: Collision between 2 boxes
OK. I'm new to these forums and I've already posted a question so I figure I have to give something back! I implemented TestOBBOBB and IntersectOBBOBB a year or two ago.
To calculate the contact manifold for 2 OBBs a good starting point is Eberly's "Game Physics" Section 5.3.4 (pp 334 - 342). This describes how to use separating axes for an overlap test between two OBBs and gives code to do it. Note the errata in the 2nd last equation on page 338 though! (I think it's listed on the books website). This code will give you a true/false overlap test.
To compute the actual contact manifold (array of all contact points between the 2 OBBs) you will need a few more geometric functions that you can get from the excellent Ericsson "Real Time Collision Detection" and to use the Sutherland-Hodgeson clipping algorithm.
I have attached my notes. You might also want to read "Dynamic Collision Detection using Oriented Bounding Boxes" also by Eberly and "CS 430/536 Computer Graphics 1 Polygon Clipping and Filling"
Hope this helps. And excuse my handwriting.
To calculate the contact manifold for 2 OBBs a good starting point is Eberly's "Game Physics" Section 5.3.4 (pp 334 - 342). This describes how to use separating axes for an overlap test between two OBBs and gives code to do it. Note the errata in the 2nd last equation on page 338 though! (I think it's listed on the books website). This code will give you a true/false overlap test.
To compute the actual contact manifold (array of all contact points between the 2 OBBs) you will need a few more geometric functions that you can get from the excellent Ericsson "Real Time Collision Detection" and to use the Sutherland-Hodgeson clipping algorithm.
I have attached my notes. You might also want to read "Dynamic Collision Detection using Oriented Bounding Boxes" also by Eberly and "CS 430/536 Computer Graphics 1 Polygon Clipping and Filling"
Hope this helps. And excuse my handwriting.
You do not have the required permissions to view the files attached to this post.
Last edited by hop on Fri Nov 20, 2009 1:06 pm, edited 1 time in total.
-
- Posts: 30
- Joined: Thu Oct 01, 2009 2:17 pm
Re: Collision between 2 boxes
Someone used to ask a similar question.
Here is the thread.
http://www.bulletphysics.org/Bullet/php ... f=4&t=4118
Notice the attachment I posted. I think it may help you.
Here is the thread.
http://www.bulletphysics.org/Bullet/php ... f=4&t=4118
Notice the attachment I posted. I think it may help you.
