本文整理汇总了C++中CCamera::ClipFrustumLines方法的典型用法代码示例。如果您正苦于以下问题:C++ CCamera::ClipFrustumLines方法的具体用法?C++ CCamera::ClipFrustumLines怎么用?C++ CCamera::ClipFrustumLines使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCamera
的用法示例。
在下文中一共展示了CCamera::ClipFrustumLines方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalcMinMaxView
void CShadowHandler::CalcMinMaxView()
{
// derive the size of the shadow-map from the
// intersection points of the camera frustum
// with the xz-plane
CCamera* cam = CCamera::GetCamera(CCamera::CAMTYPE_VISCUL);
cam->GetFrustumSides(0.0f, 0.0f, 1.0f, true);
cam->ClipFrustumLines(true, -20000.0f, mapDims.mapy * SQUARE_SIZE + 20000.0f);
shadowProjMinMax.x = -100.0f;
shadowProjMinMax.y = 100.0f;
shadowProjMinMax.z = -100.0f;
shadowProjMinMax.w = 100.0f;
//if someone could figure out how the frustum and nonlinear shadow transform really works (and not use the SJan trial and error method)
//so that we can skip this sort of fudge factors it would be good
float borderSize = 270.0f;
float maxSize = globalRendering->viewRange * 0.75f;
if (shadowMapSize == 1024) {
borderSize *= 1.5f;
maxSize *= 1.2f;
}
const std::vector<CCamera::FrustumLine>& negSides = cam->GetNegFrustumSides();
const std::vector<CCamera::FrustumLine>& posSides = cam->GetPosFrustumSides();
std::vector<CCamera::FrustumLine>::const_iterator fli;
if (!negSides.empty()) {
for (fli = negSides.begin(); fli != negSides.end(); ++fli) {
if (fli->minz < fli->maxz) {
float3 p[5];
p[0] = float3(fli->base + fli->dir * fli->minz, 0.0f, fli->minz);
p[1] = float3(fli->base + fli->dir * fli->maxz, 0.0f, fli->maxz);
p[2] = float3(fli->base + fli->dir * fli->minz, readMap->initMaxHeight + 200, fli->minz);
p[3] = float3(fli->base + fli->dir * fli->maxz, readMap->initMaxHeight + 200, fli->maxz);
p[4] = projMidPos[2];
for (int a = 0; a < 5; ++a) {
const float xd = (p[a] - projMidPos[2]).dot(sunDirX);
const float yd = (p[a] - projMidPos[2]).dot(sunDirY);
if (xd + borderSize > shadowProjMinMax.y) { shadowProjMinMax.y = xd + borderSize; }
if (xd - borderSize < shadowProjMinMax.x) { shadowProjMinMax.x = xd - borderSize; }
if (yd + borderSize > shadowProjMinMax.w) { shadowProjMinMax.w = yd + borderSize; }
if (yd - borderSize < shadowProjMinMax.z) { shadowProjMinMax.z = yd - borderSize; }
}
}
}
if (shadowProjMinMax.x < -maxSize) { shadowProjMinMax.x = -maxSize; }
if (shadowProjMinMax.y > maxSize) { shadowProjMinMax.y = maxSize; }
if (shadowProjMinMax.z < -maxSize) { shadowProjMinMax.z = -maxSize; }
if (shadowProjMinMax.w > maxSize) { shadowProjMinMax.w = maxSize; }
} else {
shadowProjMinMax.x = -maxSize;
shadowProjMinMax.y = maxSize;
shadowProjMinMax.z = -maxSize;
shadowProjMinMax.w = maxSize;
}
// xScale = (shadowProjMinMax.y - shadowProjMinMax.x) * 1.5f;
// yScale = (shadowProjMinMax.w - shadowProjMinMax.z) * 1.5f;
}