Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Creating an AABB is simple. But, if the 3d model has become rotated, how do you update the AABB to become accurate? Or is the AABB supposed to be in local space?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

Axis Aligned Bounding Box means the box itself is always on the same orientation.

To update the AABB you will need to recreate it each time the model rotates, and move it if the models positions changes.

The box will change shape and size depending on the rotation and the model you use.

If you want to have a rotating collision box than that matches up with the model, then that is completely different than an AABB, and you will need to look into the physics of your engine for that.

Edit:

If you want to update the AABB quickly, but with less accuracy, just pass the points of the original bounding box instead of the entire model.

The bounding box won't be perfectly tight, but it is guaranteed to have the entire model inside of it. Here is an article describing how to achieve this.

One thing I would like to add that is not in the article would be to create a few fully calculated bounding boxes at 10 rotations and when recalculating, use the bounding box that is closest to the current rotation, that should improve the tightness of the bounding box a lot without creating that much more overhead.

share|improve this answer
    
I was more looking for algorithms to update the AABB. I'd rather not project every vertex into world space, and then compute the AABB from that. –  DeadMG Mar 16 '11 at 22:54
    
I updated the answer with details on how to compute a less precise bounding box that is more efficient than parsing all the vertexes of the model. –  AttackingHobo Mar 16 '11 at 23:24
    
@Dave O There made it more readable. –  AttackingHobo Mar 17 '11 at 2:08
    
@DeadMG There's no way of "updating the AABB" in the sense you want it. By definition, the aabb has to completely enclose the model and if the model changes, you're pretty much forced to process all vertices. Hobo's on the spot. –  Dave O. Mar 17 '11 at 3:38
2  
..Or, if you want to skip all this updating, use bounding spheres instead. =) –  Jari Komppa Mar 17 '11 at 6:36

From wikipedia:

A bounding box is a cuboid, or in 2-D a rectangle, containing the object. In dynamical simulation, bounding boxes are preferred to other shapes of bounding volume such as bounding spheres or cylinders for objects that are roughly cuboid in shape when the intersection test needs to be fairly accurate. The benefit is obvious, for example, for objects that rest upon other, such as a car resting on the ground: a bounding sphere would show the car as possibly intersecting with the ground, which then would need to be rejected by a more expensive test of the actual model of the car; a bounding box immediately shows the car as not intersecting with the ground, saving the more expensive test.

If your model can be at any rotation, perhaps a bounding sphere is in fact a better bounding volume to be using? Bounding spheres are typically cheaper checks and many systems use several bounding volumes in preference order e.g. always check sphere, if that passes then check AABB, if that passes then ...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.