I have an old model that is in a crappy t-pose. I want to adjust the t-pose so it better aligns with more modern t-poses like mixamo so I can apply some other animations to it, but when I alter the t-pose, the model’s animations get wrecked. I’ve tried various solutions i’ve found and none of them really seem to work. I’m a programmer, not an artist so I figured I’d go at it with python, and I got pretty far but I just don’t know what to do next. The idea is to loop every bone and keyframe and adjust the rotation by the inverted t-pose rotation. Then when I actually apply my t-pose as the new rest position I expect all the bones will offset and the animation will be correct again. Can anyone help with what to do next?
import bpy
# Get the armature object
armature = bpy.data.objects["MilkShape3D Skeleton"]
a = bpy.context.object.animation_data.action;
print(a)
# Loop through all the bones in the armature
for bone in armature.pose.bones:
print(bone)
data_path = 'pose.bones["%s"].rotation_quaternion'%(bone.name)
rotOffsetW = 1 - bone.rotation_quaternion[0]
rotOffsetX = -1 * bone.rotation_quaternion[1]
rotOffsetY = -1 * bone.rotation_quaternion[2]
rotOffsetZ = -1 * bone.rotation_quaternion[3]
print ('W: ' + str(bone.rotation_quaternion[0]) + ', ' + str(rotOffsetW))
print ('X: ' + str(bone.rotation_quaternion[1]) + ', ' + str(rotOffsetX))
print ('Y: ' + str(bone.rotation_quaternion[2]) + ', ' + str(rotOffsetY))
print ('Z: ' + str(bone.rotation_quaternion[3]) + ', ' + str(rotOffsetZ))
for fc in a.fcurves:
if fc.data_path == data_path:
for p in fc.keyframe_points:
print(fc.data_path + ', ' + str(p.location))
# TODO what do I do here to adjust the roation?