[Bf-extensions-cvs] [8a3e171d] master: skinify rig: fixes for rigify by Karab44

meta-androcto noreply at git.blender.org
Wed Jul 12 03:05:44 CEST 2017


Commit: 8a3e171dabe636e089ed1f7beb2c09a101ab2afb
Author: meta-androcto
Date:   Wed Jul 12 11:05:13 2017 +1000
Branches: master
https://developer.blender.org/rBA8a3e171dabe636e089ed1f7beb2c09a101ab2afb

skinify rig: fixes for rigify by Karab44

===================================================================

M	object_skinify.py

===================================================================

diff --git a/object_skinify.py b/object_skinify.py
index 92e2a8ed..c62466f2 100644
--- a/object_skinify.py
+++ b/object_skinify.py
@@ -19,8 +19,8 @@
 bl_info = {
     "name": "Skinify Rig",
     "author": "Albert Makac (karab44)",
-    "version": (0, 8, 9),
-    "blender": (2, 7, 8),
+    "version": (0, 9, 0),
+    "blender": (2, 7, 9),
     "location": "Properties > Bone > Skinify Rig (visible on pose mode only)",
     "description": "Creates a mesh object from selected bones",
     "warning": "",
@@ -104,23 +104,47 @@ pitchipoy_data = \
 rigify_data = horse_data, shark_data, bird_data, cat_data, biped_data, human_data, \
               wolf_data, quadruped_data, human_legacy_data, pitchipoy_data
 
-
-class Rig_type(Enum):
-    HORSE = 0
-    SHARK = 1
-    BIRD = 2
-    CAT = 3
-    BIPED = 4
-    HUMAN = 5
-    WOLF = 6
-    QUAD = 7
-    LEGACY = 8
-    PITCHIPOY = 9
-    OTHER = 10
-
-
-rig_type = Rig_type.OTHER
-
+#Skin.rig_type.ENUM
+#Skin.junction_dict['bname'].data[0] idx, data[1] idx +1, data[2] thicnkess
+#NOTE each fragment contains section information about adequate bone junctions idx and idx + 1 and these vertices' ids share common thickness
+class Skin(object):
+    
+    class Rig_type(Enum):
+        HORSE = 0
+        SHARK = 1
+        BIRD = 2
+        CAT = 3
+        BIPED = 4
+        HUMAN = 5
+        WOLF = 6
+        QUAD = 7
+        LEGACY = 8
+        PITCHIPOY = 9
+        OTHER = 10
+    
+    def __init__(self, rig_type):
+        self.rig_type = rig_type
+        self.junctions_dict = dict()
+         
+            
+    def fragment_create(self, bname, idx = None, thickness = 0.0):
+        data = []
+        data.insert(0, idx)
+        
+        if idx != None:
+            data.insert(1, idx + 1)
+        else:
+            data.insert(1, None)            
+            
+        self.junctions_dict[bname] = data
+        self.junctions_dict[bname].append(thickness)
+   
+    #for the sake of code clarity     
+    def fragment_update(self, bname, idx = None, thickness = 0.0):
+        self.fragment_create(bname, idx, thickness)
+        
+
+rig_type = Skin.Rig_type.OTHER
 
 # initialize properties
 def init_props():
@@ -139,26 +163,9 @@ def init_props():
         scn.sub_level = 1
 
 
-# selects vertices
-def select_vertices(mesh_obj, idx):
-    bpy.context.scene.objects.active = mesh_obj
-    mode = mesh_obj.mode
-    bpy.ops.object.mode_set(mode='EDIT')
-    bpy.ops.mesh.select_all(action='DESELECT')
-    bpy.ops.object.mode_set(mode='OBJECT')
-
-    for i in idx:
-        mesh_obj.data.vertices[i].select = True
-
-    selectedVerts = [v.index for v in mesh_obj.data.vertices if v.select]
-
-    bpy.ops.object.mode_set(mode=mode)
-    return selectedVerts
-
-
 def identify_rig():
     if 'rigify_layers' not in bpy.context.object.data:
-        return Rig_type.OTHER  # non recognized
+        return Skin.Rig_type.OTHER  # non recognized
 
     LEGACY_LAYERS_SIZE = 28
     layers = bpy.context.object.data['rigify_layers']
@@ -175,35 +182,33 @@ def identify_rig():
             elif (props['row'] != rig[index][0]) or (props['group_prop'] != rig[index][1]):
                 break
 
-            # SUCCESS if reach the end
+            # SUCCESS if reaches the end
             if index == len(layers) - 1:
-                return Rig_type(type)
+                return Skin.Rig_type(type)
 
             index = index + 1
 
-    return Rig_type.OTHER
-
+    return Skin.Rig_type.OTHER
 
-def prepare_ignore_list(rig_type, bones):
-    # detect the head, face, hands, breast, heels or other exceptionary bones to exclusion or customization
+#prepares customizable ignore and thickness lists
+# edit these lists to suits your taste
+def prepare_lists(rig_type, finger_thickness):
+    
+  
+    # EXAMPLE IGNORE LIST
+    # detect the head, face, hands, breast, heels or other exceptionary bones for exclusion or customization
     common_ignore_list = ['eye', 'heel', 'breast', 'root']
-
-    # edit these lists to suits your taste
-
     horse_ignore_list = ['chest', 'belly', 'pelvis', 'jaw', 'nose', 'skull', 'ear.']
-
     shark_ignore_list = ['jaw']
-
     bird_ignore_list = [
             'face', 'pelvis', 'nose', 'lip', 'jaw', 'chin', 'ear.', 'brow',
             'lid', 'forehead', 'temple', 'cheek', 'teeth', 'tongue', 'beak'
             ]
     cat_ignore_list = [
-            'face', 'belly' 'pelvis.C', 'nose', 'lip', 'jaw', 'chin', 'ear.', 'brow',
+            'face', 'belly', 'pelvis.C', 'nose', 'lip', 'jaw', 'chin', 'ear.', 'brow',
             'lid', 'forehead', 'temple', 'cheek', 'teeth', 'tongue'
             ]
     biped_ignore_list = ['pelvis']
-
     human_ignore_list = [
             'face', 'pelvis', 'nose', 'lip', 'jaw', 'chin', 'ear.', 'brow',
             'lid', 'forehead', 'temple', 'cheek', 'teeth', 'tongue'
@@ -217,84 +222,119 @@ def prepare_ignore_list(rig_type, bones):
             'lid', 'forehead', 'temple', 'cheek', 'teeth', 'tongue'
             ]
     rigify_legacy_ignore_list = []
-
     pitchipoy_ignore_list = [
             'face', 'pelvis', 'nose', 'lip', 'jaw', 'chin', 'ear.', 'brow',
             'lid', 'forehead', 'temple', 'cheek', 'teeth', 'tongue'
             ]
-
     other_ignore_list = []
-
+    
+    # EXAMPLE THICKNESS
+    # feel free to modify and customize the list by adding elements followed by comma common_thickness_dict = {"hand": common_finger_thickness, "head": common_head_thickness}  
+    common_finger_thickness = finger_thickness  
+    common_thickness_dict = {"hand": common_finger_thickness}   
+    horse_thickness_dict = {}
+    shark_thickness_dict = {}
+    bird_thickness_dict = {}
+    cat_thickness_dict = {}
+    face_thickness = 0.20    
+    biped_thickness_dict = {}   
+    human_thickness_dict = {"face": face_thickness}   
+    wolf_thickness_dict = {}
+    quad_thickness_dict = {}       
+    rigify_legacy_thickness_dict = {} 
+    pitchipoy_thickness_dict = {"face": face_thickness}
+    other_thickness_dict = {}
+
+    
+    #combine lists depending on rig type
     ignore_list = common_ignore_list
-
-    if rig_type == Rig_type.HORSE:
+    thickness_dict = common_thickness_dict       
+    if rig_type == Skin.Rig_type.HORSE:
         ignore_list = ignore_list + horse_ignore_list
+        thickness_dict.update(horse_thickness_dict)
         print("RIDER OF THE APOCALYPSE")
-    elif rig_type == Rig_type.SHARK:
+    elif rig_type == Skin.Rig_type.SHARK:
         ignore_list = ignore_list + shark_ignore_list
+        thickness_dict.update(shark_thickness_dict)
         print("DEADLY JAWS")
-    elif rig_type == Rig_type.BIRD:
+    elif rig_type == Skin.Rig_type.BIRD:
         ignore_list = ignore_list + bird_ignore_list
+        thickness_dict.update(bird_thickness_dict)
         print("WINGS OF LIBERTY")
-    elif rig_type == Rig_type.CAT:
+    elif rig_type == Skin.Rig_type.CAT:
         ignore_list = ignore_list + cat_ignore_list
+        thickness_dict.update(cat_thickness_dict)
         print("MEOW")
-    elif rig_type == Rig_type.BIPED:
-        ignore_list = ignore_list + biped_ignore_list
+    elif rig_type == Skin.Rig_type.BIPED:
+        ignore_list = ignore_list + biped_ignore_list       
+        thickness_dict.update(biped_thickness_dict)       
         print("HUMANOID")
-    elif rig_type == Rig_type.HUMAN:
+    elif rig_type == Skin.Rig_type.HUMAN:
         ignore_list = ignore_list + human_ignore_list
+        thickness_dict.update(human_thickness_dict)       
         print("JUST A HUMAN AFTER ALL")
-    elif rig_type == Rig_type.WOLF:
+    elif rig_type == Skin.Rig_type.WOLF:
         ignore_list = ignore_list + wolf_ignore_list
+        thickness_dict.update(wolf_thickness_dict)
         print("WHITE FANG")
-    elif rig_type == Rig_type.QUAD:
+    elif rig_type == Skin.Rig_type.QUAD:
         ignore_list = ignore_list + quad_ignore_list
+        thickness_dict.update(quad_thickness_dict)
         print("MYSTERIOUS CREATURE")
-    elif rig_type == Rig_type.LEGACY:
+    elif rig_type == Skin.Rig_type.LEGACY:
         ignore_list = ignore_list + rigify_legacy_ignore_list
+        thickness_dict.update(rigify_legacy_thickness_dict)
         print("LEGACY RIGIFY")
-    elif rig_type == Rig_type.PITCHIPOY:
+    elif rig_type == Skin.Rig_type.PITCHIPOY:
         ignore_list = ignore_list + pitchipoy_ignore_list
+        thickness_dict.update(pitchipoy_thickness_dict)
         print("PITCHIPOY")
-    elif rig_type == Rig_type.OTHER:
+    elif rig_type == Skin.Rig_type.OTHER:
         ignore_list = ignore_list + other_ignore_list
+        thickness_dict.update(other_thickness_dict)
         print("rig non recognized...")
-
-    return ignore_list
+       
+    return ignore_list, thickness_dict
 
 
 # generates edges from vertices used by skin modifier
 def generate_edges(mesh, shape_object, bones, scale, connect_mesh=False, connect_parents=False,
-                   head_ornaments=False, generate_all=False):
+                   head_ornaments=False, generate_all=False, thickness = 0.0, finger_thickness = 0.0):
     """
-    This function adds vertices for all heads and tails
+    This function adds vertices for all bones' heads and tails
     """
-    # scene preferences
-
-    alternate_scale_list = []
-
+    
     me = mesh
     verts = []
     edges = []
     idx = 0
-    alternate_scale_idx_list = list()
-
+           
     rig_type = identify_rig()
-    ignore_list = prepare_ignore_list(rig_type, bones)
-
+    skin = Skin(rig_type)
+    
+    # prepare the list             
+    ignore_list, thickness_dict = prepare_lists(skin.rig_type, finger_thickness)
+  
+    #create default junctions for all bones
+    for b in bones:        
+        # set default thickness to all new junctions
+        skin.fragment_create(bname =  b.name, idx = None, thickness = thickness)
+    
     # edge generator loop
-    for b in bones:
-        # look for rig's hands and their childs
-        if 'hand' in b.name.lower():
-            # prepare the list
-            for c in b.children_recursive:
-                alternate_scale_list.append(c.name)
-
+    for b in bones:   
+        # look for rig's specific bones and their childs and set individual thickness
+   

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list