Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucio Rossi <lucio.rossi75@gmail.com>2017-07-24 19:14:16 +0300
committerLucio Rossi <lucio.rossi75@gmail.com>2017-07-24 19:14:30 +0300
commit33b0e2e9025965133656dd85506bbef62ca3183d (patch)
tree52f2368a79623272cadf64a9c1ca3ac209176231 /rigify/ui.py
parent49230a4c122013bf851ab37b029e7d4f624d68ad (diff)
Rigify 0.5: new features, Animation Tools and Quat/Euler converter
small fixes & UI improvements
Diffstat (limited to 'rigify/ui.py')
-rw-r--r--rigify/ui.py555
1 files changed, 536 insertions, 19 deletions
diff --git a/rigify/ui.py b/rigify/ui.py
index b35bda77..5850e23e 100644
--- a/rigify/ui.py
+++ b/rigify/ui.py
@@ -26,8 +26,12 @@ from .utils import get_rig_type, MetarigError
from .utils import write_metarig, write_widget
from .utils import unique_name
from .utils import upgradeMetarigTypes, outdated_types
+from .utils import get_keyed_frames, bones_in_frame
+from .utils import overwrite_prop_animation
+from .rigs.utils import get_limb_generated_names
from . import rig_lists
from . import generate
+from . import rot_mode
class DATA_PT_rigify_buttons(bpy.types.Panel):
@@ -38,7 +42,7 @@ class DATA_PT_rigify_buttons(bpy.types.Panel):
@classmethod
def poll(cls, context):
- return context.object.type == 'ARMATURE'
+ return context.object.type == 'ARMATURE' and context.active_object.data.get("rig_id") is None
def draw(self, context):
C = context
@@ -51,6 +55,7 @@ class DATA_PT_rigify_buttons(bpy.types.Panel):
WARNING = "Warning: Some features may change after generation"
show_warning = False
show_update_metarig = False
+ show_not_updatable = False
check_props = ['IK_follow', 'root/parent', 'FK_limb_follow', 'IK_Stretch']
@@ -63,25 +68,50 @@ class DATA_PT_rigify_buttons(bpy.types.Panel):
break
for b in obj.pose.bones:
if b.rigify_type in outdated_types.keys():
- show_update_metarig = True
- break
+ if outdated_types[b.rigify_type]:
+ show_update_metarig = True
+ else:
+ show_update_metarig = False
+ show_not_updatable = True
+ break
if show_warning:
layout.label(text=WARNING, icon='ERROR')
- layout.operator("pose.rigify_generate", text="Generate Rig", icon='POSE_HLT')
+ if show_not_updatable:
+ layout.label(text="WARNING: This metarig contains deprecated rigify rig-types and cannot be upgraded automatically.", icon='ERROR')
+ layout.label(text="If you want to use it anyway try enabling the legacy mode before generating again.")
+
+ layout.operator("pose.rigify_switch_to_legacy", text="Switch to Legacy")
+
+ enable_generate_and_advanced = not (show_not_updatable or show_update_metarig)
+
+ if show_update_metarig:
+
+ layout.label(text="This metarig contains old rig-types that can be automatically upgraded to benefit of rigify's new features.", icon='ERROR')
+ layout.label(text= "To use it as-is you need to enable legacy mode.",)
+ layout.operator("pose.rigify_upgrade_types", text="Upgrade Metarig")
+
+ row = layout.row()
+ row.operator("pose.rigify_generate", text="Generate Rig", icon='POSE_HLT')
+ row.enabled = enable_generate_and_advanced
+
if id_store.rigify_advanced_generation:
icon = 'UNLOCKED'
else:
icon = 'LOCKED'
- layout.prop(id_store, "rigify_advanced_generation", toggle=True, icon=icon)
+
+ col = layout.column()
+ col.enabled = enable_generate_and_advanced
+ row = col.row()
+ row.prop(id_store, "rigify_advanced_generation", toggle=True, icon=icon)
if id_store.rigify_advanced_generation:
- row = layout.row(align=True)
+ row = col.row(align=True)
row.prop(id_store, "rigify_generate_mode", expand=True)
- main_row = layout.row(align=True).split(percentage=0.3)
+ main_row = col.row(align=True).split(percentage=0.3)
col1 = main_row.column()
col2 = main_row.column()
col1.label(text="Rig Name")
@@ -119,16 +149,11 @@ class DATA_PT_rigify_buttons(bpy.types.Panel):
row.prop_search(id_store, "rigify_rig_ui", id_store, "rigify_rig_uis", text="", icon='TEXT')
row.enabled = (id_store.rigify_generate_mode == "overwrite")
- row = layout.row()
+ row = col.row()
row.prop(id_store, "rigify_force_widget_update")
if id_store.rigify_generate_mode == 'new':
row.enabled = False
- if show_update_metarig:
- layout.label(text="Some bones have old legacy rigify_type. Click to upgrade", icon='ERROR')
- layout.operator("pose.rigify_upgrade_types", text="Upgrade Metarig")
-
-
elif obj.mode == 'EDIT':
# Build types list
collection_name = str(id_store.rigify_collection).replace(" ", "")
@@ -165,7 +190,7 @@ class DATA_PT_rigify_layer_names(bpy.types.Panel):
@classmethod
def poll(cls, context):
- return context.object.type == 'ARMATURE'
+ return context.object.type == 'ARMATURE' and context.active_object.data.get("rig_id") is None
def draw(self, context):
layout = self.layout
@@ -500,7 +525,7 @@ class DATA_PT_rigify_bone_groups(bpy.types.Panel):
@classmethod
def poll(cls, context):
- return context.object.type == 'ARMATURE'
+ return context.object.type == 'ARMATURE' and context.active_object.data.get("rig_id") is None
def draw(self, context):
obj = context.object
@@ -546,7 +571,7 @@ class BONE_PT_rigify_buttons(bpy.types.Panel):
return False
obj = context.object
if obj:
- return obj.mode == 'POSE'
+ return obj.mode == 'POSE' and context.active_object.data.get("rig_id") is None
return False
def draw(self, context):
@@ -606,6 +631,7 @@ class BONE_PT_rigify_buttons(bpy.types.Panel):
class VIEW3D_PT_tools_rigify_dev(bpy.types.Panel):
bl_label = "Rigify Dev Tools"
bl_category = 'Tools'
+ bl_context = "armature_edit"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
@@ -623,6 +649,57 @@ class VIEW3D_PT_tools_rigify_dev(bpy.types.Panel):
r.operator("mesh.rigify_encode_mesh_widget", text="Encode Mesh Widget to Python")
+class VIEW3D_PT_rigify_animation_tools(bpy.types.Panel):
+ bl_label = "Rigify Animation Tools"
+ bl_category = 'Tools'
+ bl_context = "posemode"
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'TOOLS'
+
+ @classmethod
+ def poll(cls, context):
+ return context.object.type == 'ARMATURE' and context.active_object.data.get("rig_id") is not None
+
+ def draw(self, context):
+ obj = context.active_object
+ id_store = context.window_manager
+ if obj is not None:
+ row = self.layout.row()
+
+ if id_store.rigify_transfer_only_selected:
+ icon = 'OUTLINER_DATA_ARMATURE'
+ else:
+ icon = 'ARMATURE_DATA'
+
+ row.prop(id_store, 'rigify_transfer_only_selected', toggle=True, icon=icon)
+
+ row = self.layout.row(align=True)
+ row.operator("rigify.ik2fk", text='IK2FK Pose', icon='SNAP_ON')
+ row.operator("rigify.fk2ik", text='FK2IK Pose', icon='SNAP_ON')
+
+ row = self.layout.row(align=True)
+ row.operator("rigify.transfer_fk_to_ik", text='IK2FK Action', icon='ACTION_TWEAK')
+ row.operator("rigify.transfer_ik_to_fk", text='FK2IK Action', icon='ACTION_TWEAK')
+
+ row = self.layout.row(align=True)
+ row.operator("rigify.clear_animation", text="Clear IK Action", icon='CANCEL').type = "IK"
+ row.operator("rigify.clear_animation", text="Clear FK Action", icon='CANCEL').type = "FK"
+
+ row = self.layout.row(align=True)
+ op = row.operator("rigify.rotation_pole", icon='FORCE_HARMONIC', text='Switch to pole')
+ op.value = True
+ op.toggle = False
+ op.bake = True
+ op = row.operator("rigify.rotation_pole", icon='FORCE_MAGNETIC', text='Switch to rotation')
+ op.value = False
+ op.toggle = False
+ op.bake = True
+ row = self.layout.row(align=True)
+ row.prop(id_store, 'rigify_transfer_start_frame')
+ row.prop(id_store, 'rigify_transfer_end_frame')
+ row.operator("rigify.get_frame_range", icon='TIME', text='')
+
+
def rigify_report_exception(operator, exception):
import traceback
import sys
@@ -701,6 +778,22 @@ class UpgradeMetarigTypes(bpy.types.Operator):
return {'FINISHED'}
+class SwitchToLegacy(bpy.types.Operator):
+ """Switch to Legacy mode"""
+
+ bl_idname = "pose.rigify_switch_to_legacy"
+ bl_label = "Legacy Mode will disable Rigify new features"
+ bl_description = 'Switches Rigify to Legacy Mode'
+ bl_options = {'UNDO'}
+
+ def invoke(self, context, event):
+ return context.window_manager.invoke_confirm(self, event)
+
+ def execute(self, context):
+ bpy.context.user_preferences.addons['rigify'].preferences.legacy_mode = True
+ return {'FINISHED'}
+
+
class Sample(bpy.types.Operator):
"""Create a sample metarig to be modified before generating """ \
"""the final rig"""
@@ -815,9 +908,411 @@ class EncodeWidget(bpy.types.Operator):
return {'FINISHED'}
-#menu_func = (lambda self, context: self.layout.menu("INFO_MT_armature_metarig_add", icon='OUTLINER_OB_ARMATURE'))
+class OBJECT_OT_GetFrameRange(bpy.types.Operator):
+ """Get start and end frame range"""
+ bl_idname = "rigify.get_frame_range"
+ bl_label = "Get Frame Range"
+
+ def execute(self, context):
+ scn = context.scene
+ id_store = context.window_manager
+
+ id_store.rigify_transfer_start_frame = scn.frame_start
+ id_store.rigify_transfer_end_frame = scn.frame_end
+
+ return {'FINISHED'}
+
+
+def FktoIk(rig, window='ALL'):
+
+ scn = bpy.context.scene
+ id_store = bpy.context.window_manager
+
+ rig_id = rig.data['rig_id']
+ leg_ik2fk = eval('bpy.ops.pose.rigify_leg_ik2fk_' + rig_id)
+ arm_ik2fk = eval('bpy.ops.pose.rigify_arm_ik2fk_' + rig_id)
+ limb_generated_names = get_limb_generated_names(rig)
+
+ if window == 'ALL':
+ frames = get_keyed_frames(rig)
+ frames = [f for f in frames if f in range(id_store.rigify_transfer_start_frame, id_store.rigify_transfer_end_frame+1)]
+ elif window == 'CURRENT':
+ frames = [scn.frame_current]
+ else:
+ frames = [scn.frame_current]
+
+ if not id_store.rigify_transfer_only_selected:
+ pbones = rig.pose.bones
+ bpy.ops.pose.select_all(action='DESELECT')
+ else:
+ pbones = bpy.context.selected_pose_bones
+ bpy.ops.pose.select_all(action='DESELECT')
+
+ for b in pbones:
+ for group in limb_generated_names:
+ if b.name in limb_generated_names[group].values() or b.name in limb_generated_names[group]['controls']\
+ or b.name in limb_generated_names[group]['ik_ctrl']:
+ names = limb_generated_names[group]
+ if names['limb_type'] == 'arm':
+ func = arm_ik2fk
+ controls = names['controls']
+ ik_ctrl = names['ik_ctrl']
+ fk_ctrl = names['fk_ctrl']
+ parent = names['parent']
+ pole = names['pole']
+ rig.pose.bones[controls[0]].bone.select = True
+ rig.pose.bones[controls[4]].bone.select = True
+ rig.pose.bones[pole].bone.select = True
+ rig.pose.bones[parent].bone.select = True
+ kwargs = {'uarm_fk': controls[1], 'farm_fk': controls[2], 'hand_fk': controls[3],
+ 'uarm_ik': controls[0], 'farm_ik': ik_ctrl[1], 'hand_ik': controls[4],
+ 'pole': pole, 'main_parent': parent}
+ args = (controls[0], controls[1], controls[2], controls[3],
+ controls[4], pole, parent)
+ else:
+ func = leg_ik2fk
+ controls = names['controls']
+ ik_ctrl = names['ik_ctrl']
+ fk_ctrl = names['fk_ctrl']
+ parent = names['parent']
+ pole = names['pole']
+ rig.pose.bones[controls[0]].bone.select = True
+ rig.pose.bones[controls[6]].bone.select = True
+ rig.pose.bones[controls[5]].bone.select = True
+ rig.pose.bones[pole].bone.select = True
+ rig.pose.bones[parent].bone.select = True
+ kwargs = {'thigh_fk': controls[1], 'shin_fk': controls[2], 'foot_fk': controls[3],
+ 'mfoot_fk': controls[7], 'thigh_ik': controls[0], 'shin_ik': ik_ctrl[1],
+ 'foot_ik': controls[6], 'pole': pole, 'footroll': controls[5], 'mfoot_ik': ik_ctrl[2],
+ 'main_parent': parent}
+ args = (controls[0], controls[1], controls[2], controls[3],
+ controls[6], controls[5], pole, parent)
+
+ for f in frames:
+ if not bones_in_frame(f, rig, *args):
+ continue
+ scn.frame_set(f)
+ func(**kwargs)
+ bpy.ops.anim.keyframe_insert_menu(type='BUILTIN_KSI_VisualLocRot')
+ bpy.ops.anim.keyframe_insert_menu(type='Scaling')
+
+ bpy.ops.pose.select_all(action='DESELECT')
+ limb_generated_names.pop(group)
+ break
+
+
+def IktoFk(rig, window='ALL'):
+
+ scn = bpy.context.scene
+ id_store = bpy.context.window_manager
+
+ rig_id = rig.data['rig_id']
+ leg_fk2ik = eval('bpy.ops.pose.rigify_leg_fk2ik_' + rig_id)
+ arm_fk2ik = eval('bpy.ops.pose.rigify_arm_fk2ik_' + rig_id)
+ limb_generated_names = get_limb_generated_names(rig)
+
+ if window == 'ALL':
+ frames = get_keyed_frames(rig)
+ frames = [f for f in frames if f in range(id_store.rigify_transfer_start_frame, id_store.rigify_transfer_end_frame+1)]
+ elif window == 'CURRENT':
+ frames = [scn.frame_current]
+ else:
+ frames = [scn.frame_current]
+
+ if not id_store.rigify_transfer_only_selected:
+ bpy.ops.pose.select_all(action='DESELECT')
+ pbones = rig.pose.bones
+ else:
+ pbones = bpy.context.selected_pose_bones
+ bpy.ops.pose.select_all(action='DESELECT')
+
+ for b in pbones:
+ for group in limb_generated_names:
+ if b.name in limb_generated_names[group].values() or b.name in limb_generated_names[group]['controls']\
+ or b.name in limb_generated_names[group]['ik_ctrl']:
+ names = limb_generated_names[group]
+ if names['limb_type'] == 'arm':
+ func = arm_fk2ik
+ controls = names['controls']
+ ik_ctrl = names['ik_ctrl']
+ fk_ctrl = names['fk_ctrl']
+ parent = names['parent']
+ pole = names['pole']
+ rig.pose.bones[controls[1]].bone.select = True
+ rig.pose.bones[controls[2]].bone.select = True
+ rig.pose.bones[controls[3]].bone.select = True
+ kwargs = {'uarm_fk': controls[1], 'farm_fk': controls[2], 'hand_fk': controls[3],
+ 'uarm_ik': controls[0], 'farm_ik': ik_ctrl[1],
+ 'hand_ik': controls[4]}
+ args = (controls[0], controls[1], controls[2], controls[3],
+ controls[4], pole, parent)
+ else:
+ func = leg_fk2ik
+ controls = names['controls']
+ ik_ctrl = names['ik_ctrl']
+ fk_ctrl = names['fk_ctrl']
+ parent = names['parent']
+ pole = names['pole']
+ rig.pose.bones[controls[1]].bone.select = True
+ rig.pose.bones[controls[2]].bone.select = True
+ rig.pose.bones[controls[3]].bone.select = True
+ kwargs = {'thigh_fk': controls[1], 'shin_fk': controls[2], 'foot_fk': controls[3],
+ 'mfoot_fk': controls[7], 'thigh_ik': controls[0], 'shin_ik': ik_ctrl[1],
+ 'foot_ik': ik_ctrl[2], 'mfoot_ik': ik_ctrl[2]}
+ args = (controls[0], controls[1], controls[2], controls[3],
+ controls[6], controls[5], pole, parent)
+
+ for f in frames:
+ if not bones_in_frame(f, rig, *args):
+ continue
+ scn.frame_set(f)
+ func(**kwargs)
+ bpy.ops.anim.keyframe_insert_menu(type='BUILTIN_KSI_VisualLocRot')
+ bpy.ops.anim.keyframe_insert_menu(type='Scaling')
+
+ bpy.ops.pose.select_all(action='DESELECT')
+ limb_generated_names.pop(group)
+ break
+
+
+def clearAnimation(act, type, names):
+
+ bones = []
+ for group in names:
+ if names[group]['limb_type'] == 'arm':
+ if type == 'IK':
+ bones.extend([names[group]['controls'][0], names[group]['controls'][4]])
+ elif type == 'FK':
+ bones.extend([names[group]['controls'][1], names[group]['controls'][2], names[group]['controls'][3]])
+ else:
+ if type == 'IK':
+ bones.extend([names[group]['controls'][0], names[group]['controls'][6], names[group]['controls'][5],
+ names[group]['controls'][4]])
+ elif type == 'FK':
+ bones.extend([names[group]['controls'][1], names[group]['controls'][2], names[group]['controls'][3],
+ names[group]['controls'][4]])
+ FCurves = []
+ for fcu in act.fcurves:
+ words = fcu.data_path.split('"')
+ if (words[0] == "pose.bones[" and
+ words[1] in bones):
+ FCurves.append(fcu)
+
+ if FCurves == []:
+ return
+
+ for fcu in FCurves:
+ act.fcurves.remove(fcu)
+
+ # Put cleared bones back to rest pose
+ bpy.ops.pose.loc_clear()
+ bpy.ops.pose.rot_clear()
+ bpy.ops.pose.scale_clear()
+
+ # updateView3D()
+
+
+def rotPoleToggle(rig, window='ALL', value=False, toggle=False, bake=False):
+
+ scn = bpy.context.scene
+ id_store = bpy.context.window_manager
+
+ rig_id = rig.data['rig_id']
+ leg_fk2ik = eval('bpy.ops.pose.rigify_leg_fk2ik_' + rig_id)
+ arm_fk2ik = eval('bpy.ops.pose.rigify_arm_fk2ik_' + rig_id)
+ leg_ik2fk = eval('bpy.ops.pose.rigify_leg_ik2fk_' + rig_id)
+ arm_ik2fk = eval('bpy.ops.pose.rigify_arm_ik2fk_' + rig_id)
+ limb_generated_names = get_limb_generated_names(rig)
+
+ if window == 'ALL':
+ frames = get_keyed_frames(rig)
+ frames = [f for f in frames if f in range(id_store.rigify_transfer_start_frame, id_store.rigify_transfer_end_frame+1)]
+ elif window == 'CURRENT':
+ frames = [scn.frame_current]
+ else:
+ frames = [scn.frame_current]
+
+ if not id_store.rigify_transfer_only_selected:
+ bpy.ops.pose.select_all(action='DESELECT')
+ pbones = rig.pose.bones
+ else:
+ pbones = bpy.context.selected_pose_bones
+ bpy.ops.pose.select_all(action='DESELECT')
+
+ for b in pbones:
+ for group in limb_generated_names:
+ names = limb_generated_names[group]
+
+ if toggle:
+ new_pole_vector_value = not rig.pose.bones[names['parent']]['pole_vector']
+ else:
+ new_pole_vector_value = value
+
+ if b.name in names.values() or b.name in names['controls'] or b.name in names['ik_ctrl']:
+ if names['limb_type'] == 'arm':
+ func1 = arm_fk2ik
+ func2 = arm_ik2fk
+ controls = names['controls']
+ ik_ctrl = names['ik_ctrl']
+ fk_ctrl = names['fk_ctrl']
+ parent = names['parent']
+ pole = names['pole']
+ rig.pose.bones[controls[0]].bone.select = not new_pole_vector_value
+ rig.pose.bones[controls[4]].bone.select = not new_pole_vector_value
+ rig.pose.bones[parent].bone.select = not new_pole_vector_value
+ rig.pose.bones[pole].bone.select = new_pole_vector_value
+
+ kwargs1 = {'uarm_fk': controls[1], 'farm_fk': controls[2], 'hand_fk': controls[3],
+ 'uarm_ik': controls[0], 'farm_ik': ik_ctrl[1],
+ 'hand_ik': controls[4]}
+ kwargs2 = {'uarm_fk': controls[1], 'farm_fk': controls[2], 'hand_fk': controls[3],
+ 'uarm_ik': controls[0], 'farm_ik': ik_ctrl[1], 'hand_ik': controls[4],
+ 'pole': pole, 'main_parent': parent}
+ args = (controls[0], controls[4], pole, parent)
+ else:
+ func1 = leg_fk2ik
+ func2 = leg_ik2fk
+ controls = names['controls']
+ ik_ctrl = names['ik_ctrl']
+ fk_ctrl = names['fk_ctrl']
+ parent = names['parent']
+ pole = names['pole']
+ rig.pose.bones[controls[0]].bone.select = not new_pole_vector_value
+ rig.pose.bones[controls[6]].bone.select = not new_pole_vector_value
+ rig.pose.bones[controls[5]].bone.select = not new_pole_vector_value
+ rig.pose.bones[parent].bone.select = not new_pole_vector_value
+ rig.pose.bones[pole].bone.select = new_pole_vector_value
+
+ kwargs1 = {'thigh_fk': controls[1], 'shin_fk': controls[2], 'foot_fk': controls[3],
+ 'mfoot_fk': controls[7], 'thigh_ik': controls[0], 'shin_ik': ik_ctrl[1],
+ 'foot_ik': ik_ctrl[2], 'mfoot_ik': ik_ctrl[2]}
+ kwargs2 = {'thigh_fk': controls[1], 'shin_fk': controls[2], 'foot_fk': controls[3],
+ 'mfoot_fk': controls[7], 'thigh_ik': controls[0], 'shin_ik': ik_ctrl[1],
+ 'foot_ik': controls[6], 'pole': pole, 'footroll': controls[5], 'mfoot_ik': ik_ctrl[2],
+ 'main_parent': parent}
+ args = (controls[0], controls[6], controls[5], pole, parent)
+
+ for f in frames:
+ if not bones_in_frame(f, rig, *args):
+ continue
+ scn.frame_set(f)
+ func1(**kwargs1)
+ rig.pose.bones[names['parent']]['pole_vector'] = new_pole_vector_value
+ func2(**kwargs2)
+ if bake:
+ bpy.ops.anim.keyframe_insert_menu(type='BUILTIN_KSI_VisualLocRot')
+ bpy.ops.anim.keyframe_insert_menu(type='Scaling')
+ overwrite_prop_animation(rig, rig.pose.bones[parent], 'pole_vector', new_pole_vector_value, [f])
+
+ bpy.ops.pose.select_all(action='DESELECT')
+ limb_generated_names.pop(group)
+ break
+ scn.frame_set(0)
+
+
+class OBJECT_OT_IK2FK(bpy.types.Operator):
+ """ Snaps IK limb on FK limb at current frame"""
+ bl_idname = "rigify.ik2fk"
+ bl_label = "IK2FK"
+ bl_description = "Snaps IK limb on FK"
+
+ def execute(self,context):
+ rig = context.object
+ id_store = context.window_manager
+
+ FktoIk(rig, window='CURRENT')
+
+ return {'FINISHED'}
+
+
+class OBJECT_OT_FK2IK(bpy.types.Operator):
+ """ Snaps FK limb on IK limb at current frame"""
+ bl_idname = "rigify.fk2ik"
+ bl_label = "FK2IK"
+ bl_description = "Snaps FK limb on IK"
+
+ def execute(self,context):
+ rig = context.object
+
+ IktoFk(rig, window='CURRENT')
+
+ return {'FINISHED'}
+
+
+class OBJECT_OT_TransferFKtoIK(bpy.types.Operator):
+ """Transfers FK animation to IK"""
+ bl_idname = "rigify.transfer_fk_to_ik"
+ bl_label = "Transfer FK anim to IK"
+ bl_description = "Transfer FK animation to IK bones"
+
+ def execute(self, context):
+ rig = context.object
+ id_store = context.window_manager
+
+ FktoIk(rig)
+
+ return {'FINISHED'}
+
+
+class OBJECT_OT_TransferIKtoFK(bpy.types.Operator):
+ """Transfers FK animation to IK"""
+ bl_idname = "rigify.transfer_ik_to_fk"
+ bl_label = "Transfer IK anim to FK"
+ bl_description = "Transfer IK animation to FK bones"
+
+ def execute(self, context):
+ rig = context.object
+
+ IktoFk(rig)
+
+ return {'FINISHED'}
+
+
+class OBJECT_OT_ClearAnimation(bpy.types.Operator):
+ bl_idname = "rigify.clear_animation"
+ bl_label = "Clear Animation"
+ bl_description = "Clear Animation For FK or IK Bones"
+ type = StringProperty()
+
+ def execute(self, context):
+
+ use_global_undo = context.user_preferences.edit.use_global_undo
+ context.user_preferences.edit.use_global_undo = False
+ try:
+ rig = context.object
+ scn = context.scene
+ if not rig.animation_data:
+ return {'FINISHED'}
+ act = rig.animation_data.action
+ if not act:
+ return {'FINISHED'}
+
+ clearAnimation(act, self.type, names=get_limb_generated_names(rig))
+ finally:
+ context.user_preferences.edit.use_global_undo = use_global_undo
+ return {'FINISHED'}
+
+
+class OBJECT_OT_Rot2Pole(bpy.types.Operator):
+ bl_idname = "rigify.rotation_pole"
+ bl_label = "Rotation - Pole toggle"
+ bl_description = "Toggles IK chain between rotation and pole target"
+ bone_name = bpy.props.StringProperty(default='')
+ window = bpy.props.StringProperty(default='ALL')
+ toggle = bpy.props.BoolProperty(default=True)
+ value = bpy.props.BoolProperty(default=True)
+ bake = bpy.props.BoolProperty(default=True)
+
+ def execute(self, context):
+ rig = context.object
+
+ if self.bone_name:
+ bpy.ops.pose.select_all(action='DESELECT')
+ rig.pose.bones[self.bone_name].bone.select = True
+
+ rotPoleToggle(rig, window=self.window, toggle=self.toggle, value=self.value, bake=self.bake)
+ return {'FINISHED'}
-#from bl_ui import space_info # ensure the menu is loaded first
def register():
@@ -834,15 +1329,25 @@ def register():
bpy.utils.register_class(DATA_PT_rigify_layer_names)
bpy.utils.register_class(DATA_PT_rigify_buttons)
bpy.utils.register_class(BONE_PT_rigify_buttons)
+ bpy.utils.register_class(VIEW3D_PT_rigify_animation_tools)
bpy.utils.register_class(VIEW3D_PT_tools_rigify_dev)
bpy.utils.register_class(LayerInit)
bpy.utils.register_class(Generate)
bpy.utils.register_class(UpgradeMetarigTypes)
+ bpy.utils.register_class(SwitchToLegacy)
bpy.utils.register_class(Sample)
bpy.utils.register_class(EncodeMetarig)
bpy.utils.register_class(EncodeMetarigSample)
bpy.utils.register_class(EncodeWidget)
- #space_info.INFO_MT_armature_add.append(ui.menu_func)
+ bpy.utils.register_class(OBJECT_OT_GetFrameRange)
+ bpy.utils.register_class(OBJECT_OT_FK2IK)
+ bpy.utils.register_class(OBJECT_OT_IK2FK)
+ bpy.utils.register_class(OBJECT_OT_TransferFKtoIK)
+ bpy.utils.register_class(OBJECT_OT_TransferIKtoFK)
+ bpy.utils.register_class(OBJECT_OT_ClearAnimation)
+ bpy.utils.register_class(OBJECT_OT_Rot2Pole)
+
+ rot_mode.register()
def unregister():
@@ -860,11 +1365,23 @@ def unregister():
bpy.utils.unregister_class(DATA_PT_rigify_layer_names)
bpy.utils.unregister_class(DATA_PT_rigify_buttons)
bpy.utils.unregister_class(BONE_PT_rigify_buttons)
+ bpy.utils.unregister_class(VIEW3D_PT_rigify_animation_tools)
bpy.utils.unregister_class(VIEW3D_PT_tools_rigify_dev)
bpy.utils.unregister_class(LayerInit)
bpy.utils.unregister_class(Generate)
bpy.utils.unregister_class(UpgradeMetarigTypes)
+ bpy.utils.unregister_class(SwitchToLegacy)
bpy.utils.unregister_class(Sample)
bpy.utils.unregister_class(EncodeMetarig)
bpy.utils.unregister_class(EncodeMetarigSample)
bpy.utils.unregister_class(EncodeWidget)
+ bpy.utils.unregister_class(OBJECT_OT_GetFrameRange)
+ bpy.utils.unregister_class(OBJECT_OT_FK2IK)
+ bpy.utils.unregister_class(OBJECT_OT_IK2FK)
+ bpy.utils.unregister_class(OBJECT_OT_TransferFKtoIK)
+ bpy.utils.unregister_class(OBJECT_OT_TransferIKtoFK)
+ bpy.utils.unregister_class(OBJECT_OT_ClearAnimation)
+ bpy.utils.unregister_class(OBJECT_OT_Rot2Pole)
+
+ rot_mode.unregister()
+