【问题标题】:combine assimp bone data with other vertex data将 assimp 骨骼数据与其他顶点数据相结合
【发布时间】:2020-01-10 02:30:32
【问题描述】:

我的问题是我正在尝试使用 Assimp 从 Direct X c++ 中的 fbx 文件加载关节/骨骼数据,但我想将八位和索引存储在存储位置、uv 等的同一个顶点结构中.

我可以为每个顶点制作一个循环,但我也想在每个骨骼上制作一个循环。 这意味着我不能在同一个循环中同时拥有联合数据和其他数据。

我应该创建多个顶点对象然后将它们组合起来吗?

我也不确定如何找到每个顶点的骨骼 ID 和权重,我指望每个骨骼有 4 个,但也许我根本不应该有最后一个循环? 我不确定如何设置它。

我将不胜感激,非常感谢。

  for (UINT k = 0; k < currentMesh->mNumBones; k++)
    {

        aiBone* bone = currentMesh->mBones[k];

        for (UINT m = 0; m < bone->mNumWeights; m++)
        {
            aiVertexWeight weight = bone->mWeights[m];

            for (UINT n = 0; n < 4; n++)
            {
                //if




            }

        }




    }


     //////////////////////////////////////////////
    for (UINT k = 0; k < currentMesh->mNumVertices; k++)
    {



        Vertex vert;
        vert.position.x = currentMesh->mVertices[k].x;
        vert.position.y = currentMesh->mVertices[k].y;
        vert.position.z = currentMesh->mVertices[k].z;



        vert.TexCoord.x = currentMesh->mTextureCoords[0][k].x;
        vert.TexCoord.y = currentMesh->mTextureCoords[0][k].y;

        vert.normal.x = currentMesh->mNormals[k].x;
        vert.normal.y = currentMesh->mNormals[k].y;
        vert.normal.z = currentMesh->mNormals[k].z;





        vertexVector.push_back(vert);

    }

【问题讨论】:

    标签: assimp


    【解决方案1】:
        for (UINT k = 0; k < currentMesh->mNumBones; k++)
        {
    
            aiBone* bone = currentMesh->mBones[k];
    
            for (UINT m = 0; m < bone->mNumWeights; m++)
            {
                aiVertexWeight weight = bone->mWeights[m];
    
    
                if (vertexVector[weight.mVertexId].joints.x == 0)
                {
                    vertexVector[weight.mVertexId].joints.x = k;
                    vertexVector[weight.mVertexId].weights.x = weight.mWeight;
                }
                else if (vertexVector[weight.mVertexId].joints.y == 0)
                {
                    vertexVector[weight.mVertexId].joints.y = k;
                    vertexVector[weight.mVertexId].weights.y = weight.mWeight;
                }
                else if (vertexVector[weight.mVertexId].joints.z == 0)
                {
                    vertexVector[weight.mVertexId].joints.z = k;
                    vertexVector[weight.mVertexId].weights.z = weight.mWeight;
                }
                else if (vertexVector[weight.mVertexId].joints.w == 0)
                {
                    vertexVector[weight.mVertexId].joints.w = k;
                    vertexVector[weight.mVertexId].weights.w = weight.mWeight;
                }
    
    
    
            }
    
    
    
    
        }
    

    我访问了我已经拥有的相同结构并随后添加了内容。

    【讨论】:

      猜你喜欢
      • 2014-09-23
      • 2016-07-31
      • 2017-03-27
      • 1970-01-01
      • 2017-01-30
      • 2015-03-17
      • 2014-01-15
      • 1970-01-01
      • 2014-07-25
      相关资源
      最近更新 更多