码迷,mamicode.com
首页 > 其他好文 > 详细

D3DXComputeBoundingSphere和D3DXComputeBoundingBox

时间:2015-02-23 00:17:20      阅读:358      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!