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


C++ Mat4f::translatePreMultiply方法代码示例

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


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

示例1: createObliqueCylinder


//.........这里部分代码省略.........

    // Create vertices
    uint zPoly;
    for (zPoly = 0; zPoly <= numPolysZDir; zPoly++)
    {
        float fT = static_cast<float>((1.0/numPolysZDir)*(zPoly));
        float radius = bottomRadius + fT*(topRadius - bottomRadius);
        Vec3f center(fT*topOffsetX, fT*topOffsetY, fT*height);

        Vec3fArray verts;
        verts.reserve(numSlices);
        Vec3f point = Vec3f::ZERO;

        double da = 2*PI_D/numSlices;
        uint i;
        for (i = 0; i < numSlices; i++) 
        {
            // Precompute this one (A = i*da;)
            double sinA = Math::sin(i*da);
            double cosA = Math::cos(i*da);

            point.x() = static_cast<float>(-sinA*radius);
            point.y() = static_cast<float>( cosA*radius);
            point.z() = 0;

            point += center;

            verts.add(point);
        }

        uint baseNodeIdx = builder->addVertices(verts);

        // First time we only create the sourceNodes
        if (zPoly != 0)
        {
            uint offset = baseNodeIdx - numSlices;
            uint piConn[4] = { 0, 0, 0, 0 };

            // Normals facing outwards
            if (normalsOutwards)
            {
                uint i;
                for (i = 0; i < numSlices; i++) 
                {
                    piConn[0] = offset + i;
                    piConn[1] = offset + i + 1;
                    piConn[2] = offset + i + numSlices + 1;
                    piConn[3] = offset + i + numSlices;

                    if (i == numSlices - 1) 
                    {
                        piConn[1] = offset;
                        piConn[2] = offset + numSlices;
                    }

                    builder->addQuad(piConn[0], piConn[1], piConn[2], piConn[3]);
                }
            }

            // Normals facing inwards
            else
            {
                uint i;
                for (i = 0; i < numSlices; i++) 
                {
                    piConn[0] = offset + i + 1;
                    piConn[1] = offset + i;
                    piConn[2] = offset + i + numSlices;
                    piConn[3] = offset + i + numSlices + 1;

                    if (i == numSlices - 1) 
                    {
                        piConn[0] = offset;
                        piConn[3] = offset + numSlices;
                    }

                    builder->addQuad(piConn[0], piConn[1], piConn[2], piConn[3]);
                }
            }
        }
    }

    if (closedBot)
    {
        createDisc(bottomRadius, numSlices, builder);
    }

    if (closedTop)
    {
        uint startIdx = builder->vertexCount();
        createDisc(topRadius, numSlices, builder);
        uint endIdx = builder->vertexCount() - 1;

        // Translate the top disc sourceNodes, also flip it to get the normals the right way
        Mat4f mat = Mat4f::fromRotation(Vec3f(1.0f, 0.0f, 0.0f), Math::toRadians(180.0f));
        mat.translatePreMultiply(Vec3f(topOffsetX, topOffsetY, height));

        builder->transformVertexRange(startIdx, endIdx, mat);
    }
}
开发者ID:akva2,项目名称:ResInsight,代码行数:101,代码来源:cvfGeometryUtils.cpp


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