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

**URL:** <https://forums.unrealengine.com/t/how-to-get-boneweights-and-boneindices-of-skeletalmesh-c/417396>\
**Category:** World Creation\
**Tags:** weight, vertices, bone, unreal-engine, Physics, skeletalmesh, CPP, question\
**Created:** [February 15, 2018, 2:01pm UTC](https://forums.unrealengine.com/t/how-to-get-boneweights-and-boneindices-of-skeletalmesh-c/417396 "2018-02-15T14:01:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![L4D\_LEGEND](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@L4D\_LEGEND](https://forums.unrealengine.com/u/L4D_LEGEND)\
**Post date:** [February 15, 2018, 2:01pm UTC](https://forums.unrealengine.com/t/how-to-get-boneweights-and-boneindices-of-skeletalmesh-c/417396/1 "2018-02-15T14:01:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![L4D\_LEGEND](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@L4D\_LEGEND](https://forums.unrealengine.com/u/L4D_LEGEND)\
**Post date:** [March 26, 2018, 11:48am UTC](https://forums.unrealengine.com/t/how-to-get-boneweights-and-boneindices-of-skeletalmesh-c/417396/2 "2018-03-26T11:48:04Z")

</div>

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

 ![235109-untitledasd.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/9/3/b93aae2fa7ebbc2391af34a0da72f3d598d57b22.png)

---

<div class="post-metadata">

**Author:** ![Anonymous\_c79aea4986fd726db6bff6714bf989a0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_c79aea4986fd726db6bff6714bf989a0](https://forums.unrealengine.com/u/Anonymous_c79aea4986fd726db6bff6714bf989a0)\
**Post date:** [April 29, 2019, 11:19am UTC](https://forums.unrealengine.com/t/how-to-get-boneweights-and-boneindices-of-skeletalmesh-c/417396/3 "2019-04-29T11:19:07Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_a0f5e554](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a0f5e554](https://forums.unrealengine.com/u/anonymous_user_a0f5e554)\
**Post date:** [June 21, 2019, 2:53pm UTC](https://forums.unrealengine.com/t/how-to-get-boneweights-and-boneindices-of-skeletalmesh-c/417396/4 "2019-06-21T14:53:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![DentonJC](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DentonJC](https://forums.unrealengine.com/u/DentonJC)\
**Post date:** [November 10, 2023, 9:39pm UTC](https://forums.unrealengine.com/t/how-to-get-boneweights-and-boneindices-of-skeletalmesh-c/417396/5 "2023-11-10T21:39:04Z")

</div>

In 4.27 and 5.0+ I use this:

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

```

Note that you will still need to map the bone indices from SkinWeightInfo to their corresponding bone index inside the SkeletalMesh’s BoneMap such as:

```auto
int32 BoneIndex = SkinWeightBuffer.GetBoneIndex(vertexindex, 0);
int32 ActualBone = LODData.RenderSections[0].BoneMap[BoneIndex];
FName BoneName = SKMesh->GetBoneName(ActualBone);

```

Each entry in the SkinWeightInfo array corresponds to a mesh vertex

---

<div class="post-metadata">

**Author:** ![MostHost\_LA](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mosthost_la/32/907035_2.png) [@MostHost\_LA](https://forums.unrealengine.com/u/MostHost_LA)\
**Post date:** [August 29, 2024, 11:10pm UTC](https://forums.unrealengine.com/t/how-to-get-boneweights-and-boneindices-of-skeletalmesh-c/417396/6 "2024-08-29T23:10:54Z")

</div>

Are you sure on the variable definitions and bond index limits?

What used to work originally is probably been increased by at least one order of magnitude since they released metahumans.

Not that limiting the index to a smaller value is incorrect. Matrer of fact it can never go out of index.

The original solution is also wrong.  
You can’t cast to int and then cast to double without loosing precision.  
In the realm of animation you need that precision.

Seems to me that the /255 part claiming its the maximum byte means that the wrong math is being used for it entierly.  
Then again, it does depend on what value is in fact store by the index.

The point is, if you divide 1.5 by 255 it isn’t the same as dividing 1 by 255.  
And that’s basically what the code above would do.

---

<div class="post-metadata">

**Author:** ![DentonJC](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DentonJC](https://forums.unrealengine.com/u/DentonJC)\
**Post date:** [January 31, 2025, 11:21pm UTC](https://forums.unrealengine.com/t/how-to-get-boneweights-and-boneindices-of-skeletalmesh-c/417396/7 "2025-01-31T23:21:58Z")

</div>

Many game engines store the skin weights as a byte for optimization and memory reasons. Its essentially a normalized float between 0-1. There is going to be almost no benefit visually to storing them in higher precision.

In the above code he is just normalizing it back to the 0-1 scale. But ya right, casting to a float would be good enough, no reason to use double.

---

<div class="post-metadata">

**Author:** ![MostHost\_LA](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mosthost_la/32/907035_2.png) [@MostHost\_LA](https://forums.unrealengine.com/u/MostHost_LA)\
**Post date:** [February 1, 2025, 2:25am UTC](https://forums.unrealengine.com/t/how-to-get-boneweights-and-boneindices-of-skeletalmesh-c/417396/8 "2025-02-01T02:25:25Z")

</div>

Your model however has a high fidelity and DCCs usually support much higher precision for a simple float.  
The problem with unreal looking like trash comparatively to any DCC is the precision it can support (which is fairly low and gets truncated as well).

And yes, thats 100% because of optimization - but it is 2025, maybe we can actually step things up so that LOD0 on characters match DCCs a bit closer…

Just not the way its shown above… the problem starts with the import of the data from FBX to engine asset…

---

<div class="post-metadata">

**Author:** ![DentonJC](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DentonJC](https://forums.unrealengine.com/u/DentonJC)\
**Post date:** [February 18, 2025, 12:18am UTC](https://forums.unrealengine.com/t/how-to-get-boneweights-and-boneindices-of-skeletalmesh-c/417396/9 "2025-02-18T00:18:14Z")

</div>

Nobody would be able to tell the difference visually.

Its not really worth the cost of doubling memory usage for such a minor thing. Remember that DCC is not real time, game engines are though.

---

<div class="post-metadata">

**Author:** ![MostHost\_LA](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mosthost_la/32/907035_2.png) [@MostHost\_LA](https://forums.unrealengine.com/u/MostHost_LA)\
**Post date:** [February 18, 2025, 5:19am UTC](https://forums.unrealengine.com/t/how-to-get-boneweights-and-boneindices-of-skeletalmesh-c/417396/10 "2025-02-18T05:19:43Z")

</div>

Everyone is able to see the difference.  
If you haven’t, you are either blind or not looking.

Either way, your post in no way helps or furthers the conversation, if anything, it hinders it.

Its not “good enough”, particularly when the engine literally wastes rendering overhead on BS like nanite. The extra cost is _much_ better spent in doing skeletal meshes appropriately.

One can always build from source, and also force Double Quaternions - but then, you made it clear you aren’t even aware of the base issue or are unable to see it in the first place - which does beg the question as to wtf you are posting in this thread for, but I digress…
