本文整理汇总了C++中CFrustum::CreateFromPortal方法的典型用法代码示例。如果您正苦于以下问题:C++ CFrustum::CreateFromPortal方法的具体用法?C++ CFrustum::CreateFromPortal怎么用?C++ CFrustum::CreateFromPortal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFrustum
的用法示例。
在下文中一共展示了CFrustum::CreateFromPortal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//.........这里部分代码省略.........
if (pSector==PortalTraverser.i_start) continue;
}
// Early-out sphere
if (!F.testSphere_dirty(PORTAL->S.P,PORTAL->S.R)) continue;
// SSA (if required)
if (PortalTraverser.i_options&CPortalTraverser::VQ_SSA)
{
Fvector dir2portal;
dir2portal.sub (PORTAL->S.P, PortalTraverser.i_vBase);
float R = PORTAL->S.R ;
float distSQ = dir2portal.square_magnitude();
float ssa = R*R/distSQ;
dir2portal.div (_sqrt(distSQ));
ssa *= _abs(PORTAL->P.n.dotproduct(dir2portal));
if (ssa<r_ssaDISCARD) continue;
if (PortalTraverser.i_options&CPortalTraverser::VQ_FADE) {
if (ssa<r_ssaLOD_A) PortalTraverser.fade_portal (PORTAL,ssa);
if (ssa<r_ssaLOD_B) continue ;
}
}
// Clip by frustum
svector<Fvector,8>& POLY = PORTAL->getPoly();
S.assign (&*POLY.begin(),POLY.size()); D.clear();
sPoly* P = F.ClipPoly(S,D);
if (0==P) continue;
// Scissor and optimized HOM-testing
_scissor scissor ;
if (PortalTraverser.i_options&CPortalTraverser::VQ_SCISSOR && (!PORTAL->bDualRender))
{
// Build scissor rectangle in projection-space
Fbox2 bb; bb.invalidate(); float depth = flt_max;
sPoly& p = *P;
for (u32 vit=0; vit<p.size(); vit++) {
Fvector4 t;
Fmatrix& M = PortalTraverser.i_mXFORM_01;
Fvector& v = p[vit];
t.x = v.x*M._11 + v.y*M._21 + v.z*M._31 + M._41;
t.y = v.x*M._12 + v.y*M._22 + v.z*M._32 + M._42;
t.z = v.x*M._13 + v.y*M._23 + v.z*M._33 + M._43;
t.w = v.x*M._14 + v.y*M._24 + v.z*M._34 + M._44;
t.mul (1.f/t.w);
if (t.x < bb.min.x) bb.min.x = t.x;
if (t.x > bb.max.x) bb.max.x = t.x;
if (t.y < bb.min.y) bb.min.y = t.y;
if (t.y > bb.max.y) bb.max.y = t.y;
if (t.z < depth) depth = t.z;
}
// Msg ("bb(%s): (%f,%f)-(%f,%f), d=%f", PORTAL->bDualRender?"true":"false",bb.min.x, bb.min.y, bb.max.x, bb.max.y,depth);
if (depth<EPS) {
scissor = R_scissor;
// Cull by HOM (slower algo)
if (
(PortalTraverser.i_options&CPortalTraverser::VQ_HOM) &&
(!RImplementation.HOM.visible(*P))
) continue;
} else {
// perform intersection (this is just to be sure, it is probably clipped in 3D already)
if (bb.min.x > R_scissor.min.x) scissor.min.x = bb.min.x; else scissor.min.x = R_scissor.min.x;
if (bb.min.y > R_scissor.min.y) scissor.min.y = bb.min.y; else scissor.min.y = R_scissor.min.y;
if (bb.max.x < R_scissor.max.x) scissor.max.x = bb.max.x; else scissor.max.x = R_scissor.max.x;
if (bb.max.y < R_scissor.max.y) scissor.max.y = bb.max.y; else scissor.max.y = R_scissor.max.y;
scissor.depth = depth;
// Msg ("scissor: (%f,%f)-(%f,%f)", scissor.min.x, scissor.min.y, scissor.max.x, scissor.max.y);
// Check if box is non-empty
if (scissor.min.x >= scissor.max.x) continue;
if (scissor.min.y >= scissor.max.y) continue;
// Cull by HOM (faster algo)
if (
(PortalTraverser.i_options&CPortalTraverser::VQ_HOM) &&
(!RImplementation.HOM.visible(scissor,depth))
) continue;
}
} else {
scissor = R_scissor;
// Cull by HOM (slower algo)
if (
(PortalTraverser.i_options&CPortalTraverser::VQ_HOM) &&
(!RImplementation.HOM.visible(*P))
) continue;
}
// Create _new_ frustum and recurse
CFrustum Clip;
Clip.CreateFromPortal (P, PORTAL->P.n, PortalTraverser.i_vBase,PortalTraverser.i_mXFORM);
PORTAL->marker = PortalTraverser.i_marker;
PORTAL->bDualRender = FALSE;
pSector->traverse (Clip,scissor);
}
}