diff options
author | Benjy Cook <benjycook@hotmail.com> | 2011-07-18 22:44:54 +0400 |
---|---|---|
committer | Benjy Cook <benjycook@hotmail.com> | 2011-07-18 22:44:54 +0400 |
commit | 0dcc7d05abe9d1557675c63e07f8b5ff3cb49ec3 (patch) | |
tree | d30ac4af2fbe7e598ae381f2d0c98372096e184d /release/scripts/modules | |
parent | a6e2fba994f0ad58851a49ae123fb256b7cbf871 (diff) |
Bugfixing for retargeting - unconnected bones now retarget alot better. Also some placeholder code for a fix scale operator
Diffstat (limited to 'release/scripts/modules')
-rw-r--r-- | release/scripts/modules/mocap_tools.py | 10 | ||||
-rw-r--r-- | release/scripts/modules/retarget.py | 23 |
2 files changed, 29 insertions, 4 deletions
diff --git a/release/scripts/modules/mocap_tools.py b/release/scripts/modules/mocap_tools.py index 33e9105201c..1ce76dfbe6f 100644 --- a/release/scripts/modules/mocap_tools.py +++ b/release/scripts/modules/mocap_tools.py @@ -567,3 +567,13 @@ def rotate_fix_armature(arm_data): for bone in connectedBones: arm_data.edit_bones[bone].use_connect = True bpy.ops.object.mode_set(mode='OBJECT', toggle=False) + + +def scale_fix_armature(performer_obj, enduser_obj): + perf_bones = performer_obj.data.bones + end_bones = enduser_obj.data.bones + + #perf_avg = performer_obj.dimensions + #end_avg = enduser_obj.dimensions + #print(perf_avg, end_avg) + #performer_obj.scale /= (perf_avg / end_avg) diff --git a/release/scripts/modules/retarget.py b/release/scripts/modules/retarget.py index 0b694453865..e8c9f3e25aa 100644 --- a/release/scripts/modules/retarget.py +++ b/release/scripts/modules/retarget.py @@ -105,7 +105,12 @@ def createIntermediate(performer_obj, enduser_obj, root, s_frame, e_frame, scene else: perf_bone = performer_bones[perf_bone_name[0].name] inter_bone.matrix_basis = singleBoneRetarget(inter_bone, perf_bone) - + elif inter_bone.parent: + if "Temp" in inter_bone.parent.name: + inter_bone.parent.bone.use_inherit_rotation = True + inter_bone.bone.use_inherit_rotation = True + else: + inter_bone.bone.use_inherit_rotation = True inter_bone.keyframe_insert("rotation_quaternion") for child in inter_bone.children: retargetPerfToInter(child) @@ -119,12 +124,14 @@ def createIntermediate(performer_obj, enduser_obj, root, s_frame, e_frame, scene bpy.ops.object.mode_set(mode='EDIT') #add some temporary connecting bones in case end user bones are not connected to their parents for bone in inter_obj.data.edit_bones: - if not bone.use_connect and bone.parent: + if not bone.use_connect and bone.parent and inter_obj.data.bones[bone.name].reverseMap: newBone = inter_obj.data.edit_bones.new("Temp") - newBone.head = bone.parent.head + newBone.head = bone.parent.tail newBone.tail = bone.head newBone.parent = bone.parent bone.parent = newBone + bone.use_connect = True + newBone.use_connect = True #resets roll bpy.ops.armature.calculate_roll(type='Z') bpy.ops.object.mode_set(mode="OBJECT") @@ -165,7 +172,7 @@ def retargetEnduser(inter_obj, enduser_obj, root, s_frame, e_frame, scene): if trg_bone.parent and trg_bone.bone.use_inherit_rotation: srcParent = src_bone.parent - if not trg_bone.bone.use_connect: + if "Temp" in srcParent.name: srcParent = srcParent.parent parent_mat = srcParent.matrix parent_rest = trg_bone.parent.bone.matrix_local @@ -187,6 +194,8 @@ def retargetEnduser(inter_obj, enduser_obj, root, s_frame, e_frame, scene): end_bone.keyframe_insert("rotation_axis_angle") else: end_bone.keyframe_insert("rotation_euler") + if not end_bone.bone.use_connect: + end_bone.keyframe_insert("location") for bone in end_bone.children: bakeTransform(bone) @@ -384,11 +393,16 @@ def NLASystemInitialize(enduser_obj, s_frame): def totalRetarget(performer_obj, enduser_obj, scene, s_frame, e_frame): perf_arm = performer_obj.data end_arm = enduser_obj.data + print("creating Dictionary") feetBones, root = createDictionary(perf_arm, end_arm) + print("cleaning stuff up") perf_obj_mat, enduser_obj_mat = cleanAndStoreObjMat(performer_obj, enduser_obj) turnOffIK(enduser_obj) + print("creating intermediate armature") inter_obj = createIntermediate(performer_obj, enduser_obj, root, s_frame, e_frame, scene) + print("retargeting from intermediate to end user") retargetEnduser(inter_obj, enduser_obj, root, s_frame, e_frame, scene) + print("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) @@ -396,6 +410,7 @@ def totalRetarget(performer_obj, enduser_obj, scene, s_frame, e_frame): bpy.ops.object.select_name(name=inter_obj.name, extend=False) bpy.ops.object.delete() NLASystemInitialize(enduser_obj, s_frame) + print("retargeting done!") if __name__ == "__main__": |