Jump to content

  • Log In with Google      Sign In   
  • Create Account


get colliding face of 2 AABB's?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 coffeecup   Members   -  Reputation: 126

Like
0Likes
Like

Posted 27 December 2012 - 03:35 AM

So far I have 2 AABB's, one stationary and one moving, checking against min(x,y,z) and max(x,y,z) of the 2 AABB's I can tell if they intersect.

 

Now I would like to implement a "slide against the wall" effect, therefore I need to get the normal of the colliding face, but I have troubles understanding how I can compute which face is colliding.

 

I googled a lot and found something about SAT (  http://www.codezealot.org/archives/55 ) but I am still confused, is this the only technique to get the colliding face or are there other options available?

 

 

I would appreciate some hints or pseudo code to get me started.

 



Sponsor:

#2 Rattenhirn   Crossbones+   -  Reputation: 1629

Like
3Likes
Like

Posted 27 December 2012 - 04:11 AM

SAT works by finding all the common axises (sp?) between the two colliders and see how much they overlap. If one of them doesn't overlap, there's no collision. Otherwise the collision normal can be devised from the overlaps.

AABB's, by definition, have the common axises global x, y and z. With the min/max tests you find out if all of them overlap or not. So what's left to do, is figure out, how much they overlap, and them simply pick the largest overlap, since the axises are also, by definition, the face normals.

I hope that helps!

And maybe someone can let me know what the correct plural of axis is... ;)

#3 coffeecup   Members   -  Reputation: 126

Like
1Likes
Like

Posted 27 December 2012 - 05:12 AM

thanks, indeed that helped, i got a little confused reading so much stuff about SAT.

 

now i calculate the distance between the 2 boxes using the min and max values for each axis and take the largest distance which gives me the correct normal.

 

the plural of axis is axes.



#4 Rattenhirn   Crossbones+   -  Reputation: 1629

Like
1Likes
Like

Posted 27 December 2012 - 08:01 AM

Yes, SAT can get pretty tricky, if more complex geometries are involved. Two AABBs are probably the second easiest, right after two spheres.

 

I found this website to be very helpful in explaining the theorem, it also has nifty interactive examples:

 

http://www.metanetsoftware.com/technique/tutorialA.html

 

Unfortunately it only covers 2D collisions...






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS