From c281ae4227896225b84db0a0a751e87174405423 Mon Sep 17 00:00:00 2001 From: Adam Crockett Date: Thu, 4 Apr 2024 21:47:18 +0100 Subject: [PATCH 1/2] Sets the root bone size to a size in proportion to the exported model --- mixamoroot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mixamoroot.py b/mixamoroot.py index 285001d..db53d78 100644 --- a/mixamoroot.py +++ b/mixamoroot.py @@ -293,7 +293,7 @@ def add_root_bone(root_bone_name="Root", hip_bone_name="mixamorig:Hips", remove_ bpy.ops.object.mode_set(mode='EDIT') root_bone = armature.data.edit_bones.new(name_prefix + root_bone_name) - root_bone.tail.y = 30 + root_bone.tail.y = 0.3 armature.data.edit_bones[hip_bone_name].parent = armature.data.edit_bones[name_prefix + root_bone_name] bpy.ops.object.mode_set(mode='OBJECT') From 0ee3436b1a005e417d0a88bfaaaecdccd350c798 Mon Sep 17 00:00:00 2001 From: Adam Crockett Date: Thu, 4 Apr 2024 22:10:44 +0100 Subject: [PATCH 2/2] After thinking some more, the root bones size should be proportionate the the original models height --- mixamoroot.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mixamoroot.py b/mixamoroot.py index db53d78..01e0651 100644 --- a/mixamoroot.py +++ b/mixamoroot.py @@ -292,8 +292,15 @@ def add_root_bone(root_bone_name="Root", hip_bone_name="mixamorig:Hips", remove_ armature = bpy.context.selected_objects[0] bpy.ops.object.mode_set(mode='EDIT') + # Get the bounding box dimensions + bounding_box = armature.bound_box + fixed_ratio = 0.3 + armature_height = bounding_box[6][2] - bounding_box[0][2] # Index 2 corresponds to the z-dimension + root_bone_length = armature_height * fixed_ratio + root_bone = armature.data.edit_bones.new(name_prefix + root_bone_name) - root_bone.tail.y = 0.3 + root_bone.tail.y = root_bone_length + armature.data.edit_bones[hip_bone_name].parent = armature.data.edit_bones[name_prefix + root_bone_name] bpy.ops.object.mode_set(mode='OBJECT')