Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #396 from animate1978/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
animate1978 authored Jan 6, 2024
2 parents 99e08d0 + 51cd601 commit 7e7537f
Show file tree
Hide file tree
Showing 18 changed files with 3,074 additions and 1,297 deletions.
1,415 changes: 1,415 additions & 0 deletions HE_scalp_mesh.py

Large diffs are not rendered by default.

300 changes: 179 additions & 121 deletions __init__.py

Large diffs are not rendered by default.

1,158 changes: 654 additions & 504 deletions addon_updater.py

Large diffs are not rendered by default.

1,275 changes: 689 additions & 586 deletions addon_updater_ops.py

Large diffs are not rendered by default.

41 changes: 32 additions & 9 deletions algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,30 @@ def correct_morph(base_form, current_form, morph_deltas, bboxes):
# Functions
# ------------------------------------------------------------------------

def check_mesh(obj):
config_data = file_ops.get_configuration()
model_config = config_data.get(obj.get("manuellab_id"))
if not model_config:
logger.debug("check_obj %s model %s is not found", obj.name, obj.get("manuellab_id"))
return False

templates = {}
for template in config_data["templates_list"]:
tpl_conf = config_data.get(template)
if tpl_conf:
tpl_name = tpl_conf.get("template_model")
if tpl_name:
templates[tpl_name] = tpl_conf

tpl_config = templates.get(model_config.get("template_model"))
if not tpl_config:
logger.debug("check_obj %s template %s is not found", obj.name, model_config.get("template_model"))
return False
result = len(obj.data.vertices) == tpl_config.get("vertices") and len(obj.data.polygons) == tpl_config.get("faces")
if not result:
logger.debug("check_obj %s vertex/face count mismatch: %d %d %d %d", obj.name, len(obj.data.vertices), tpl_config.get("vertices"), len(obj.data.polygons), tpl_config.get("faces"))
return result

