本文整理汇总了C++中Box3F::computeVertex方法的典型用法代码示例。如果您正苦于以下问题:C++ Box3F::computeVertex方法的具体用法?C++ Box3F::computeVertex怎么用?C++ Box3F::computeVertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Box3F
的用法示例。
在下文中一共展示了Box3F::computeVertex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createCullingVolume
//.........这里部分代码省略.........
}
// Compute the metrics of the culling volume in relation to the view frustum.
//
// For this, we are short-circuiting things slightly. The correct way (other than doing
// full screen projections) would be to transform all the polygon points into camera
// space, lay an AABB around those points, and then find the X and Z extents on the near plane.
//
// However, while not as accurate, a faster way is to just project the axial vectors
// of the bounding box onto both the camera right and up vector. This gives us a rough
// estimate of the camera-space size of the polygon we're looking at.
const MatrixF& cameraTransform = getCameraState().getViewWorldMatrix();
const Point3F cameraRight = cameraTransform.getRightVector();
const Point3F cameraUp = cameraTransform.getUpVector();
const Point3F wsPolyBoundsExtents = wsPolyBounds.getExtents();
F32 widthEstimate =
getMax( mFabs( wsPolyBoundsExtents.x * cameraRight.x ),
getMax( mFabs( wsPolyBoundsExtents.y * cameraRight.y ),
mFabs( wsPolyBoundsExtents.z * cameraRight.z ) ) );
F32 heightEstimate =
getMax( mFabs( wsPolyBoundsExtents.x * cameraUp.x ),
getMax( mFabs( wsPolyBoundsExtents.y * cameraUp.y ),
mFabs( wsPolyBoundsExtents.z * cameraUp.z ) ) );
// If the current camera is a perspective one, divide the two estimates
// by the distance of the nearest bounding box vertex to the camera
// to account for perspective distortion.
if( !isOrtho )
{
const Point3F nearestVertex = wsPolyBounds.computeVertex(
Box3F::getPointIndexFromOctant( - viewDir )
);
const F32 distance = ( nearestVertex - viewPos ).len();
widthEstimate /= distance;
heightEstimate /= distance;
}
// If we are creating an occluder, check to see if the estimates fit
// our minimum requirements.
if( type == SceneCullingVolume::Occluder )
{
const F32 widthEstimatePercentage = widthEstimate / getCullingFrustum().getWidth();
const F32 heightEstimatePercentage = heightEstimate / getCullingFrustum().getHeight();
if( widthEstimatePercentage < smOccluderMinWidthPercentage ||
heightEstimatePercentage < smOccluderMinHeightPercentage )
return false; // Reject.
}
// Use the area estimate as the volume's sort point.
const F32 sortPoint = widthEstimate * heightEstimate;
// Finally, if it's an occluder, compute a near cap. The near cap prevents objects
// in front of the occluder from testing positive. The same could be achieved by
// manually comparing distances before testing objects but since that would amount
// to the same checks the plane/AABB tests do, it's easier to just add another plane.
// Additionally, it gives the benefit of being able to create more precise culling
// results by angling the plane.
//NOTE: Could consider adding a near cap for includers too when generating a volume
// for the outdoor zone as that may prevent quite a bit of space from being included.
// However, given that this space will most likely just be filled with interior
// stuff anyway, it's probably not worth it.
if( type == SceneCullingVolume::Occluder )
{
const U32 nearCapIndex = numPlanes;
planes[ nearCapIndex ] = PlaneF(
vertices[ mostDistantVertices[ 0 ] ],
vertices[ mostDistantVertices[ 1 ] ],
vertices[ leastDistantVert ] );
// Invert the plane, if necessary.
if( planes[ nearCapIndex ].whichSide( viewPos ) == PlaneF::Front )
planes[ nearCapIndex ].invert();
numPlanes ++;
}
// Create the volume from the planes.
outVolume = SceneCullingVolume(
type,
PlaneSetF( planes, numPlanes )
);
outVolume.setSortPoint( sortPoint );
// Done.
return true;
}