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?
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.
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.
\$\begingroup\$ 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. \$\endgroup\$– DeadMGMar 16, 2011 at 22:54
\$\begingroup\$ 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. \$\endgroup\$ Mar 16, 2011 at 23:24
\$\begingroup\$ @Dave O There made it more readable. \$\endgroup\$ Mar 17, 2011 at 2:08
\$\begingroup\$ @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. \$\endgroup\$– Dave O.Mar 17, 2011 at 3:38
2\$\begingroup\$ ..Or, if you want to skip all this updating, use bounding spheres instead. =) \$\endgroup\$ Mar 17, 2011 at 6:36
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 ...