def looking_for_humanoid_obj():
"""
Looking for a mesh that is OK for the lab
Expand All @@ -345,8 +369,8 @@ def looking_for_humanoid_obj():
name = ""
for obj in bpy.data.objects:
if obj.type == "MESH":
if "manuellab_vers" in get_object_keys(obj):
if utils.check_version(obj["manuellab_vers"]):
if "manuellab_vers" in obj and "manuellab_id" in obj:
if utils.check_version(obj["manuellab_vers"]) and check_mesh(obj):
human_obj = obj
name = human_obj.name
break
Expand Down Expand Up @@ -1090,19 +1114,19 @@ def swap_material(old_mat_name, new_mat_name, char_name):
obj = bpy.data.objects[char_name]
if obj == None:
return None

#Try and get materials if either does not exist return None

try:

mat_old = bpy.data.materials[old_mat_name]
mat_new = bpy.data.materials[new_mat_name]

except:
logger.debug("Material not found")
return None


#Assign new material to old material slot
materialslen = len(obj.data.materials)
for i in range(0,materialslen):
Expand Down Expand Up @@ -1160,7 +1184,7 @@ def create_enum_property_items(values=[], key_length=3, tip_length=4):
values[i],
str(values[i])[0:tip_length]))
return return_list

def split_name(name, splitting_char=' -_²&=¨^$£%µ,?;!§+*/:[]\"\'{}', indexes=[]):
if len(splitting_char) < 1:
return name
Expand All @@ -1187,4 +1211,3 @@ def split(name, splitting_char=' -_²&=¨^$£%µ,?;!§+*/:[]\"\'{}'):
if len(t) > 0:
return_list.append(t)
return split(return_list, splitting_char[1:])

4 changes: 2 additions & 2 deletions creation_tools_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ def add_content(key, key_in, content):
"texture_tongue_albedo": "", "texture_teeth_albedo": "",
"texture_nails_albedo": "", "texture_eyelash_albedo": "",
"texture_frecklemask": "", "texture_blush": "",
"texture_sebum": "", "texture_lipmap": "", "texture_subdermal": "",
"texture_thickness": "", "texture_iris_color": "",
"texture_sebum": "", "texture_lipmap": "",
"texture_roughness": "", "texture_iris_color": "",
"texture_iris_bump": "", "texture_sclera_color": "",
"texture_translucent_mask": "", "texture_sclera_mask": "",
"morphs_extra_file": "", "shared_morphs_file": "",
Expand Down
34 changes: 17 additions & 17 deletions data/characters_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"texture_blush": "human_female_blush.png",
"texture_sebum": "human_female_sebum.png",
"texture_lipmap": "human_female_lipmap.png",
"texture_thickness": "human_female_thickness.png",
"texture_roughness": "human_female_roughness.png",
"texture_iris_color" : "iris_color.png",
"texture_iris_bump" : "iris_bump.png",
"texture_sclera_color" : "sclera_color.png",
Expand Down Expand Up @@ -113,7 +113,7 @@
"texture_blush": "human_female_blush.png",
"texture_sebum": "human_female_sebum.png",
"texture_lipmap": "human_female_lipmap.png",
"texture_thickness": "human_female_thickness.png",
"texture_roughness": "human_female_roughness.png",
"texture_iris_color" : "iris_color.png",
"texture_iris_bump" : "iris_bump.png",
"texture_sclera_color" : "sclera_color.png",
Expand Down Expand Up @@ -149,7 +149,7 @@
"texture_blush": "human_female_blush.png",
"texture_sebum": "human_female_sebum.png",
"texture_lipmap": "human_female_lipmap.png",
"texture_thickness": "human_female_thickness.png",
"texture_roughness": "human_female_roughness.png",
"texture_iris_color" : "iris_color.png",
"texture_iris_bump" : "iris_bump.png",
"texture_sclera_color" : "sclera_color.png",
Expand Down Expand Up @@ -185,7 +185,7 @@
"texture_blush": "human_female_blush.png",
"texture_sebum": "human_female_sebum.png",
"texture_lipmap": "human_female_lipmap.png",
"texture_thickness": "human_female_thickness.png",
"texture_roughness": "human_female_roughness.png",
"texture_iris_color" : "iris_color.png",
"texture_iris_bump" : "iris_bump.png",
"texture_sclera_color" : "sclera_color.png",
Expand Down Expand Up @@ -221,7 +221,7 @@
"texture_blush": "human_male_blush.png",
"texture_sebum": "human_male_sebum.png",
"texture_lipmap": "human_male_lipmap.png",
"texture_thickness": "human_male_thickness.png",
"texture_roughness": "human_male_roughness.png",
"texture_iris_color" : "iris_color.png",
"texture_iris_bump" : "iris_bump.png",
"texture_sclera_color" : "sclera_color.png",
Expand Down Expand Up @@ -257,7 +257,7 @@
"texture_blush": "human_male_blush.png",
"texture_sebum": "human_male_sebum.png",
"texture_lipmap": "human_male_lipmap.png",
"texture_thickness": "human_male_thickness.png",
"texture_roughness": "human_male_roughness.png",
"texture_iris_color" : "iris_color.png",
"texture_iris_bump" : "iris_bump.png",
"texture_sclera_color" : "sclera_color.png",
Expand Down Expand Up @@ -293,7 +293,7 @@
"texture_blush": "human_male_blush.png",
"texture_sebum": "human_male_sebum.png",
"texture_lipmap": "human_male_lipmap.png",
"texture_thickness": "human_male_thickness.png",
"texture_roughness": "human_male_roughness.png",
"texture_iris_color" : "iris_color.png",
"texture_iris_bump" : "iris_bump.png",
"texture_sclera_color" : "sclera_color.png",
Expand Down Expand Up @@ -329,7 +329,7 @@
"texture_blush": "human_male_blush.png",
"texture_sebum": "human_male_sebum.png",
"texture_lipmap": "human_male_lipmap.png",
"texture_thickness": "human_male_thickness.png",
"texture_roughness": "human_male_roughness.png",
"texture_iris_color" : "iris_color.png",
"texture_iris_bump" : "iris_bump.png",
"texture_sclera_color" : "sclera_color.png",
Expand Down Expand Up @@ -365,7 +365,7 @@
"texture_blush": "",
"texture_sebum": "",
"texture_lipmap": "",
"texture_thickness": "",
"texture_roughness": "",
"texture_iris_color" : "",
"texture_iris_bump" : "",
"texture_sclera_color" : "",
Expand Down Expand Up @@ -403,7 +403,7 @@
"texture_blush": "",
"texture_sebum": "",
"texture_lipmap": "",
"texture_thickness": "",
"texture_roughness": "",
"texture_iris_color" : "",
"texture_iris_bump" : "",
"texture_sclera_color" : "",
Expand Down Expand Up @@ -441,7 +441,7 @@
"texture_blush": "human_female_blush.png",
"texture_sebum": "human_female_sebum.png",
"texture_lipmap": "human_female_lipmap.png",
"texture_thickness": "human_female_thickness.png",
"texture_roughness": "human_female_roughness.png",
"texture_iris_color" : "iris_color.png",
"texture_iris_bump" : "iris_bump.png",
"texture_sclera_color" : "sclera_color.png",
Expand Down Expand Up @@ -477,7 +477,7 @@
"texture_blush": "",
"texture_sebum": "",
"texture_lipmap": "",
"texture_thickness": "",
"texture_roughness": "",
"texture_iris_color" : "",
"texture_iris_bump" : "",
"texture_sclera_color" : "",
Expand Down Expand Up @@ -515,7 +515,7 @@
"texture_blush": "",
"texture_sebum": "",
"texture_lipmap": "",
"texture_thickness": "",
"texture_roughness": "",
"texture_iris_color" : "",
"texture_iris_bump" : "",
"texture_sclera_color" : "",
Expand Down Expand Up @@ -553,7 +553,7 @@
"texture_blush": "human_male_blush.png",
"texture_sebum": "human_male_sebum.png",
"texture_lipmap": "human_male_lipmap.png",
"texture_thickness": "human_male_thickness.png",
"texture_roughness": "human_male_roughness.png",
"texture_iris_color" : "iris_color.png",
"texture_iris_bump" : "iris_bump.png",
"texture_sclera_color" : "sclera_color.png",
Expand Down Expand Up @@ -589,7 +589,7 @@
"texture_blush": "human_female_blush.png",
"texture_sebum": "human_female_sebum.png",
"texture_lipmap": "human_female_lipmap.png",
"texture_thickness": "human_female_thickness.png",
"texture_roughness": "human_female_roughness.png",
"texture_iris_color" : "iris_color.png",
"texture_iris_bump" : "iris_bump.png",
"texture_sclera_color" : "sclera_color.png",
Expand Down Expand Up @@ -625,7 +625,7 @@
"texture_blush": "human_male_blush.png",
"texture_sebum": "human_male_sebum.png",
"texture_lipmap": "human_male_lipmap.png",
"texture_thickness": "human_male_thickness.png",
"texture_roughness": "human_male_roughness.png",
"texture_iris_color" : "iris_color.png",
"texture_iris_bump" : "iris_bump.png",
"texture_sclera_color" : "sclera_color.png",
Expand Down Expand Up @@ -661,7 +661,7 @@
"texture_blush": "human_male_blush.png",
"texture_sebum": "human_male_sebum.png",
"texture_lipmap": "human_male_lipmap.png",
"texture_thickness": "human_male_thickness.png",
"texture_roughness": "human_male_roughness.png",
"texture_iris_color" : "iris_color.png",
"texture_iris_bump" : "iris_bump.png",
"texture_sclera_color" : "sclera_color.png",
Expand Down
Binary file modified data/humanoid_library.blend
Binary file not shown.
Binary file added data/textures/human_female_roughness.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/textures/human_male_roughness.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 22 additions & 19 deletions expressionscreator.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
logger = logging.getLogger(__name__)

class ExpressionsCreator():

def __init__(self):

self.standard_expressions_list = ["abdomExpansion_min", "abdomExpansion_max",
"browOutVertL_min", "browOutVertL_max", "browOutVertR_min",
"browOutVertR_max", "browsMidVert_min", "browsMidVert_max",
Expand Down Expand Up @@ -181,7 +181,7 @@ def __init__(self):
self.expression_ID_list = [("HU", "Humans", "Standard in MB-Lab"),
("AN", "Anime", "Standard in MB-Lab"),
("OT", "OTHER", "For another model")]

self.forbidden_char_list = '-_²&=¨^$£%µ,?;!§+*/'

self.expression_name = ["", "", 0]
Expand All @@ -200,14 +200,14 @@ def __init__(self):
# and create them only when model is changed.
# Used only BEFORE finalization of the model,
# in the Combined Expression Editor.

self.humanoid = None
# Instance of class Humanoid

#--------------Play with variables
def set_lab_version(self, lab_version):
self.lab_vers = list(lab_version)

def get_standard_expressions_list(self):
return self.standard_expressions_list

Expand Down Expand Up @@ -255,7 +255,7 @@ def get_expression_ID(self):

def get_expression_ID_list(self):
return self.expression_ID_list

def get_next_number(self):
self.expression_name[2] += 1
return str(self.expression_name[2]).zfill(3)
Expand All @@ -272,6 +272,9 @@ def set_expressions_modifiers(self, huma):
if len(self.expressions_modifiers) > 0:
return self.expressions_modifiers
category = self.humanoid.get_category("Expressions")
if not category:
logger.error("Expressions is aren't found in humanoid")
return
self.expressions_modifiers = category.get_modifier_tiny_name(self.body_parts_expr_list)

def get_expressions_modifiers(self):
Expand Down Expand Up @@ -302,7 +305,7 @@ def get_expressions_sub_categories(self):
sorted_list = sorted(list(self.expressions_modifiers.keys()))
self.expressions_sub_categories = algorithms.create_enum_property_items(sorted_list, tip_length=100)
return self.expressions_sub_categories

def is_comb_expression_exists(self, root_model, name):
if len(root_model) < 1 or len(name) < 1:
return False
Expand All @@ -315,7 +318,7 @@ def is_comb_expression_exists(self, root_model, name):
except:
return False
return False

#--------------EnumProperty for expressions in UI
#--------------AFTER finalization of the character

Expand All @@ -332,7 +335,7 @@ def get_expressions_items(self):

def get_expressions_item(self, key):
return algorithms.get_enum_property_item(key, self.editor_expressions_items)

#--------------Loading data
def get_all_expression_files(self, data_path, data_type_path, body_type):
#Get all files in morphs directory, with standard ones.
Expand All @@ -349,7 +352,7 @@ def get_all_expression_files(self, data_path, data_type_path, body_type):
found_files += [os.path.join(dir, item)]
return found_files

#--------------Saving all changed base expression in a filedef
#--------------Saving all changed base expression in a filedef
def save_face_expression(self, filepath):
# Save all expression morphs as a new face expression
# in its dedicated file.
Expand All @@ -365,36 +368,36 @@ def save_face_expression(self, filepath):
with open(filepath, "w") as j_file:
json.dump(char_data, j_file, indent=2)
j_file.close()

# data_source can be a filepath but also the data themselves.
def load_face_expression(self, data_source, reset_unassigned=True):

if self.humanoid == None:
return

obj = self.humanoid.get_object()
log_msg_type = "Expression data"

if isinstance(data_source, str):
log_msg_type = file_ops.simple_path(data_source)
charac_data = file_ops.load_json_data(data_source, "Expression data")
else:
charac_data = data_source

logger.info("Loading expression from {0}".format(log_msg_type))

if "manuellab_vers" in charac_data:
if not utils.check_version(charac_data["manuellab_vers"]):
logger.warning("{0} created with vers. {1}. Current vers is {2}".format(log_msg_type, charac_data["manuellab_vers"], self.lab_vers))
else:
logger.info("No lab version specified in {0}".format(log_msg_type))

if "structural" in charac_data:
char_data = charac_data["structural"]
else:
logger.warning("No structural data in {0}".format(log_msg_type))
char_data = {}

# data are loaded, now update the character.
if char_data is not None:
for name in self.humanoid.character_data.keys():
Expand Down
Loading

0 comments on commit 7e7537f

Please sign in to comment.