[Bf-extensions-cvs] [eea66a63] blender-v2.79-release: object skinify, platform compatibility, Fix T52536
meta-androcto
noreply at git.blender.org
Mon Sep 4 15:39:41 CEST 2017
Commit: eea66a6388cdbf220a5b1fd03299a30415b1e0f2
Author: meta-androcto
Date: Tue Aug 29 21:09:14 2017 +1000
Branches: blender-v2.79-release
https://developer.blender.org/rBAeea66a6388cdbf220a5b1fd03299a30415b1e0f2
object skinify, platform compatibility, Fix T52536
===================================================================
M object_skinify.py
===================================================================
diff --git a/object_skinify.py b/object_skinify.py
index 02e7fadd..e2a7330a 100644
--- a/object_skinify.py
+++ b/object_skinify.py
@@ -19,7 +19,7 @@
bl_info = {
"name": "Skinify Rig",
"author": "Albert Makac (karab44)",
- "version": (0, 9, 2),
+ "version": (0, 9, 9),
"blender": (2, 7, 9),
"location": "Properties > Bone > Skinify Rig (visible on pose mode only)",
"description": "Creates a mesh object from selected bones",
@@ -46,7 +46,7 @@ from mathutils import (
)
from bpy.app.handlers import persistent
from enum import Enum
-
+import sys
# can the armature data properties group_prop and row be fetched directly from the rigify script?
horse_data = \
@@ -105,47 +105,91 @@ rigify_data = horse_data, shark_data, bird_data, cat_data, biped_data, human_dat
wolf_data, quadruped_data, human_legacy_data, pitchipoy_data
-# Skin.rig_type.ENUM
-# Skin.junction_dict['bname'].data[0] idx, data[1] idx + 1, data[2] thickness
-# 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):
+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
+#TODO this class contains temporary workaround needed due to https://developer.blender.org/T52536 but in general it's good and elegant solution
+# remove sys.platform idx variations after issue is solved
+class Idx_Store(object):
+ def __init__(self, rig_type, os_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 is not 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
+ self.hand_r_merge = []
+ self.hand_l_merge = []
+ self.hands_pretty = []
+ self.root = []
+
+ if not self.rig_type == Rig_type.LEGACY and not self.rig_type == Rig_type.HUMAN and not self.rig_type == Rig_type.PITCHIPOY:
+ return
+
+ if self.rig_type == Rig_type.LEGACY:
+ if os_type == 'win32':
+ self.hand_l_merge = [7, 8, 13, 17, 22, 27]
+ self.hand_r_merge = [30, 35, 39, 44, 45, 50]
+ self.hands_pretty = [6, 29]
+ self.root = [59]
+ print("WIN")
+ if os_type == 'linux':
+ self.hand_l_merge = [8, 9, 14, 18, 23, 28]
+ self.hand_r_merge = [31, 32, 37, 41, 46, 51]
+ self.hands_pretty = [7, 30]
+ self.root = [59]
+ print("LIN")
+ if os_type == 'darwin':
+ self.hand_l_merge = [7, 12, 16, 17, 22, 27]
+ self.hand_r_merge = [30, 35, 39, 40, 45, 50]
+ self.hands_pretty = [6, 29]
+ self.root = [59]
+ print("DARWIN")
+
+
+ if self.rig_type == Rig_type.HUMAN or self.rig_type == Rig_type.PITCHIPOY:
+ if os_type == 'win32':
+ self.hand_l_merge = [9, 14, 18, 23, 24, 29]
+ self.hand_r_merge = [32, 37, 41, 46, 51, 52]
+ self.hands_pretty = [8, 31]
+ self.root = [56]
+ print("WIN")
+ if os_type == 'linux':
+ self.hand_l_merge = [10, 11, 16, 20, 25, 30]
+ self.hand_r_merge = [33, 34, 39, 43, 48, 53]
+ self.hands_pretty = [9, 32]
+ self.root = [56]
+ print("LIN")
+ if os_type == 'darwin':
+ self.hand_l_merge = [10, 15, 19, 29, 24, 30]
+ self.hand_r_merge = [33, 38, 42, 47, 48, 53]
+ self.hands_pretty = [9, 32]
+ self.root = [56]
+
+ print("DARWIN")
+
+
+ def get_all_idx(self):
+ return self.hand_l_merge, self.hand_r_merge, self.hands_pretty, self.root
+
+ def get_hand_l_merge_idx(self):
+ return self.hand_l_merge
+
+ def get_hand_r_merge_idx(self):
+ return self.hand_r_merge
+
+ def get_hands_pretty_idx(self):
+ return self.hands_pretty
+
+ def get_root_idx(self):
+ return self.root
# initialize properties
@@ -165,9 +209,26 @@ 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 Skin.Rig_type.OTHER # non recognized
+ return Rig_type.OTHER # non recognized
LEGACY_LAYERS_SIZE = 28
layers = bpy.context.object.data['rigify_layers']
@@ -184,33 +245,35 @@ def identify_rig():
elif (props['row'] != rig[index][0]) or (props['group_prop'] != rig[index][1]):
break
- # SUCCESS if reaches the end
+ # SUCCESS if reach the end
if index == len(layers) - 1:
- return Skin.Rig_type(type)
+ return Rig_type(type)
index = index + 1
- return Skin.Rig_type.OTHER
-
+ return Rig_type.OTHER
-# 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
+def prepare_ignore_list(rig_type, bones):
+ # detect the head, face, hands, breast, heels or other exceptionary bones to 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'
@@ -224,119 +287,84 @@ def prepare_lists(rig_type, finger_thickness):
'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
- thickness_dict = common_thickness_dict
- if rig_type == Skin.Rig_type.HORSE:
+
+ if rig_type == Rig_type.HORSE:
ignore_list = ignore_list + horse_ignore_list
- thickness_dict.update(horse_thickness_dict)
print("RIDER OF THE APOCALYPSE")
- elif rig_type == Skin.Rig_type.SHARK:
+ elif rig_type == Rig_type.SHARK:
ignore_list = ignore_list + shark_ignore_list
- thickness_dict.update(shark_thickness_dict)
print("DEADLY JAWS")
- elif rig_type == Skin.Rig_type.BIRD:
+ elif rig_type == Rig_type.BIRD:
ignore_list = ignore_list + bird_ignore_list
- thickness_dict.update(bird_thickness_dict)
print("WINGS OF LIBERTY")
- elif rig_type == Skin.Rig_type.CAT:
+ elif rig_type == Rig_type.CAT:
ignore_list = ignore_list + cat_ignore_list
- thickness_dict.update(cat_thickness_dict)
print("MEOW")
- elif rig_type == Skin.Rig_type.BIPED:
+ elif rig_type == Rig_type.BIPED:
ignore_list = ignore_list + biped_ignore_list
- thickness_dict.update(biped_thickness_dict)
print("HUMANOID")
- elif rig_type == Skin.Rig_type.HUMAN:
+ elif rig_type == Rig_type.HUMAN:
ignore_list = ignore_list + human_ignore_list
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list