RedWoft

To be or not to be, it is a question.
Bounding sphere
#ifndef BOUNDING_SPHERE_H
#define BOUNDING_SPHERE_H

#include 
"BoundingVolume.h"

namespace Math
{
    
// Bounding sphere.
    class BoundingSphere:public BoundingVolume
    {
    
public:

        
// @desc: None.
        BoundingSphere();

        
// @desc: Set member variable to the values that the parameters specified.
        BoundingSphere(const Vector3& p_vec3Center, float p_fRadius);

        
// @desc: None.
        virtual ~BoundingSphere();

        
// @desc: Check the visibility of bounding sphere.
        virtual bool CheckVisible(const Frustum& p_Frustum);

        
// The center of bounding sphere.
        Vector3 m_vec3Center;

        
// The radius of bounding sphere.
        float m_fRadius;
    };

    
// @desc: None.
    BoundingSphere::BoundingSphere():m_vec3Center(),m_fRadius(0.0f){}

    
// @desc: Set member variable to the values that the parameters specified.
    BoundingSphere::BoundingSphere(const Vector3& p_vec3Center, float p_fRadius):m_vec3Center(p_vec3Center),m_fRadius(p_fRadius){}

    
// @desc: None.
    BoundingSphere::~BoundingSphere(){}

    
// @desc: Check the visibility of bounding sphere.
    bool BoundingSphere::CheckVisible(const Frustum& p_Frustum)
    {
        
const float fNegativeRadius = -m_fRadius;
        
const Plane* pClipPlane = p_Frustum.GetClipPlane();
        
for (unsigned i = 0U; i < Frustum::s_uiPlaneNumber; ++i)
        {
            
if (PointToPlane(pClipPlane[i], m_vec3Center) < fNegativeRadius)
            {
                
return false;
            }
        }
        
return true;
    }
}

#endif

 

posted on 2010-07-01 05:29  RedWoft  阅读(523)  评论(0)    收藏  举报