How to get BoneWeights and BoneIndices of skeletalMesh c++?

Hello,
I want to know the boneWeights and boneIndices for each vertex of a skeletalMesh
Thanks.

I found the answer myself.

Here is how:

  • First you need to get the target mesh.
  • Then get the vertices.
  • After that we need to loop them, and use the index of the iteration to get the boneIndices and boneWeights of each vertex.
  • Now we have a uint8 value, we need to access the data inside this byte buffer.
  • We will cast this vertex.InfluenceBones[0] to Int, where index 0 for the first bone index and 1 for the second and so on for 3 and 4.
  • Now for boneWeights, almost the same for the previous step.
  • Firstly, we will cast vertex.InfluencesWeights[0] to Int then cast it to double and divide it with 255.0
    where index 0 for the first bone index and 1 for the second and so on for 3 and 4.

“255.0” is the maximum number of each byte in that buffer

I used this method, but I got error bone index. The same FBX, many vertices bone index is 0(rootBone), but in Unity, no any vertices bone index is 0(rootBone)

How did you do it? The GetSkeletalMeshResource method doesn’t even exist in the Unreal Engine

In 4.27 I use this:

FSkeletalMeshLODRenderData& lodd = Mesh->SkeletalMesh->GetResourceForRendering()->LODRenderData[0];
FSkinWeightVertexBuffer* SkinWeightBuffer = &lodd.SkinWeightVertexBuffer;
TArray SkinWeightInfo;
SkinWeightBuffer->GetSkinWeights(SkinWeightInfo);

Each entry in the SkinWeightInfo array corresponds to a mesh vertex