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


C++ MeshBase::getVertexAttrib方法代码示例

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


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

示例1: append

void MeshBase::append(const MeshBase& other)
{
    FW_ASSERT(&other != this);
    FW_ASSERT(isInMemory());
    FW_ASSERT(other.isInMemory());

    Array<bool> dstAttribUsed(NULL, numAttribs());
    for (int i = 0; i < numAttribs(); i++)
        dstAttribUsed[i] = false;

    Array<Vec2i> copy;
    Array<Vec2i> convert;
    for (int i = 0; i < other.numAttribs(); i++)
    {
        const AttribSpec& src = other.attribSpec(i);
        for (int j = 0; j < numAttribs(); j++)
        {
            const AttribSpec& dst = attribSpec(j);
            if (src.type != dst.type || dstAttribUsed[j])
                continue;

            if (src.format != dst.format || src.length != dst.length)
                convert.add(Vec2i(i, j));
            else
            {
                for (int k = 0; k < src.bytes; k++)
                    copy.add(Vec2i(src.offset + k, dst.offset + k));
            }
            dstAttribUsed[j] = true;
            break;
        }
    }

    int oldNumVertices = m_numVertices;
    resizeVertices(oldNumVertices + other.m_numVertices);
    for (int i = 0; i < other.m_numVertices; i++)
    {
        if (copy.getSize())
        {
            const U8* src = &other.m_vertices[i * other.m_stride];
            U8* dst = &m_vertices[(i + oldNumVertices) * m_stride];
            for (int j = 0; j < copy.getSize(); j++)
                dst[copy[j].y] = src[copy[j].x];
        }
        for (int j = 0; j < convert.getSize(); j++)
            setVertexAttrib(i + oldNumVertices, convert[j].y,
                other.getVertexAttrib(i, convert[j].x));
    }

    int oldNumSubmeshes = numSubmeshes();
    resizeSubmeshes(oldNumSubmeshes + other.numSubmeshes());
    for (int i = 0; i < other.numSubmeshes(); i++)
    {
        const Submesh& src = other.m_submeshes[i];
        Submesh& dst = m_submeshes[i + oldNumSubmeshes];

        dst.indices->reset(src.indices->getSize());
        for (int j = 0; j < src.indices->getSize(); j++)
            dst.indices->set(j, src.indices->get(j) + oldNumVertices);
        dst.material = src.material;
    }
}
开发者ID:AllioNicholas,项目名称:CG_AS1,代码行数:62,代码来源:Mesh.cpp


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