diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-12-10 14:56:31 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-12-10 14:56:31 +0300 |
commit | f26e188a7c049249b4b76e3af069f53ea0d08404 (patch) | |
tree | ed2566ba3623d7be0597d33c85ac2fcbcc8ee160 /release | |
parent | 901962c6213d896c2e8434b23cd2a3ffbc9a615a (diff) |
- rigify context changes & example for delta
- sequencer transform had 0.0 for rotation minimum
- missed icon rename in last commit
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/io/export_mdd.py | 2 | ||||
-rw-r--r-- | release/scripts/modules/graphviz_export.py | 2 | ||||
-rw-r--r-- | release/scripts/modules/rigify/__init__.py | 83 | ||||
-rw-r--r-- | release/scripts/modules/rigify/arm.py | 2 | ||||
-rw-r--r-- | release/scripts/modules/rigify/delta.py | 30 | ||||
-rw-r--r-- | release/scripts/modules/rigify/finger.py | 4 | ||||
-rw-r--r-- | release/scripts/modules/rigify/leg.py | 2 | ||||
-rw-r--r-- | release/scripts/modules/rigify/neck.py | 2 | ||||
-rw-r--r-- | release/scripts/modules/rigify/palm.py | 2 | ||||
-rw-r--r-- | release/scripts/modules/rigify/spine.py | 2 | ||||
-rw-r--r-- | release/scripts/modules/rna_prop_ui.py | 2 |
11 files changed, 98 insertions, 35 deletions
diff --git a/release/scripts/io/export_mdd.py b/release/scripts/io/export_mdd.py index c160b94e546..9753a63ce48 100644 --- a/release/scripts/io/export_mdd.py +++ b/release/scripts/io/export_mdd.py @@ -163,7 +163,7 @@ class ExportMDD(bpy.types.Operator): # List of operator properties, the attributes will be assigned # to the class instance from the operator settings before calling. - path = StringProperty(name="File Path", description="File path used for exporting the MDD file", maxlen= 1024, default= "tmp.mdd") + path = StringProperty(name="File Path", description="File path used for exporting the MDD file", maxlen= 1024, default= "") fps = IntProperty(name="Frames Per Second", description="Number of frames/second", min=minfps, max=maxfps, default= 25) start_frame = IntProperty(name="Start Frame", description="Start frame for baking", min=minframe,max=maxframe,default=1) end_frame = IntProperty(name="End Frame", description="End frame for baking", min=minframe, max=maxframe, default= 250) diff --git a/release/scripts/modules/graphviz_export.py b/release/scripts/modules/graphviz_export.py index 92eb427f8d2..e4bce9a85a9 100644 --- a/release/scripts/modules/graphviz_export.py +++ b/release/scripts/modules/graphviz_export.py @@ -48,7 +48,7 @@ def compat_str(text, line_length=0): #text = text.replace(']', ']\n') text = text.replace("\n", "\\n") text = text.replace('"', '\\"') - return "* " + text + return text def graph_armature(obj, path, FAKE_PARENT=True, CONSTRAINTS=True, DRIVERS=True, XTRA_INFO=True): diff --git a/release/scripts/modules/rigify/__init__.py b/release/scripts/modules/rigify/__init__.py index 2f099474990..224a8da2136 100644 --- a/release/scripts/modules/rigify/__init__.py +++ b/release/scripts/modules/rigify/__init__.py @@ -25,7 +25,7 @@ from Mathutils import Vector from rna_prop_ui import rna_idprop_ui_prop_get empty_layer = [False] * 32 - +DELIMITER = '-._' def auto_class(slots, name="ContainerClass", class_dict=None): @@ -300,7 +300,7 @@ def get_side_name(name): whether it is a a left or right (or center, or whatever) bone. Returns an empty string if nothing is found. ''' - if name[-2] in "-._": + if name[-2] in DELIMITER: return name[-2:] else: return "" @@ -310,7 +310,7 @@ def get_base_name(name): Returns the part of a string (typically a bone's name) corresponding to it's base name (no sidedness, no ORG prefix). ''' - if name[-2] in "-._": + if name[-2] in DELIMITER: return name[:-2] else: return name @@ -408,12 +408,34 @@ def add_pole_target_bone(obj, base_bone_name, name, mode='CROSS'): return poll_name +def validate_rig(context, obj): + for pbone in obj.pose.bones: + bone_name = pbone.name + bone_type = pbone.get("type", "") + + if bone_type: + bone_type_list = [bt for bt in bone_type.replace(",", " ").split()] + else: + bone_type_list = [] + + for bone_type in bone_type_list: + type_pair = bone_type.split(".") + submod_name = type_pair[0] + + submod = __import__(name="%s.%s" % (__package__, submod_name), fromlist=[submod_name]) + reload(submod) + + submod.metarig_definition(obj, bone_name) + + # missing, - check for duplicate root bone. + def generate_rig(context, obj_orig, prefix="ORG-", META_DEF=True): from collections import OrderedDict global_undo = context.user_preferences.edit.global_undo context.user_preferences.edit.global_undo = False + mode_orig = context.mode bpy.ops.object.mode_set(mode='OBJECT') @@ -495,8 +517,7 @@ def generate_rig(context, obj_orig, prefix="ORG-", META_DEF=True): # Only calculate bone definitions once if submod_name not in bone_def_dict: - metarig_definition_func = getattr(submod, "metarig_definition") - bone_def_dict[submod_name] = metarig_definition_func(obj, bone_name) + bone_def_dict[submod_name] = submod.metarig_definition(obj, bone_name) bone_typeinfo = bone_typeinfos.setdefault(bone_name, []) @@ -579,8 +600,10 @@ def generate_rig(context, obj_orig, prefix="ORG-", META_DEF=True): # obj.restrict_view = True obj.data.draw_axes = False - context.user_preferences.edit.global_undo = global_undo + bpy.ops.object.mode_set(mode=mode_orig) + context.user_preferences.edit.global_undo = global_undo + return obj @@ -594,7 +617,7 @@ def write_meta_rig(obj, func_name="metarig_template"): bpy.ops.object.mode_set(mode='EDIT') code.append(" bpy.ops.object.mode_set(mode='EDIT')") - code.append(" obj = bpy.context.object") + code.append(" obj = bpy.context.active_object") code.append(" arm = obj.data") arm = obj.data @@ -642,7 +665,7 @@ def write_meta_rig(obj, func_name="metarig_template"): return "\n".join(code) -def generate_test(context): +def generate_test(context, metarig_type="", GENERATE_FINAL=True): import os new_objects = [] @@ -654,6 +677,9 @@ def generate_test(context): obj_new.data = armature scene.objects.link(obj_new) scene.objects.active = obj_new + for obj in scene.objects: + obj.selected = False + obj_new.selected = True files = os.listdir(os.path.dirname(__file__)) for f in files: @@ -664,6 +690,10 @@ def generate_test(context): continue module_name = f[:-3] + + if (module_name and module_name != metarig_type): + continue + submodule = __import__(name="%s.%s" % (__package__, module_name), fromlist=[module_name]) metarig_template = getattr(submodule, "metarig_template", None) @@ -671,17 +701,21 @@ def generate_test(context): if metarig_template: create_empty_armature("meta_" + module_name) # sets active metarig_template() - obj = context.object - obj_new = generate_rig(context, obj) - - new_objects.append((obj, obj_new)) + obj = context.active_object + obj.location = scene.cursor_location + + if GENERATE_FINAL: + obj_new = generate_rig(context, obj) + new_objects.append((obj, obj_new)) + else: + new_objects.append((obj, None)) else: print("note: rig type '%s' has no metarig_template(), can't test this", module_name) return new_objects -def generate_test_all(context): +def generate_test_all(context, GRAPH=False): import rigify import graphviz_export import os @@ -689,18 +723,19 @@ def generate_test_all(context): reload(graphviz_export) new_objects = rigify.generate_test(context) + + if GRAPH: + base_name = os.path.splitext(bpy.data.filename)[0] + for obj, obj_new in new_objects: + for obj in (obj, obj_new): + fn = base_name + "-" + bpy.utils.clean_name(obj.name) - base_name = os.path.splitext(bpy.data.filename)[0] - for obj, obj_new in new_objects: - for obj in (obj, obj_new): - fn = base_name + "-" + bpy.utils.clean_name(obj.name) - - path_dot = fn + ".dot" - path_png = fn + ".png" - saved = graphviz_export.graph_armature(obj, path_dot, CONSTRAINTS=True, DRIVERS=True) + path_dot = fn + ".dot" + path_png = fn + ".png" + saved = graphviz_export.graph_armature(obj, path_dot, CONSTRAINTS=True, DRIVERS=True) - #if saved: - # os.system("dot -Tpng %s > %s; eog %s" % (path_dot, path_png, path_png)) + #if saved: + # os.system("dot -Tpng %s > %s; eog %s" % (path_dot, path_png, path_png)) i = 0 for obj, obj_new in new_objects: @@ -713,4 +748,4 @@ def generate_test_all(context): if __name__ == "__main__": - generate_rig(bpy.context, bpy.context.object) + generate_rig(bpy.context, bpy.context.active_object) diff --git a/release/scripts/modules/rigify/arm.py b/release/scripts/modules/rigify/arm.py index 35be7f34e4b..6a457a28ac2 100644 --- a/release/scripts/modules/rigify/arm.py +++ b/release/scripts/modules/rigify/arm.py @@ -29,7 +29,7 @@ METARIG_NAMES = "shoulder", "arm", "forearm", "hand" def metarig_template(): # generated by rigify.write_meta_rig bpy.ops.object.mode_set(mode='EDIT') - obj = bpy.context.object + obj = bpy.context.active_object arm = obj.data bone = arm.edit_bones.new('shoulder') bone.head[:] = 0.0000, -0.4515, 0.0000 diff --git a/release/scripts/modules/rigify/delta.py b/release/scripts/modules/rigify/delta.py index 00d79ed33df..974dcf3f6d5 100644 --- a/release/scripts/modules/rigify/delta.py +++ b/release/scripts/modules/rigify/delta.py @@ -25,6 +25,34 @@ from rigify import get_bone_data METARIG_NAMES = tuple() +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('bonesker') + bone.head[:] = 0.0000, 0.0000, 0.0000 + bone.tail[:] = -0.0000, 0.7382, 0.1895 + bone.roll = -0.0000 + bone.connected = False + bone = arm.edit_bones.new('delta') + bone.head[:] = -0.0497, 0.8414, 0.3530 + bone.tail[:] = -0.2511, 1.1588, 0.9653 + bone.roll = 2.6044 + bone.connected = False + bone.parent = arm.edit_bones['bonesker'] + bone = arm.edit_bones.new('boney') + bone.head[:] = 0.7940, 2.5592, 0.4134 + bone.tail[:] = 0.7940, 3.3975, 0.4890 + bone.roll = 3.1416 + bone.connected = False + bone.parent = arm.edit_bones['delta'] + + bpy.ops.object.mode_set(mode='OBJECT') + pbone = obj.pose.bones['delta'] + pbone['type'] = 'delta' + + def metarig_definition(obj, orig_bone_name): ''' The bone given is the head, its parent is the body, @@ -37,7 +65,7 @@ def metarig_definition(obj, orig_bone_name): children = delta.children if len(children) != 1: - print("only 1 child supported for delta") + raise Exception("only 1 child supported for delta on bone '%s'" % delta.name) bone_definition = [delta.name, children[0].name] diff --git a/release/scripts/modules/rigify/finger.py b/release/scripts/modules/rigify/finger.py index ad4206cc432..ae09652926b 100644 --- a/release/scripts/modules/rigify/finger.py +++ b/release/scripts/modules/rigify/finger.py @@ -28,7 +28,7 @@ METARIG_NAMES = "finger_01", "finger_02", "finger_03" def metarig_template(): bpy.ops.object.mode_set(mode='EDIT') - obj = bpy.context.object + obj = bpy.context.active_object arm = obj.data bone = arm.edit_bones.new('finger.01') bone.head[:] = 0.0000, 0.0000, 0.0000 @@ -73,7 +73,7 @@ def metarig_definition(obj, orig_bone_name): children = bone.children if len(children) != 1: - raise Exception("expected the chain to have 2 children without a fork") + raise Exception("expected the chain to have 2 children from bone '%s' without a fork" % orig_bone_name) bone = children[0] bone_definition.append(bone.name) # finger_02, finger_03 chain += 1 diff --git a/release/scripts/modules/rigify/leg.py b/release/scripts/modules/rigify/leg.py index aaed335f6c7..f4be80b0f9d 100644 --- a/release/scripts/modules/rigify/leg.py +++ b/release/scripts/modules/rigify/leg.py @@ -28,7 +28,7 @@ METARIG_NAMES = "hips", "thigh", "shin", "foot", "toe", "heel" def metarig_template(): # generated by rigify.write_meta_rig bpy.ops.object.mode_set(mode='EDIT') - obj = bpy.context.object + obj = bpy.context.active_object arm = obj.data bone = arm.edit_bones.new('hips') bone.head[:] = 0.0000, 0.0000, 0.0000 diff --git a/release/scripts/modules/rigify/neck.py b/release/scripts/modules/rigify/neck.py index 0aeee59225e..031806d2ea0 100644 --- a/release/scripts/modules/rigify/neck.py +++ b/release/scripts/modules/rigify/neck.py @@ -29,7 +29,7 @@ METARIG_NAMES = ("body", "head") def metarig_template(): # generated by rigify.write_meta_rig bpy.ops.object.mode_set(mode='EDIT') - obj = bpy.context.object + obj = bpy.context.active_object arm = obj.data bone = arm.edit_bones.new('body') bone.head[:] = -0.0000, -0.2771, -1.3345 diff --git a/release/scripts/modules/rigify/palm.py b/release/scripts/modules/rigify/palm.py index 078e3125b00..ed9eade2dff 100644 --- a/release/scripts/modules/rigify/palm.py +++ b/release/scripts/modules/rigify/palm.py @@ -28,7 +28,7 @@ METARIG_NAMES = tuple() def metarig_template(): # generated by rigify.write_meta_rig bpy.ops.object.mode_set(mode='EDIT') - obj = bpy.context.object + obj = bpy.context.active_object arm = obj.data bone = arm.edit_bones.new('hand') bone.head[:] = 0.0082, -1.2492, 0.0000 diff --git a/release/scripts/modules/rigify/spine.py b/release/scripts/modules/rigify/spine.py index ed42d6a2e46..cc65ae44e28 100644 --- a/release/scripts/modules/rigify/spine.py +++ b/release/scripts/modules/rigify/spine.py @@ -29,7 +29,7 @@ METARIG_NAMES = ("pelvis", "ribcage") def metarig_template(): # generated by rigify.write_meta_rig bpy.ops.object.mode_set(mode='EDIT') - obj = bpy.context.object + obj = bpy.context.active_object arm = obj.data bone = arm.edit_bones.new('pelvis') bone.head[:] = -0.0000, -0.2559, 0.8673 diff --git a/release/scripts/modules/rna_prop_ui.py b/release/scripts/modules/rna_prop_ui.py index dd71da74d35..07b3a7c1c42 100644 --- a/release/scripts/modules/rna_prop_ui.py +++ b/release/scripts/modules/rna_prop_ui.py @@ -120,7 +120,7 @@ def draw(layout, context, context_member, use_edit=True): prop = row.operator("wm.properties_edit", text="edit") assign_props(prop, val_draw, key) - prop = row.operator("wm.properties_remove", text="", icon='ICON_ZOOMOUT') + prop = row.operator("wm.properties_remove", text="", icon='ZOOMOUT') assign_props(prop, val_draw, key) |