diff --git a/mixamoroot.py b/mixamoroot.py
index 285001d..6d3faba 100644
--- a/mixamoroot.py
+++ b/mixamoroot.py
@@ -3,20 +3,16 @@
'''
Copyright (C) 2022 Richard Perry
Copyright (C) Average Godot Enjoyer (Johngoss725)
-
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
-
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
You should have received a copy of the GNU General Public License
along with this program. If not, see .
-
Note that Johngoss725's original contributions were published under a
Creative Commons 1.0 Universal License (CC0-1.0) located at
.
@@ -107,12 +103,37 @@ def copyHips(root_bone_name="Root", hip_bone_name="mixamorig:Hips", name_prefix=
for i in myFcurves:
hip_bone_fcvurve = 'pose.bones["'+hip_bone_name+'"].location'
if str(i.data_path)==hip_bone_fcvurve:
- myFcurves.remove(i)
+ if i.array_index != 1:
+ myFcurves.remove(i)
bpy.ops.pose.select_all(action='DESELECT')
bpy.context.object.pose.bones[name_prefix + root_bone_name].bone.select = True
bpy.ops.graph.paste()
-
+
+ # Get the animation data and action
+ anim_data = bpy.context.object.animation_data
+ action = anim_data.action if anim_data else None
+
+ # Get the fcurves for the root bone's location
+ fcurves = [fcurve for fcurve in action.fcurves if fcurve.data_path == 'pose.bones["{}"].location'.format(name_prefix + root_bone_name) and fcurve.array_index in range(3)]
+ for i in fcurves:
+ print(i.data_path)
+
+ # Set the minimum Y value of the root bone to 0
+ z_fcurve = fcurves[1]
+ for keyframe in z_fcurve.keyframe_points:
+ if keyframe.co.y < 0:
+ keyframe.co.y = 0
+
+
+ anim_data = bpy.context.object.animation_data
+ action = anim_data.action if anim_data else None
+ hips_fcurves = [hips_fcurve for hips_fcurve in action.fcurves if hips_fcurve.data_path == 'pose.bones["{}"].location'.format(hip_bone_name) and hips_fcurve.array_index in range(3)]
+ for keyframe in hips_fcurves[0].keyframe_points:
+ if keyframe.co.y > 0:
+ keyframe.co.y = 0
+ #keyframe.co.y = keyframe.co.y / 2
+
bpy.context.area.ui_type = 'VIEW_3D'
bpy.ops.object.mode_set(mode='OBJECT')
@@ -338,18 +359,19 @@ def get_all_anims(source_dir, root_bone_name="Root", hip_bone_name="mixamorig:Hi
for file in files:
print("file: " + str(file))
- try:
- filepath = source_dir+"/"+file
- import_armature(filepath, root_bone_name, hip_bone_name, remove_prefix, name_prefix, insert_root, delete_armatures)
- imported_objects = set(bpy.context.scene.objects) - old_objs
- if delete_armatures and num_files > 1:
- deleteArmature(imported_objects)
- num_files -= 1
-
-
- except Exception as e:
- log.error("[Mixamo Root] ERROR get_all_anims raised %s when processing %s" % (str(e), file))
- return -1
+ if not file.endswith('.DS_Store') and file.endswith('.fbx'):
+ try:
+ filepath = source_dir+"/"+file
+ import_armature(filepath, root_bone_name, hip_bone_name, remove_prefix, name_prefix, insert_root, delete_armatures)
+ imported_objects = set(bpy.context.scene.objects) - old_objs
+ if delete_armatures and num_files > 1:
+ deleteArmature(imported_objects)
+ num_files -= 1
+
+
+ except Exception as e:
+ log.error("[Mixamo Root] ERROR get_all_anims raised %s when processing %s" % (str(e), file))
+ return -1
bpy.context.area.ui_type = current_context
bpy.context.scene.frame_start = 0
bpy.ops.object.mode_set(mode='OBJECT')