This repository has been archived by the owner on Jul 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 317
/
__init__.py
executable file
·6852 lines (6009 loc) · 293 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# MB-Lab
#
# MB-Lab fork website : https://github.com/animate1978/MB-Lab
#
# ##### 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 3
# 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 #####
#
# ManuelbastioniLAB - Copyright (C) 2015-2018 Manuel Bastioni
# MB-Lab Imports
import logging
import time
import datetime
import json
import os
import numpy
#from pathlib import Path
from math import radians, degrees
import bpy
from bpy.app.handlers import persistent
from bpy_extras.io_utils import ExportHelper, ImportHelper
#from . import addon_updater_ops
from . import algorithms
from . import animationengine
from . import creation_tools_ops
from . import expressionengine
from . import expressionscreator
from . import facerig
from . import file_ops
from . import hairengine
from . import humanoid
from . import humanoid_rotations
from . import jointscreator
from . import morphcreator
from . import node_ops
from . import numpy_ops
from . import object_ops
from . import proxyengine
from . import transfor
from . import utils
from . import preferences
from . import mesh_ops
from . import measurescreator
from . import skeleton_ops
from . import vgroupscreator
from . import HE_scalp_mesh
logger = logging.getLogger(__name__)
# MB-Lab Blender Info
#
bl_info = {
"name": "MB-Lab",
"author": "Manuel Bastioni, MB-Lab Community",
"version": (1, 8, 1),
"blender": (4, 0, 0),
"location": "View3D > Tools > MB-Lab",
"description": "Character creation tool based off of ManuelbastioniLAB",
"warning": "",
'doc_url': "https://mb-lab-docs.readthedocs.io/en/latest/index.html",
'tracker_url': 'https://github.com/animate1978/MB-Lab/issues',
"category": "Characters"
}
mblab_humanoid = humanoid.Humanoid(bl_info["version"])
mblab_retarget = animationengine.RetargetEngine()
mblab_shapekeys = expressionengine.ExpressionEngineShapeK()
mblab_proxy = proxyengine.ProxyEngine()
mbcrea_expressionscreator = expressionscreator.ExpressionsCreator()
mbcrea_transfor = transfor.Transfor(mblab_humanoid)
gui_status = "NEW_SESSION"
gui_err_msg = ""
gui_allows_other_modes = False
# GUI panels for MB-Lab
gui_active_panel = None
gui_active_panel_middle = None
gui_active_panel_display = None
gui_active_panel_fin = None
# GUI panels for MB-Dev
gui_active_panel_first = None
gui_active_panel_second = None
gui_active_panel_third = None
#Delete List
CY_Hshader_remove = []
UN_shader_remove = []
# BEGIN
def start_lab_session():
global mblab_humanoid
global gui_status, gui_err_msg
logger.info("Start_the lab session...")
file_ops.configuration_done = None # See variable in the file for more details
scn = bpy.context.scene
character_identifier = scn.mblab_character_name
rigging_type = "base"
if scn.mblab_use_ik:
rigging_type = "ik"
if scn.mblab_use_muscle:
rigging_type = "muscle"
if scn.mblab_use_muscle and scn.mblab_use_ik:
rigging_type = "muscle_ik"
lib_filepath = file_ops.get_blendlibrary_path()
obj = None
is_existing = False
is_obj = algorithms.looking_for_humanoid_obj()
if is_obj[0] == "ERROR":
gui_status = "ERROR_SESSION"
gui_err_msg = is_obj[1]
return
if is_obj[0] == "NO_OBJ":
base_model_name = mblab_humanoid.characters_config[character_identifier]["template_model"]
obj = file_ops.import_object_from_lib(lib_filepath, base_model_name, character_identifier)
if obj != None:
# obj can be None when a config file has missing data.
obj["manuellab_vers"] = bl_info["version"]
obj["manuellab_id"] = character_identifier
obj["manuellab_rig"] = rigging_type
if is_obj[0] == "FOUND":
obj = file_ops.get_object_by_name(is_obj[1])
character_identifier = obj["manuellab_id"]
rigging_type = obj["manuellab_rig"]
is_existing = True
if not obj:
logger.critical("Init failed...")
gui_status = "ERROR_SESSION"
gui_err_msg = "Init failed. Check the log file"
else:
mblab_humanoid.init_database(obj, character_identifier, rigging_type)
if mblab_humanoid.has_data:
gui_status = "ACTIVE_SESSION"
if scn.mblab_use_cycles or scn.mblab_use_eevee:
if scn.mblab_use_cycles:
scn.render.engine = 'CYCLES'
else:
scn.render.engine = 'BLENDER_EEVEE'
if scn.mblab_use_lamps:
object_ops.add_lighting()
else:
scn.render.engine = 'BLENDER_WORKBENCH'
logger.info("Rendering engine now is %s", scn.render.engine)
init_morphing_props(mblab_humanoid)
init_categories_props(mblab_humanoid)
init_measures_props(mblab_humanoid)
init_restposes_props(mblab_humanoid)
init_presets_props(mblab_humanoid)
init_ethnic_props(mblab_humanoid)
init_metaparameters_props(mblab_humanoid)
init_material_parameters_props(mblab_humanoid)
mblab_humanoid.update_materials()
if is_existing:
logger.info("Re-init the character %s", obj.name)
mblab_humanoid.store_mesh_in_cache()
mblab_humanoid.reset_mesh()
mblab_humanoid.recover_prop_values_from_obj_attr()
mblab_humanoid.restore_mesh_from_cache()
else:
mblab_humanoid.reset_mesh()
mblab_humanoid.update_character(mode="update_all")
# All inits for creation tools.
morphcreator.init_morph_names_database()
mbcrea_expressionscreator.reset_expressions_items()
mbcrea_transfor.set_scene(scn)
init_cmd_props(mblab_humanoid)
measurescreator.init_all()
creation_tools_ops.init_config()
# End for that.
algorithms.deselect_all_objects()
algorithms.remove_censors()
@persistent
def check_manuelbastionilab_session(dummy):
global mblab_humanoid
global gui_status, gui_err_msg
scn = bpy.context.scene
if mblab_humanoid:
# init_femaleposes_props()
# init_maleposes_props()
gui_status = "NEW_SESSION"
is_obj = algorithms.looking_for_humanoid_obj()
if is_obj[0] == "FOUND":
# gui_status = "RECOVERY_SESSION"
# if scn.do_not_ask_again:
start_lab_session()
if is_obj[0] == "ERROR":
gui_status = "ERROR_SESSION"
gui_err_msg = is_obj[1]
return
bpy.app.handlers.load_post.append(check_manuelbastionilab_session)
def sync_character_to_props():
# It's important to avoid problems with Blender undo system
global mblab_humanoid
mblab_humanoid.sync_character_data_to_obj_props()
mblab_humanoid.update_character()
def realtime_update(self, context):
"""
Update the character while the prop slider moves.
"""
global mblab_humanoid
if mblab_humanoid.bodydata_realtime_activated:
# time1 = time.time()
scn = bpy.context.scene
mblab_humanoid.update_character(category_name=scn.morphingCategory, mode="update_realtime")
#Teto
# Dirty, but I didn't want to touch the code too much.
# I tried things, but I am pretty sure that they would
# bring inconsistencies when changing model without
# quitting Blender.
# So we always update expressions category, because same
# prop are used in "facial expression creator".
if scn.morphingCategory != "Expressions":
mblab_humanoid.update_character(category_name="Expressions", mode="update_realtime")
#End Teto
mblab_humanoid.sync_gui_according_measures()
# print("realtime_update: {0}".format(time.time()-time1))
def age_update(self, context):
global mblab_humanoid
time1 = time.time()
if mblab_humanoid.metadata_realtime_activated:
time1 = time.time()
mblab_humanoid.calculate_transformation("AGE")
def mass_update(self, context):
global mblab_humanoid
if mblab_humanoid.metadata_realtime_activated:
mblab_humanoid.calculate_transformation("FAT")
def tone_update(self, context):
global mblab_humanoid
if mblab_humanoid.metadata_realtime_activated:
mblab_humanoid.calculate_transformation("MUSCLE")
def modifiers_update(self, context):
sync_character_to_props()
def set_cycles_render_engine(self, context):
if context.scene.mblab_use_cycles:
context.scene.mblab_use_eevee = False
def set_eevee_render_engine(self, context):
if context.scene.mblab_use_eevee:
context.scene.mblab_use_cycles = False
def preset_update(self, context):
"""
Update the character while prop slider moves
"""
scn = bpy.context.scene
global mblab_humanoid
obj = mblab_humanoid.get_object()
filepath = os.path.join(
mblab_humanoid.presets_path,
"".join([obj.preset, ".json"]))
mblab_humanoid.load_character(filepath, mix=scn.mblab_mix_characters)
def ethnic_update(self, context):
scn = bpy.context.scene
global mblab_humanoid
obj = mblab_humanoid.get_object()
filepath = os.path.join(
mblab_humanoid.phenotypes_path,
"".join([obj.ethnic, ".json"]))
mblab_humanoid.load_character(filepath, mix=scn.mblab_mix_characters)
def material_update(self, context):
global mblab_humanoid
if mblab_humanoid.material_realtime_activated:
mblab_humanoid.update_materials(update_textures_nodes=False)
def measure_units_update(self, context):
global mblab_humanoid
mblab_humanoid.sync_gui_according_measures()
def human_expression_update(self, context):
global mblab_shapekeys
scn = bpy.context.scene
mblab_shapekeys.sync_expression_to_gui()
def restpose_update(self, context):
global mblab_humanoid
armature = mblab_humanoid.get_armature()
filepath = os.path.join(
mblab_humanoid.restposes_path,
"".join([armature.rest_pose, ".json"]))
mblab_retarget.load_pose(filepath, armature)
def malepose_update(self, context):
global mblab_retarget
armature = utils.get_active_armature()
filepath = os.path.join(
mblab_retarget.maleposes_path,
"".join([armature.male_pose, ".json"]))
mblab_retarget.load_pose(filepath, use_retarget=True)
def femalepose_update(self, context):
global mblab_retarget
armature = utils.get_active_armature()
filepath = os.path.join(
mblab_retarget.femaleposes_path,
"".join([armature.female_pose, ".json"]))
mblab_retarget.load_pose(filepath, use_retarget=True)
def init_morphing_props(humanoid_instance):
for prop in humanoid_instance.character_data:
setattr(
bpy.types.Object,
prop,
bpy.props.FloatProperty(
name=prop.split("_")[1],
min=-5.0,
max=5.0,
soft_min=0.0,
soft_max=1.0,
precision=3,
default=0.5,
subtype='FACTOR',
update=realtime_update))
def init_cmd_props(humanoid_instance):
for prop in morphcreator.get_all_cmd_attr_names(humanoid_instance):
setattr(
bpy.types.Object,
prop,
bpy.props.BoolProperty(
name=prop.split("_")[2],
default=False))
def init_measures_props(humanoid_instance):
for measure_name, measure_val in humanoid_instance.morph_engine.measures.items():
setattr(
bpy.types.Object,
measure_name,
bpy.props.FloatProperty(
name=measure_name, min=0.0, max=500.0,
subtype='FACTOR',
default=measure_val))
humanoid_instance.sync_gui_according_measures()
#Teto
def get_categories_enum(exclude=[]):
categories_enum = []
# All categories for "Body Measures"
for category in mblab_humanoid.get_categories(exclude):
categories_enum.append(
(category.name, category.name, category.name))
return categories_enum
def init_categories_props(humanoid_instance):
global mbcrea_expressionscreator
bpy.types.Scene.morphingCategory = bpy.props.EnumProperty(
items=get_categories_enum(),
update=modifiers_update,
name="Morphing categories")
# Sub-categories for "Facial expressions"
mbcrea_expressionscreator.set_expressions_modifiers(mblab_humanoid)
sub_categories_enum = mbcrea_expressionscreator.get_expressions_sub_categories()
bpy.types.Scene.expressionsSubCategory = bpy.props.EnumProperty(
items=sub_categories_enum,
update=modifiers_update,
name="Expressions sub-categories")
# Special properties used by transfor.Transfor
bpy.types.Scene.transforMorphingCategory = bpy.props.EnumProperty(
items=get_categories_enum(["Expressions"]),
update=modifiers_update,
name="Morphing categories")
#End Teto
def init_restposes_props(humanoid_instance):
if humanoid_instance.exists_rest_poses_database():
restpose_items = file_ops.generate_items_list(humanoid_instance.restposes_path)
bpy.types.Object.rest_pose = bpy.props.EnumProperty(
items=restpose_items,
name="Rest pose",
default=restpose_items[0][0],
update=restpose_update)
def init_maleposes_props():
global mblab_retarget
if mblab_retarget.maleposes_exist:
if not hasattr(bpy.types.Object, 'male_pose'):
malepose_items = file_ops.generate_items_list(mblab_retarget.maleposes_path)
bpy.types.Object.male_pose = bpy.props.EnumProperty(
items=malepose_items,
name="Male pose",
default=malepose_items[0][0],
update=malepose_update)
def init_femaleposes_props():
global mblab_retarget
if mblab_retarget.femaleposes_exist:
if not hasattr(bpy.types.Object, 'female_pose'):
femalepose_items = file_ops.generate_items_list(mblab_retarget.femaleposes_path)
bpy.types.Object.female_pose = bpy.props.EnumProperty(
items=femalepose_items,
name="Female pose",
default=femalepose_items[0][0],
update=femalepose_update)
def init_expression_props():
for expression_name in mblab_shapekeys.expressions_labels:
if not hasattr(bpy.types.Object, expression_name):
setattr(
bpy.types.Object,
expression_name,
bpy.props.FloatProperty(
name=expression_name,
min=0.0,
max=1.0,
precision=3,
default=0.0,
subtype='FACTOR',
update=human_expression_update))
def init_presets_props(humanoid_instance):
if humanoid_instance.exists_preset_database():
preset_items = file_ops.generate_items_list(humanoid_instance.presets_path)
bpy.types.Object.preset = bpy.props.EnumProperty(
items=preset_items,
name="Types",
update=preset_update)
def init_ethnic_props(humanoid_instance):
if humanoid_instance.exists_phenotype_database():
ethnic_items = file_ops.generate_items_list(humanoid_instance.phenotypes_path)
bpy.types.Object.ethnic = bpy.props.EnumProperty(
items=ethnic_items,
name="Phenotype",
update=ethnic_update)
def init_metaparameters_props(humanoid_instance):
for meta_data_prop in humanoid_instance.character_metaproperties.keys():
upd_function = None
if "age" in meta_data_prop:
upd_function = age_update
if "mass" in meta_data_prop:
upd_function = mass_update
if "tone" in meta_data_prop:
upd_function = tone_update
if "last" in meta_data_prop:
upd_function = None
if "last_" not in meta_data_prop:
setattr(
bpy.types.Object,
meta_data_prop,
bpy.props.FloatProperty(
name=meta_data_prop, min=-1.0, max=1.0,
precision=3,
default=0.0,
subtype='FACTOR',
update=upd_function))
def init_material_parameters_props(humanoid_instance):
for material_data_prop, value in humanoid_instance.character_material_properties.items():
setattr(
bpy.types.Object,
material_data_prop,
bpy.props.FloatProperty(
name=material_data_prop,
min=0.0,
max=1.0,
precision=2,
subtype='FACTOR',
update=material_update,
default=value))
def angle_update_0(self, context):
global mblab_retarget
scn = bpy.context.scene
value = scn.mblab_rot_offset_0
mblab_retarget.correct_bone_angle(0, value)
def angle_update_1(self, context):
global mblab_retarget
scn = bpy.context.scene
value = scn.mblab_rot_offset_1
mblab_retarget.correct_bone_angle(1, value)
def angle_update_2(self, context):
global mblab_retarget
scn = bpy.context.scene
value = scn.mblab_rot_offset_2
mblab_retarget.correct_bone_angle(2, value)
def get_character_items(self, context):
items = []
for obj in bpy.data.objects:
if obj.type == 'MESH':
if algorithms.get_template_model(obj) is not None:
items.append((obj.name, obj.name, obj.name))
return items
def get_proxy_items(self, context):
items = []
for obj in bpy.data.objects:
if obj.type == 'MESH':
if algorithms.get_template_model(obj) is None:
items.append((obj.name, obj.name, obj.name))
if len(items) == 0:
items = [("NO_PROXY_FOUND", "No proxy found", "No proxy found")]
return items
def get_proxy_items_from_library(self, context):
items = mblab_proxy.assets_models
return items
def update_proxy_library(self, context):
mblab_proxy.update_assets_models()
def load_proxy_item(self, context):
scn = bpy.context.scene
mblab_proxy.load_asset(scn.mblab_assets_models)
#Choose Hair Colors
def hair_style_list(self, context):
scn = bpy.context.scene
if scn.mblab_use_cycles: #and context.scene.mblab_use_pHair:
fileName = hairengine.get_hair_npz('CY_shader_presets.npz')
data = node_ops.get_universal_dict(fileName)
dat = data['arr_0'].tolist()
items = dat
else:
fileName = hairengine.get_hair_npz('universal_hair_shader.npz')
items = node_ops.get_universal_list(fileName)
#[(identifier, name, description, icon, number)
return [(i, i, i) for i in items]
# MB-Lab Properties
bpy.types.Scene.mblab_proxy_library = bpy.props.StringProperty(
name="Library folder",
description="Folder with assets blend files",
default="",
maxlen=1024,
update=update_proxy_library,
subtype='DIR_PATH')
bpy.types.Scene.mblab_fitref_name = bpy.props.EnumProperty(
items=get_character_items,
name="Character")
bpy.types.Scene.mblab_proxy_name = bpy.props.EnumProperty(
items=get_proxy_items,
name="Proxy")
bpy.types.Scene.mblab_final_prefix = bpy.props.StringProperty(
name="Prefix",
description="The prefix of names for finalized model, skeleton and materials. If none, it will be generated automatically",
default="")
bpy.types.Scene.mblab_rot_offset_0 = bpy.props.FloatProperty(
name="Tweak rot X",
min=-1,
max=1,
precision=2,
subtype='FACTOR',
update=angle_update_0,
default=0.0)
bpy.types.Scene.mblab_rot_offset_1 = bpy.props.FloatProperty(
name="Tweak rot Y",
min=-1,
max=1,
precision=2,
subtype='FACTOR',
update=angle_update_1,
default=0.0)
bpy.types.Scene.mblab_rot_offset_2 = bpy.props.FloatProperty(
name="Tweak rot Z",
min=-1,
max=1,
precision=2,
subtype='FACTOR',
update=angle_update_2,
default=0.0)
bpy.types.Scene.mblab_proxy_offset = bpy.props.FloatProperty(
name="Offset",
min=0,
max=100,
subtype='FACTOR',
default=0)
bpy.types.Scene.mblab_proxy_threshold = bpy.props.FloatProperty(
name="Influence",
min=0,
max=1000,
default=20,
subtype='FACTOR',
description="Maximum distance threshold for proxy vertices to closely follow the body surface")
bpy.types.Scene.mblab_proxy_use_advanced = bpy.props.BoolProperty(
name="Advanced",
default=False,
description="Use advanced options")
bpy.types.Scene.mblab_proxy_reverse_fit = bpy.props.BoolProperty(
name="Reversed fitting",
default=False,
description="Refit the mesh from the character to the base mesh, as a step in converting a character-specific item to a generic proxy")
bpy.types.Scene.mblab_proxy_use_all_faces = bpy.props.BoolProperty(
name="Use all faces",
default=False,
description="Use all base mesh faces for close fitting, including insides of the mouth etc")
bpy.types.Scene.mblab_proxy_no_smoothing = bpy.props.BoolProperty(
name="Disable smoothing",
default=False,
description="Disable additional smoothing applied to the fitting results")
bpy.types.Scene.mblab_use_ik = bpy.props.BoolProperty(
name="Use Inverse Kinematic",
default=False,
description="Use inverse kinematic armature")
bpy.types.Scene.mblab_use_muscle = bpy.props.BoolProperty(
name="Use basic muscles",
default=False,
description="Use basic muscle armature")
bpy.types.Scene.mblab_remove_all_modifiers = bpy.props.BoolProperty(
name="Remove modifiers",
default=False,
description="If checked, all the modifiers will be removed, except the armature (displacement, subdivision, corrective smooth, etc)")
bpy.types.Scene.mblab_use_cycles = bpy.props.BoolProperty(
name="Use Cycles engine",
default=True,
update=set_cycles_render_engine,
description="This is needed in order to use the skin editor and shaders (highly recommended)")
bpy.types.Scene.mblab_use_eevee = bpy.props.BoolProperty(
name="Use EEVEE engine",
default=False,
update=set_eevee_render_engine,
description="This is needed in order to use the skin editor and shaders")
bpy.types.Scene.mblab_use_lamps = bpy.props.BoolProperty(
name="Use portrait studio lights",
default=False,
description="Add a set of lights optimized for portrait. Useful during the design of skin (recommended)")
bpy.types.Scene.mblab_show_measures = bpy.props.BoolProperty(
name="Measurements",
description="Show measures controls",
update=modifiers_update)
bpy.types.Scene.mblab_measure_filter = bpy.props.StringProperty(
name="Filter",
default="",
description="Filter the measures to show")
bpy.types.Scene.mblab_expression_filter = bpy.props.StringProperty(
name="Filter",
default="",
description="Filter the expressions to show")
#Teto
def mbcrea_enum_expressions_items_update(self, context):
return mbcrea_expressionscreator.get_expressions_items()
bpy.types.Scene.mbcrea_enum_expressions_items = bpy.props.EnumProperty(
items=mbcrea_enum_expressions_items_update,
name="",
default=None,
options={'ANIMATABLE'},
)
#End Teto
bpy.types.Scene.mblab_mix_characters = bpy.props.BoolProperty(
name="Mix with current",
description="Mix templates")
bpy.types.Scene.mblab_template_name = bpy.props.EnumProperty(
items=mblab_humanoid.template_types,
name="Select",
default="human_female_base")
def mbcrea_root_directories_update(self, context):
global mblab_humanoid
global mblab_retarget
global mblab_shapekeys
global mblab_proxy
global mbcrea_expressionscreator
global mbcrea_transfor
file_ops.set_data_path(bpy.context.scene.mbcrea_root_data)
mblab_humanoid = humanoid.Humanoid(bl_info["version"])
mblab_retarget = animationengine.RetargetEngine()
mblab_shapekeys = expressionengine.ExpressionEngineShapeK()
mblab_proxy = proxyengine.ProxyEngine()
mbcrea_expressionscreator = expressionscreator.ExpressionsCreator()
mbcrea_transfor = transfor.Transfor(mblab_humanoid)
bpy.types.Scene.mbcrea_root_data = bpy.props.EnumProperty(
items=file_ops.get_root_directories(),
name="Project",
update=mbcrea_root_directories_update,
default="data")
def update_characters_name(self, context):
global mblab_humanoid
return mblab_humanoid.humanoid_types
bpy.types.Scene.mblab_character_name = bpy.props.EnumProperty(
items=update_characters_name,
name="Select",
default=None)
bpy.types.Scene.mblab_assets_models = bpy.props.EnumProperty(
items=get_proxy_items_from_library,
update=load_proxy_item,
name="Assets model")
bpy.types.Scene.mblab_transfer_proxy_weights = bpy.props.BoolProperty(
name="Transfer weights from body to proxy (replace existing)",
description="If the proxy has already rigging weights, they will be replaced with the weights projected from the character body",
default=True)
bpy.types.Scene.mblab_save_images_and_backup = bpy.props.BoolProperty(
name="Save images and backup character",
description="Save all images from the skin shader and backup the character in json format",
default=True)
bpy.types.Object.mblab_use_inch = bpy.props.BoolProperty(
name="Inch",
update=measure_units_update,
description="Use inch instead of cm")
bpy.types.Scene.mblab_export_proportions = bpy.props.BoolProperty(
name="Include proportions",
description="Include proportions in the exported character file")
bpy.types.Scene.mblab_export_materials = bpy.props.BoolProperty(
name="Include materials",
default=True,
description="Include materials in the exported character file")
bpy.types.Scene.mblab_show_texture_load_save = bpy.props.BoolProperty(
name="Import-export images",
description="Show controls to import and export texture images")
bpy.types.Scene.mblab_add_mask_group = bpy.props.BoolProperty(
name="Add mask vertgroup",
description="Create a new vertgroup and use it as mask the body under proxy.",
default=False)
bpy.types.Scene.mblab_preserve_mass = bpy.props.BoolProperty(
name="Mass",
description="Preserve the current relative mass percentage")
bpy.types.Scene.mblab_preserve_height = bpy.props.BoolProperty(
name="Height",
description="Preserve the current character height")
bpy.types.Scene.mblab_preserve_tone = bpy.props.BoolProperty(
name="Tone",
description="Preserve the current relative tone percentage")
bpy.types.Scene.mblab_preserve_fantasy = bpy.props.BoolProperty(
name="Fantasy",
description="Preserve the current amount of fantasy morphs")
bpy.types.Scene.mblab_preserve_body = bpy.props.BoolProperty(
name="Body",
description="Preserve the body features")
bpy.types.Scene.mblab_preserve_face = bpy.props.BoolProperty(
name="Face",
description="Preserve the face features, but not the head shape")
bpy.types.Scene.mblab_preserve_phenotype = bpy.props.BoolProperty(
name="Phenotype",
description="Preserve characteristic traits, like people that are members of the same family")
bpy.types.Scene.mblab_set_tone_and_mass = bpy.props.BoolProperty(
name="Use fixed tone and mass values",
description="Enable the setting of fixed values for mass and tone using a slider UI")
bpy.types.Scene.mblab_body_mass = bpy.props.FloatProperty(
name="Body mass",
min=0.0,
max=1.0,
default=0.5,
subtype='FACTOR',
description="Preserve the current character body mass")
bpy.types.Scene.mblab_body_tone = bpy.props.FloatProperty(
name="Body tone",
min=0.0,
max=1.0,
default=0.5,
subtype='FACTOR',
description="Preserve the current character body tone")
bpy.types.Scene.mblab_morphing_spectrum = bpy.props.EnumProperty(
items=morphcreator.get_spectrum(),
name="Spectrum",
default="GE")
bpy.types.Scene.mblab_morph_min_max = bpy.props.EnumProperty(
items=morphcreator.get_min_max(),
name="min/max",
default="MA")
bpy.types.Scene.mblab_morphing_body_type = bpy.props.StringProperty(
name="Ethnic group",
description="Overide the ethnic group.\n4 letters, without f_ or m_.\nExample : af01\nLet empty to not overide",
#default="",
maxlen=4,
subtype='FILE_NAME')
bpy.types.Scene.mblab_morphing_file_extra_name = bpy.props.StringProperty(
name="Extra name",
description="Typically it's the name of the author",
default="pseudo",
maxlen=1024,
subtype='FILE_NAME')
bpy.types.Scene.mblab_incremental_saves = bpy.props.BoolProperty(
name="Autosaves",
description="Does an incremental save each time\n the final save button is pressed.\nFrom 001 to 999\nCaution : returns to 001 between sessions")
bpy.types.Scene.mblab_morph_name = bpy.props.StringProperty(
name="Name",
description="Format : ExplicitPartMorphed\n(Without body part category)",
default="",
maxlen=1024,
subtype='FILE_NAME')
bpy.types.Scene.mblab_body_part_name = bpy.props.EnumProperty(
items=morphcreator.get_body_parts(),
name="Body part",
default="BO")
bpy.types.Scene.mblab_body_tone = bpy.props.FloatProperty(
name="Body tone",
min=0.0,
max=1.0,
default=0.5,
subtype='FACTOR',
description="Preserve the current character body mass")
bpy.types.Scene.mblab_random_engine = bpy.props.EnumProperty(
items=[("LI", "Light", "Little variations from the standard"),
("RE", "Realistic", "Realistic characters"),
("NO", "Noticeable", "Very characterized people"),
("CA", "Caricature", "Engine for caricatures"),
("EX", "Extreme", "Extreme characters")],
name="Engine",
default="LI")
bpy.types.Scene.mblab_facs_rig = bpy.props.BoolProperty(
name="Import FACS Rig")
#Hair color Drop Down List
bpy.types.Scene.mblab_hair_color = bpy.props.EnumProperty(
items=hair_style_list,
name="Color Select",
update=hair_style_list)
#Hair new color name
bpy.types.Scene.mblab_new_hair_color = bpy.props.StringProperty(
name="Save Hair Color",
default="",
description="Enter name for new hair color")
# MB-Lab Operations
class ButtonParametersOff(bpy.types.Operator):
bl_label = 'Body Measures'
bl_idname = 'mbast.button_parameters_off'
bl_description = 'Close details panel'
bl_context = 'objectmode'
bl_options = {'REGISTER', 'INTERNAL'}
def execute(self, context):
global gui_active_panel_middle
gui_active_panel_middle = None
return {'FINISHED'}
class ButtonParametersOn(bpy.types.Operator):
bl_label = 'Body Measures'
bl_idname = 'mbast.button_parameters_on'
bl_description = 'Open details panel'
bl_context = 'objectmode'
bl_options = {'REGISTER', 'INTERNAL'}
def execute(self, context):
global gui_active_panel_middle
gui_active_panel_middle = "parameters"
sync_character_to_props()
return {'FINISHED'}
class ButtonUtilitiesOff(bpy.types.Operator):
bl_label = 'UTILITIES'
bl_idname = 'mbast.button_utilities_off'
bl_description = 'Close utilities panel'
bl_context = 'objectmode'
bl_options = {'REGISTER', 'INTERNAL'}
def execute(self, context):
global gui_active_panel_fin
gui_active_panel_fin = None
return {'FINISHED'}
class ButtonUtilitiesOn(bpy.types.Operator):
bl_label = 'UTILITIES'
bl_idname = 'mbast.button_utilities_on'
bl_description = 'Open utilities panel'
bl_context = 'objectmode'
bl_options = {'REGISTER', 'INTERNAL'}
def execute(self, context):
global gui_active_panel_fin
gui_active_panel_fin = "utilities"