diff options
author | Benjy Cook <benjycook@hotmail.com> | 2011-08-11 00:37:57 +0400 |
---|---|---|
committer | Benjy Cook <benjycook@hotmail.com> | 2011-08-11 00:37:57 +0400 |
commit | fba1f50d0af22199f8d73aa6eb5e95e75c3f3d6a (patch) | |
tree | 1ea5c9ef0b7dece5f79470554348c838ec33f79e /release | |
parent | 1eaeaf8cd8ea7ee923b6aeb26b031368ff6d679a (diff) |
Mostly finished implementation of animation stitching, with lock bone functionality, allowing the user to choose a bone that maintains its position during the blend
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/modules/mocap_tools.py | 22 | ||||
-rw-r--r-- | release/scripts/startup/ui_mocap.py | 8 |
2 files changed, 22 insertions, 8 deletions
diff --git a/release/scripts/modules/mocap_tools.py b/release/scripts/modules/mocap_tools.py index 0e296faf9f8..b490d571dd8 100644 --- a/release/scripts/modules/mocap_tools.py +++ b/release/scripts/modules/mocap_tools.py @@ -760,12 +760,13 @@ def path_editing(context, stride_obj, path): def anim_stitch(context, enduser_obj): - selected_bone = enduser_obj.pose.bones["Toes.L"] - second_offset = 5 - stitch_settings = enduser_obj.data.stitch_settings action_1 = stitch_settings.first_action action_2 = stitch_settings.second_action + if stitch_settings.stick_bone!="": + selected_bone = enduser_obj.pose.bones[stitch_settings.stick_bone] + else: + selected_bone = enduser_obj.pose.bones[0] scene = context.scene TrackNamesA = enduser_obj.data.mocapNLATracks[action_1] TrackNamesB = enduser_obj.data.mocapNLATracks[action_2] @@ -777,18 +778,21 @@ def anim_stitch(context, enduser_obj): mocapTrack.name = TrackNamesB.base_track mocapStrip = mocapTrack.strips.new(TrackNamesB.base_track, stitch_settings.blend_frame, mocapAction) mocapStrip.extrapolation = "HOLD_FORWARD" - mocapStrip.action_frame_start+=second_offset - mocapStrip.action_frame_end+=second_offset + mocapStrip.blend_in = stitch_settings.blend_amount + mocapStrip.action_frame_start+=stitch_settings.second_offset + mocapStrip.action_frame_end+=stitch_settings.second_offset constraintTrack = anim_data.nla_tracks.new() constraintTrack.name = TrackNamesB.auto_fix_track constraintAction = bpy.data.actions[TrackNamesB.auto_fix_track] constraintStrip = constraintTrack.strips.new(TrackNamesB.auto_fix_track, stitch_settings.blend_frame, constraintAction) constraintStrip.extrapolation = "HOLD_FORWARD" + constraintStrip.blend_in = stitch_settings.blend_amount userTrack = anim_data.nla_tracks.new() userTrack.name = TrackNamesB.manual_fix_track userAction = bpy.data.actions[TrackNamesB.manual_fix_track] userStrip = userTrack.strips.new(TrackNamesB.manual_fix_track, stitch_settings.blend_frame, userAction) userStrip.extrapolation = "HOLD_FORWARD" + userStrip.blend_in = stitch_settings.blend_amount #stride bone if enduser_obj.parent: if enduser_obj.parent.name == "stride_bone": @@ -805,14 +809,16 @@ def anim_stitch(context, enduser_obj): actionBTrack = stride_anim_data.nla_tracks.new() actionBTrack.name = TrackNamesB.stride_action actionBStrip = actionBTrack.strips.new(TrackNamesB.stride_action, stitch_settings.blend_frame, bpy.data.actions[TrackNamesB.stride_action]) + actionBStrip.action_frame_start+=stitch_settings.second_offset + actionBStrip.action_frame_end+=stitch_settings.second_offset + actionBStrip.blend_in = stitch_settings.blend_amount actionBStrip.extrapolation = "NOTHING" #we need to change the stride_bone's action to add the offset scene.frame_set(stitch_settings.blend_frame - 1) - desired_pos = selected_bone.tail * enduser_obj.matrix_world + desired_pos = (selected_bone.matrix.to_translation() * enduser_obj.matrix_world) scene.frame_set(stitch_settings.blend_frame) - actual_pos = selected_bone.tail * enduser_obj.matrix_world + actual_pos = (selected_bone.matrix.to_translation() * enduser_obj.matrix_world) offset = actual_pos - desired_pos - print(offset) for i,fcurve in enumerate([fcurve for fcurve in bpy.data.actions[TrackNamesB.stride_action].fcurves if fcurve.data_path=="location"]): print(offset[i],i,fcurve.array_index) diff --git a/release/scripts/startup/ui_mocap.py b/release/scripts/startup/ui_mocap.py index 01802893c4c..0788366547e 100644 --- a/release/scripts/startup/ui_mocap.py +++ b/release/scripts/startup/ui_mocap.py @@ -121,6 +121,12 @@ class AnimationStitchSettings(bpy.types.PropertyGroup): blend_amount = bpy.props.IntProperty(name="Blend amount", description="Size of blending transitiion, on both sides of the stitch", default=10) + second_offset = bpy.props.IntProperty(name="Second offset", + description="Frame offset for 2nd animation, where it should start", + default=10) + stick_bone = bpy.props.StringProperty(name="Stick Bone", + description="Bone to freeze during transition", + default="") bpy.utils.register_class(AnimationStitchSettings) @@ -355,6 +361,8 @@ class ExtraToolsPanel(bpy.types.Panel): layout.prop_search(settings, "second_action", enduser_arm, "mocapNLATracks") layout.prop(settings, "blend_frame") layout.prop(settings, "blend_amount") + layout.prop(settings, "second_offset") + layout.prop_search(settings, "stick_bone", context.active_object.pose, "bones") layout.operator('mocap.animstitch', text="Stitch Animations") |