diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-12-17 22:48:30 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-12-17 22:48:30 +0300 |
commit | 0c813b2a0ee4e293428caa3fc7d2b706377c92cf (patch) | |
tree | 516119c4cb48fd8d51e0582bdc618206c1978400 /release | |
parent | 959e0486cfe144005ea23220b30de51f09541544 (diff) |
autorigging front end, access in pose mode armature panel (at the bottom)
demo: http://download.blender.org/durian/metarig_demo.ogv
sintel base rig also, would like to include more generic/simple rigs eventually
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/modules/rigify/arm_biped_generic.py | 12 | ||||
-rw-r--r-- | release/scripts/modules/rigify/leg_biped_generic.py | 4 | ||||
-rw-r--r-- | release/scripts/op/add_armature_human.py | 623 | ||||
-rw-r--r-- | release/scripts/ui/properties_data_armature_rigify.py | 352 |
4 files changed, 979 insertions, 12 deletions
diff --git a/release/scripts/modules/rigify/arm_biped_generic.py b/release/scripts/modules/rigify/arm_biped_generic.py index 2363b5366e6..509f1bb7aef 100644 --- a/release/scripts/modules/rigify/arm_biped_generic.py +++ b/release/scripts/modules/rigify/arm_biped_generic.py @@ -164,14 +164,6 @@ def ik(obj, definitions, base_names, options): con.chain_length = 2 con.pole_angle = -90.0 # XXX, RAD2DEG - # ID Propery on the hand for IK/FK switch - - prop = rna_idprop_ui_prop_get(ik_chain.hand_p, "ik", create=True) - ik_chain.hand_p["ik"] = 0.5 - prop["soft_min"] = 0.0 - prop["soft_max"] = 1.0 - - # last step setup layers layers = get_layer_dict(options) lay = layers["ik"] @@ -292,8 +284,8 @@ def fk(obj, definitions, base_names, options): def main(obj, bone_definition, base_names, options): - bones_ik = ik(obj, bone_definition, base_names, options) bones_fk = fk(obj, bone_definition, base_names, options) + bones_ik = ik(obj, bone_definition, base_names, options) bpy.ops.object.mode_set(mode='OBJECT') - blend_bone_list(obj, bone_definition, bones_ik, bones_fk, target_bone=bone_definition[1], blend_default=1.0) + blend_bone_list(obj, bone_definition, bones_fk, bones_ik, target_bone=bones_fk[1], blend_default=1.0) diff --git a/release/scripts/modules/rigify/leg_biped_generic.py b/release/scripts/modules/rigify/leg_biped_generic.py index 7cb71009596..745ee49cbfe 100644 --- a/release/scripts/modules/rigify/leg_biped_generic.py +++ b/release/scripts/modules/rigify/leg_biped_generic.py @@ -367,8 +367,8 @@ def fk(obj, bone_definition, base_names, options): def main(obj, bone_definition, base_names, options): - bones_ik = ik(obj, bone_definition, base_names, options) bones_fk = fk(obj, bone_definition, base_names, options) + bones_ik = ik(obj, bone_definition, base_names, options) bpy.ops.object.mode_set(mode='OBJECT') - blend_bone_list(obj, bone_definition, bones_ik, bones_fk, target_bone=bone_definition[1], blend_default=0.0) + blend_bone_list(obj, bone_definition, bones_fk, bones_ik, target_bone=bones_ik[1], blend_default=0.0) diff --git a/release/scripts/op/add_armature_human.py b/release/scripts/op/add_armature_human.py new file mode 100644 index 00000000000..264f290f271 --- /dev/null +++ b/release/scripts/op/add_armature_human.py @@ -0,0 +1,623 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# <pep8-80 compliant> +import bpy +import Mathutils +from math import cos, sin, pi + +# could this be stored elsewhere? + +def metarig_template(): + # generated by rigify.write_meta_rig + bpy.ops.object.mode_set(mode='EDIT') + obj = bpy.context.active_object + arm = obj.data + bone = arm.edit_bones.new('root') + bone.head[:] = 0.0000, 0.0000, 0.0000 + bone.tail[:] = 0.0000, 0.4000, 0.0000 + bone.roll = 0.0000 + bone.connected = False + bone = arm.edit_bones.new('pelvis') + bone.head[:] = -0.0000, -0.0145, 1.1263 + bone.tail[:] = -0.0000, -0.0145, 0.9563 + bone.roll = 3.1416 + bone.connected = False + bone.parent = arm.edit_bones['root'] + bone = arm.edit_bones.new('torso') + bone.head[:] = -0.0000, -0.0145, 1.1263 + bone.tail[:] = -0.0000, -0.0145, 1.2863 + bone.roll = 3.1416 + bone.connected = False + bone.parent = arm.edit_bones['pelvis'] + bone = arm.edit_bones.new('spine.01') + bone.head[:] = 0.0000, 0.0394, 0.9688 + bone.tail[:] = -0.0000, -0.0145, 1.1263 + bone.roll = 0.0000 + bone.connected = False + bone.parent = arm.edit_bones['torso'] + bone = arm.edit_bones.new('spine.02') + bone.head[:] = -0.0000, -0.0145, 1.1263 + bone.tail[:] = -0.0000, -0.0213, 1.2884 + bone.roll = -0.0000 + bone.connected = True + bone.parent = arm.edit_bones['spine.01'] + bone = arm.edit_bones.new('thigh.L') + bone.head[:] = 0.0933, -0.0421, 1.0434 + bone.tail[:] = 0.0933, -0.0516, 0.5848 + bone.roll = 0.0000 + bone.connected = False + bone.parent = arm.edit_bones['spine.01'] + bone = arm.edit_bones.new('thigh.R') + bone.head[:] = -0.0933, -0.0421, 1.0434 + bone.tail[:] = -0.0933, -0.0516, 0.5848 + bone.roll = -0.0000 + bone.connected = False + bone.parent = arm.edit_bones['spine.01'] + bone = arm.edit_bones.new('spine.03') + bone.head[:] = -0.0000, -0.0213, 1.2884 + bone.tail[:] = -0.0000, 0.0160, 1.3705 + bone.roll = -0.0000 + bone.connected = True + bone.parent = arm.edit_bones['spine.02'] + bone = arm.edit_bones.new('shin.L') + bone.head[:] = 0.0933, -0.0516, 0.5848 + bone.tail[:] = 0.0915, 0.0100, 0.1374 + bone.roll = 0.0034 + bone.connected = True + bone.parent = arm.edit_bones['thigh.L'] + bone = arm.edit_bones.new('shin.R') + bone.head[:] = -0.0933, -0.0516, 0.5848 + bone.tail[:] = -0.0915, 0.0100, 0.1374 + bone.roll = -0.0034 + bone.connected = True + bone.parent = arm.edit_bones['thigh.R'] + bone = arm.edit_bones.new('spine.04') + bone.head[:] = -0.0000, 0.0160, 1.3705 + bone.tail[:] = -0.0000, 0.0590, 1.4497 + bone.roll = -0.0000 + bone.connected = True + bone.parent = arm.edit_bones['spine.03'] + bone = arm.edit_bones.new('foot.L') + bone.head[:] = 0.0915, 0.0100, 0.1374 + bone.tail[:] = 0.1033, -0.0968, 0.0510 + bone.roll = 2.8964 + bone.connected = True + bone.parent = arm.edit_bones['shin.L'] + bone = arm.edit_bones.new('foot.R') + bone.head[:] = -0.0915, 0.0100, 0.1374 + bone.tail[:] = -0.1033, -0.0968, 0.0510 + bone.roll = -2.8793 + bone.connected = True + bone.parent = arm.edit_bones['shin.R'] + bone = arm.edit_bones.new('neck_base') + bone.head[:] = -0.0000, 0.0590, 1.4497 + bone.tail[:] = -0.0000, 0.0401, 1.5389 + bone.roll = -0.0000 + bone.connected = True + bone.parent = arm.edit_bones['spine.04'] + bone = arm.edit_bones.new('toe.L') + bone.head[:] = 0.1033, -0.0968, 0.0510 + bone.tail[:] = 0.1136, -0.1848, 0.0510 + bone.roll = 0.0001 + bone.connected = True + bone.parent = arm.edit_bones['foot.L'] + bone = arm.edit_bones.new('heel.L') + bone.head[:] = 0.0809, 0.0969, -0.0000 + bone.tail[:] = 0.1020, -0.0846, -0.0000 + bone.roll = -0.0001 + bone.connected = False + bone.parent = arm.edit_bones['foot.L'] + bone = arm.edit_bones.new('toe.R') + bone.head[:] = -0.1033, -0.0968, 0.0510 + bone.tail[:] = -0.1136, -0.1848, 0.0510 + bone.roll = -0.0002 + bone.connected = True + bone.parent = arm.edit_bones['foot.R'] + bone = arm.edit_bones.new('heel.R') + bone.head[:] = -0.0809, 0.0969, -0.0000 + bone.tail[:] = -0.1020, -0.0846, -0.0000 + bone.roll = -0.0000 + bone.connected = False + bone.parent = arm.edit_bones['foot.R'] + bone = arm.edit_bones.new('head') + bone.head[:] = -0.0000, 0.0401, 1.5389 + bone.tail[:] = -0.0000, 0.0401, 1.5979 + bone.roll = 3.1416 + bone.connected = True + bone.parent = arm.edit_bones['neck_base'] + bone = arm.edit_bones.new('DLT-shoulder.L') + bone.head[:] = 0.0141, -0.0346, 1.4991 + bone.tail[:] = 0.1226, 0.0054, 1.4991 + bone.roll = 0.0005 + bone.connected = False + bone.parent = arm.edit_bones['neck_base'] + bone = arm.edit_bones.new('DLT-shoulder.R') + bone.head[:] = -0.0141, -0.0346, 1.4991 + bone.tail[:] = -0.1226, 0.0054, 1.4991 + bone.roll = -0.0005 + bone.connected = False + bone.parent = arm.edit_bones['neck_base'] + bone = arm.edit_bones.new('neck.01') + bone.head[:] = -0.0000, 0.0401, 1.5389 + bone.tail[:] = -0.0000, 0.0176, 1.5916 + bone.roll = 0.0000 + bone.connected = False + bone.parent = arm.edit_bones['head'] + bone = arm.edit_bones.new('shoulder.L') + bone.head[:] = 0.0141, -0.0346, 1.4991 + bone.tail[:] = 0.1226, 0.0216, 1.5270 + bone.roll = -0.1225 + bone.connected = False + bone.parent = arm.edit_bones['DLT-shoulder.L'] + bone = arm.edit_bones.new('shoulder.R') + bone.head[:] = -0.0141, -0.0346, 1.4991 + bone.tail[:] = -0.1226, 0.0216, 1.5270 + bone.roll = 0.0849 + bone.connected = False + bone.parent = arm.edit_bones['DLT-shoulder.R'] + bone = arm.edit_bones.new('neck.02') + bone.head[:] = -0.0000, 0.0176, 1.5916 + bone.tail[:] = -0.0000, 0.0001, 1.6499 + bone.roll = 0.0000 + bone.connected = True + bone.parent = arm.edit_bones['neck.01'] + bone = arm.edit_bones.new('DLT-upper_arm.L') + bone.head[:] = 0.1482, 0.0483, 1.4943 + bone.tail[:] = 0.2586, 0.1057, 1.5124 + bone.roll = 1.4969 + bone.connected = False + bone.parent = arm.edit_bones['shoulder.L'] + bone = arm.edit_bones.new('DLT-upper_arm.R') + bone.head[:] = -0.1482, 0.0483, 1.4943 + bone.tail[:] = -0.2586, 0.1057, 1.5124 + bone.roll = -1.4482 + bone.connected = False + bone.parent = arm.edit_bones['shoulder.R'] + bone = arm.edit_bones.new('neck.03') + bone.head[:] = -0.0000, 0.0001, 1.6499 + bone.tail[:] = -0.0000, 0.0001, 1.8522 + bone.roll = 0.0000 + bone.connected = True + bone.parent = arm.edit_bones['neck.02'] + bone = arm.edit_bones.new('upper_arm.L') + bone.head[:] = 0.1482, 0.0483, 1.4943 + bone.tail[:] = 0.3929, 0.0522, 1.4801 + bone.roll = 1.6281 + bone.connected = False + bone.parent = arm.edit_bones['DLT-upper_arm.L'] + bone = arm.edit_bones.new('upper_arm.R') + bone.head[:] = -0.1482, 0.0483, 1.4943 + bone.tail[:] = -0.3929, 0.0522, 1.4801 + bone.roll = -1.6281 + bone.connected = False + bone.parent = arm.edit_bones['DLT-upper_arm.R'] + bone = arm.edit_bones.new('forearm.L') + bone.head[:] = 0.3929, 0.0522, 1.4801 + bone.tail[:] = 0.6198, 0.0364, 1.4906 + bone.roll = 1.5240 + bone.connected = True + bone.parent = arm.edit_bones['upper_arm.L'] + bone = arm.edit_bones.new('forearm.R') + bone.head[:] = -0.3929, 0.0522, 1.4801 + bone.tail[:] = -0.6198, 0.0364, 1.4906 + bone.roll = -1.5219 + bone.connected = True + bone.parent = arm.edit_bones['upper_arm.R'] + bone = arm.edit_bones.new('hand.L') + bone.head[:] = 0.6198, 0.0364, 1.4906 + bone.tail[:] = 0.6592, 0.0364, 1.4853 + bone.roll = -3.0065 + bone.connected = True + bone.parent = arm.edit_bones['forearm.L'] + bone = arm.edit_bones.new('hand.R') + bone.head[:] = -0.6198, 0.0364, 1.4906 + bone.tail[:] = -0.6592, 0.0364, 1.4853 + bone.roll = 3.0065 + bone.connected = True + bone.parent = arm.edit_bones['forearm.R'] + bone = arm.edit_bones.new('palm.04.L') + bone.head[:] = 0.6514, 0.0658, 1.4906 + bone.tail[:] = 0.7287, 0.0810, 1.4747 + bone.roll = -3.0715 + bone.connected = False + bone.parent = arm.edit_bones['hand.L'] + bone = arm.edit_bones.new('palm.03.L') + bone.head[:] = 0.6533, 0.0481, 1.4943 + bone.tail[:] = 0.7386, 0.0553, 1.4781 + bone.roll = -3.0290 + bone.connected = False + bone.parent = arm.edit_bones['hand.L'] + bone = arm.edit_bones.new('palm.02.L') + bone.head[:] = 0.6539, 0.0305, 1.4967 + bone.tail[:] = 0.7420, 0.0250, 1.4835 + bone.roll = -3.0669 + bone.connected = False + bone.parent = arm.edit_bones['hand.L'] + bone = arm.edit_bones.new('palm.01.L') + bone.head[:] = 0.6514, 0.0116, 1.4961 + bone.tail[:] = 0.7361, -0.0074, 1.4823 + bone.roll = -2.9422 + bone.connected = False + bone.parent = arm.edit_bones['hand.L'] + bone = arm.edit_bones.new('thumb.01.L') + bone.head[:] = 0.6380, -0.0005, 1.4848 + bone.tail[:] = 0.6757, -0.0408, 1.4538 + bone.roll = -0.7041 + bone.connected = False + bone.parent = arm.edit_bones['hand.L'] + bone = arm.edit_bones.new('palm.04.R') + bone.head[:] = -0.6514, 0.0658, 1.4906 + bone.tail[:] = -0.7287, 0.0810, 1.4747 + bone.roll = 3.0715 + bone.connected = False + bone.parent = arm.edit_bones['hand.R'] + bone = arm.edit_bones.new('palm.03.R') + bone.head[:] = -0.6533, 0.0481, 1.4943 + bone.tail[:] = -0.7386, 0.0553, 1.4781 + bone.roll = 3.0290 + bone.connected = False + bone.parent = arm.edit_bones['hand.R'] + bone = arm.edit_bones.new('palm.02.R') + bone.head[:] = -0.6539, 0.0305, 1.4967 + bone.tail[:] = -0.7420, 0.0250, 1.4835 + bone.roll = 3.0669 + bone.connected = False + bone.parent = arm.edit_bones['hand.R'] + bone = arm.edit_bones.new('thumb.01.R') + bone.head[:] = -0.6380, -0.0005, 1.4848 + bone.tail[:] = -0.6757, -0.0408, 1.4538 + bone.roll = 0.7041 + bone.connected = False + bone.parent = arm.edit_bones['hand.R'] + bone = arm.edit_bones.new('palm.01.R') + bone.head[:] = -0.6514, 0.0116, 1.4961 + bone.tail[:] = -0.7361, -0.0074, 1.4823 + bone.roll = 2.9332 + bone.connected = False + bone.parent = arm.edit_bones['hand.R'] + bone = arm.edit_bones.new('finger_pinky.01.L') + bone.head[:] = 0.7287, 0.0810, 1.4747 + bone.tail[:] = 0.7698, 0.0947, 1.4635 + bone.roll = -3.0949 + bone.connected = True + bone.parent = arm.edit_bones['palm.04.L'] + bone = arm.edit_bones.new('finger_ring.01.L') + bone.head[:] = 0.7386, 0.0553, 1.4781 + bone.tail[:] = 0.7890, 0.0615, 1.4667 + bone.roll = -3.0081 + bone.connected = True + bone.parent = arm.edit_bones['palm.03.L'] + bone = arm.edit_bones.new('finger_middle.01.L') + bone.head[:] = 0.7420, 0.0250, 1.4835 + bone.tail[:] = 0.7975, 0.0221, 1.4712 + bone.roll = -2.9982 + bone.connected = True + bone.parent = arm.edit_bones['palm.02.L'] + bone = arm.edit_bones.new('finger_index.01.L') + bone.head[:] = 0.7361, -0.0074, 1.4823 + bone.tail[:] = 0.7843, -0.0204, 1.4718 + bone.roll = -3.0021 + bone.connected = True + bone.parent = arm.edit_bones['palm.01.L'] + bone = arm.edit_bones.new('thumb.02.L') + bone.head[:] = 0.6757, -0.0408, 1.4538 + bone.tail[:] = 0.6958, -0.0568, 1.4376 + bone.roll = -0.6963 + bone.connected = True + bone.parent = arm.edit_bones['thumb.01.L'] + bone = arm.edit_bones.new('finger_pinky.01.R') + bone.head[:] = -0.7287, 0.0810, 1.4747 + bone.tail[:] = -0.7698, 0.0947, 1.4635 + bone.roll = 3.0949 + bone.connected = True + bone.parent = arm.edit_bones['palm.04.R'] + bone = arm.edit_bones.new('finger_ring.01.R') + bone.head[:] = -0.7386, 0.0553, 1.4781 + bone.tail[:] = -0.7890, 0.0615, 1.4667 + bone.roll = 2.9892 + bone.connected = True + bone.parent = arm.edit_bones['palm.03.R'] + bone = arm.edit_bones.new('finger_middle.01.R') + bone.head[:] = -0.7420, 0.0250, 1.4835 + bone.tail[:] = -0.7975, 0.0221, 1.4712 + bone.roll = 2.9816 + bone.connected = True + bone.parent = arm.edit_bones['palm.02.R'] + bone = arm.edit_bones.new('thumb.02.R') + bone.head[:] = -0.6757, -0.0408, 1.4538 + bone.tail[:] = -0.6958, -0.0568, 1.4376 + bone.roll = 0.6963 + bone.connected = True + bone.parent = arm.edit_bones['thumb.01.R'] + bone = arm.edit_bones.new('finger_index.01.R') + bone.head[:] = -0.7361, -0.0074, 1.4823 + bone.tail[:] = -0.7843, -0.0204, 1.4718 + bone.roll = 2.9498 + bone.connected = True + bone.parent = arm.edit_bones['palm.01.R'] + bone = arm.edit_bones.new('finger_pinky.02.L') + bone.head[:] = 0.7698, 0.0947, 1.4635 + bone.tail[:] = 0.7910, 0.1018, 1.4577 + bone.roll = -3.0949 + bone.connected = True + bone.parent = arm.edit_bones['finger_pinky.01.L'] + bone = arm.edit_bones.new('finger_ring.02.L') + bone.head[:] = 0.7890, 0.0615, 1.4667 + bone.tail[:] = 0.8177, 0.0650, 1.4600 + bone.roll = -3.0006 + bone.connected = True + bone.parent = arm.edit_bones['finger_ring.01.L'] + bone = arm.edit_bones.new('finger_middle.02.L') + bone.head[:] = 0.7975, 0.0221, 1.4712 + bone.tail[:] = 0.8289, 0.0206, 1.4643 + bone.roll = -2.9995 + bone.connected = True + bone.parent = arm.edit_bones['finger_middle.01.L'] + bone = arm.edit_bones.new('finger_index.02.L') + bone.head[:] = 0.7843, -0.0204, 1.4718 + bone.tail[:] = 0.8117, -0.0275, 1.4660 + bone.roll = -3.0064 + bone.connected = True + bone.parent = arm.edit_bones['finger_index.01.L'] + bone = arm.edit_bones.new('thumb.03.L') + bone.head[:] = 0.6958, -0.0568, 1.4376 + bone.tail[:] = 0.7196, -0.0671, 1.4210 + bone.roll = -0.8072 + bone.connected = True + bone.parent = arm.edit_bones['thumb.02.L'] + bone = arm.edit_bones.new('finger_pinky.02.R') + bone.head[:] = -0.7698, 0.0947, 1.4635 + bone.tail[:] = -0.7910, 0.1018, 1.4577 + bone.roll = 3.0949 + bone.connected = True + bone.parent = arm.edit_bones['finger_pinky.01.R'] + bone = arm.edit_bones.new('finger_ring.02.R') + bone.head[:] = -0.7890, 0.0615, 1.4667 + bone.tail[:] = -0.8177, 0.0650, 1.4600 + bone.roll = 3.0341 + bone.connected = True + bone.parent = arm.edit_bones['finger_ring.01.R'] + bone = arm.edit_bones.new('finger_middle.02.R') + bone.head[:] = -0.7975, 0.0221, 1.4712 + bone.tail[:] = -0.8289, 0.0206, 1.4643 + bone.roll = 3.0291 + bone.connected = True + bone.parent = arm.edit_bones['finger_middle.01.R'] + bone = arm.edit_bones.new('thumb.03.R') + bone.head[:] = -0.6958, -0.0568, 1.4376 + bone.tail[:] = -0.7196, -0.0671, 1.4210 + bone.roll = 0.8072 + bone.connected = True + bone.parent = arm.edit_bones['thumb.02.R'] + bone = arm.edit_bones.new('finger_index.02.R') + bone.head[:] = -0.7843, -0.0204, 1.4718 + bone.tail[:] = -0.8117, -0.0275, 1.4660 + bone.roll = 3.0705 + bone.connected = True + bone.parent = arm.edit_bones['finger_index.01.R'] + bone = arm.edit_bones.new('finger_pinky.03.L') + bone.head[:] = 0.7910, 0.1018, 1.4577 + bone.tail[:] = 0.8109, 0.1085, 1.4523 + bone.roll = -3.0949 + bone.connected = True + bone.parent = arm.edit_bones['finger_pinky.02.L'] + bone = arm.edit_bones.new('finger_ring.03.L') + bone.head[:] = 0.8177, 0.0650, 1.4600 + bone.tail[:] = 0.8396, 0.0677, 1.4544 + bone.roll = -2.9819 + bone.connected = True + bone.parent = arm.edit_bones['finger_ring.02.L'] + bone = arm.edit_bones.new('finger_middle.03.L') + bone.head[:] = 0.8289, 0.0206, 1.4643 + bone.tail[:] = 0.8534, 0.0193, 1.4589 + bone.roll = -3.0004 + bone.connected = True + bone.parent = arm.edit_bones['finger_middle.02.L'] + bone = arm.edit_bones.new('finger_index.03.L') + bone.head[:] = 0.8117, -0.0275, 1.4660 + bone.tail[:] = 0.8331, -0.0333, 1.4615 + bone.roll = -3.0103 + bone.connected = True + bone.parent = arm.edit_bones['finger_index.02.L'] + bone = arm.edit_bones.new('finger_pinky.03.R') + bone.head[:] = -0.7910, 0.1018, 1.4577 + bone.tail[:] = -0.8109, 0.1085, 1.4523 + bone.roll = 3.0949 + bone.connected = True + bone.parent = arm.edit_bones['finger_pinky.02.R'] + bone = arm.edit_bones.new('finger_ring.03.R') + bone.head[:] = -0.8177, 0.0650, 1.4600 + bone.tail[:] = -0.8396, 0.0677, 1.4544 + bone.roll = 2.9819 + bone.connected = True + bone.parent = arm.edit_bones['finger_ring.02.R'] + bone = arm.edit_bones.new('finger_middle.03.R') + bone.head[:] = -0.8289, 0.0206, 1.4643 + bone.tail[:] = -0.8534, 0.0193, 1.4589 + bone.roll = 3.0004 + bone.connected = True + bone.parent = arm.edit_bones['finger_middle.02.R'] + bone = arm.edit_bones.new('finger_index.03.R') + bone.head[:] = -0.8117, -0.0275, 1.4660 + bone.tail[:] = -0.8331, -0.0333, 1.4615 + bone.roll = 2.9917 + bone.connected = True + bone.parent = arm.edit_bones['finger_index.02.R'] + + bpy.ops.object.mode_set(mode='OBJECT') + pbone = obj.pose.bones['root'] + pbone['type'] = 'root' + pbone = obj.pose.bones['root'] + pbone['root.layer'] = 16 + pbone = obj.pose.bones['torso'] + pbone['type'] = 'spine_pivot_flex' + pbone = obj.pose.bones['torso'] + pbone['spine_pivot_flex.later_main'] = 1 + pbone = obj.pose.bones['torso'] + pbone['spine_pivot_flex.layer_extra'] = 2 + pbone = obj.pose.bones['thigh.L'] + pbone['type'] = 'leg_biped_generic' + pbone = obj.pose.bones['thigh.L'] + pbone['leg_biped_generic.layer_ik'] = 12 + pbone = obj.pose.bones['thigh.L'] + pbone['leg_biped_generic.layer_fk'] = 11 + pbone = obj.pose.bones['thigh.R'] + pbone['type'] = 'leg_biped_generic' + pbone = obj.pose.bones['thigh.R'] + pbone['leg_biped_generic.layer_ik'] = 14 + pbone = obj.pose.bones['thigh.R'] + pbone['leg_biped_generic.layer_fk'] = 13 + pbone = obj.pose.bones['head'] + pbone['type'] = 'neck_flex' + pbone = obj.pose.bones['head'] + pbone['neck_flex.layer_extra'] = 4 + pbone = obj.pose.bones['head'] + pbone['neck_flex.layer_main'] = 3 + pbone = obj.pose.bones['DLT-shoulder.L'] + pbone['type'] = 'delta' + pbone = obj.pose.bones['DLT-shoulder.R'] + pbone['type'] = 'delta' + pbone = obj.pose.bones['shoulder.L'] + pbone['type'] = 'copy' + pbone = obj.pose.bones['shoulder.L'] + pbone['copy.layer'] = 1 + pbone = obj.pose.bones['shoulder.R'] + pbone['type'] = 'copy' + pbone = obj.pose.bones['shoulder.R'] + pbone['copy.layer'] = 1 + pbone = obj.pose.bones['DLT-upper_arm.L'] + pbone['type'] = 'delta' + pbone = obj.pose.bones['DLT-upper_arm.R'] + pbone['type'] = 'delta' + pbone = obj.pose.bones['upper_arm.L'] + pbone['type'] = 'arm_biped_generic' + pbone = obj.pose.bones['upper_arm.L'] + pbone['arm_biped_generic.elbow_parent'] = 'spine.04' + pbone = obj.pose.bones['upper_arm.L'] + pbone['arm_biped_generic.layer_fk'] = 7 + pbone = obj.pose.bones['upper_arm.L'] + pbone['arm_biped_generic.layer_ik'] = 8 + pbone = obj.pose.bones['upper_arm.R'] + pbone['type'] = 'arm_biped_generic' + pbone = obj.pose.bones['upper_arm.R'] + pbone['arm_biped_generic.layer_fk'] = 9 + pbone = obj.pose.bones['upper_arm.R'] + pbone['arm_biped_generic.layer_ik'] = 10 + pbone = obj.pose.bones['upper_arm.R'] + pbone['arm_biped_generic.elbow_parent'] = 'spine.04' + pbone = obj.pose.bones['palm.01.L'] + pbone['type'] = 'palm_curl' + pbone = obj.pose.bones['palm.01.L'] + pbone['palm_curl.layer'] = 5 + pbone = obj.pose.bones['thumb.01.L'] + pbone['type'] = 'finger_curl' + pbone = obj.pose.bones['thumb.01.L'] + pbone['finger_curl.layer_main'] = 5 + pbone = obj.pose.bones['thumb.01.L'] + pbone['finger_curl.layer_extra'] = 6 + pbone = obj.pose.bones['thumb.01.R'] + pbone['type'] = 'finger_curl' + pbone = obj.pose.bones['thumb.01.R'] + pbone['finger_curl.layer_main'] = 5 + pbone = obj.pose.bones['thumb.01.R'] + pbone['finger_curl.layer_extra'] = 6 + pbone = obj.pose.bones['palm.01.R'] + pbone['type'] = 'palm_curl' + pbone = obj.pose.bones['palm.01.R'] + pbone['palm_curl.layer'] = 5 + pbone = obj.pose.bones['finger_pinky.01.L'] + pbone['type'] = 'finger_curl' + pbone = obj.pose.bones['finger_pinky.01.L'] + pbone['finger_curl.layer_main'] = 5 + pbone = obj.pose.bones['finger_pinky.01.L'] + pbone['finger_curl.layer_extra'] = 6 + pbone = obj.pose.bones['finger_ring.01.L'] + pbone['type'] = 'finger_curl' + pbone = obj.pose.bones['finger_ring.01.L'] + pbone['finger_curl.layer_main'] = 5 + pbone = obj.pose.bones['finger_ring.01.L'] + pbone['finger_curl.layer_extra'] = 6 + pbone = obj.pose.bones['finger_middle.01.L'] + pbone['type'] = 'finger_curl' + pbone = obj.pose.bones['finger_middle.01.L'] + pbone['finger_curl.layer_main'] = 5 + pbone = obj.pose.bones['finger_middle.01.L'] + pbone['finger_curl.layer_extra'] = 6 + pbone = obj.pose.bones['finger_index.01.L'] + pbone['type'] = 'finger_curl' + pbone = obj.pose.bones['finger_index.01.L'] + pbone['finger_curl.layer_main'] = 5 + pbone = obj.pose.bones['finger_index.01.L'] + pbone['finger_curl.layer_extra'] = 6 + pbone = obj.pose.bones['finger_pinky.01.R'] + pbone['type'] = 'finger_curl' + pbone = obj.pose.bones['finger_pinky.01.R'] + pbone['finger_curl.layer_main'] = 5 + pbone = obj.pose.bones['finger_pinky.01.R'] + pbone['finger_curl.layer_extra'] = 6 + pbone = obj.pose.bones['finger_ring.01.R'] + pbone['type'] = 'finger_curl' + pbone = obj.pose.bones['finger_ring.01.R'] + pbone['finger_curl.layer_main'] = 5 + pbone = obj.pose.bones['finger_ring.01.R'] + pbone['finger_curl.layer_extra'] = 6 + pbone = obj.pose.bones['finger_middle.01.R'] + pbone['type'] = 'finger_curl' + pbone = obj.pose.bones['finger_middle.01.R'] + pbone['finger_curl.layer_main'] = 5 + pbone = obj.pose.bones['finger_middle.01.R'] + pbone['finger_curl.layer_extra'] = 6 + pbone = obj.pose.bones['finger_index.01.R'] + pbone['type'] = 'finger_curl' + pbone = obj.pose.bones['finger_index.01.R'] + pbone['finger_curl.layer_main'] = 5 + pbone = obj.pose.bones['finger_index.01.R'] + pbone['finger_curl.layer_extra'] = 6 + + +class AddHuman(bpy.types.Operator): + '''Add an advanced human metarig base.''' + bl_idname = "object.armature_human_advanced_add" + bl_label = "Add Humanoid (advanced metarig)" + bl_register = True + bl_undo = True + + def execute(self, context): + bpy.ops.object.armature_add() + obj = context.active_object + mode_orig = obj.mode + bpy.ops.object.mode_set(mode='EDIT') # grr, remove bone + bones = context.active_object.data.edit_bones + bones.remove(bones[0]) + metarig_template() + bpy.ops.object.mode_set(mode=mode_orig) + return ('FINISHED',) + +# Register the operator +bpy.ops.add(AddHuman) + +# Add to a menu +import dynamic_menu + +menu_func = (lambda self, context: self.layout.operator(AddHuman.bl_idname, icon='OUTLINER_OB_ARMATURE', text="Human (Meta-Rig)")) + +menu_item = dynamic_menu.add(bpy.types.INFO_MT_armature_add, menu_func) + +if __name__ == "__main__": + bpy.ops.mesh.armature_human_advanced_add() diff --git a/release/scripts/ui/properties_data_armature_rigify.py b/release/scripts/ui/properties_data_armature_rigify.py new file mode 100644 index 00000000000..e5fc1377d0f --- /dev/null +++ b/release/scripts/ui/properties_data_armature_rigify.py @@ -0,0 +1,352 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# <pep8 compliant> +import bpy + +narrowui = 180 + + +class PoseTemplateSettings(bpy.types.IDPropertyGroup): + pass + + +class PoseTemplate(bpy.types.IDPropertyGroup): + pass + +PoseTemplate.StringProperty(attr="name", + name="Name of the slave", + description="", + maxlen=64, + default="") + + +PoseTemplateSettings.CollectionProperty(attr="templates", type=PoseTemplate, name="Templates", description="") +PoseTemplateSettings.IntProperty(attr="active_template_index", + name="Index of the active slave", + description="", + default=-1, + min=-1, + max=65535) + +PoseTemplateSettings.BoolProperty(attr="generate_def_rig", + name="Create Deform Rig", + description="Create a copy of the metarig, constrainted by the generated rig", + default=False) + +bpy.types.Scene.PointerProperty(attr="pose_templates", type=PoseTemplateSettings, name="Network Render", description="Network Render Settings") + + +def metarig_templates(): + import rigify + return rigify.get_submodule_types() + + +class DATA_PT_template(bpy.types.Panel): + bl_label = "Meta-Rig Templates" + bl_space_type = 'PROPERTIES' + bl_region_type = 'WINDOW' + bl_context = "data" + bl_default_closed = True + + templates = [] + + def poll(self, context): + obj = context.object + if obj: + return (obj.mode in ('POSE', 'OBJECT')) + return False + + def draw(self, context): + layout = self.layout + try: + active_type = context.active_pose_bone["type"] + except: + active_type = None + + scene = context.scene + pose_templates = scene.pose_templates + + if pose_templates.active_template_index == -1: + pose_templates.active_template_index = 0 + + if not self.templates: + self.templates[:] = metarig_templates() + + while(len(pose_templates.templates) < len(self.templates)): + pose_templates.templates.add() + while(len(pose_templates.templates) > len(self.templates)): + pose_templates.templates.remove(0) + + for i, template_name in enumerate(self.templates): + template = pose_templates.templates[i] + if active_type == template_name: + template.name = "<%s>" % template_name.replace("_", " ") + else: + template.name = " %s " % template_name.replace("_", " ") + + row = layout.row() + row.operator("pose.metarig_generate", text="Generate") + row.operator("pose.metarig_validate", text="Check") + row.operator("pose.metarig_graph", text="Graph") + row = layout.row() + row.prop(pose_templates, "generate_def_rig") + + row = layout.row() + col = row.column() + col.template_list(pose_templates, "templates", pose_templates, "active_template_index", rows=1) + + subrow = col.split(percentage=0.5, align=True) + subsubrow = subrow.row(align=True) + subsubrow.operator("pose.metarig_assign", text="Assign") + subsubrow.operator("pose.metarig_clear", text="Clear") + + subsubrow = subrow.split(percentage=0.8) + subsubrow.operator("pose.metarig_sample_add", text="Sample").metarig_type = self.templates[pose_templates.active_template_index] + subsubrow.operator("pose.metarig_sample_add", text="All").metarig_type = "" # self.templates[pose_templates.active_template_index] + + sub = row.column(align=True) + sub.operator("pose.metarig_reload", icon="FILE_REFRESH", text="") + + +# operators +from bpy.props import StringProperty + + +class Reload(bpy.types.Operator): + '''Re-Scan the metarig package directory for scripts''' + + bl_idname = "pose.metarig_reload" + bl_label = "Re-Scan the list of metarig types" + + def execute(self, context): + DATA_PT_template.templates[:] = metarig_templates() + return ('FINISHED',) + + +def rigify_report_exception(operator, exception): + import traceback + import sys + import os + # find the module name where the error happened + # hint, this is the metarig type! + exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() + fn = traceback.extract_tb(exceptionTraceback)[-1][0] + fn = os.path.basename(fn) + fn = os.path.splitext(fn)[0] + message = [] + if fn.startswith("__"): + message.append("Incorrect armature...") + else: + message.append("Incorrect armature for type '%s'" % fn) + message.append(exception.message) + + message.reverse() # XXX - stupid! menu's are upside down! + + operator.report(set(['INFO']), '\n'.join(message)) + + +class Generate(bpy.types.Operator): + '''Generates a metarig from the active armature''' + + bl_idname = "pose.metarig_generate" + bl_label = "Generate Metarig" + + def execute(self, context): + import rigify + reload(rigify) + + meta_def = context.scene.pose_templates.generate_def_rig + + try: + rigify.generate_rig(context, context.object, META_DEF=meta_def) + except rigify.RigifyError as rig_exception: + rigify_report_exception(self, rig_exception) + + return ('FINISHED',) + + +class Validate(bpy.types.Operator): + '''Validate a metarig from the active armature''' + + bl_idname = "pose.metarig_validate" + bl_label = "Validate Metarig" + + def execute(self, context): + import rigify + reload(rigify) + try: + rigify.validate_rig(context, context.object) + except rigify.RigifyError as rig_exception: + rigify_report_exception(self, rig_exception) + return ('FINISHED',) + + +class Sample(bpy.types.Operator): + '''Create a sample metarig to be modified before generating the final rig.''' + + bl_idname = "pose.metarig_sample_add" + bl_label = "Re-Scan Metarig Scripts" + + metarig_type = StringProperty(name="Type", description="Name of the rig type to generate a sample of, a blank string for all", maxlen=128, default="") + + def execute(self, context): + import rigify + reload(rigify) + final = (self.properties.metarig_type == "") + objects = rigify.generate_test(context, metarig_type=self.properties.metarig_type, GENERATE_FINAL=final) + + if len(objects) > 1: + for i, (obj_meta, obj_gen) in enumerate(objects): + obj_meta.location.x = i * 1.0 + if obj_gen: + obj_gen.location.x = i * 1.0 + + return ('FINISHED',) + + +class Graph(bpy.types.Operator): + '''Create a graph from the active armature through graphviz''' + + bl_idname = "pose.metarig_graph" + bl_label = "Pose Graph" + + def execute(self, context): + import os + import graphviz_export + import bpy + reload(graphviz_export) + obj = bpy.context.object + path = os.path.splitext(bpy.data.filename)[0] + "-" + bpy.utils.clean_name(obj.name) + path_dot = path + ".dot" + path_png = path + ".png" + saved = graphviz_export.graph_armature(bpy.context.object, path_dot, CONSTRAINTS=False, DRIVERS=False) + + if saved: + # if we seriously want this working everywhere we'll need some new approach + #os.system("dot -Tpng %s > %s; gnome-open %s &" % (path_dot, path_png, path_png)) + os.system("python /b/xdot.py '%s' &" % path_dot) + + + return ('FINISHED',) + + +class AsScript(bpy.types.Operator): + '''Write the edit armature out as a python script''' + + bl_idname = "pose.metarig_to_script" + bl_label = "Write Metarig to Script" + bl_register = True + bl_undo = True + + path = StringProperty(name="File Path", description="File path used for exporting the Armature file", maxlen=1024, default="") + + def execute(self, context): + import rigify_utils + reload(rigify_utils) + obj = context.object + code = rigify_utils.write_meta_rig(obj) + path = self.properties.path + file = open(path, "w") + file.write(code) + file.close() + + return ('FINISHED',) + + def invoke(self, context, event): + import os + obj = context.object + self.properties.path = os.path.splitext(bpy.data.filename)[0] + "-" + bpy.utils.clean_name(obj.name) + ".py" + wm = context.manager + wm.add_fileselect(self) + return ('RUNNING_MODAL',) + + +# operators that use the GUI +class ActiveAssign(bpy.types.Operator): + '''Assign to the active posebone''' + + bl_idname = "pose.metarig_assign" + bl_label = "Assign to the active posebone" + + def poll(self, context): + bone = context.active_pose_bone + return bool(bone and bone.id_data.mode == 'POSE') + + def execute(self, context): + scene = context.scene + pose_templates = scene.pose_templates + template_name = DATA_PT_template.templates[pose_templates.active_template_index] + context.active_pose_bone["type"] = template_name + return ('FINISHED',) + + +class ActiveClear(bpy.types.Operator): + '''Clear type from the active posebone''' + + bl_idname = "pose.metarig_clear" + bl_label = "Metarig Clear Type" + + def poll(self, context): + bone = context.active_pose_bone + return bool(bone and bone.id_data.mode == 'POSE') + + def execute(self, context): + scene = context.scene + del context.active_pose_bone["type"] + return ('FINISHED',) + + +import space_info +import dynamic_menu + + +class INFO_MT_armature_metarig_add(dynamic_menu.DynMenu): + bl_idname = "INFO_MT_armature_metarig_add" + bl_label = "Meta-Rig" + + def draw(self, context): + import rigify + + layout = self.layout + layout.operator_context = 'INVOKE_REGION_WIN' + + for submodule_type in rigify.get_submodule_types(): + text = bpy.utils.display_name(submodule_type) + layout.operator("pose.metarig_sample_add", text=text, icon='OUTLINER_OB_ARMATURE').metarig_type = submodule_type + +bpy.types.register(DATA_PT_template) + +bpy.types.register(PoseTemplateSettings) +bpy.types.register(PoseTemplate) + +bpy.ops.add(Reload) +bpy.ops.add(Generate) +bpy.ops.add(Validate) +bpy.ops.add(Sample) +bpy.ops.add(Graph) +bpy.ops.add(AsScript) + +bpy.ops.add(ActiveAssign) +bpy.ops.add(ActiveClear) + + +bpy.types.register(INFO_MT_armature_metarig_add) + +menu_func = (lambda self, context: self.layout.menu("INFO_MT_armature_metarig_add", icon='OUTLINER_OB_ARMATURE')) +menu_item = dynamic_menu.add(bpy.types.INFO_MT_armature_add, menu_func) |