[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39274] branches/soc-2011-pepper/release/ scripts: Mostly finished implementation of animation stitching, with lock bone functionality, allowing the user to choose a bone that maintains its position during the blend

Benjy Cook benjycook at hotmail.com
Wed Aug 10 22:37:58 CEST 2011


Revision: 39274
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39274
Author:   benjycook
Date:     2011-08-10 20:37:57 +0000 (Wed, 10 Aug 2011)
Log Message:
-----------
Mostly finished implementation of animation stitching, with lock bone functionality, allowing the user to choose a bone that maintains its position during the blend

Modified Paths:
--------------
    branches/soc-2011-pepper/release/scripts/modules/mocap_tools.py
    branches/soc-2011-pepper/release/scripts/startup/ui_mocap.py

Modified: branches/soc-2011-pepper/release/scripts/modules/mocap_tools.py
===================================================================
--- branches/soc-2011-pepper/release/scripts/modules/mocap_tools.py	2011-08-10 20:36:52 UTC (rev 39273)
+++ branches/soc-2011-pepper/release/scripts/modules/mocap_tools.py	2011-08-10 20:37:57 UTC (rev 39274)
@@ -760,12 +760,13 @@
 
 
 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 @@
     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 @@
             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)

Modified: branches/soc-2011-pepper/release/scripts/startup/ui_mocap.py
===================================================================
--- branches/soc-2011-pepper/release/scripts/startup/ui_mocap.py	2011-08-10 20:36:52 UTC (rev 39273)
+++ branches/soc-2011-pepper/release/scripts/startup/ui_mocap.py	2011-08-10 20:37:57 UTC (rev 39274)
@@ -121,6 +121,12 @@
     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 @@
             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")
 
 




More information about the Bf-blender-cvs mailing list