本文整理汇总了C++中Terrain::SetCulled方法的典型用法代码示例。如果您正苦于以下问题:C++ Terrain::SetCulled方法的具体用法?C++ Terrain::SetCulled怎么用?C++ Terrain::SetCulled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terrain
的用法示例。
在下文中一共展示了Terrain::SetCulled方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalculateCulling
void DxManager::CalculateCulling()
{
D3DXMATRIX view = this->camera->GetViewMatrix();
D3DXMATRIX proj = this->camera->GetProjectionMatrix();
/*
float zMinimum = -proj._43 / proj._33;
float r = this->params.FarClip / (this->params.FarClip - zMinimum);
proj._33 = r;
proj._43 = -r * zMinimum;
*/
D3DXMATRIX VP;
D3DXMatrixMultiply(&VP, &view, &proj);
// Calculate near plane of frustum.
FrustrumPlanes[0].a = VP._14 + VP._13;
FrustrumPlanes[0].b = VP._24 + VP._23;
FrustrumPlanes[0].c = VP._34 + VP._33;
FrustrumPlanes[0].d = VP._44 + VP._43;
D3DXPlaneNormalize(&FrustrumPlanes[0], &FrustrumPlanes[0]);
// Calculate far plane of frustum.
FrustrumPlanes[1].a = VP._14 - VP._13;
FrustrumPlanes[1].b = VP._24 - VP._23;
FrustrumPlanes[1].c = VP._34 - VP._33;
FrustrumPlanes[1].d = VP._44 - VP._43;
D3DXPlaneNormalize(&FrustrumPlanes[1], &FrustrumPlanes[1]);
// Calculate left plane of frustum.
FrustrumPlanes[2].a = VP._14 + VP._11;
FrustrumPlanes[2].b = VP._24 + VP._21;
FrustrumPlanes[2].c = VP._34 + VP._31;
FrustrumPlanes[2].d = VP._44 + VP._41;
D3DXPlaneNormalize(&FrustrumPlanes[2], &FrustrumPlanes[2]);
// Calculate right plane of frustum.
FrustrumPlanes[3].a = VP._14 - VP._11;
FrustrumPlanes[3].b = VP._24 - VP._21;
FrustrumPlanes[3].c = VP._34 - VP._31;
FrustrumPlanes[3].d = VP._44 - VP._41;
D3DXPlaneNormalize(&FrustrumPlanes[3], &FrustrumPlanes[3]);
// Calculate top plane of frustum.
FrustrumPlanes[4].a = VP._14 - VP._12;
FrustrumPlanes[4].b = VP._24 - VP._22;
FrustrumPlanes[4].c = VP._34 - VP._32;
FrustrumPlanes[4].d = VP._44 - VP._42;
D3DXPlaneNormalize(&FrustrumPlanes[4], &FrustrumPlanes[4]);
// Calculate bottom plane of frustum.
FrustrumPlanes[5].a = VP._14 + VP._12;
FrustrumPlanes[5].b = VP._24 + VP._22;
FrustrumPlanes[5].c = VP._34 + VP._32;
FrustrumPlanes[5].d = VP._44 + VP._42;
D3DXPlaneNormalize(&FrustrumPlanes[5], &FrustrumPlanes[5]);
//Terrain
for(int i = 0; i < this->terrains.size(); i++)
{
Terrain* terr = this->terrains.get(i);
float scale = max(terr->GetScale().x, max(terr->GetScale().y, terr->GetScale().z));
if(pe.FrustrumVsSphere(this->FrustrumPlanes, terr->GetBoundingSphere(), terr->GetWorldMatrix(), scale))
{
terr->SetCulled(false);
}
else
{
terr->SetCulled(true);
}
}
//Static meshes
for(int i = 0; i < this->objects.size(); i++)
{
StaticMesh* ms = this->objects.get(i);
MaloW::Array<MeshStrip*>* strips = ms->GetStrips();
for(int u = 0; u < strips->size(); u++)
{
MeshStrip* s = strips->get(u);
float scale = max(ms->GetScaling().x, max(ms->GetScaling().y, ms->GetScaling().z));
if(pe.FrustrumVsSphere(this->FrustrumPlanes, s->GetBoundingSphere(), ms->GetWorldMatrix(), scale))
{
s->SetCulled(false);
}
else
{
s->SetCulled(true);
}
}
}
//Animated meshes
for(int i = 0; i < this->animations.size(); i++)
{
AnimatedMesh* ms = this->animations.get(i);
MeshStrip* s = ms->GetStrips()->get(0);
//.........这里部分代码省略.........