标签:directx direct3d 游戏编程 游戏开发 包围体
函数D3DXComputeBoundingSphere和D3DXComputeBoundingBox分别计算出一个物体的外接球和外接体;使用D3DXComputeBoundingSphere和D3DXComputeBoundingBox计算Mesh对象的边界;边界范围接近对象真实的边界,可加速碰撞检测等计算。
函数原型如下;
HRESULT WINAPI D3DXComputeBoundingSphere(
const D3DXVECTOR3 *pFirstPosition,
DWORD NumVertices,
DWORD dwStride,
D3DXVECTOR3 *pCenter,
FLOAT *pRadius
);
HRESULT WINAPI D3DXComputeBoundingBox(
const D3DXVECTOR3 *pFirstPosition,
DWORD NumVertices,
DWORD dwStride,
D3DXVECTOR3 *pMin,
D3DXVECTOR3 *pMax
);
包围体:
struct BoundingBox
{
BoundingBox();
bool isPointInside(D3DXVECTOR3& p);
D3DXVECTOR3 _min;
D3DXVECTOR3 _max;
};
struct BoundingSphere
{
BoundingSphere();
D3DXVECTOR3 _center;
float _radius;
};
D3DXComputeBoundingSphere和D3DXComputeBoundingBox
标签:directx direct3d 游戏编程 游戏开发 包围体
原文地址:http://blog.csdn.net/a809146548/article/details/43910867