[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32711] trunk/blender/release/scripts: Removed old rigify code, as it is starting to interfere with the newer Rigify addon.

Nathan Vegdahl cessen at cessen.com
Tue Oct 26 07:07:10 CEST 2010


Revision: 32711
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32711
Author:   cessen
Date:     2010-10-26 07:07:09 +0200 (Tue, 26 Oct 2010)

Log Message:
-----------
Removed old rigify code, as it is starting to interfere with the newer Rigify addon.
The newer addon currently resides here: bzr://bzr.cessen.com/rigify
But will eventually be included in svn.

Removed Paths:
-------------
    trunk/blender/release/scripts/modules/rigify/
    trunk/blender/release/scripts/modules/rigify_utils.py
    trunk/blender/release/scripts/op/add_armature_human.py
    trunk/blender/release/scripts/ui/properties_data_armature_rigify.py

Deleted: trunk/blender/release/scripts/modules/rigify_utils.py
===================================================================
--- trunk/blender/release/scripts/modules/rigify_utils.py	2010-10-26 01:55:06 UTC (rev 32710)
+++ trunk/blender/release/scripts/modules/rigify_utils.py	2010-10-26 05:07:09 UTC (rev 32711)
@@ -1,467 +0,0 @@
-# ##### 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ##### END GPL LICENSE BLOCK #####
-
-# <pep8 compliant>
-
-# rigify its self does not depend on this module, however some of the
-# rigify templates use these utility functions.
-#
-# So even though this can be for general purpose use, this module was created
-# for rigify so in some cases seemingly generic functions make assumptions
-# that a generic function would need to check for.
-
-import bpy
-from mathutils import Vector
-from rna_prop_ui import rna_idprop_ui_prop_get
-
-DELIMITER = '-._'
-EMPTY_LAYER = [False] * 32
-
-
-def add_stretch_to(obj, from_name, to_name, name):
-    '''
-    Adds a bone that stretches from one to another
-    '''
-
-    mode_orig = obj.mode
-    bpy.ops.object.mode_set(mode='EDIT')
-
-    arm = obj.data
-    stretch_ebone = arm.edit_bones.new(name)
-    stretch_name = stretch_ebone.name
-    del name
-
-    head = stretch_ebone.head = arm.edit_bones[from_name].head.copy()
-    #tail = stretch_ebone.tail = arm.edit_bones[to_name].head.copy()
-
-    # annoying exception for zero length bones, since its using stretch_to the rest pose doesnt really matter
-    #if (head - tail).length < 0.1:
-    if 1:
-        tail = stretch_ebone.tail = arm.edit_bones[from_name].tail.copy()
-
-
-    # Now for the constraint
-    bpy.ops.object.mode_set(mode='OBJECT')
-
-    stretch_pbone = obj.pose.bones[stretch_name]
-
-    con = stretch_pbone.constraints.new('COPY_LOCATION')
-    con.target = obj
-    con.subtarget = from_name
-
-    con = stretch_pbone.constraints.new('STRETCH_TO')
-    con.target = obj
-    con.subtarget = to_name
-    con.rest_length = (head - tail).length
-    con.keep_axis = 'PLANE_X'
-    con.volume = 'NO_VOLUME'
-
-    bpy.ops.object.mode_set(mode=mode_orig)
-
-    return stretch_name
-
-
-def copy_bone_simple(arm, from_bone, name, parent=False):
-    ebone = arm.edit_bones[from_bone]
-    ebone_new = arm.edit_bones.new(name)
-
-    if parent:
-        ebone_new.use_connect = ebone.use_connect
-        ebone_new.parent = ebone.parent
-
-    ebone_new.head = ebone.head
-    ebone_new.tail = ebone.tail
-    ebone_new.roll = ebone.roll
-    ebone_new.layers = list(ebone.layers)
-    return ebone_new
-
-
-def copy_bone_simple_list(arm, from_bones, to_bones, parent=False):
-
-    if len(from_bones) != len(to_bones):
-        raise Exception("bone list sizes must match")
-
-    copy_bones = [copy_bone_simple(arm, bone_name, to_bones[i], True) for i, bone_name in enumerate(from_bones)]
-
-    # now we need to re-parent
-    for ebone in copy_bones:
-        parent = ebone.parent
-        if parent:
-            try:
-                i = from_bones.index(parent.name)
-            except:
-                i = -1
-
-            if i == -1:
-                ebone.parent = None
-            else:
-                ebone.parent = copy_bones[i]
-
-    return copy_bones
-
-
-def blend_bone_list(obj, apply_bones, from_bones, to_bones, target_bone=None, target_prop="blend", blend_default=0.5):
-
-    if obj.mode == 'EDIT':
-        raise Exception("blending cant be called in editmode")
-
-    if len(apply_bones) != len(from_bones):
-        raise Exception("lists differ in length (from -> apply): \n\t%s\n\t%s" % (from_bones, apply_bones))
-    if len(apply_bones) != len(to_bones):
-        raise Exception("lists differ in length (to -> apply): \n\t%s\n\t%s" % (to_bones, apply_bones))
-
-    # setup the blend property
-    if target_bone is None:
-        target_bone = apply_bones[-1] # default to the last bone
-
-    prop_pbone = obj.pose.bones[target_bone]
-    if prop_pbone.get(target_bone) is None:
-        prop = rna_idprop_ui_prop_get(prop_pbone, target_prop, create=True)
-        prop_pbone[target_prop] = blend_default
-        prop["soft_min"] = 0.0
-        prop["soft_max"] = 1.0
-
-    driver_path = prop_pbone.path_from_id() + ('["%s"]' % target_prop)
-
-    def blend_target(driver):
-        var = driver.variables.new()
-        var.name = target_bone
-        var.targets[0].id_type = 'OBJECT'
-        var.targets[0].id = obj
-        var.targets[0].data_path = driver_path
-
-    def blend_transforms(new_pbone, from_bone_name, to_bone_name):
-        con = new_pbone.constraints.new('COPY_TRANSFORMS')
-        con.target = obj
-        con.subtarget = from_bone_name
-
-        con = new_pbone.constraints.new('COPY_TRANSFORMS')
-        con.target = obj
-        con.subtarget = to_bone_name
-
-        fcurve = con.driver_add("influence")
-        driver = fcurve.driver
-        driver.type = 'AVERAGE'
-        fcurve.modifiers.remove(fcurve.modifiers[0]) # grr dont need a modifier
-
-        blend_target(driver)
-
-    for i, new_bone_name in enumerate(apply_bones):
-        from_bone_name = from_bones[i]
-        to_bone_name = to_bones[i]
-
-        # allow skipping some bones by having None in the list
-        if None in (new_bone_name, from_bone_name, to_bone_name):
-            continue
-
-        new_pbone = obj.pose.bones[new_bone_name]
-
-        blend_transforms(new_pbone, from_bone_name, to_bone_name)
-
-
-def add_pole_target_bone(obj, base_bone_name, name, mode='CROSS'):
-    '''
-    Does not actually create a poll target, just the bone to use as a poll target
-    '''
-    mode_orig = obj.mode
-    bpy.ops.object.mode_set(mode='EDIT')
-
-    arm = obj.data
-
-    poll_ebone = arm.edit_bones.new(name)
-    base_ebone = arm.edit_bones[base_bone_name]
-    poll_name = poll_ebone.name
-    parent_ebone = base_ebone.parent
-
-    base_head = base_ebone.head.copy()
-    base_tail = base_ebone.tail.copy()
-    base_dir = base_head - base_tail
-
-    parent_head = parent_ebone.head.copy()
-    parent_tail = parent_ebone.tail.copy()
-    parent_dir = parent_head - parent_tail
-
-    distance = (base_dir.length + parent_dir.length)
-
-    if mode == 'CROSS':
-        # direction from the angle of the joint
-        offset = base_dir.copy().normalize() - parent_dir.copy().normalize()
-        offset.length = distance
-    elif mode == 'ZAVERAGE':
-        # between both bones Z axis
-        z_axis_a = base_ebone.matrix.copy().rotation_part() * Vector((0.0, 0.0, -1.0))
-        z_axis_b = parent_ebone.matrix.copy().rotation_part() * Vector((0.0, 0.0, -1.0))
-        offset = (z_axis_a + z_axis_b).normalize() * distance
-    else:
-        # preset axis
-        offset = Vector((0.0, 0.0, 0.0))
-        if mode[0] == "+":
-            val = distance
-        else:
-            val = - distance
-
-        setattr(offset, mode[1].lower(), val)
-
-    poll_ebone.head = base_head + offset
-    poll_ebone.tail = base_head + (offset * (1.0 - (1.0 / 4.0)))
-
-    bpy.ops.object.mode_set(mode=mode_orig)
-
-    return poll_name
-
-
-def get_side_name(name):
-    '''
-    Returns the last part of a string (typically a bone's name) indicating
-    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 DELIMITER:
-        return name[-2:]
-    else:
-        return ""
-
-
-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 DELIMITER:
-        return name[:-2]
-    else:
-        return name
-
-
-def write_meta_rig(obj, func_name="metarig_template"):
-    '''
-    Write a metarig as a python script, this rig is to have all info needed for
-    generating the real rig with rigify.
-    '''
-    code = []
-
-    code.append("def %s():" % func_name)
-    code.append("    # generated by rigify.write_meta_rig")
-    bpy.ops.object.mode_set(mode='EDIT')
-    code.append("    bpy.ops.object.mode_set(mode='EDIT')")
-
-    code.append("    obj = bpy.context.active_object")
-    code.append("    arm = obj.data")
-
-    arm = obj.data
-    # write parents first
-    bones = [(len(bone.parent_recursive), bone.name) for bone in arm.edit_bones]
-    bones.sort(key=lambda item: item[0])
-    bones = [item[1] for item in bones]
-
-
-    for bone_name in bones:
-        bone = arm.edit_bones[bone_name]
-        code.append("    bone = arm.edit_bones.new('%s')" % bone.name)
-        code.append("    bone.head[:] = %.4f, %.4f, %.4f" % bone.head.to_tuple(4))
-        code.append("    bone.tail[:] = %.4f, %.4f, %.4f" % bone.tail.to_tuple(4))
-        code.append("    bone.roll = %.4f" % bone.roll)
-        code.append("    bone.use_connect = %s" % str(bone.use_connect))
-        if bone.parent:
-            code.append("    bone.parent = arm.edit_bones['%s']" % bone.parent.name)
-
-    bpy.ops.object.mode_set(mode='OBJECT')
-    code.append("")
-    code.append("    bpy.ops.object.mode_set(mode='OBJECT')")
-
-    for bone_name in bones:
-        pbone = obj.pose.bones[bone_name]
-        pbone_written = False
-
-        # Only 1 level of props, simple types supported
-        for key, value in pbone.items():
-            if key.startswith("_"):
-                continue
-
-            if type(value) not in (float, str, int):
-                print("Unsupported ID Prop:", str((key, value)))
-                continue
-
-            if type(value) == str:
-                value = "'" + value + "'"
-
-            if not pbone_written: # only write bones we need
-                code.append("    pbone = obj.pose.bones['%s']" % bone_name)
-
-            code.append("    pbone['%s'] = %s" % (key, value))
-
-    return "\n".join(code)
-
-

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list