🎉 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!

two 3d cubes in collision(AABB), how to check which faces are colliding?

Started by
2 comments, last by Hanseul Shin 6 years, 1 month ago

I'm implementing a simple collision detection, I can detect if two cubes are colliding using max,min points, but can't figure out how to check which faces are colliding.

1- only the first cube can move with velocity but can't rotate.

2- second cube cannot move or rotate

Thank you!

Advertisement

Subtract the center of each AABB so you have a vector pointing from shape A to shape B. Then look at the components of this vector. The component with the largest absolute can represent two faces, one on each AABB. On shape A, the face will be the one with the normal pointing in the same direction as the signed value of said component. On shape B, the face will be one pointing in exactly the opposite direction.

13 minutes ago, Randy Gaul said:

Subtract the center of each AABB so you have a vector pointing from shape A to shape B. Then look at the components of this vector. The component with the largest absolute can represent two faces, one on each AABB. On shape A, the face will be the one with the normal pointing in the same direction as the signed value of said component. On shape B, the face will be one pointing in exactly the opposite direction.

Thank you so mch for your Answer @Randy Gaul!

If I'm understanding correctly,

1- substract the center of each AABB = 3d vector a.

2- if |x| of a is the biggest, this represents a face on each AABB.

3- if x is pointing at the same(or exact opposte) direction of the normal(of a face), two AABB are colliding on those faces.

Thank you!

This topic is closed to new replies.

Advertisement