Skip to content

Commit 8ba1b7f

Browse files
author
Roberto De Ioris
authored
Update FixingMixamoRootMotionWithPython.md
1 parent c603afd commit 8ba1b7f

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tutorials/FixingMixamoRootMotionWithPython.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,3 +420,44 @@ Always pay attention when choosing asset names (expecially if you are automatica
420420
Remember that you can open the asset-related editor by simply calling ```ue.open_editor_for_asset(uobject)```
421421

422422
Note that calling ```ue.add_asset_view_context_menu_extension(callable)``` will generate a new context menu every time. There is currently no support for cleaning the context menu (well, except for restarting the editor :P)
423+
424+
## Update 20170927 by issue 228
425+
426+
https://github.com/20tab/UnrealEnginePython/issues/228
427+
428+
Marat Yakupov reported in issue 228 a problem with the mixamo ybot model. The problem is caused by the multiple sections available in the mesh. The mixamo.py has been updated to support multiple sections:
429+
430+
```python
431+
def fix_bones_influences(self, mesh, old_skeleton):
432+
required_bones = []
433+
# iterate sections
434+
for section in range(0, mesh.skeletal_mesh_sections_num()):
435+
vertices = mesh.skeletal_mesh_get_soft_vertices(0, section)
436+
ue.log_warning(len(vertices))
437+
new_vertices = []
438+
old_bone_map = mesh.skeletal_mesh_get_bone_map(0, section)
439+
new_bone_map = []
440+
441+
for vertex in vertices:
442+
bone_ids = list(vertex.influence_bones)
443+
for index, bone_id in enumerate(bone_ids):
444+
if vertex.influence_weights[index] > 0:
445+
bone_ids[index] = self.get_updated_bone_index(old_skeleton, mesh.Skeleton, old_bone_map, new_bone_map, bone_id)
446+
if new_bone_map[bone_ids[index]] not in required_bones:
447+
required_bones.append(new_bone_map[bone_ids[index]])
448+
vertex.influence_bones = bone_ids
449+
new_vertices.append(vertex)
450+
451+
# assign new vertices
452+
mesh.skeletal_mesh_set_soft_vertices(new_vertices, 0, section)
453+
# add the new bone mapping
454+
mesh.skeletal_mesh_set_bone_map(new_bone_map, 0, section)
455+
456+
# specify which bones are active and required (ensure root is added to required bones)
457+
mesh.skeletal_mesh_set_active_bone_indices(required_bones)
458+
if 0 not in required_bones:
459+
required_bones += [0]
460+
mesh.skeletal_mesh_set_required_bones(required_bones)
461+
```
462+
463+
As you can see we still assume a single LOD (the 0 before the section is always the lod)

0 commit comments

Comments
 (0)