Game Development Reference
In-Depth Information
p.x <= _max.x && p.y <= _max.y && p.z <= _max.z)
{
return true;
}
else
{
return false;
}
}
d3d::BoundingSphere::BoundingSphere()
{
_radius = 0.0f;
}
11.4.3 Sample Application: Bounding Volumes
The Bounding Volumes sample located in this chapter's folder in the
companion files demonstrates using D3DXComputeBoundingSphere
and D3DXComputeBoundingBox . The program loads an XFile and
computes its bounding sphere and mesh. It then creates two
ID3DXMesh objects, one to model the bounding sphere and one to
model the bounding box. The mesh corresponding to the XFile is then
rendered with either the bounding sphere or bounding box displayed
(see Figure 11.5). The user can switch between displaying the bound-
ing sphere and bounding box mesh by pressing the Spacebar.
Figure 11.5: A
screen shot of the
Bounding Volumes
sample. Note that
transparency using
alpha blending is
used to make the
bounding sphere
transparent.
The sample is pretty straightforward, and we will leave it to you to
study the source code. The two functions we implement that are of
interest to this discussion compute the bounding sphere and bounding
box of a specific mesh:
Search WWH ::




Custom Search