index 0602de5e5961d9a18b00fc89d1ac4de0130512f0..bec7b8aaa3e532bee3460bb265d64c89549a41ea 100644 (file)
@@ -21,6 +21,7 @@
import bpy
from mathutils import *
from math import radians, acos
+import cProfile

def hasIKConstraint(pose_bone):
@@ -44,6 +45,7 @@ def createDictionary(perf_arm, end_arm):
end_bone = end_arm.bones[perf_bone.map]
newMap = end_bone.reverseMap.add()
newMap.name = perf_bone.name
+            end_bone.foot = perf_bone.foot

#root is the root of the enduser
root = end_arm.bones[0].name
@@ -142,6 +144,8 @@ def createIntermediate(performer_obj, enduser_obj, root, s_frame, e_frame, scene
inter_bone.bone.use_inherit_rotation = True

for t in range(s_frame, e_frame):
+        if (t - s_frame) % 10 == 0:
+            print("First pass: retargeting frame {0}/{1}".format(t, e_frame - s_frame))
scene.frame_set(t)
for bone in inter_bones:
retargetPerfToInter(bone)
@@ -199,6 +203,8 @@ def retargetEnduser(inter_obj, enduser_obj, root, s_frame, e_frame, scene):
bakeTransform(bone)

for t in range(s_frame, e_frame):
+        if (t - s_frame) % 10 == 0:
+            print("Second pass: retargeting frame {0}/{1}".format(t, e_frame - s_frame))
scene.frame_set(t)
end_bone = end_bones[root]
end_bone.location = Vector((0, 0, 0))
@@ -378,10 +384,16 @@ def NLASystemInitialize(enduser_obj, s_frame):
mocapTrack.name = "Base Mocap Track"
mocapStrip = mocapTrack.strips.new("Base Mocap", s_frame, mocapAction)
constraintTrack = anim_data.nla_tracks.new()
-    constraintTrack.name = "Mocap constraints"
-    constraintAction = bpy.data.actions.new("Mocap constraints")
-    constraintStrip = constraintTrack.strips.new("Mocap constraints", s_frame, constraintAction)
+    constraintTrack.name = "Mocap fixes"
+    constraintAction = bpy.data.actions.new("Mocap fixes")
+    constraintStrip = constraintTrack.strips.new("Mocap fixes", s_frame, constraintAction)
constraintStrip.extrapolation = "NOTHING"
+    userTrack = anim_data.nla_tracks.new()
+    userTrack.name = "Mocap manual fix"
+    userAction = bpy.data.actions.new("Mocap manual fix")
+    userStrip = userTrack.strips.new("Mocap manual fix", s_frame, userAction)
+    userStrip.extrapolation = "HOLD"
+    #userStrip.blend_type = "MULITPLY" - doesn't work due to work, will be activated soon
anim_data.nla_tracks.active = constraintTrack
anim_data.action = constraintAction
anim_data.action_extrapolation = "NOTHING"
@@ -396,11 +408,11 @@ def totalRetarget(performer_obj, enduser_obj, scene, s_frame, e_frame):
print("cleaning stuff up")
perf_obj_mat, enduser_obj_mat = cleanAndStoreObjMat(performer_obj, enduser_obj)
turnOffIK(enduser_obj)
-    print("creating intermediate armature")
+    print("Creating intermediate armature (for first pass)")
inter_obj = createIntermediate(performer_obj, enduser_obj, root, s_frame, e_frame, scene)
-    print("retargeting from intermediate to end user")
+    print("First pass: retargeting from intermediate to end user")
retargetEnduser(inter_obj, enduser_obj, root, s_frame, e_frame, scene)
-    print("retargeting root translation and clean up")
+    print("Second pass: retargeting root translation and clean up")
stride_bone = copyTranslation(performer_obj, enduser_obj, feetBones, root, s_frame, e_frame, scene, enduser_obj_mat)
IKRetarget(performer_obj, enduser_obj, s_frame, e_frame, scene)
restoreObjMat(performer_obj, enduser_obj, perf_obj_mat, enduser_obj_mat, stride_bone)
@@ -410,6 +422,5 @@ def totalRetarget(performer_obj, enduser_obj, scene, s_frame, e_frame):
NLASystemInitialize(enduser_obj, s_frame)
print("retargeting done!")

-
if __name__ == "__main__":
totalRetarget()