0

I am doing Ray intersection test with AABB.It works fine till I start rotating the AABB contained object.My AABBs by default have normalized coordinated ranging from (-1 , 1) ,so in order to get them into Object's world dimensions I update AABB mins and max transforming those with Object's model matrix.But if the matrix has a rotation on it,the ray test work only when it has the default zero rotation.Does it mean I can't rotate AABB for doing intersect test?

Michael IV
  • 11,016
  • 12
  • 92
  • 223
  • 1
    Well, if you rotate AABB, than it is NOT AABB anymore :) – Jaa-c May 09 '14 at 01:17
  • Yes,I understand,but how could I test against such a rotated AABB. Probably need to transform the ray? – Michael IV May 09 '14 at 01:22
  • No, that will not work. If you rotate AABB with a model, then it simply won't be AABB of that model anymore. Just draw it if you don't see it. You either have to recompute AABB every time you rotate the model or you have to use some other bounding box. – Jaa-c May 09 '14 at 01:25
  • You mean,recompute to have it clear from Object's rotation? – Michael IV May 09 '14 at 01:26
  • No, compute it again from the rotated object. – Jaa-c May 09 '14 at 01:27
  • The code I put btw was the wrong one.I used it to test vs Frustum planes...But yeah I see what you mean... – Michael IV May 09 '14 at 01:29

1 Answers1

3

If you rotate AABB with the original model, it's not AABB of that model anymore. What you need to do is compute AABB again after you rotated the object, or you need to use different bounding box, that is not axis aligned (OBB).

See what happens if you rotate AABB together with an object:

enter image description here

Jaa-c
  • 5,017
  • 4
  • 34
  • 64