[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39178] branches/soc-2011-pepper/release/ scripts: Created property systems for multiple retargets on a single armature, for this type of use and animation stitching.
Benjy Cook
benjycook at hotmail.com
Mon Aug 8 13:09:56 CEST 2011
Revision: 39178
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39178
Author: benjycook
Date: 2011-08-08 11:09:56 +0000 (Mon, 08 Aug 2011)
Log Message:
-----------
Created property systems for multiple retargets on a single armature, for this type of use and animation stitching. Also contains some placeholder UI and code for animation stitching.
Modified Paths:
--------------
branches/soc-2011-pepper/release/scripts/modules/mocap_constraints.py
branches/soc-2011-pepper/release/scripts/modules/mocap_tools.py
branches/soc-2011-pepper/release/scripts/modules/retarget.py
branches/soc-2011-pepper/release/scripts/startup/ui_mocap.py
Modified: branches/soc-2011-pepper/release/scripts/modules/mocap_constraints.py
===================================================================
--- branches/soc-2011-pepper/release/scripts/modules/mocap_constraints.py 2011-08-08 09:09:44 UTC (rev 39177)
+++ branches/soc-2011-pepper/release/scripts/modules/mocap_constraints.py 2011-08-08 11:09:56 UTC (rev 39178)
@@ -59,7 +59,7 @@
c_type = "LIMIT_LOCATION"
#create and store the new constraint within m_constraint
real_constraint = cons_obj.constraints.new(c_type)
- real_constraint.name = "Mocap fix " + str(len(cons_obj.constraints))
+ real_constraint.name = "Auto fixes " + str(len(cons_obj.constraints))
m_constraint.real_constraint_bone = consObjToBone(cons_obj)
m_constraint.real_constraint = real_constraint.name
#set the rest of the constraint properties
@@ -364,7 +364,8 @@
simpleBake += [end_bone]
for bone in selectedBones:
bone.bone.select = True
- constraintTrack = obj.animation_data.nla_tracks["Mocap fixes"]
+ tracks = [track for track in obj.data.mocapNLATracks if track.active][0]
+ constraintTrack = obj.animation_data.nla_tracks[tracks.auto_fix_track]
constraintStrip = constraintTrack.strips[0]
constraintStrip.action_frame_start = s_frame
constraintStrip.action_frame_end = e_frame
@@ -403,7 +404,8 @@
obj = context.active_object
bones = obj.pose.bones
scene = bpy.context.scene
- constraintTrack = obj.animation_data.nla_tracks["Mocap fixes"]
+ tracks = obj.data.mocapNLATracks[obj.animation_data.action]
+ constraintTrack = obj.animation_data.nla_tracks[tracks.auto_fix_track]
constraintStrip = constraintTrack.strips[0]
action = constraintStrip.action
# delete the fcurves on the strip
Modified: branches/soc-2011-pepper/release/scripts/modules/mocap_tools.py
===================================================================
--- branches/soc-2011-pepper/release/scripts/modules/mocap_tools.py 2011-08-08 09:09:44 UTC (rev 39177)
+++ branches/soc-2011-pepper/release/scripts/modules/mocap_tools.py 2011-08-08 11:09:56 UTC (rev 39178)
@@ -757,3 +757,11 @@
eval_time_fcurve.keyframe_points.insert(frame=t, value=parameterization[t])
y_fcurve.mute = True
print("finished path editing")
+
+
+def anim_stitch(context, enduser_obj):
+ stitch_settings = enduser_obj.data.stitch_settings
+ action_1 = stitch_settings.first_action
+ action_2 = stitch_settings.second_action
+ TrackNamesA = enduser_obj.data.mocapNLATracks[action_1]
+ TrackNamesB = enduser_obj.data.mocapNLATracks[action_2]
Modified: branches/soc-2011-pepper/release/scripts/modules/retarget.py
===================================================================
--- branches/soc-2011-pepper/release/scripts/modules/retarget.py 2011-08-08 09:09:44 UTC (rev 39177)
+++ branches/soc-2011-pepper/release/scripts/modules/retarget.py 2011-08-08 11:09:56 UTC (rev 39178)
@@ -272,21 +272,31 @@
if endV.length != 0:
linearAvg.append(hipV.length / endV.length)
- bpy.ops.object.add()
- stride_bone = bpy.context.active_object
- stride_bone.name = "stride_bone"
-
+ action_name = performer_obj.animation_data.action.name
+ #if you have a parent, and that parent is a previously created stride bone
+ if enduser_obj.parent:
+ stride_action = bpy.data.actions.new("Stride Bone " + action_name)
+ stride_bone = enduser_obj.parent
+ stride_bone.animation_data.action = stride_action
+ else:
+ bpy.ops.object.add()
+ stride_bone = bpy.context.active_object
+ stride_bone.name = "stride_bone"
+ print(stride_bone)
+ stride_bone.location = Vector((0, 0, 0))
if linearAvg:
#determine the average change in scale needed
avg = sum(linearAvg) / len(linearAvg)
scene.frame_set(s_frame)
- initialPos = (tailLoc(perf_bones[perfRoot]) / avg)
+ initialPos = (tailLoc(perf_bones[perfRoot]) / avg) + stride_bone.location
for t in range(s_frame, e_frame):
scene.frame_set(t)
#calculate the new position, by dividing by the found ratio between performer and enduser
newTranslation = (tailLoc(perf_bones[perfRoot]) / avg)
stride_bone.location = enduser_obj_mat * (newTranslation - initialPos)
stride_bone.keyframe_insert("location")
+ stride_bone.animation_data.action.name = ("Stride Bone " + action_name)
+
return stride_bone
@@ -299,7 +309,7 @@
# set constraint target to corresponding empty if targetless,
# if not, keyframe current target to corresponding empty
perf_bone = pose_bone.bone.reverseMap[-1].name
- orgLocTrg = originalLocationTarget(pose_bone)
+ orgLocTrg = originalLocationTarget(pose_bone, enduser_obj)
if not ik_constraint.target:
ik_constraint.target = orgLocTrg
target = orgLocTrg
@@ -322,6 +332,7 @@
target.location = final_loc
target.keyframe_insert("location")
ik_constraint.mute = False
+ scene.frame_set(s_frame)
def turnOffIK(enduser_obj):
@@ -358,44 +369,59 @@
empty = bpy.data.objects[pose_bone.name + "Org"]
empty.parent = stride_bone
performer_obj.matrix_world = perf_obj_mat
+ enduser_obj.parent = stride_bone
enduser_obj.matrix_world = enduser_obj_mat
- enduser_obj.parent = stride_bone
#create (or return if exists) the related IK empty to the bone
-def originalLocationTarget(end_bone):
+def originalLocationTarget(end_bone, enduser_obj):
if not end_bone.name + "Org" in bpy.data.objects:
bpy.ops.object.add()
empty = bpy.context.active_object
empty.name = end_bone.name + "Org"
empty.empty_draw_size = 0.1
- #empty.parent = enduser_obj
+ empty.parent = enduser_obj
empty = bpy.data.objects[end_bone.name + "Org"]
return empty
#create the specified NLA setup for base animation, constraints and tweak layer.
-def NLASystemInitialize(enduser_obj, s_frame):
+def NLASystemInitialize(enduser_obj, s_frame, name):
anim_data = enduser_obj.animation_data
+ if not name in enduser_obj.data.mocapNLATracks:
+ NLATracks = enduser_obj.data.mocapNLATracks.add()
+ NLATracks.name = name
+ else:
+ NLATracks = enduser_obj.data.mocapNLATracks[name]
+ for track in enduser_obj.data.mocapNLATracks:
+ track.active = False
mocapAction = anim_data.action
- mocapAction.name = "Base Mocap"
+ mocapAction.name = "Base " + name
anim_data.use_nla = True
+ for track in anim_data.nla_tracks:
+ anim_data.nla_tracks.remove(track)
mocapTrack = anim_data.nla_tracks.new()
- mocapTrack.name = "Base Mocap Track"
- mocapStrip = mocapTrack.strips.new("Base Mocap", s_frame, mocapAction)
+ mocapTrack.name = "Base " + name
+ NLATracks.base_track = mocapTrack.name
+ mocapStrip = mocapTrack.strips.new("Base " + name, s_frame, mocapAction)
constraintTrack = anim_data.nla_tracks.new()
- constraintTrack.name = "Mocap fixes"
- constraintAction = bpy.data.actions.new("Mocap fixes")
- constraintStrip = constraintTrack.strips.new("Mocap fixes", s_frame, constraintAction)
+ constraintTrack.name = "Auto fixes " + name
+ NLATracks.auto_fix_track = constraintTrack.name
+ constraintAction = bpy.data.actions.new("Auto fixes " + name)
+ constraintStrip = constraintTrack.strips.new("Auto fixes " + name, 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)
+ userTrack.name = "Manual fixes " + name
+ NLATracks.manual_fix_track = userTrack.name
+ if enduser_obj.parent.animation_data:
+ NLATracks.stride_action = enduser_obj.parent.animation_data.action.name
+ userAction = bpy.data.actions.new("Manual fixes " + name)
+ userStrip = userTrack.strips.new("Manual fixes " + name, 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
+ NLATracks.active = True
+ #anim_data.action = constraintAction
anim_data.action_extrapolation = "NOTHING"
@@ -419,7 +445,7 @@
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_name(name=inter_obj.name, extend=False)
bpy.ops.object.delete()
- NLASystemInitialize(enduser_obj, s_frame)
+ NLASystemInitialize(enduser_obj, s_frame, performer_obj.animation_data.action.name)
print("retargeting done!")
if __name__ == "__main__":
Modified: branches/soc-2011-pepper/release/scripts/startup/ui_mocap.py
===================================================================
--- branches/soc-2011-pepper/release/scripts/startup/ui_mocap.py 2011-08-08 09:09:44 UTC (rev 39177)
+++ branches/soc-2011-pepper/release/scripts/startup/ui_mocap.py 2011-08-08 11:09:56 UTC (rev 39178)
@@ -110,6 +110,35 @@
bpy.types.Armature.mocap_constraints = bpy.props.CollectionProperty(type=MocapConstraint)
+
+class AnimationStitchSettings(bpy.types.PropertyGroup):
+ first_action = bpy.props.StringProperty(name="Action 1",
+ description="First action in stitch")
+ second_action = bpy.props.StringProperty(name="Action 2",
+ description="Second action in stitch")
+ blend_frame = bpy.props.IntProperty(name="Stitch frame",
+ description="Frame to locate stitch on")
+ blend_amount = bpy.props.IntProperty(name="Blend amount",
+ description="Size of blending transitiion, on both sides of the stitch",
+ default=10)
+
+bpy.utils.register_class(AnimationStitchSettings)
+
+
+class MocapNLATracks(bpy.types.PropertyGroup):
+ name = bpy.props.StringProperty()
+ active = bpy.props.BoolProperty()
+ base_track = bpy.props.StringProperty()
+ auto_fix_track = bpy.props.StringProperty()
+ manual_fix_track = bpy.props.StringProperty()
+ stride_action = bpy.props.StringProperty()
+
+bpy.utils.register_class(MocapNLATracks)
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list