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


C++ BBox::BoundingSphere方法代码示例

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


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

示例1: b

// Bounding Sphere Tests
TEST_F(BBoxTest, BoundingSphereWorks) {
    BBox b (Point (0, 0, 0), Point (1, 1, 1));

    Point center;
    float radius;

    b.BoundingSphere (&center, &radius);

    EXPECT_EQ (.5, center.x);
    EXPECT_EQ (.5, center.y);
    EXPECT_EQ (.5, center.z);

    EXPECT_EQ (sqrtf(.75), radius);
}
开发者ID:trprice,项目名称:branching_example,代码行数:15,代码来源:BBox_Tests.cpp

示例2: ProcessVertices


//.........这里部分代码省略.........
            // line indices
            m_HairAsset.m_LineIndices.push_back(id);
            m_HairAsset.m_LineIndices.push_back(id + 1);

            // triangle indices
            m_HairAsset.m_TriangleIndices.push_back(2 * id);
            m_HairAsset.m_TriangleIndices.push_back(2 * id + 1);
            m_HairAsset.m_TriangleIndices.push_back(2 * id + 2);
            m_HairAsset.m_TriangleIndices.push_back(2 * id + 2);
            m_HairAsset.m_TriangleIndices.push_back(2 * id + 1);
            m_HairAsset.m_TriangleIndices.push_back(2 * id + 3);
            id++;
        }

        id++;

        TressFXHairVertex* vertices = &m_Vertices[indexRootVert];

        for ( int j = 0; j < m_HairAsset.m_NumOfVerticesInStrand; j++ )
        {
            // triangle vertices
            StrandVertex strandVertex;
            strandVertex.position = XMFLOAT3(vertices[j].position.x, vertices[j].position.y, vertices[j].position.z);
            strandVertex.tangent = XMFLOAT3(vertices[j].tangent.x, vertices[j].tangent.y, vertices[j].tangent.z);
            strandVertex.texcoord = XMFLOAT4(vertices[j].texcoord.x, vertices[j].texcoord.y, vertices[j].texcoord.z, 0);
            m_HairAsset.m_pTriangleVertices[index] = strandVertex;

            float tVal = m_HairAsset.m_pTriangleVertices[index].texcoord.z;
            m_HairAsset.m_pThicknessCoeffs[index] = sqrt(1.f - tVal * tVal);

            XMFLOAT4 v;

            // temp vertices
            v.x = vertices[j].position.x;
            v.y = vertices[j].position.y;
            v.z = vertices[j].position.z;
            v.w = vertices[j].invMass;
            m_HairAsset.m_pVertices[index] = v;

            // global rotations
            v.x = vertices[j].globalTransform.GetRotation().x;
            v.y = vertices[j].globalTransform.GetRotation().y;
            v.z = vertices[j].globalTransform.GetRotation().z;
            v.w = vertices[j].globalTransform.GetRotation().w;
            m_HairAsset.m_pGlobalRotations[index] = v;

            // local rotations
            v.x = vertices[j].localTransform.GetRotation().x;
            v.y = vertices[j].localTransform.GetRotation().y;
            v.z = vertices[j].localTransform.GetRotation().z;
            v.w = vertices[j].localTransform.GetRotation().w;
            m_HairAsset.m_pLocalRotations[index] = v;

            // ref vectors
            v.x = vertices[j].referenceVector.x;
            v.y = vertices[j].referenceVector.y;
            v.z = vertices[j].referenceVector.z;
            m_HairAsset.m_pRefVectors[index].x = v.x;
            m_HairAsset.m_pRefVectors[index].y = v.y;
            m_HairAsset.m_pRefVectors[index].z = v.z;

            index++;
        }

        int groupId = m_HairStrands[i].m_GroupID;
        m_HairAsset.m_pHairStrandType[i] = groupId;

        if ( m_usingPerStrandTexCoords )
        {
            m_HairAsset.m_pStrandTexCoords[i] = m_HairStrands[i].m_texCoord;
        }

        if ( m_HairStrands[i].m_bGuideHair )
        {
            indexGuideHairStrand = i;
            pGuideHair = &m_HairStrands[i];
            m_HairAsset.m_pFollowRootOffset[i] = XMFLOAT4(0, 0, 0, (float)indexGuideHairStrand); // forth component is an index to the guide hair strand. For guide hair, it points itself.
        }
        else
        {
            assert(pGuideHair);
            tressfx_vec3& offset = m_SlaveOffset[i];
            m_HairAsset.m_pFollowRootOffset[i] = XMFLOAT4(offset.x, offset.y, offset.z, (float)indexGuideHairStrand);
        }
    }

    // Find the bounding sphere
    BBox bBox;

    for ( int i = 0; i < (int)m_Vertices.size(); ++i )
    {
        const TressFXHairVertex& vertex = m_Vertices[i];
        bBox = Union(bBox, Float3(vertex.position.x, vertex.position.y, vertex.position.z));
    }

    Float3 c; float radius;
    bBox.BoundingSphere(&c, &radius);
    m_HairAsset.m_bSphere.center = XMFLOAT3(c.x, c.y, c.z);
    m_HairAsset.m_bSphere.radius = radius;
}
开发者ID:GPUOpen-Effects,项目名称:TressFX,代码行数:101,代码来源:TressFXAsset.cpp


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