Esempio n. 1
0
Ogre::Sphere EditSphere::scaleSphere(const Ogre::Sphere _sp, const double scale)
{
    Ogre::Sphere sp = _sp;
    sp.setCenter(sp.getCenter()/scale);
    sp.setRadius(sp.getRadius()/scale);
    return sp;
}
Esempio n. 2
0
BOOL CCamera_Scene::_IsValidEye(
    const Fairy::TerrainData* pTerrainData,	//地形数据
    const fVector3& fvEye,					//眼睛点
    FLOAT fCameraNearDis)					//近距离
{
    //近距碰撞球
    Ogre::Sphere ballNear;
    ballNear.setCenter(Ogre::Vector3(fvEye.x, fvEye.y, fvEye.z));
    ballNear.setRadius(fCameraNearDis);

    CAMERA_INTER_GRIDS gridsTerrain;
    if(!_GetInterPatch(
                pTerrainData,
                fvEye,
                gridsTerrain))
    {
        //眼睛在地形外面
        return TRUE;
    }

    //近距球是否在地形下面
    for(INT i=0; i<(INT)gridsTerrain.m_fvGrid.size(); i++)
    {
        const Ogre::AxisAlignedBox& theGridBox = gridsTerrain.m_fvGrid[i];

        //是否相交
        if(Ogre::Math::intersects(ballNear, theGridBox)) return FALSE;
    }

    return TRUE;
}