AA bounding boxes

Started by
8 comments, last by Draigan 21 years, 5 months ago
I''m using a tight-fitting axis-aligned bounding box on my objects in my 3D engine. However, whenever an object rotates, the bounding box does not envelope the object anymore due to the way the axis shift during rotation. How are most people around here handling this? Should I make the bounding box much looser so that it has the same axis length equal to the longest axis length? In such a case, if I had an object whose origin is 0,0,0 and it extents upward 100 units, then my bounding box would have to be centered at 0,0,0 as well and it''s axis length equal to 200 to accomodate the rotations right? Thanks in advance for anyones input/advice.
Advertisement
i switched to OBB for objects that i had to transform every frame. it seemed to take as much time to shrink/expand the AABB as it did to transform the boxes verts. i never did performance test it though.
You should test how critical a good fitting bounding box is for your specific application. If it is very important, you should consider using an OBB. As the AP said, transforming the OBB is pretty fast (naive code uses 8 vector/matrix multiplies, optimized code uses 4). The drawback of OBBs is that intersection tests (frustum, collision, etc) are slower than AABBs. It can also be problematic, if your bounding box is part of a hierarchy. So in short, for what exactly do you need your bounding boxes ?
...naive code uses 8 vector/matrix multiplies, optimized code uses 4...

How? And also any papers on optimizing OBB/Ftustum test would also be welcome.

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
quote:
...naive code uses 8 vector/matrix multiplies, optimized code uses 4...

How?

Well, 8 is straightforward, just rotate all 8 OBB vertices. Alternatively, you can just rotate a single reference point, and 3 vectors defining the (non-normalized) local coordsys of the OBB. If needed, the remaining OBB vertices can then be computed by vector addition. You could also do it with 3 transforms and a crossproduct, but then you'll lose then length information of the 3rd coordsys coordinate, so in effect that would (probably) be slower (Edit: perhaps not, if you use 3DNow/SSE). Other alternative would be to extract the OBBs coordsys frome it's local matrix. That would require some matrix concatenations, so it might not be as efficient as the vector rotation method.

Papers... hmm, I must have some, but it's been a while I haven't done any OBB stuff anymore. If nobody else posts something, I'll check my bookmarks and post some links.

/ Yann

[edited by - Yann L on November 21, 2002 4:55:18 PM]
Well, I eventually will probably want to do a lot with the bounding boxes. Right now I''m using them for object picking in a large world editor that I''m making. But I will want to use them for my collision routines and whatnot so I may want to do hierarchial boxes.

ALso, how are you generating your OOBs? It seems to me that it''s much harder to generate them for an arbitrary set. Right now if I switch to an OOB, I would just calculate a tight fitting AABB and use that but I''m sure there are better ways.

Also, how are you storing your OOBs? Is it by 8 vertices?
quote:
ALso, how are you generating your OOBs? It seems to me that it's much harder to generate them for an arbitrary set.

Yeah, it's a little harder. Typically, you try to find the dominant axis of the object, and construct from there. There are various methods to do that, I'll check for a paper I have in mind, it presented a very fast method using convex hulls.

quote:
Also, how are you storing your OOBs? Is it by 8 vertices?

You could, but better is either by their local coordinate system matrix and a few scalars, or by a reference vertex and 3 coordsys vectors.



[edited by - Yann L on November 21, 2002 4:59:51 PM]
take a look at Eberly''s work: http://www.magic-software.com/Intersection3D.html

he has some pretty good pdfs written on using OBBs re: frustrum intersection and collision detection.
Here''s the paper (not really a paper, more a short note), on how to quickly (O(n log n)) compute a good-fit OBB for a set of triangles: click (Postscript document).
Hey thanks everyone. I''ve started to convert over to the OOB stuff. Gotta rewrite a lot of stuff (like intersections and that crap). But I''m sure it''ll work out fine. The beauty of all of it is that I can still use AABBs and just compute them from the OOB so all isn''t really lost.

This topic is closed to new replies.

Advertisement