Game Development Reference
In-Depth Information
These functions are designed to be flexible and can work with various
vertex formats.
HRESULT D3DXComputeBoundingSphere(
LPD3DXVECTOR3 pFirstPosition,
DWORD NumVertices,
DWORD dwStride,
D3DXVECTOR3* pCenter,
FLOAT* pRadius
);
pFirstPosition —A pointer to a vector in the first vertex of an
array of vertices that describes the position of the vertex
NumVertices —The number of vertices in the vertex array
dwStride —The size of each vertex in bytes. This is needed
because a vertex structure may have additional information such as
a normal vector and texture coordinates that is not needed for the
bounding sphere function, and the function needs to know how
much data to skip over to get to the next vertex position.
pCenter —Returns the center of the bounding sphere
pRadius —Returns the radius of the bounding sphere
HRESULT D3DXComputeBoundingBox(
LPD3DXVECTOR3 pFirstPosition,
DWORD NumVertices,
DWORD dwStride,
D3DXVECTOR3* pMin,
D3DXVECTOR3* pMax
);
The first three parameters are exactly the same as the first three in
D3DXComputeBoundingSphere . The last two parameters are used to
return the bounding box's minimum and maximum point, respectively.
11.4.1 Some New Special Constants
Let's introduce two constants that prove useful throughout the rest of
this topic. We add these to the d3d namespace:
namespace d3d
{
...
const float INFINITY = FLT_MAX;
const float EPSILON = 0.001f;
The INFINITY constant is simply used to represent the largest num-
ber that we can store in a float . Since we can't have a float bigger
than FLT_MAX , we can conceptualize it as infinity, which makes for
more readable code that signifies ideas of infinity. The EPSILON
Team-Fly ®
Search WWH ::




Custom Search