Skip to content

Commit 4fa7d95

Browse files
author
Roberto De Ioris
authored
Update FixingMixamoRootMotionWithPython.md
1 parent 043c129 commit 4fa7d95

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

tutorials/FixingMixamoRootMotionWithPython.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,51 @@ Double click on the skeleton to open its editor and you should see the new bone
144144

145145
## Step 3: fixing skeletal mesh bone influences
146146

147+
In the last screenshot we have seen a broken deformation. What happened to our vampire ?
148+
149+
Each skeletal mesh LOD has a series of 'soft skin vertices' mapped to it. Each vertex data structure contains the classic position, tangents (included normals) and uvs values, as well as 2 additional fields for storing up to 8 'bone influences'. A bone influence is composed by a bone index (note: not the same index of the skeleton, see below) and a bone weight. Weight define how much the bone deforms the vertex.
150+
151+
Changing the bone hierarchy (remember, we have added the 'root' bone), resulted in different bone indices, so each vertex is potentially pointing to the wrong bone.
152+
153+
In addition to this, soft skin vertices do not use the skeleton hierarchy, but point to an additional map (the BoneMap) that contains a simple array of the used bones.
154+
155+
A BoneMap looks like this:
156+
157+
```python
158+
[17, 22, 26, 30]
159+
```
160+
161+
so index 0 means bone 17, index 1 means bone 22 and so on. This additional mapping is for performance reasons, but we need to deal with it.
162+
163+
To retrieve the BoneMap of a skeletal mesh you can use:
164+
165+
```python
166+
bone_map = mesh.skeletal_mesh_get_bone_map()
167+
```
168+
169+
and to assign a new one:
170+
171+
```python
172+
mesh.skeletal_mesh_get_bone_map([17, 22, 26, 30, ...])
173+
```
174+
175+
In the same way you can retrieve soft skin vertices:
176+
177+
```python
178+
vertices = mesh.skeletal_mesh_get_soft_vertices()
179+
```
180+
181+
each vertex is a FSoftSkinVertex class with the following fields:
182+
183+
* position (the vertex position vector)
184+
* color (the vertex color, can be used by materials)
185+
* tangent_x, tangent_y, tangent_z (tangents/normal)
186+
* uvs (texture coordinates)
187+
* influence_bones (tuple with up to 8 BoneMap indices)
188+
* influence_weights (bone weight as integer, 0 to 255)
189+
190+
Our objective is to update the influence_bones tuple for each vertex and to regenerate the BoneMap:
191+
147192
```python
148193

149194
class RootMotionFixer:

0 commit comments

Comments
 (0)