Game Development Reference
In-Depth Information
But the big advantage of bounding spheres is that instantaneous collision detection
between two spheres is very simple, so this representation may be a great candid-
ate for a first-line collision check.
Axis-Aligned Bounding Box
For a 2D game, an axis-aligned bounding box (or AABB) is a rectangle where
every edge is parallel to either the x-axis or y-axis. Similarly, in 3D an AABB is a
rectangular prism where every side of the prism is parallel to one of the coordin-
ate axis planes. In both 2D and 3D, an AABB can be represented by two points: a
minimum and a maximum point. In 2D, the minimum corresponds to the bottom-
left point whereas the maximum corresponds to the top-right point.
class AABB2D
Vector2 min
Vector2 max
end
Because an AABB must keep its sides parallel to the coordinate axes, if an object
is rotated the AABB may have to stretch, as demonstrated in Figure 7.3 . But for
3D games, humanoid characters will typically only rotate about the up axis, and
with these types of rotations the bounding box for the character may not change
at all. Because of this, it's very common to use AABBs as a basic form of colli-
sionrepresentationforhumanoidcharacters,especiallybecausecollisiondetection
between AABBs, as with spheres, is not particularly expensive.
Figure 7.3 Axis-aligned bounding boxes for different orientations of a character.
Search WWH ::




Custom Search