   OBB containment checks
  I'm refactoring my basic 3D code, as what I had, had too high a "resembles cthulthu" quotient. I've also discovered I left much of the containment math undone, which I'm currently fixing. So - The current question: OBB containment checks. Specifically, for right now, OBB-OBB containment checks.This is what I'm mostly using for OBB-OBB intersection checks (In short form): ra = halfSizeA.X; if (ra < 0)ra = -ra; rb = halfSizeB.X * Math.Abs(yourOBBFromMyFrame[0][0]) +halfSizeB.Y * Math.Abs(yourOBBFromMyFrame[0][1]) +halfSizeB.Z * Math.Abs(yourOBBFromMyFrame[0][2]); if (rb < 0)rb = -rb; t = translationMyFrame.X; if (t < 0)t = -t; if (t > (ra + rb))return false;Using a little logic, would containment be: ra = halfSizeA.X; if (ra < 0)ra = -ra; rb = halfSizeB.X * Math.Abs(yourOBBFromMyFrame[0][0]) +halfSizeB.Y * Math.Abs(yourOBBFromMyFrame[0][1]) +halfSizeB.Z * Math.Abs(yourOBBFromMyFrame[0][2]); if (rb < 0)rb = -rb; t = translationMyFrame.X; if (t < 0)t = -t; if ((t + ra) > rb)return false;
  Figured it out. Just counter-rotate and treat as AABB-AABB.   ;  Hey! I am actually trying to do this same thing, can you post your solution?Your help will be greatly appreciated   ;  Certainly:public static Boolean ContainmentOBBXAABB(ref Vector2 centerA, ref Vector2 halfSizeA, ref Radian rotationA, ref Vector2 centerB, ref Vector2 halfSizeB){    return ContainmentAABBXOBB(ref centerA, ref halfSizeA, ref centerB, ref halfSizeB, -rotationA);}public static Boolean ContainmentAABBXOBB(ref Vector2 centerA, ref Vector2 halfSizeA, ref Vector2 centerB, ref Vector2 halfSizeB, ref Radian rotationB){    Vector2 halfSizeRotatedB = halfSizeB.Rotated(rotationB);    return ContainmentAABBXAABB(ref centerA, halfSizeA, ref centerB, halfSizeRotatedB);}What this does is takes the AABB box B, treats the OBB box A as an AABB box, rotates the AABB box B the opposite of the OBB box A and sees if it contains the virtual AABB box....This is a lot easier to understand if you draw it out.For a standard AABBXAABB containment - In AABBXAABB intersection, you check wether any of the sides are separated - That is, if the right side of A is further left than the left side of B.Modified for containment, you want to check that none of the sides of A are outside of the sides of B.If you actually do need the answer, I can give it to you, but it's one of those "You'll kick yourself if you do" things. :)   ;  Yeah, I'm sorry, I'm still having trouble wrapping my head around it - could you send me your 3D OBB-OBB containment code? It would really help me out.   ;  I haven't written it yet, but it would simply be counter-rotating one of the OBB's to an AABB. Rotating the other OBB by the same amount leaves you with an AABB containing an OBB and an OBB inside an AABB is just an AABB. Draw it out, if you like - That's how I figured it out.Draw a rotated box with a non-rotated box inside.Draw the containing box counter-rotated so that it's not rotated. Rotate the contained box to match.Draw a non-rotated box around the contained box.You now have an AABBxAABB containment check. :)   