Jump to content
  • Advertisement
Sign in to follow this  

OBB Intersection Tests

This topic is 2646 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all,

I'm implementing a few different OBB intersection tests (mainly ray/OBB and OBB/OBB for now). I have implemented two versions of ray/OBB intersection tests.

One is from Real Time Rendering which uses a Slabs Method.
The other is from David Eberly's book which uses a 6 separating axes test.

I have both algorithms working but I have a question I am hoping someone may be able to shed some light on. I am having trouble finding documentation that talks about how to handle OBB's that exist in a game engine (i.e. world space). The OBB may undergo translation, rotation, scaling, etc, which are all baked into the modelMatrix. These algorithms assume an OBB with unit vectors. Thus in order for these algorithms to work we must convert the axes of the OBB to unit vectors.

Here is my solution to this problem:

To convert an OBB center C to world coordinates, simply multiply it by the objects modelMatrix. Easy enough.

To convert the axes of the OBB to world space we take the 4x4 modelMatrix and convert it to an upper 3x3 modelMatrix (i.e. rotationMatrix), and multiply the axes by this matrix. Next we normalize the vectors. However, we must also change the values of the extents (or half lengths) since we have normalized the vectors. I do this by taking the inverse of the value used to normalize the vectors and multiply the extents by that.

len = Math.sqrt(axisU.x*axisU.x + axisU.y*axisU.y + axisU.z*axisU.z)
len = 1/len
axisU.x = axisU.x*len
axisU.y = axisU.y*len
axisU.z = axisU.z*len
extentU = extentU*(1/len);

and repeat for the other 2 axes/extents.

Then we can go on our marry way implementing the algorithms with unit vectors.

I am not a math ninja like Mr. Eberly and I'm not sure if this is the most effecient way of doing things. Obviously for intersection tests, having effecient algorithms is imporant. I was hoping someone may be able to offer some advice on my implementatation and how to handle OBB's combined with a modelMatrix.

Thanks in advance.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!