当前位置: 首页>>代码示例>>C++>>正文


C++ CDebug::AddDebugRectangle方法代码示例

本文整理汇总了C++中CDebug::AddDebugRectangle方法的典型用法代码示例。如果您正苦于以下问题:C++ CDebug::AddDebugRectangle方法的具体用法?C++ CDebug::AddDebugRectangle怎么用?C++ CDebug::AddDebugRectangle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CDebug的用法示例。


在下文中一共展示了CDebug::AddDebugRectangle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateNode

void COctree::CreateNode(CVector3 *pVertices, int numberOfVerts, CVector3 vCenter, float width)
{
    // This is our main function that creates the octree.  We will recurse through
    // this function until we finish subdividing.  Either this will be because we
    // subdivided too many levels or we divided all of the triangles up.

    // Create a variable to hold the number of triangles
    int numberOfTriangles = numberOfVerts / 3;

    // Initialize this node's center point.  Now we know the center of this node.
    m_vCenter = vCenter;

    // Initialize this nodes cube width.  Now we know the width of this current node.
    m_Width = width;

    // Add the current node to our debug rectangle list so we can visualize it.
    // We can now see this node visually as a cube when we render the rectangles.
    // Since it's a cube we pass in the width for width, height and depth.
    g_Debug.AddDebugRectangle(vCenter, width, width, width);

    // Check if we have too many triangles in this node and we haven't subdivided
    // above our max subdivisions.  If so, then we need to break this node into
    // 8 more nodes (hence the word OCTree).  Both must be true to divide this node.
    if( (numberOfTriangles > g_MaxTriangles) && (g_CurrentSubdivision < g_MaxSubdivisions) )
    {
        // Since we need to subdivide more we set the divided flag to true.
        // This let's us know that this node does NOT have any vertices assigned to it,
        // but nodes that perhaps have vertices stored in them (Or their nodes, etc....)
        // We will querey this variable when we are drawing the octree.
        m_bSubDivided = true;

        // Create a list for each new node to store if a triangle should be stored in it's
        // triangle list.  For each index it will be a true or false to tell us if that triangle
        // is in the cube of that node.  Below we check every point to see where it's
        // position is from the center (I.E. if it's above the center, to the left and
        // back it's the TOP_LEFT_BACK node).  Depending on the node we set the pList
        // index to true.  This will tell us later which triangles go to which node.
        // You might catch that this way will produce doubles in some nodes.  Some
        // triangles will intersect more than 1 node right?  We won't split the triangles
        // in this tutorial just to keep it simple, but the next tutorial we will.

        // Create the list of booleans for each triangle index
        vector<bool> pList1(numberOfTriangles);		// TOP_LEFT_FRONT node list
        vector<bool> pList2(numberOfTriangles);		// TOP_LEFT_BACK node list
        vector<bool> pList3(numberOfTriangles);		// TOP_RIGHT_BACK node list
        vector<bool> pList4(numberOfTriangles);		// TOP_RIGHT_FRONT node list
        vector<bool> pList5(numberOfTriangles);		// BOTTOM_LEFT_FRONT node list
        vector<bool> pList6(numberOfTriangles);		// BOTTOM_LEFT_BACK node list
        vector<bool> pList7(numberOfTriangles);		// BOTTOM_RIGHT_BACK node list
        vector<bool> pList8(numberOfTriangles);		// BOTTOM_RIGHT_FRONT node list

        // Create this variable to cut down the thickness of the code below (easier to read)
        CVector3 vCtr = vCenter;

        // Go through all of the vertices and check which node they belong too.  The way
        // we do this is use the center of our current node and check where the point
        // lies in relationship to the center.  For instance, if the point is
        // above, left and back from the center point it's the TOP_LEFT_BACK node.
        // You'll see we divide by 3 because there are 3 points in a triangle.
        // If the vertex index 0 and 1 are in a node, 0 / 3 and 1 / 3 is 0 so it will
        // just set the 0'th index to TRUE twice, which doesn't hurt anything.  When
        // we get to the 3rd vertex index of pVertices[] it will then be checking the
        // 1st index of the pList*[] array.  We do this because we want a list of the
        // triangles in the node, not the vertices.
        for(int i = 0; i < numberOfVerts; i++)
        {
            // Create some variables to cut down the thickness of the code (easier to read)
            CVector3 vPoint = pVertices[i];

            // Check if the point lines within the TOP LEFT FRONT node
            if( (vPoint.x <= vCtr.x) && (vPoint.y >= vCtr.y) && (vPoint.z >= vCtr.z) )
                pList1[i / 3] = true;

            // Check if the point lines within the TOP LEFT BACK node
            if( (vPoint.x <= vCtr.x) && (vPoint.y >= vCtr.y) && (vPoint.z <= vCtr.z) )
                pList2[i / 3] = true;

            // Check if the point lines within the TOP RIGHT BACK node
            if( (vPoint.x >= vCtr.x) && (vPoint.y >= vCtr.y) && (vPoint.z <= vCtr.z) )
                pList3[i / 3] = true;

            // Check if the point lines within the TOP RIGHT FRONT node
            if( (vPoint.x >= vCtr.x) && (vPoint.y >= vCtr.y) && (vPoint.z >= vCtr.z) )
                pList4[i / 3] = true;

            // Check if the point lines within the BOTTOM LEFT FRONT node
            if( (vPoint.x <= vCtr.x) && (vPoint.y <= vCtr.y) && (vPoint.z >= vCtr.z) )
                pList5[i / 3] = true;

            // Check if the point lines within the BOTTOM LEFT BACK node
            if( (vPoint.x <= vCtr.x) && (vPoint.y <= vCtr.y) && (vPoint.z <= vCtr.z) )
                pList6[i / 3] = true;

            // Check if the point lines within the BOTTOM RIGHT BACK node
            if( (vPoint.x >= vCtr.x) && (vPoint.y <= vCtr.y) && (vPoint.z <= vCtr.z) )
                pList7[i / 3] = true;

            // Check if the point lines within the BOTTOM RIGHT FRONT node
            if( (vPoint.x >= vCtr.x) && (vPoint.y <= vCtr.y) && (vPoint.z >= vCtr.z) )
                pList8[i / 3] = true;
//.........这里部分代码省略.........
开发者ID:jiangguang5201314,项目名称:ZNginx,代码行数:101,代码来源:Octree.cpp


注:本文中的CDebug::AddDebugRectangle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。