本文整理汇总了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;
}
示例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);
}