本文整理汇总了C++中VisRenderContext_cl::GetViewProperties方法的典型用法代码示例。如果您正苦于以下问题:C++ VisRenderContext_cl::GetViewProperties方法的具体用法?C++ VisRenderContext_cl::GetViewProperties怎么用?C++ VisRenderContext_cl::GetViewProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisRenderContext_cl
的用法示例。
在下文中一共展示了VisRenderContext_cl::GetViewProperties方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetLightInfluenceArea
int VMobileForwardRenderLoop::GetLightInfluenceArea(VisLightSource_cl *pLight)
{
VASSERT(pLight != NULL);
VisRenderContext_cl *pContext = VisRenderContext_cl::GetCurrentContext();
int iScreenWidth,iScreenHeight;
pContext->GetSize(iScreenWidth, iScreenHeight);
if (pLight->GetType() == VIS_LIGHT_DIRECTED)
{
// directional lights influence the whole screen
return (iScreenWidth*iScreenHeight);
}
hkvMat4 projMatrix = pContext->GetViewProperties()->getProjectionMatrix(hkvClipSpaceYRange::MinusOneToOne);
hkvMat4 viewMatrix = pContext->GetCamera()->GetWorldToCameraTransformation();
// get position/ radius of bounding sphere
hkvVec3 vPosition;
float fRadius = 0.0f;
if (pLight->GetType() == VIS_LIGHT_POINT)
{
vPosition = pLight->GetPosition();
fRadius = pLight->GetRadius();
}
else if (pLight->GetType() == VIS_LIGHT_SPOTLIGHT)
{
hkvAlignedBBox bBox;
pLight->GetBoundingBox(bBox);
vPosition = bBox.getBoundingSphere().m_vCenter;
fRadius = bBox.getBoundingSphere().m_fRadius;
}
else
VASSERT_MSG(false, "Unsupported light type");
// get corners of bounding rectangle in view space
hkvVec4 vPositionVS = viewMatrix*vPosition.getAsVec4(1.0f);
hkvVec4 vCorners[4];
vCorners[0] = vPositionVS+hkvVec4(-fRadius, -fRadius, 0.0f, 0.0f);
vCorners[1] = vPositionVS+hkvVec4(fRadius, -fRadius, 0.0f, 0.0f);
vCorners[2] = vPositionVS+hkvVec4(fRadius, fRadius, 0.0f, 0.0f);
vCorners[3] = vPositionVS+hkvVec4(-fRadius, fRadius, 0.0f, 0.0f);
// get corners of bounding rectangle in normalized device coordinates
for (int i=0;i<4;i++)
{
vCorners[i] = projMatrix*vCorners[i];
vCorners[i] /= vCorners[i].w;
}
// clip corners of bounding rectangle
hkvVec2 vMin(vCorners[0].x, vCorners[0].y);
vMin.clampTo(hkvVec2(-1.0f, -1.0f), hkvVec2(1.0f, 1.0f));
hkvVec2 vMax(vCorners[2].x, vCorners[2].y);
vMax.clampTo(hkvVec2(-1.0f, -1.0f), hkvVec2(1.0f, 1.0f));
// calculate influence area
int iWidth = (int)((vMax.x-vMin.x)*0.5f*iScreenWidth);
int iHeight = (int)((vMax.y-vMin.y)*0.5f*iScreenHeight);
return (iWidth*iHeight);
}
示例2: GetFrustumFarCorners
void VRendererNodeHelper::GetFrustumFarCorners(hkvVec3* pVectors)
{
VisRenderContext_cl *pContext = m_pRendererNode->GetReferenceContext();
hkvMat4 projMat = pContext->GetViewProperties()->getProjectionMatrix(hkvClipSpaceYRange::MinusOneToOne);
projMat.invert ();
// top left far corner
pVectors[0].set(-1.0f,1.0f,1.0f);
// bottom left far corner
pVectors[1].set(-1.0f,-1.0f,1.0f);
// bottom right far corner
pVectors[2].set(1.0f,-1.0f,1.0f);
// top right far corner
pVectors[3].set(1.0f,1.0f,1.0f);
for(int i=0;i<4;i++)
{
hkvVec4 vTransformed = projMat.transform (pVectors[i].getAsPosition());
pVectors[i] = vTransformed.getAsVec3 () / vTransformed.w;
}
}