本文整理汇总了C++中CFrustum::BoxInFrustum方法的典型用法代码示例。如果您正苦于以下问题:C++ CFrustum::BoxInFrustum方法的具体用法?C++ CFrustum::BoxInFrustum怎么用?C++ CFrustum::BoxInFrustum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFrustum
的用法示例。
在下文中一共展示了CFrustum::BoxInFrustum方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindLeaf
void CQuake3BSP::RenderLevel(const CVector3 &vPos)
{
// Reset our bitset so all the slots are zero.
m_FacesDrawn.ClearAll();
// Grab the leaf index that our camera is in
int leafIndex = FindLeaf(vPos);
// Grab the cluster that is assigned to the leaf
int cluster = m_pLeafs[leafIndex].cluster;
// Initialize our counter variables (start at the last leaf and work down)
int i = m_numOfLeafs;
g_VisibleFaces = 0;
// Go through all the leafs and check their visibility
while(i--)
{
// Get the current leaf that is to be tested for visibility from our camera's leaf
tBSPLeaf *pLeaf = &(m_pLeafs[i]);
// If the current leaf can't be seen from our cluster, go to the next leaf
if(!IsClusterVisible(cluster, pLeaf->cluster))
continue;
// If the current leaf is not in the camera's frustum, go to the next leaf
if(!g_Frustum.BoxInFrustum((float)pLeaf->min.x, (float)pLeaf->min.y, (float)pLeaf->min.z,
(float)pLeaf->max.x, (float)pLeaf->max.y, (float)pLeaf->max.z))
continue;
// If we get here, the leaf we are testing must be visible in our camera's view.
// Get the number of faces that this leaf is in charge of.
int faceCount = pLeaf->numOfLeafFaces;
// Loop through and render all of the faces in this leaf
while(faceCount--)
{
// Grab the current face index from our leaf faces array
int faceIndex = m_pLeafFaces[pLeaf->leafface + faceCount];
// Before drawing this face, make sure it's a normal polygon
if(m_pFaces[faceIndex].type != FACE_POLYGON) continue;
// Since many faces are duplicated in other leafs, we need to
// make sure this face already hasn't been drawn.
if(!m_FacesDrawn.On(faceIndex))
{
// Increase the rendered face count to display for fun
g_VisibleFaces++;
// Set this face as drawn and render it
m_FacesDrawn.Set(faceIndex);
RenderFace(faceIndex);
}
}
}
}
示例2: FindLeaf
void CQuake3BSP::RenderLevel(const CVector3 &vPos)
{
// Reset our bitset so all the slots are zero.
m_FacesDrawn.ClearAll();
/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *
// In this new revision of RenderLevel(), we do things a bit differently.
// Instead of looping through all the faces, we now want to loop through
// all of the leafs. Each leaf stores a list of faces assign to it.
// We call FindLeaf() to find the current leaf index that our camera is
// in. This leaf will then give us the cluster that the camera is in. The
// cluster is then used to test visibility between our current cluster
// and other leaf clusters. If another leaf's cluster is visible from our
// current cluster, the leaf's bounding box is checked against our frustum.
// Assuming the bounding box is inside of our frustum, we draw all the faces
// stored in that leaf.
// Grab the leaf index that our camera is in
int leafIndex = FindLeaf(vPos);
// Grab the cluster that is assigned to the leaf
int cluster = m_pLeafs[leafIndex].cluster;
// Initialize our counter variables (start at the last leaf and work down)
int i = m_numOfLeafs;
g_VisibleFaces = 0;
// Go through all the leafs and check their visibility
while(i--)
{
// Get the current leaf that is to be tested for visibility from our camera's leaf
tBSPLeaf *pLeaf = &(m_pLeafs[i]);
// If the current leaf can't be seen from our cluster, go to the next leaf
if(!IsClusterVisible(cluster, pLeaf->cluster))
continue;
// If the current leaf is not in the camera's frustum, go to the next leaf
if(!g_Frustum.BoxInFrustum((float)pLeaf->min.x, (float)pLeaf->min.y, (float)pLeaf->min.z,
(float)pLeaf->max.x, (float)pLeaf->max.y, (float)pLeaf->max.z))
continue;
// If we get here, the leaf we are testing must be visible in our camera's view.
// Get the number of faces that this leaf is in charge of.
int faceCount = pLeaf->numOfLeafFaces;
// Loop through and render all of the faces in this leaf
while(faceCount--)
{
// Grab the current face index from our leaf faces array
int faceIndex = m_pLeafFaces[pLeaf->leafface + faceCount];
// Before drawing this face, make sure it's a normal polygon
if(m_pFaces[faceIndex].type != FACE_POLYGON) continue;
// Since many faces are duplicated in other leafs, we need to
// make sure this face already hasn't been drawn.
if(!m_FacesDrawn.On(faceIndex))
{
// Increase the rendered face count to display for fun
g_VisibleFaces++;
// Set this face as drawn and render it
m_FacesDrawn.Set(faceIndex);
RenderFace(faceIndex);
}
}
}
/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *
}