I'm trying to implement a collision system using oriented bounding boxes, using a center for the box, it's extents as a 3D Vector and a rotation matrix, which is all stuff I picked up online and seem to be somewhat the standard.

Detecting the center is no problem so I'm gonna leave these out here.

My problem however is importing the data from a 3D file. Say I've placed a box with 2 units length on each side aligned to the world axis. The logic results here are extents of 1,1,1 and I use an identity matrix for rotation - easy.

However I'm stuck when I rotate the box in the 3D program, say 30 degrees each axis. How would I parse the box? I only have these 8 vertices as information, and I guess what I would need to do is to find out the rotation of said box, apply it to the vertices so they are aligned to world axes and then calculate the extents out of that.

How do I get the rotation of the box when I only have the vertex information of the box available?

  • 1
    \$\begingroup\$ Are you sure you need this? Generally you would export collision data with the visual mesh data from the editor rather than trying to reconstruct collision volumes from visual meshes. You might need to turn on an option in your editor or use a more capable file format that can support those additional volumes (things like OBJ and such can't do it). \$\endgroup\$ – Sean Middleditch Oct 24 '13 at 19:53
  • \$\begingroup\$ You could represent the Obb axis in addition to its extent. This way you can apply arbitrary transformations to the box just by applying them on the axis. \$\endgroup\$ – dsilva.vinicius Oct 24 '13 at 23:33
  • \$\begingroup\$ That's somewhat my question dsilva, but how do I get that information from those 8 vertices? \$\endgroup\$ – cboe Oct 29 '13 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.