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


C++ MeshBuilder::SetMaterialName方法代码示例

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


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

示例1: ImportMesh

    //THIS MUST HAPPEN AFTER IMPORTING SKELETONS.
    //-----------------------------------------------------------------------------------
    static void ImportMesh(SceneImport* import, FbxMesh* mesh, MatrixStack4x4& matrixStack, std::map<int, FbxNode*>& nodeToJointIndex)
    {
        MeshBuilder builder = MeshBuilder();
        ASSERT_OR_DIE(mesh->IsTriangleMesh(), "Was unable to load the mesh, it's not a triangle mesh!");
        Matrix4x4 geoTransform = GetGeometricTransform(mesh);
        matrixStack.Push(geoTransform);

        int controlPointCount = mesh->GetControlPointsCount();

        //Figure out our weighs for all verts before importing any of them
        std::vector<SkinWeight> skinWeights;
        if (HasSkinWeights(mesh))
        {
            skinWeights.resize(controlPointCount);
            GetSkinWeights(import, skinWeights, mesh, nodeToJointIndex);
        }
        else
        {
            FbxNode* node = mesh->GetNode();
            //Walk tree up till you reach the node associated with that joint.
            //Find the first parent node that has a joint associated with it
            //All vertices (fully weighted)
            //All Skin Weights = indices{jointINdex, 0, 0, 0 } weights{1.0f, 0.0f, 0.0f, 0.0f};

            int jointIndex = Skeleton::INVALID_JOINT_INDEX;
            for (auto iter = nodeToJointIndex.begin(); iter != nodeToJointIndex.end(); ++iter)
            {
                if (iter->second == node)
                {
                    jointIndex = iter->first;
                    break;
                }
            }

            if (jointIndex == Skeleton::INVALID_JOINT_INDEX)
            {
                for (unsigned int i = 0; i < skinWeights.size(); ++i)
                {
                    skinWeights[i].indices = Vector4Int::ZERO;
                    skinWeights[i].weights = Vector4::UNIT_X;
                }
            }
            else
            {
                for (unsigned int i = 0; i < skinWeights.size(); ++i)
                {
                    skinWeights[i].indices = Vector4Int(jointIndex, 0, 0, 0);
                    skinWeights[i].weights = Vector4::UNIT_X;
                }
            }
        }

        builder.Begin();
        {
            Matrix4x4 transform = matrixStack.GetTop();
            int polyCount = mesh->GetPolygonCount();
            for (int polyIndex = 0; polyIndex < polyCount; ++polyIndex)
            {
                int vertCount = mesh->GetPolygonSize(polyIndex);
                ASSERT_OR_DIE(vertCount == 3, "Vertex count was not 3");
                for (int vertIndex = 0; vertIndex < vertCount; ++vertIndex)
                {
                    ImportVertex(builder, transform, mesh, polyIndex, vertIndex, skinWeights);
                }
            }
        }
        builder.End();

        FbxSurfaceMaterial* material = mesh->GetNode()->GetMaterial(0);
        builder.SetMaterialName(material->GetName());

        matrixStack.Pop();

        import->meshes.push_back(builder);
    }
开发者ID:picoriley,项目名称:CloudyCraft,代码行数:77,代码来源:fbx.cpp


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