-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathpanels.py
4062 lines (3397 loc) · 176 KB
/
panels.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
# Copyright (C) 2021 Victor Soupday
# This file is part of CC/iC Blender Tools <https://github.com/soupday/cc_blender_tools>
#
# CC/iC Blender Tools 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.
#
# CC/iC Blender Tools 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 CC/iC Blender Tools. If not, see <https://www.gnu.org/licenses/>.
import bpy
import textwrap
import os
from . import addon_updater_ops, iconutils, rigging, rigutils
from . import (link, rigify_mapping_data, bones, characters, sculpting, springbones,
bake, rigidbody, physics, colorspace, modifiers, channel_mixer, nodeutils,
utils, params, vars)
from .drivers import get_head_body_object_quick
PIPELINE_TAB_NAME = "CC/iC Pipeline"
CREATE_TAB_NAME = "CC/iC Create"
LINK_TAB_NAME = "CC/iC Link"
# Panel functions and classes
#
def fake_drop_down(row, label, prop_name, prop_bool_value, icon = "TRIA_DOWN", icon_closed = "TRIA_RIGHT"):
props = vars.props()
row.alignment="LEFT"
if prop_bool_value:
row.prop(props, prop_name, icon=icon, text=label, emboss=False)
else:
row.prop(props, prop_name, icon=icon_closed, text=label, emboss=False)
if icon != "TRIA_DOWN":
if prop_bool_value:
row.prop(props, prop_name, icon="TRIA_DOWN", icon_only=True, emboss=False)
else:
row.prop(props, prop_name, icon="TRIA_RIGHT", icon_only=True, emboss=False)
return prop_bool_value
def get_layout_width(context=None, region_type="UI"):
ui_shelf = None
if not context:
context = bpy.context
area = context.area
width = 15
for region in area.regions:
if region.type == region_type:
ui_shelf = region
width = int(ui_shelf.width / 8)
return width
def wrapped_text_box(layout, info_text, width, alert = False, icon = None):
wrapper = textwrap.TextWrapper(width=width)
info_list = wrapper.wrap(info_text)
box = layout.box()
box.alert = alert
first = True
for text in info_list:
if first and icon:
box.label(text=text, icon=icon)
else:
box.label(text=text)
first = False
def warn_icon(row, icon = "ERROR"):
col = row.column()
col.alert = True
col.label(text="", icon=icon)
def character_info_box(chr_cache, chr_rig, layout, show_name = True, show_type = True, show_type_selector = True):
props = vars.props()
prefs = vars.prefs()
is_character = False
is_non_standard = True
is_morph = False
if chr_cache:
character_name = chr_cache.character_name
is_non_standard = chr_cache.is_non_standard()
if chr_cache.is_standard():
type_text = f"Standard ({chr_cache.generation})"
else:
type_text = f"Non-Standard ({chr_cache.generation})"
is_character = True
if chr_cache.is_morph():
is_morph = True
is_non_standard = False
type_text = "Obj/Morph"
elif chr_rig:
character_name = chr_rig.name
type_text = "Generic"
is_non_standard = True
is_character = True
box = layout.box()
if is_character:
if show_name:
box.row().label(text=f"Character: {character_name}")
if show_type:
box.row().label(text=f"Type: {type_text}")
if show_type_selector:
if is_non_standard:
row = box.row()
if chr_cache:
row.prop(chr_cache, "non_standard_type", expand=True)
elif chr_rig:
row.prop(prefs, "export_non_standard_mode", expand=True)
else:
box.row().label(text=f"No Character")
return box
def reconnect_character_ui(context, layout: bpy.types.UILayout, chr_cache):
width = get_layout_width(context, "UI")
rig = utils.get_context_armature(context)
if not context.selected_objects:
rig = None
wrapped_text_box(layout, "Linking", width, alert=False, icon="LINKED")
if not chr_cache and rig and rigutils.is_rl_rigify_armature(rig):
row = layout.row()
row.scale_y = 1.5
op = row.operator("ccic.characterlink", icon="OUTLINER_OB_ARMATURE", text="Connect Rigified").param = "CONNECT"
elif not chr_cache and rig and rigutils.is_rl_armature(rig):
row = layout.row()
row.scale_y = 1.5
op = row.operator("ccic.characterlink", icon="ARMATURE_DATA", text="Connect Character").param = "CONNECT"
else:
row = layout.row(align=True)
row.scale_y = 1.5
op = row.operator("ccic.characterlink", icon="LINKED", text="Link").param = "LINK"
op = row.operator("ccic.characterlink", icon="APPEND_BLEND", text="Append").param = "APPEND"
def pipeline_export_group(chr_cache, chr_rig, layout: bpy.types.UILayout):
props = vars.props()
prefs = vars.prefs()
character_info_box(chr_cache, chr_rig, layout)
if chr_cache and chr_cache.rigified:
row = layout.row()
row.alert = True
row.label(text="Export from Rigging & Animation", icon="ERROR")
# export to CC3
character_export_button(chr_cache, chr_rig, layout)
layout.separator()
# export to Unity
character_export_unity_button(chr_cache, layout)
#layout.separator()
#
## export to Unreal
# character_export_unreal_button(chr_cache, layout)
def rigify_export_group(chr_cache, layout):
props = vars.props()
prefs = vars.prefs()
row = layout.row()
row.label(text="Include T-Pose")
row.prop(prefs, "rigify_export_t_pose", text="")
layout.label(text="Bone Naming:")
layout.prop(prefs, "rigify_export_naming", expand=True)
row = layout.row()
row.scale_y = 2
if prefs.rigify_export_mode == "MESH":
row.operator("cc3.exporter", icon="ARMATURE_DATA", text="Export Mesh").param = "EXPORT_RIGIFY"
elif prefs.rigify_export_mode == "MOTION":
row.operator("cc3.exporter", icon="ARMATURE_DATA", text="Export Motion").param = "EXPORT_RIGIFY"
else:
row.operator("cc3.exporter", icon="ARMATURE_DATA", text="Export Mesh & Motion").param = "EXPORT_RIGIFY"
layout.row().prop(prefs, "rigify_export_mode", expand=True)
def character_export_button(chr_cache, chr_rig, layout : bpy.types.UILayout, scale=2, warn=True):
# export to CC3
text = "Export to CC3/4"
icon = "MOD_ARMATURE"
standard_export = chr_cache and chr_cache.is_standard()
non_standard_export = (chr_cache and chr_cache.is_non_standard()) or (chr_rig and not standard_export)
if chr_cache:
row = layout.row()
row.scale_y = scale
param = "EXPORT_CC3"
if chr_cache and chr_cache.is_import_type("OBJ"):
text = "Export Morph Target"
icon = "ARROW_LEFTRIGHT"
if not chr_cache.is_valid_for_export():
row.alert = True
row.enabled = False
text = "Invalid Character!"
param = "EXPORT_CC3_INVALID"
row.operator("cc3.exporter", icon=icon, text=text).param = param
if not chr_cache.can_standard_export():
row.enabled = False
if warn and not chr_cache.get_import_has_key():
if chr_cache.is_import_type("FBX"):
layout.row().label(text="No Fbx-Key file!", icon="ERROR")
elif chr_cache.is_import_type("OBJ"):
layout.row().label(text="No Obj-Key file!", icon="ERROR")
elif chr_rig:
row = layout.row()
row.scale_y = scale
text = "Export Non-Standard"
icon = "MONKEY"
row.operator("cc3.exporter", icon=icon, text=text).param = "EXPORT_NON_STANDARD"
else:
row = layout.row()
row.scale_y = scale
row.operator("cc3.exporter", icon=icon, text=text).param = "EXPORT_CC3"
row.enabled = False
if warn:
row = layout.row()
row.alert = True
row.label(text="No current character!", icon="ERROR")
def character_export_unity_button(chr_cache, layout):
props = vars.props()
prefs = vars.prefs()
column = layout.column()
# export button
row = column.row()
row.scale_y = 2
if props.is_unity_project():
row.operator("cc3.exporter", icon="CUBE", text="Update Unity Project").param = "UPDATE_UNITY"
else:
row.operator("cc3.exporter", icon="CUBE", text="Export To Unity").param = "EXPORT_UNITY"
# export mode
column.row().prop(prefs, "export_unity_mode", expand=True)
# disable if no character, or not an fbx import
if not chr_cache or not (chr_cache.is_import_type("FBX") or chr_cache.is_import_type("BLEND")) or chr_cache.rigified:
column.enabled = False
def character_export_unreal_button(chr_cache, layout):
props = vars.props()
prefs = vars.prefs()
column = layout.column()
# export button
row = column.row()
row.scale_y = 2
row.operator("cc3.exporter", icon="EVENT_U", text="Export To Unreal").param = "EXPORT_UNREAL"
# disable if no character, or not an fbx import
if not chr_cache or not chr_cache.is_import_type("FBX") or chr_cache.rigified:
column.enabled = False
def rigid_body_sim_ui(chr_cache, arm, obj, layout : bpy.types.UILayout,
fixed_parent=False, only_parent_mode=None,
show_selector=True, enabled=True):
props = vars.props()
if not chr_cache or not arm:
return
rigid_body = rigidbody.get_rigid_body(chr_cache, obj)
rigid_body_sim = None
parent_mode = chr_cache.available_spring_rigs
if fixed_parent:
parent_mode = only_parent_mode
prefix = springbones.get_spring_rig_prefix(parent_mode)
rigid_body_sim = rigidbody.get_spring_rigid_body_system(arm, prefix)
has_spring_rig = springbones.has_spring_rig(chr_cache, arm, parent_mode)
disable_on_linked(layout, chr_cache)
box = layout.box()
if fake_drop_down(box.row(),
"Rigid Body Sim",
"section_rigidbody_spring_ui",
props.section_rigidbody_spring_ui,
icon="BLENDER", icon_closed="BLENDER"):
column = box.column()
column.enabled = enabled
if not fixed_parent and show_selector:
split = column.split(factor=0.45)
split.column().label(text="Hair System")
#split.column().prop(props, "hair_rig_bone_root", text="")
split.column().prop(chr_cache, "available_spring_rigs", text="")
if not has_spring_rig:
row = column.row()
row.label(text = "No Spring Rig", icon="ERROR")
if rigid_body_sim:
split = column.split(factor=0.5)
col_1 = split.column()
col_2 = split.column()
col_1.label(text="Influence")
col_2.prop(rigid_body_sim, "[\"rigid_body_influence\"]", text="", slider=True)
col_1.label(text="Restrain")
col_2.prop(rigid_body_sim, "[\"rigid_body_limit\"]", text="", slider=True)
col_1.label(text="Curve")
col_2.prop(rigid_body_sim, "[\"rigid_body_curve\"]", text="", slider=True)
col_1.label(text="Mass")
col_2.prop(rigid_body_sim, "[\"rigid_body_mass\"]", text="", slider=True)
col_1.label(text="Margin")
col_2.prop(rigid_body_sim, "[\"rigid_body_margin\"]", text="", slider=True)
col_1.label(text="Dampening")
col_2.prop(rigid_body_sim, "[\"rigid_body_dampening\"]", text="", slider=True)
col_1.label(text="Stiffness")
col_2.prop(rigid_body_sim, "[\"rigid_body_stiffness\"]", text="", slider=True)
col_1.label(text="Angle Range")
col_2.prop(rigid_body_sim, "[\"rigid_body_angle_limit\"]", text="", slider=True)
column.separator()
if parent_mode:
if not rigid_body_sim:
row = column.row()
row.scale_y = 2.0
row.operator("cc3.springbones", icon=utils.check_icon("CON_KINEMATIC"), text="Build Simulation").param = "MAKE_RIGID_BODY_SYSTEM"
column.separator()
if not has_spring_rig:
row.enabled = False
else:
row = column.row()
row.scale_y = 2.0
warn_icon(row, "X")
row.operator("cc3.springbones", icon=utils.check_icon("X"), text="Remove Simulation").param = "REMOVE_RIGID_BODY_SYSTEM"
column.separator()
else:
column.row().label(text = "No spring rig selected", icon="ERROR")
column.row().label(text="Rigid Body Colliders:")
if rigidbody.has_rigid_body_colliders(arm):
row = column.row(align=True)
colliders_visible = rigidbody.colliders_visible(arm)
row.operator("cc3.springbones", icon=utils.check_icon("HIDE_OFF"), text="", depress=colliders_visible).param = "TOGGLE_SHOW_COLLIDERS"
is_pose_position = rigutils.is_rig_rest_position(arm)
row.operator("ccic.rigutils", icon="OUTLINER_OB_ARMATURE", text="", depress=is_pose_position).param = "TOGGLE_SHOW_RIG_POSE"
row.operator("cc3.springbones", icon=utils.check_icon("X"), text="Remove Colliders").param = "REMOVE_COLLIDERS"
#column.row().prop(rigid_body, "collision_margin", text="Collision Margin", slider=True)
else:
column.row().operator("cc3.springbones", icon=utils.check_icon("META_CAPSULE"), text="Add Colliders").param = "BUILD_COLLIDERS"
column.separator()
# Cache
has_rigidbody, rigidbody_baked, rigidbody_baking, rigidbody_point_cache = springbones.rigidbody_state()
column.row().label(text="Animation Range:")
row = column.row(align=True)
row.prop(bpy.context.scene, "use_preview_range", text="", toggle=True)
grid = row.grid_flow(columns=2, align=True)
grid.operator("cc3.scene", icon="FULLSCREEN_ENTER", text="Expand").param = "ANIM_RANGE_EXPAND"
grid.operator("cc3.scene", icon="FULLSCREEN_EXIT", text="Fit").param = "ANIM_RANGE_FIT"
column.row().label(text="Rigid Body Cache:")
row = column.row()
row.operator("cc3.springbones", icon=utils.check_icon("LOOP_BACK"), text="Reset Simulation").param = "RESET_PHYSICS"
row = column.row()
row.scale_y = 1.5
row.context_pointer_set("point_cache", rigidbody_point_cache)
depress = rigidbody_baking
row.alert = rigidbody_baked
if rigidbody_baked:
row.operator("ptcache.free_bake", text="Free Simulation", icon="REC")
else:
row.operator("ptcache.bake", text="Bake Simulation", icon="REC", depress=rigidbody_baking).bake = True
def cache_timeline_physics_ui(chr_cache, layout : bpy.types.UILayout):
if not chr_cache:
return
layout.box().label(text="Timeline & Physics Cache", icon="PREVIEW_RANGE")
layout.row().label(text="Animation Range:")
row = layout.row(align=True)
row.prop(bpy.context.scene, "use_preview_range", text="", toggle=True)
grid = row.grid_flow(columns=2, align=True)
grid.operator("cc3.scene", icon="FULLSCREEN_ENTER", text="Expand").param = "ANIM_RANGE_EXPAND"
grid.operator("cc3.scene", icon="FULLSCREEN_EXIT", text="Fit").param = "ANIM_RANGE_FIT"
layout.separator()
"""
if not bpy.data.filepath:
row = layout.row()
row.alert = True
row.label(text="Blendfile should be saved", icon="ERROR")
row = layout.row()
row.alert = True
row.label(text="before baking physics", icon="REMOVE")
layout.separator()
"""
if bpy.context.object:
layout.label(text=bpy.context.object.name, icon="OBJECT_DATA")
has_cloth, cloth_baked, cloth_baking, cloth_point_cache = physics.cloth_physics_state(bpy.context.object)
has_rigidbody, rigidbody_baked, rigidbody_baking, rigidbody_point_cache = springbones.rigidbody_state()
grid = layout.grid_flow(row_major=True, columns=2)
grid_column = grid.column(align=True)
grid_column.label(text="Cloth Physics", icon="MOD_CLOTH")
row = grid_column.row(align=True)
row.operator("cc3.scene", icon="LOOP_BACK", text="Reset").param = "PHYSICS_PREP_CLOTH"
row = grid_column.row(align=True)
row.context_pointer_set("point_cache", cloth_point_cache)
row.scale_y = 1.5
row.alert = cloth_baked
if cloth_baked:
row.operator("ptcache.free_bake", text="Free", icon="REC")
else:
row.operator("ptcache.bake", text="Bake", icon="REC", depress=cloth_baking).bake = True
if not has_cloth:
grid_column.enabled = False
grid_column = grid.column(align=True)
grid_column.label(text="Spring Physics", icon="CON_KINEMATIC")
row = grid_column.row(align=True)
row.operator("cc3.scene", icon="LOOP_BACK", text="Reset").param = "PHYSICS_PREP_RBW"
row = grid_column.row(align=True)
row.context_pointer_set("point_cache", rigidbody_point_cache)
row.scale_y = 1.5
row.alert = rigidbody_baked
if rigidbody_baked:
row.operator("ptcache.free_bake", text="Free", icon="REC")
else:
row.operator("ptcache.bake", text="Bake", icon="REC", depress=rigidbody_baking).bake = True
if not has_rigidbody:
grid_column.enabled = False
layout.separator()
has_cloth, has_collision, has_rigidbody, all_baked, any_baked, all_baking, any_baking = physics.get_scene_physics_state()
layout.label(text="All Dynamics:", icon="PHYSICS")
column = layout.column(align=True)
column.operator("cc3.scene", icon="LOOP_BACK", text="Reset All").param = "PHYSICS_PREP_ALL"
row = column.row(align=True)
row.scale_y = 1.5
row.alert = all_baked
all_depress = all_baking
if any_baked:
row.operator("ptcache.free_bake_all", text="Free All Dynamics", icon="REC")
else:
row.operator("ptcache.bake_all", text="Bake All Dynamics", icon="REC", depress=all_depress).bake = True
def character_tools_ui(context, layout: bpy.types.UILayout):
props = vars.props()
prefs = vars.prefs()
chr_cache, obj, mat, obj_cache, mat_cache = utils.get_context_character(context, strict=True)
non_chr_objects = [ obj for obj in context.selected_objects
if props.get_object_cache(obj) is None
and (obj.type == "MESH"
or obj.type == "EMPTY")]
generic_rig = None
rig = None
if chr_cache:
rig = chr_cache.get_armature()
else:
generic_rig = characters.get_generic_rig(context.selected_objects)
if generic_rig:
rig = generic_rig
if chr_cache:
chr_name = chr_cache.character_name
elif generic_rig:
chr_name = generic_rig.name
elif non_chr_objects:
chr_name = non_chr_objects[0].name
else:
chr_name = "None Selected"
if chr_cache:
if chr_cache.is_non_standard():
type_string = chr_cache.non_standard_type.capitalize()
else:
type_string = chr_cache.generation.capitalize()
elif generic_rig or non_chr_objects:
type_string = "Generic"
else:
type_string = ""
box = layout.box()
if type_string:
box.label(text=f"{chr_name} ({type_string})", icon="TOOL_SETTINGS")
else:
box.label(text=f"{chr_name}", icon="TOOL_SETTINGS")
col = layout.column(align=True)
grid = col.grid_flow(row_major=True, columns=2, align=True)
grid.scale_y = 1.5
grid.operator("cc3.character", icon="RESTRICT_SELECT_OFF", text="Select").param = "SELECT_ACTOR_ALL"
grid.operator("cc3.character", icon="ARMATURE_DATA", text="Select Rig").param = "SELECT_ACTOR_RIG"
row1 = grid.row(align=True)
row1.operator("ccic.rename_character", icon="GREASEPENCIL", text="Edit")
row2 = grid.row(align=True)
row2.operator("cc3.character", icon="DUPLICATE", text="Duplicate").param = "DUPLICATE"
if not chr_cache:
grid.enabled = False
if is_linked_or_override(chr_cache):
row1.enabled = False
row2.enabled = False
split = col.split(factor=0.5, align=True)
col_1 = split.column(align=True)
col_2 = split.column(align=True)
col_1.scale_y = 1.5
col_2.scale_y = 1.5
col_1.operator("cc3.rigifier", icon="OUTLINER_OB_ARMATURE", text="Rigify").param ="DATALINK_RIGIFY"
if not (chr_cache and chr_cache.is_avatar() and not chr_cache.rigified and chr_cache.can_be_rigged()):
col_1.enabled = False
if chr_cache:
col_2.operator("cc3.importer", icon="PANEL_CLOSE", text="Delete").param ="DELETE_CHARACTER"
elif generic_rig or non_chr_objects:
if generic_rig:
col_2.operator("ccic.convert_generic", icon="COMMUNITY", text="Convert")
elif non_chr_objects:
col_2.operator("ccic.convert_generic", icon="OUTLINER_OB_META", text="Convert")
else:
col_2.operator("cc3.importer", icon="PANEL_CLOSE", text="Delete").param ="DELETE_CHARACTER"
col_2.enabled = False
if chr_cache or generic_rig or non_chr_objects:
if chr_cache:
if chr_cache.link_id:
row = layout.row()
row.label(text=f"Link ID: {chr_cache.link_id}")
if chr_cache.import_file:
row.operator("ccic.datalink", icon="FILE_FOLDER", text="").param = "SHOW_ACTOR_FILES"
else:
layout.row().label(text=f"{type_string}: Unlinked")
elif generic_rig:
layout.row().label(text=f"Armature: {generic_rig.name}")
elif non_chr_objects:
obj_text = "Objects: "
for i, obj in enumerate(non_chr_objects):
if i > 0:
obj_text += ", "
obj_text += obj.name
if len(non_chr_objects) == 0:
obj_text += "None"
layout.row().label(text=obj_text)
def render_prefs_ui(layout: bpy.types.UILayout):
prefs = vars.prefs()
props = vars.props()
# Cycles Prefs
if prefs.render_target == "CYCLES":
suffix = "B4.1" if utils.B410() else "B3.4"
box = layout.box()
if fake_drop_down(box.row(),
f"Cycles Prefs ({suffix})",
"cycles_options",
props.cycles_options):
column = box.column()
split = column.split(factor=0.5)
col_1 = split.column()
col_2 = split.column()
if utils.B400():
col_1.label(text = "SSR Iris Brightness")
col_2.prop(prefs, "cycles_ssr_iris_brightness_b410", text = "")
col_1.label(text = "Skin SSS")
col_2.prop(prefs, "cycles_sss_skin_b410", text = "")
col_1.label(text = "Hair SSS")
col_2.prop(prefs, "cycles_sss_hair_b410", text = "")
col_1.label(text = "Teeth SSS")
col_2.prop(prefs, "cycles_sss_teeth_b410", text = "")
col_1.label(text = "Tongue SSS")
col_2.prop(prefs, "cycles_sss_tongue_b410", text = "")
col_1.label(text = "Eyes SSS")
col_2.prop(prefs, "cycles_sss_eyes_b410", text = "")
col_1.label(text = "Default SSS")
col_2.prop(prefs, "cycles_sss_default_b410", text = "")
col_1.label(text = "Roughness Power")
col_2.prop(prefs, "cycles_roughness_power_b410", text = "")
col_1.label(text = "Normal Strength")
col_2.prop(prefs, "cycles_normal_b410", text = "")
col_1.label(text = "Skin Normal Strength")
col_2.prop(prefs, "cycles_normal_skin_b410", text = "")
col_1.label(text = "Micro Normal Strength")
col_2.prop(prefs, "cycles_micro_normal_b410", text = "")
else:
col_1.label(text = "SSR Iris Brightness")
col_2.prop(prefs, "cycles_ssr_iris_brightness_b341", text = "")
col_1.label(text = "Skin SSS")
col_2.prop(prefs, "cycles_sss_skin_b341", text = "")
col_1.label(text = "Hair SSS")
col_2.prop(prefs, "cycles_sss_hair_b341", text = "")
col_1.label(text = "Teeth SSS")
col_2.prop(prefs, "cycles_sss_teeth_b341", text = "")
col_1.label(text = "Tongue SSS")
col_2.prop(prefs, "cycles_sss_tongue_b341", text = "")
col_1.label(text = "Eyes SSS")
col_2.prop(prefs, "cycles_sss_eyes_b341", text = "")
col_1.label(text = "Default SSS")
col_2.prop(prefs, "cycles_sss_default_b341", text = "")
col_1.label(text = "Roughness Power")
col_2.prop(prefs, "cycles_roughness_power_b341", text = "")
col_1.label(text = "Normal Strength")
col_2.prop(prefs, "cycles_normal_b341", text = "")
col_1.label(text = "Skin Normal Strength")
col_2.prop(prefs, "cycles_normal_skin_b341", text = "")
col_1.label(text = "Micro Normal Strength")
col_2.prop(prefs, "cycles_micro_normal_b341", text = "")
col_1.operator("cc3.setpreferences", icon="FILE_REFRESH", text="Reset").param="RESET_CYCLES"
col_2.operator("cc3.setproperties", icon="DECORATE_DRIVER", text="Update").param = "APPLY_ALL"
# Eevee Prefs
else:
suffix = "B4.2" if utils.B420() else "B3.4"
box = layout.box()
if fake_drop_down(box.row(),
f"Eevee Prefs ({suffix})",
"eevee_options",
props.eevee_options):
column = box.column()
split = column.split(factor=0.5)
col_1 = split.column()
col_2 = split.column()
if utils.B420():
col_1.label(text = "SSR Iris Brightness")
col_2.prop(prefs, "eevee_ssr_iris_brightness_b420", text = "")
col_1.label(text = "Skin SSS")
col_2.prop(prefs, "eevee_sss_skin_b420", text = "")
col_1.label(text = "Hair SSS")
col_2.prop(prefs, "eevee_sss_hair_b420", text = "")
col_1.label(text = "Teeth SSS")
col_2.prop(prefs, "eevee_sss_teeth_b420", text = "")
col_1.label(text = "Tongue SSS")
col_2.prop(prefs, "eevee_sss_tongue_b420", text = "")
col_1.label(text = "Eyes SSS")
col_2.prop(prefs, "eevee_sss_eyes_b420", text = "")
col_1.label(text = "Default SSS")
col_2.prop(prefs, "eevee_sss_default_b420", text = "")
col_1.label(text = "Roughness Power")
col_2.prop(prefs, "eevee_roughness_power_b420", text = "")
col_1.label(text = "Normal Strength")
col_2.prop(prefs, "eevee_normal_b420", text = "")
col_1.label(text = "Skin Normal Strength")
col_2.prop(prefs, "eevee_normal_skin_b420", text = "")
col_1.label(text = "Micro Normal Strength")
col_2.prop(prefs, "eevee_micro_normal_b420", text = "")
else:
col_1.label(text = "SSR Iris Brightness")
col_2.prop(prefs, "eevee_ssr_iris_brightness_b341", text = "")
col_1.label(text = "Skin SSS")
col_2.prop(prefs, "eevee_sss_skin_b341", text = "")
col_1.label(text = "Hair SSS")
col_2.prop(prefs, "eevee_sss_hair_b341", text = "")
col_1.label(text = "Teeth SSS")
col_2.prop(prefs, "eevee_sss_teeth_b341", text = "")
col_1.label(text = "Tongue SSS")
col_2.prop(prefs, "eevee_sss_tongue_b341", text = "")
col_1.label(text = "Eyes SSS")
col_2.prop(prefs, "eevee_sss_eyes_b341", text = "")
col_1.label(text = "Default SSS")
col_2.prop(prefs, "eevee_sss_default_b341", text = "")
col_1.label(text = "Roughness Power")
col_2.prop(prefs, "eevee_roughness_power_b341", text = "")
col_1.label(text = "Normal Strength")
col_2.prop(prefs, "eevee_normal_b341", text = "")
col_1.label(text = "Skin Normal Strength")
col_2.prop(prefs, "eevee_normal_skin_b341", text = "")
col_1.label(text = "Micro Normal Strength")
col_2.prop(prefs, "eevee_micro_normal_b341", text = "")
col_1.operator("cc3.setpreferences", icon="FILE_REFRESH", text="Reset").param="RESET_EEVEE"
col_2.operator("cc3.setproperties", icon="DECORATE_DRIVER", text="Update").param = "APPLY_ALL"
def is_linked_or_override(chr_cache):
linked_or_override = False
if chr_cache:
arm = chr_cache.get_armature()
if arm:
linked_or_override = utils.obj_is_override(arm) or utils.obj_is_linked(arm)
return linked_or_override
def disable_on_linked(layout, chr_cache):
layout.enabled = not is_linked_or_override(chr_cache)
class ARMATURE_UL_List(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
if self.layout_type in {'DEFAULT', 'COMPACT'}:
layout.label(text=item.name if item else "", translate=False, icon_value=icon)
elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'
layout.label(text="", icon_value=icon)
def filter_items(self, context, data, propname):
filtered = []
ordered = []
items = getattr(data, propname)
filtered = [self.bitflag_filter_item] * len(items)
for i, item in enumerate(items):
item_name = utils.strip_name(item.name)
allowed = False
if item.type == "ARMATURE": # only list armatures
if "rl_set_generation" in item:
set_generation = item["rl_set_generation"]
if set_generation != "Rigify" and set_generation != "Rigify+":
allowed = True
elif "_Rigify" not in item_name: # don't list rigified armatures
if "_Retarget" not in item_name: # don't list retarget armatures
if len(item.data.bones) > 0:
for allowed_bone in rigify_mapping_data.ALLOWED_RIG_BONES: # only list armatures of the allowed sources
if rigutils.bone_name_in_armature_regex(item, allowed_bone):
allowed = True
# filter by name
if allowed and self.filter_name and self.filter_name != "*":
if self.filter_name not in item.name:
allowed = False
# block not allowed
if not allowed:
filtered[i] &= ~self.bitflag_filter_item
return filtered, ordered
class ACTION_UL_List(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
if self.layout_type in {'DEFAULT', 'COMPACT'}:
layout.label(text=item.name if item else "", translate=False, icon_value=icon)
elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'
layout.label(text="", icon_value=icon)
def filter_items(self, context, data, propname):
props = vars.props()
filtered = []
ordered = []
arm_name = None
arm_object = utils.collection_at_index(props.armature_list_index, bpy.data.objects)
arm_set_generation = None
if arm_object:
if arm_object.type == "ARMATURE":
arm_name = arm_object.name
if "rl_set_generation" in arm_object:
arm_set_generation = arm_object["rl_set_generation"]
rl_arm_id = utils.get_rl_object_id(arm_object)
items = getattr(data, propname)
filtered = [self.bitflag_filter_item] * len(items)
item : bpy.types.Action
for i, item in enumerate(items):
allowed = False
action_set_generation = None
action_type = None
action_armature_id = None
if "rl_set_generation" in item:
action_set_generation = item["rl_set_generation"]
if "rl_action_type" in item:
action_type = item["rl_action_type"]
if "rl_armature_id" in item:
action_armature_id = item["rl_armature_id"]
if props.armature_action_filter and arm_object:
if arm_set_generation and action_set_generation and action_type and rl_arm_id and action_armature_id:
if (arm_set_generation == action_set_generation and
action_type == "ARM" and
action_armature_id == rl_arm_id):
allowed = True
else:
prefix, rig_id, type_id, obj_id, motion_id = rigutils.decode_action_name(item)
if type_id and rig_id and type_id == "A" and rig_id == arm_name:
allowed = True
elif len(item.fcurves) > 0:
if item.fcurves[0].data_path.startswith("key_blocks"):
# no shape key actions
allowed = False
else:
# only actions with curves
allowed = True
# filter by name
if allowed and self.filter_name and self.filter_name != "*":
if self.filter_name not in item.name:
allowed = False
# block not allowed
if not allowed:
filtered[i] &= ~self.bitflag_filter_item
return filtered, ordered
class ACTION_SET_UL_List(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
if self.layout_type in {'DEFAULT', 'COMPACT'}:
layout.label(text=item.name if item else "", translate=False, icon_value=icon)
elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'
layout.label(text="", icon_value=icon)
def filter_items(self, context, data, propname):
props = vars.props()
filtered = []
ordered = []
items = getattr(data, propname)
filtered = [self.bitflag_filter_item] * len(items)
item : bpy.types.Action
chr_cache = props.get_context_character_cache(context)
arm_set_generation = None
if chr_cache:
arm = chr_cache.get_armature()
if "rl_set_generation" in arm:
arm_set_generation = arm["rl_set_generation"]
for i, item in enumerate(items):
allowed = False
action_set_generation = None
action_type = None
if "rl_set_generation" in item:
action_set_generation = item["rl_set_generation"]
if "rl_action_type" in item:
action_type = item["rl_action_type"]
if (arm_set_generation and
action_set_generation and
action_type == "ARM" and
(not props.filter_motion_set or arm_set_generation == action_set_generation)):
allowed = True
# filter by name
if allowed and self.filter_name and self.filter_name != "*":
if self.filter_name not in item.name:
allowed = False
# block not allowed
if not allowed:
filtered[i] &= ~self.bitflag_filter_item
return filtered, ordered
class UNITY_ACTION_UL_List(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
if self.layout_type in {'DEFAULT', 'COMPACT'}:
layout.label(text=item.name if item else "", translate=False, icon_value=icon)
elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'
layout.label(text="", icon_value=icon)
def filter_items(self, context, data, propname):
filtered = []
ordered = []
items = getattr(data, propname)
filtered = [self.bitflag_filter_item] * len(items)
item : bpy.types.Action
for i, item in enumerate(items):
if "_Unity" in item.name and "|A|" in item.name:
if len(item.fcurves) == 0: # no fcurves, no animation...
filtered[i] &= ~self.bitflag_filter_item
elif item.fcurves[0].data_path.startswith("key_blocks"): # only shapekey actions have key blocks...
filtered[i] &= ~self.bitflag_filter_item
if self.filter_name and self.filter_name != "*":
if self.filter_name not in item.name:
filtered[i] &= ~self.bitflag_filter_item
else:
filtered[i] &= ~self.bitflag_filter_item
return filtered, ordered
class CC3CharacterSettingsPanel(bpy.types.Panel):
bl_idname = "CC3_PT_Character_Settings_Panel"
bl_label = "Character Build Settings"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = PIPELINE_TAB_NAME
bl_options = {"DEFAULT_CLOSED"}
def draw(self, context):
layout = self.layout
props = vars.props()
PREFS = vars.prefs()
chr_cache, obj, mat, obj_cache, mat_cache = utils.get_context_character(context)
mesh_in_selection = False
for obj in bpy.context.selected_objects:
if obj.type == "MESH":
mesh_in_selection = True
box = layout.box()
#op = box.operator("cc3.importer", icon="IMPORT", text="Import Character")
#op.param ="IMPORT"
# import details
if chr_cache:
if fake_drop_down(box.row(), "Import Details", "stage1_details", props.stage1_details):
box.label(text="Name: " + chr_cache.character_name)
box.label(text="Type: " + chr_cache.get_import_type().upper())
split = box.split(factor=0.4)
col_1 = split.column()
col_2 = split.column()
col_1.label(text="Generation:")
col_2.prop(chr_cache, "generation", text="")
col_1.label(text="Key File:")
has_key = "Yes" if chr_cache.get_import_has_key() else "No"
col_2.label(text=has_key)
col_1.label(text="Render For:")
col_2.prop(chr_cache, "render_target", text="")
box.prop(chr_cache, "import_file", text="")
for obj_cache in chr_cache.object_cache:
#o = obj_cache.get_object()
#if o:
box.prop(obj_cache, "object", text="")
else:
box.label(text="Name: " + chr_cache.character_name)
else:
box.label(text="No Character")
disable_on_linked(box, chr_cache)
# Build Settings
# Build prefs in title
box = layout.box()
if fake_drop_down(box.row(), "Build Settings", "show_build_prefs2", props.show_build_prefs2,
icon="TOOL_SETTINGS", icon_closed="TOOL_SETTINGS"):
column = box.column()
column.prop(PREFS, "import_deduplicate")
column.prop(PREFS, "import_auto_convert")
if PREFS.import_auto_convert:
column.prop(PREFS, "auto_convert_materials")
column.prop(PREFS, "build_limit_textures")
column.prop(PREFS, "build_pack_texture_channels")
column.prop(PREFS, "build_reuse_baked_channel_packs")
column.prop(PREFS, "build_armature_edit_modifier")
column.prop(PREFS, "build_armature_preserve_volume")
column.separator()
column.label(text="Drivers:")
column.prop(PREFS, "build_shape_key_bone_drivers_jaw")
column.prop(PREFS, "build_shape_key_bone_drivers_eyes")
column.prop(PREFS, "build_shape_key_bone_drivers_head")
column.prop(PREFS, "build_body_key_drivers")
column.separator()
column.label(text="Experimental:")
column.prop(PREFS, "build_skin_shader_dual_spec")
column = layout.column(align=True)
row = column.row(align=True)
row.prop(props, "physics_mode", toggle=True, text="Build Physics")
row.prop(props, "wrinkle_mode", toggle=True, text="Wrinkles")
row = column.row(align=True)
row.prop(chr_cache if chr_cache else props, "setup_mode", expand=True)
row = column.row(align=True)
row.prop(PREFS, "render_target", expand=True)
row = column.row(align=True)
row.prop(PREFS, "refractive_eyes", expand=True)
# ACES Prefs
if colorspace.is_aces():
layout.box().label(text="ACES Settings", icon="COLOR")
split = layout.split(factor=0.5)
col_1 = split.column()
col_2 = split.column()
col_1.label(text="sRGB Override")
col_2.prop(PREFS, "aces_srgb_override", text="")
col_1.label(text="Data Override")
col_2.prop(PREFS, "aces_data_override", text="")
render_prefs_ui(layout)
# Build Button
if chr_cache:
box = layout.box()
box.row().label(text="Rebuild", icon="MOD_BUILD")
col = box.column()
row = col.row()
row.scale_y = 2