当前位置: 首页>>代码示例>>C++>>正文


C++ AxisAlignedBox::getAllCorners方法代码示例

本文整理汇总了C++中AxisAlignedBox::getAllCorners方法的典型用法代码示例。如果您正苦于以下问题:C++ AxisAlignedBox::getAllCorners方法的具体用法?C++ AxisAlignedBox::getAllCorners怎么用?C++ AxisAlignedBox::getAllCorners使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AxisAlignedBox的用法示例。


在下文中一共展示了AxisAlignedBox::getAllCorners方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getVisibility

    PagingLandScapeOctreeCamera::Visibility PagingLandScapeOctreeCamera::getVisibility( const AxisAlignedBox &bound ) const 
    {
        // Null boxes always invisible
        if ( bound.isNull() )
            return NONE;

        // Make any pending updates to the calculated frustum
        Camera::updateView();

        // Get corners of the box
        const Vector3 * const pCorners = bound.getAllCorners();

        // For each plane, see if all points are on the negative side
        // If so, object is not visible.
        // If one or more are, it's partial.
        // If all aren't, full

        static unsigned int corners[ 8 ] = {0, 4, 3, 5, 2, 6, 1, 7};

        static unsigned int planes[ 6 ] = {FRUSTUM_PLANE_TOP, FRUSTUM_PLANE_BOTTOM,
                        FRUSTUM_PLANE_LEFT, FRUSTUM_PLANE_RIGHT,
                        FRUSTUM_PLANE_FAR, FRUSTUM_PLANE_NEAR };

        bool all_inside = true;

        const bool infinite_far_clip = (mFarDist == 0);
        for ( int plane = 0; plane < 6; ++plane )
        {

            const unsigned int currPlane = planes[ plane ];

            // Skip far plane if infinite view frustum
            if (infinite_far_clip && currPlane == FRUSTUM_PLANE_FAR)
                continue;

            bool all_outside = true;
            const Plane &frustumPlane = mFrustumPlanes[ currPlane ];
            for ( unsigned int corner = 0; corner < 8; ++corner )
            {
                const Real distance = frustumPlane.getDistance( pCorners[ corners[ corner ] ] );
               
                all_outside = all_outside && ( distance < 0 );
                all_inside = all_inside && ( distance >= 0 );

                if ( !all_outside && !all_inside )
                    break;
            }

            if ( all_outside )
                return NONE;
        }

        if ( all_inside )
            return FULL;
        else
            return PARTIAL;

    }
开发者ID:proton,项目名称:ireon,代码行数:58,代码来源:OgrePagingLandScapeOctreeCamera.cpp

示例2: aabbToSphere

static Sphere aabbToSphere(const AxisAlignedBox& aabb)
{
    if (!aabb.isNull())
    {
        // Compute sphere
        float radius = -1.0f;
        const Vector3* corners = aabb.getAllCorners();
        for(unsigned int i = 0; i < 6; ++i)
        {
            float distance = corners[i].distance(aabb.getCenter());
            if (distance>radius)
            {
                radius = distance;
            }
        }
        return Sphere(aabb.getCenter(), radius);
    }
    else
        return Sphere(Vector3::ZERO, -1.0f);
}
开发者ID:lostdj,项目名称:NightCityBlues-2,代码行数:20,代码来源:ApplicationUtilities.cpp


注:本文中的AxisAlignedBox::getAllCorners方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。