-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpanel.py
1827 lines (1486 loc) · 87.7 KB
/
panel.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
# from typing import Text
# from ctypes import alignment
# from unittest.mock import DEFAULT
import bpy,os,glob
from os.path import join
import sys
import textwrap
from bpy.types import Operator, Panel, UIList, PropertyGroup, Menu
from bpy.props import EnumProperty, CollectionProperty, IntProperty
global DEFAULT_NAME
DEFAULT_NAME = 'py310_torch1.13.0_cu117_env'
DEFAULT_NAME_WHAM = 'py39_torch1.11.0_cu113_env'
DEFAULT_NAME_SLAHMR = 'py310_torch1.13.0_cu117_env_SLAHMR'
# def updt_bool_imgs(self,context):
# fourd_prop = context.scene.fourd_prop
# if fourd_prop.bool_custom_imgs:
# fourd_prop.bool_batch_execution = False
# # print('1-1')
# def updt_bool_batch(self,context):
# fourd_prop = context.scene.fourd_prop
# if fourd_prop.bool_batch_execution:
# fourd_prop.bool_custom_imgs = False
# # print('2-1')
# def updt_bool_max_img(self,context):
# fourd_prop = context.scene.fourd_prop
# if fourd_prop.bool_max_img:
# fourd_prop.bool_enable_max_img = True
# else:
# fourd_prop.bool_enable_max_img = False
# fourd_prop.int_max_img = 10
# def updt_bool_max_res(self,context):
# fourd_prop = context.scene.fourd_prop
# if fourd_prop.bool_max_res:
# fourd_prop.bool_enable_max_res = True
# else:
# fourd_prop.bool_enable_max_res = False
# fourd_prop.int_max_res = 4096
def select_action_strip(self,context):
armature = bpy.context.selected_objects[0]
a_strips = armature.animation_data.nla_tracks[0].strips
for i,ast in enumerate(a_strips):
if i == self.active_track_index:
ast.select = True
else:
ast.select = False
# armature.animation_data.nla_tracks[0].strips[self.active_track_index].select = True
def update_fps(self,context):
bpy.context.scene.render.fps=int(self.enum_fps)
def update_venv_name_from_list(self,context):
global DEFAULT_NAME
fourd_prop = context.scene.fourd_prop
# folder = fourd_prop.str_sd_prompt.strip().replace(' ','_')
folder = fourd_prop.enum_custom_venv_list
if folder == '-1':
# fourd_prop.str_custom_venv_name = 'text2light_39_env'
fourd_prop.str_custom_venv_name = DEFAULT_NAME
if folder > '0': #0 é o que chamo the Nothing no panel
fourd_prop.str_custom_venv_name = folder
def _label_multiline(context, text, parent):
chars = int(context.region.width / 7) # 7 pix on 1 character
wrapper = textwrap.TextWrapper(width=chars)
text_lines = wrapper.wrap(text=text)
for text_line in text_lines:
parent.label(text=text_line)
def updt_custom_venv_name(self,context):
fourd_prop = context.scene.fourd_prop
custom_venv_name = fourd_prop.str_custom_venv_name
path_addon = os.path.dirname(os.path.abspath(__file__))
custom_path_txt = join(path_addon,'custom_path.txt')
with open(custom_path_txt, "wt") as fout_custom:
fout_custom.write(custom_venv_name)
def updt_bool_custom_venv(self,context):
global DEFAULT_NAME
fourd_prop = context.scene.fourd_prop
# wm = context.window_manager
if not self.bool_custom_venv:
fourd_prop.str_custom_venv_name = DEFAULT_NAME
def updt_bool_venv_custom_name(self,context):
fourd_prop = context.scene.fourd_prop
# wm = context.window_manager
if self.bool_custom_venv_name:
fourd_prop.bool_custom_venv_name_from_list = False
def updt_bool_venv_custom_name_from_list(self,context):
fourd_prop = context.scene.fourd_prop
# wm = context.window_manager
if self.bool_custom_venv_name_from_list:
fourd_prop.bool_custom_venv_name= False
def folder_venv_callback(scene, context):
fourd_prop = context.scene.fourd_prop
directory = fourd_prop.str_venv_path
if os.path.exists(directory):
folders = []
# for root, dirs, files in os.walk(directory):
for name_file_dir in os.listdir(directory):
if os.path.isdir(join(directory,name_file_dir)) and name_file_dir.endswith('_39_env'):
folders.append(name_file_dir)
# list_folder = folders[0]
list_folder = folders
# print(list_folder)
items = []
i=0
####
#generate the custom size to search for Constraint name (to be able to use "startswith")
# len_name_start_ctr = len(name+'-{:03}'.format(0))
items.append(("-1","Choose a Folder","Choose a Folder"))
for x in range(len(list_folder)):
i=i+1
items.append((list_folder[x],"%s" % list_folder[x],"Data: %s" % list_folder[x]))
if len(items) == 0:
items.append((str(0),"Nothing","No Data available"))
else:
items = [(str(0),"Nothing","No Data available")]
return items
def rig_list_callback(scene, context):
# fourd_prop = context.scene.fourd_prop
path_addon = os.path.dirname(os.path.abspath(__file__))
rig_files = os.path.join(path_addon,'rig','*.json')
list_files_json = glob.glob(rig_files)
items= []
items.append(("-1","-----Choose a Rig-----","Choose a RIG"))
for f in list_files_json:
file = os.path.splitext(os.path.basename(f))[0]
items.append((file,"%s" % file,"Data: %s" % file))
if len(items) == 0:
items.append((str(0),"Nothing","No Data available"))
return items
def floor_distance_fine_tune(self,context):
floor = context.scene.floor
floor.children[0].location[2] = self.fl_floor_distance_fine_tune
class ACTION_UL_list(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
scene = data
ob = item
# print('data: ',data,'\n','item: ', item,'\n','icon: ',icon,'\n','active_date: ', active_data,'\n','active_propname: ', active_propname,'\n')
if self.layout_type in {'DEFAULT', 'COMPACT'}:
layout.prop(ob, "name", text="", emboss=False, icon_value=layout.icon(ob))
class ACTION_STRIP_UL_list(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
scene = data
ob = item
# print('data: ',data,'\n','item: ', item,'\n','icon: ',icon,'\n','active_date: ', active_data,'\n','active_propname: ', active_propname,'\n')
if self.layout_type in {'DEFAULT', 'COMPACT'}:
if ob.name.startswith('Transition'):
layout.prop(ob, "name", text="------", emboss=False, icon_value=layout.icon(ob))
else:
layout.prop(ob, "name", text="", emboss=False, icon_value=layout.icon(ob))
def ik_control_panel(context,layout,row,path_venv,file_fbx):
scene = context.scene
fourd_prop = context.scene.fourd_prop
row.separator()
row.separator()
row.prop(scene,'source')
# row.separator()
row.operator('fdh.stg2_full')
row.operator('fdh.switch_ik_fk_part',text='Switch FK-IK Hands').option=0
row.operator('fdh.switch_ik_fk_part',text='Switch FK-IK Foot').option=1
rowb = layout.row(align=True).box()
rowb = rowb.column(align=True)
row = rowb.row(align=True)
# row.enabled = enable_ctr
row.enabled = True
row.prop(scene, "ik_advanced",
icon="TRIA_DOWN" if scene.ik_advanced else "TRIA_RIGHT",
icon_only=True, emboss=False
)
row_alert_create_venv = row.column(align=True)
if os.path.exists(path_venv) and os.path.exists(file_fbx):
row_alert_create_venv.alert = False
else:
row_alert_create_venv.alert = True
row_alert_create_venv.label(text='IK Adv Options')
if scene.ik_advanced:
scn = context.scene
row = rowb.column(align=True)
row_ik_adv = row.column(align=True)
# row_path2 = row.row(align=True)
# row_path.label(text='Select a valid Path')
row_ik_adv.operator('fdh.append_stg2')
row_ik_adv.prop(scn,'target_stg2')
row_ik_adv.operator('fdh.stg2_retarget')
row_ik_adv.operator('fdh.mr_switch_snap_anim')
row_ik_adv.label(text='Floor setup')
row_ik_adv.prop(scn,'floor')
row_ik_adv_setup = row_ik_adv.column(align=1)
if scn.floor == None:
row_ik_adv_setup.enabled = False
else:
row_ik_adv_setup.enabled = True
row_ik_adv_setup.operator('fdh.setup_floor')
row_ik_adv_setup.prop(fourd_prop,'fl_floor_distance_fine_tune')
row_ik_adv.label(text='Foot Lock')
row_ik_adv.prop(scn,'foot_lock_left',text='Left')
row_ik_adv.prop(scn,'foot_lock_right',text='Right')
row_ik_adv.operator('fdh.setup_foot_lock')
row_ik_adv.separator()
row_ik_adv_row = row_ik_adv.row(align=1)
row_ik_adv_row.operator('fdh.start_end__foot_lock',text='L Copy B2E').option=4
row_ik_adv_row.operator('fdh.start_end__foot_lock',text='R Copy B2E').option=5
row_ik_adv.separator()
row_ik_adv_row = row_ik_adv.row(align=1)
row_ik_adv_row.operator('fdh.start_end__foot_lock',text='L Start').option=0
row_ik_adv_row.operator('fdh.start_end__foot_lock',text='R Start').option=2
row_ik_adv_row = row_ik_adv.row(align=1)
row_ik_adv_row.operator('fdh.start_end__foot_lock',text='L End').option=1
row_ik_adv_row.operator('fdh.start_end__foot_lock',text='R End').option=3
row_ik_adv.separator()
row_ik_adv_row = row_ik_adv.row(align=1)
row_ik_adv_row.operator('fdh.clear_foot_lock',text='L Clear').option=0
row_ik_adv_row.operator('fdh.clear_foot_lock',text='R Clear').option=1
row_ik_adv.separator()
row_ik_adv.operator('fdh.fix_foot_fcurve')
row_ik_adv.label(text='Transition Frames')
row_ik_adv_row = row_ik_adv.row(align=1)
row_ik_adv_row.prop(fourd_prop,'int_fadein_foot_lock_frames',text="In")
row_ik_adv_row.prop(fourd_prop,'int_fadeout_foot_lock_frames',text="Out")
class FOURDHUMANS_PT_Panel(bpy.types.Panel):
# bl_idname = "CEB_PT_TA"
bl_label = "4D Humans"
bl_category = "CEB"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
def draw(self, context):
scene = context.scene
fourd_prop = context.scene.fourd_prop
layout = self.layout
scene = context.scene
fourd_prop = context.scene.fourd_prop
path_addon = os.path.dirname(os.path.abspath(__file__))
pkl_folder = os.path.join(path_addon,'4D-Humans-main','outputs','results')
path_venv = join(fourd_prop.str_venv_path,fourd_prop.str_custom_venv_name)
path_venv_wham = join(fourd_prop.str_venv_path,fourd_prop.str_custom_venv_name_wham)
path_venv_slahmr = join(fourd_prop.str_venv_path,fourd_prop.str_custom_venv_name_slahmr)
flag_installed = join(fourd_prop.str_venv_path,fourd_prop.str_custom_venv_name,'Lib','site-packages','torch')
flag_installed_wham = join(fourd_prop.str_venv_path,fourd_prop.str_custom_venv_name_wham,'Lib','site-packages','torch')
flag_installed_wham_reqs = join(fourd_prop.str_venv_path,fourd_prop.str_custom_venv_name_wham,'Lib','site-packages','mmcv')
flag_installed_pre_detectron2 = join(fourd_prop.str_venv_path,fourd_prop.str_custom_venv_name,'Lib','site-packages','pycocotools')
flag_installed_detectron2 = join(fourd_prop.str_venv_path,fourd_prop.str_custom_venv_name,'Lib','site-packages','detectron2')
flag_installed_slahmr_torch = join(fourd_prop.str_venv_path,fourd_prop.str_custom_venv_name_slahmr,'Lib','site-packages','torch')
flag_installed_slahmr_reqs = join(fourd_prop.str_venv_path,fourd_prop.str_custom_venv_name_slahmr,'Lib','site-packages','torchgeometry')
flag_installed_slahmr_detectron2 = join(fourd_prop.str_venv_path,fourd_prop.str_custom_venv_name_slahmr,'Lib','site-packages','detectron2')
# flag_installed_slahmr_torch_scatter = join(fourd_prop.str_venv_path,fourd_prop.str_custom_venv_name_slahmr,'Lib','site-packages','torch_scatter')
flag_installed_slahmr_lietorch = join(fourd_prop.str_venv_path,fourd_prop.str_custom_venv_name_slahmr,'Lib','site-packages','lietorch')
flag_installed_cv2 = join(fourd_prop.str_venv_path,fourd_prop.str_custom_venv_name,'Lib','site-packages','scipy')
flag_installed_smpl_male = join(path_addon,'wham','dataset','body_models','smpl','SMPL_MALE.pkl')
flag_installed_smpl_female = join(path_addon,'wham','dataset','body_models','smpl','SMPL_FEMALE.pkl')
flag_installed_smpl_neutral = join(path_addon,'wham','dataset','body_models','smpl','SMPL_NEUTRAL.pkl')
flag_ckp_dpvo_pth = join(path_addon,'wham','checkpoints','dpvo.pth')
flag_ckp_hmr2a_ckpt = join(path_addon,'wham','checkpoints','hmr2a.ckpt')
flag_ckp_vitpose = join(path_addon,'wham','checkpoints','vitpose-h-multi-coco.pth')
flag_ckp_wham_vit_w = join(path_addon,'wham','checkpoints','wham_vit_w_3dpw.pth.tar')
flag_ckp_wha_vit_bedlam = join(path_addon,'wham','checkpoints','wham_vit_bedlam_w_3dpw.pth.tar')
flag_ckp_yolov8x = join(path_addon,'wham','checkpoints','yolov8x.pt')
flag_wham_body_models = join(path_addon,'wham','dataset','body_models','smplx2smpl.pkl')
flag_video_wham = join(path_addon,'wham','example_data','video.mp4')
flag_wham_pickle = join(path_addon,'wham','output','demo','video','wham_output.pickle')
file_fbx = os.path.join(path_addon,'basicModel_m_lbs_10_207_0_v1.0.2.fbx')
CACHE_DIR = os.path.join(os.path.expanduser('~'), ".cache")
smpl_path = os.path.join(CACHE_DIR, "phalp/3D/models/smpl/SMPL_NEUTRAL.pkl")
smpl_path2 = os.path.join(CACHE_DIR, "4DHumans/data/smpl/SMPL_NEUTRAL.pkl")
file_pkl = os.path.join(pkl_folder,'demo_video_converted.pkl')
file_smooth = os.path.join(pkl_folder,'demo_video_converted_smooth.pkl')
# flag_installed_einops = join(fourd_prop.str_venv_path,fourd_prop.str_custom_venv_name,'Lib','site-packages','einops')
row = layout.column(align=True).box()
row = row.column(align=True)
row_col = row.row(align=1)
row_col.prop(fourd_prop,'bool_4dhumans',toggle=True,text='4D Humans')
row_col.prop(fourd_prop,'bool_wham',toggle=True,text='WHAM')
row_col.prop(fourd_prop,'bool_slahmr',toggle=True,text='SLAHMR')
row_col = row.row(align=True)
row_col.prop(fourd_prop,'bool_retarget_panel',toggle=True,text='Retarget')
row_col.prop(fourd_prop,'bool_extract_marked_frames_panel',toggle=True,text='Extract Marked Frames')
row_col = row.row(align=True)
row_col.prop(fourd_prop,'bool_ik_control_panel',toggle=True,text='IK Control')
if fourd_prop.bool_4dhumans:
row_col = row.row(align=True)
row_col.label(text='Panels')
row_col.prop(fourd_prop,'bool_core_panel',toggle=True,text='Core')
row_col.prop(fourd_prop,'bool_core_exe_panel',toggle=True,text='Exe')
row_col.prop(fourd_prop,'bool_core_imp_exp_panel',toggle=True,text='I/E')
row_col.prop(fourd_prop,'bool_core_smooth_panel',toggle=True,text='S')
row_col.prop(fourd_prop,'bool_core_load_panel',toggle=True,text='L')
row_col = row.row(align=True)
row_col.prop(fourd_prop,'bool_smooth_panel',toggle=True,text='Smooth')
row_col.prop(fourd_prop,'bool_footlock_panel',toggle=True,text='Foot')
row_col.prop(fourd_prop,'bool_export_panel',toggle=True,text='Export Tools')
row_col = row.row(align=True)
row_col.prop(fourd_prop,'bool_nla_action_panel',toggle=True,text='NLA Action')
row_col.prop(fourd_prop,'bool_nla_track_panel',toggle=True,text='NLA Track')
if fourd_prop.bool_core_panel:
if fourd_prop.bool_core_exe_panel:
row = layout.row(align=True).box()
row = row.column(align=True)
row.label(text='Video:')
row.operator('fdh.add_video')
row.separator()
row_text = row.column()
row_load_video = row.column()
if fourd_prop.str_videopath == '':
row_text.alert = True
text_path = 'Please choose a path'
row_load_video.enabled = False
else:
text_path = 'Video Path: '+fourd_prop.str_videopath
row_text.alert = False
row_load_video.enabled = True
_label_multiline(
context=context,
text=text_path,
parent=row_text
)
# row.operator('wm.url_open',text='Instructions',icon='URL').url = 'https://github.com/satoshi-ikehata/SDM-UniPS-CVPR2023#step-2-image-acquisition'
row_load_video.separator()
row_load_video.operator('fdh.load_video_3dview')
row_exe = layout.box()
row_exe_run = row_exe.column(align=True)
row_fps = row_exe.column(align=True)
if fourd_prop.str_videopath == '':
row_exe_run.enabled = False
else:
row_exe_run.enabled = True
if os.path.exists(path_venv):
row_exe_run.alert = False
row_exe_run.enabled = True
else:
row_exe_run.alert = True
row_exe_run.enabled = False
# row_exe_run.label(text='Part 1 - Generate PKL')
row_exe_run.operator('fdh.execute').option = 0
row_exe_run.operator('fdh.execute',text='Execute w/ Less VRAM').option = 1
row_exe_run.separator()
# row_exe_run.label(text='Part 2 - Convert PKL')
# row_exe_run
if fourd_prop.enum_fps == str(context.scene.render.fps):
row_fps.prop(fourd_prop,'enum_fps')
else:
row_fps.operator('fdh.set_ini_fps')
if fourd_prop.bool_core_imp_exp_panel:
# row_exe_resmooth = row_exe
# if os.path.exists(file_smooth):
# row_exe_resmooth.enabled = True
# else:
# row_exe_resmooth.enabled = False
# row_exe_resmooth.operator('fdh.smooth',text='ReSmooth').pkl_file='demo_video_converted_smooth.pkl'
row_anim_exp = layout.box()
row_anim_exp.label(text='Import/Export Animation')
row_anim_exp.operator('wm.url_open',text='Animation Library',icon='URL').url = 'https://www.patreon.com/cebstudios/posts?filters%5Btag%5D=4d-humans-animation'
row_anim_exp = row_anim_exp.column(align=True)
row_anim_exp_buttom = row_anim_exp.column(align=True)
row_anim_exp_text = row_anim_exp.column(align=True)
row_anim_exp_buttom_col = row_anim_exp_buttom.column(align=True)
row_anim_exp_buttom = row_anim_exp_buttom.row(align=True)
if os.path.exists(file_pkl):
row_anim_exp_buttom.operator('fdh.export_animation',text='Export')
row_anim_exp_buttom.operator('fdh.import_pkl_animation',text='Import').option=0
row_anim_exp_buttom_col.operator('fdh.import_pkl_animation',text='Import PKL Google Colab').option=1
if fourd_prop.str_pklpath != '':
text_pkl_path = "Loaded PKL: "+fourd_prop.str_pklpath
_label_multiline(
context=context,
text=text_pkl_path,
parent=row_anim_exp_text
)
if fourd_prop.bool_core_smooth_panel:
if os.path.exists(file_pkl):
row_smooth = layout.box()
row_smooth = row_smooth.column(align=True)
row_smooth.label(text='Smooth PKL')
row_smooth_col = row_smooth.row(align=True)
# row_smooth.operator('fdh.smooth').pkl_file='demo_video_converted.pkl'
smooth_both = row_smooth_col.operator('fdh.smooth',text='Both')
smooth_both.pkl_file='demo_video_converted.pkl'
smooth_both.smooth_what='both'
smooth_pose = row_smooth_col.operator('fdh.smooth',text='Pose')
smooth_pose.pkl_file='demo_video_converted.pkl'
smooth_pose.smooth_what='pose'
smooth_trans = row_smooth_col.operator('fdh.smooth',text='Translation')
smooth_trans.pkl_file='demo_video_converted.pkl'
smooth_trans.smooth_what='trans'
if fourd_prop.bool_core_load_panel:
row = layout.box()
row = row.column(align=True)
if fourd_prop.int_tot_character == 0 and os.path.exists(file_pkl):
row_column_pre_alert = row.row(align=True)
row_column_pre_alert.alert = True
row_column_pre_alert.operator('fdh.read_pkl_data').option=0
row_column_pre = row.row(align=True)
row_column_pre.label(text='Characters : '+str(fourd_prop.int_tot_character))
row_column_pre.prop(fourd_prop,'bool_fix_z',toggle=True)
row.prop(fourd_prop,'int_character',text='Number')
row.prop(fourd_prop,'bool_use_selected_character')
row_chr = row.column(align=True)
if fourd_prop.bool_use_selected_character:
row_chr.enabled = True
else:
row_chr.enabled = False
row_chr.prop(context.scene,'source',text='Character')
row_column = row.row(align=True)
row_column_import = row_column.row(align=True)
# if (fourd_prop.int_character <= fourd_prop.int_tot_character and os.path.exists(file_fbx) and not fourd_prop.bool_use_selected_character) or (fourd_prop.bool_use_selected_character and len(bpy.context.selected_objects)>0 and bpy.context.selected_objects[0].type == 'ARMATURE'):
if (fourd_prop.int_character <= fourd_prop.int_tot_character and os.path.exists(file_fbx) and not fourd_prop.bool_use_selected_character) or (fourd_prop.bool_use_selected_character and context.scene.source != None and context.scene.source.type == 'ARMATURE'):
row_column_import.enabled = True
else:
row_column_import.enabled = False
row_column_import.operator('fdh.import_character',text='Import Raw').option=0
row_column_import2 = row_column_import.column(align=True)
if os.path.exists(file_smooth):
row_column_import2.enabled = True
else:
row_column_import2.enabled = False
row_column_import2.operator('fdh.import_character',text='Import Smooth').option=1
# row.separator()
# row.operator('fdh.stg2_full')
# row.operator('fdh.switch_ik_fk_part',text='Switch FK-IK Hands').option=0
# row.operator('fdh.switch_ik_fk_part',text='Switch FK-IK Foot').option=1
# rowb = layout.row(align=True).box()
# rowb = rowb.column(align=True)
# row = rowb.row(align=True)
# # row.enabled = enable_ctr
# row.enabled = True
# row.prop(scene, "ik_advanced",
# icon="TRIA_DOWN" if scene.ik_advanced else "TRIA_RIGHT",
# icon_only=True, emboss=False
# )
# row_alert_create_venv = row.column(align=True)
# if os.path.exists(path_venv) and os.path.exists(file_fbx):
# row_alert_create_venv.alert = False
# else:
# row_alert_create_venv.alert = True
# row_alert_create_venv.label(text='IK Adv Options')
# if scene.ik_advanced:
# scn = context.scene
# row = rowb.column(align=True)
# row_ik_adv = row.column(align=True)
# # row_path2 = row.row(align=True)
# # row_path.label(text='Select a valid Path')
# row_ik_adv.operator('fdh.append_stg2')
# row_ik_adv.prop(scn,'target_stg2')
# row_ik_adv.operator('fdh.stg2_retarget')
# row_ik_adv.operator('fdh.mr_switch_snap_anim')
# row_ik_adv.label(text='Floor setup')
# row_ik_adv.prop(scn,'floor')
# row_ik_adv_setup = row_ik_adv.column(align=1)
# if scn.floor == None:
# row_ik_adv_setup.enabled = False
# else:
# row_ik_adv_setup.enabled = True
# row_ik_adv_setup.operator('fdh.setup_floor')
# row_ik_adv_setup.prop(fourd_prop,'fl_floor_distance_fine_tune')
# row_ik_adv.label(text='Foot Lock')
# row_ik_adv.prop(scn,'foot_lock_left',text='Left')
# row_ik_adv.prop(scn,'foot_lock_right',text='Right')
# row_ik_adv.operator('fdh.setup_foot_lock')
# row_ik_adv_row = row_ik_adv.row(align=1)
# row_ik_adv_row.operator('fdh.start_end__foot_lock',text='L Start').option=0
# row_ik_adv_row.operator('fdh.start_end__foot_lock',text='R Start').option=2
# row_ik_adv_row = row_ik_adv.row(align=1)
# row_ik_adv_row.operator('fdh.start_end__foot_lock',text='L End').option=1
# row_ik_adv_row.operator('fdh.start_end__foot_lock',text='R End').option=3
# row_ik_adv.separator()
# row_ik_adv_row = row_ik_adv.row(align=1)
# row_ik_adv_row.operator('fdh.clear_foot_lock',text='L Clear').option=0
# row_ik_adv_row.operator('fdh.clear_foot_lock',text='R Clear').option=1
# row_ik_adv.separator()
# row_ik_adv.operator('fdh.fix_foot_fcurve')
# row_ik_adv.label(text='Transition Frames')
# row_ik_adv_row = row_ik_adv.row(align=1)
# row_ik_adv_row.prop(fourd_prop,'int_fadein_foot_lock_frames',text="In")
# row_ik_adv_row.prop(fourd_prop,'int_fadeout_foot_lock_frames',text="Out")
row.separator()
row = layout.box()
row_output_folder = row.column()
if os.path.exists(pkl_folder):
row_output_folder.enabled = True
else:
row_output_folder.enabled = False
row_output_folder.operator('fdh.open_output_folder')
if fourd_prop.bool_ik_control_panel:
row = layout.box()
row = row.column(align=True)
ik_control_panel(context,layout,row,path_venv,file_fbx)
if fourd_prop.bool_smooth_panel:
row_smooth2 = layout.box()
row_smooth2 = row_smooth2.column(align=True)
row_smooth2.label(text='Smooth Anim Curves')
row_smooth2.label(text='Giacomo Spaconi "j4ck" Method')
row_smooth2.prop(fourd_prop,'bool_selected_bones')
row_smooth2.operator('fdh.smooth2',text='Complete').option = 0
row_smooth2 = row_smooth2.row(align=True)
row_smooth2.operator('fdh.smooth2',text='Fix Graph').option = 1
row_smooth2.operator('fdh.smooth2',text='Smooth').option = 2
if fourd_prop.bool_footlock_panel:
row_flock = layout.box()
row_flock = row_flock.column(align=True)
row_flock.label(text='Foot Lock')
row_flock_sub0 = row_flock.row(align=True)
row_flock_sub0.operator('fdh.foot_lock_marker',text='Floor Reference').option=2
row_flock_sub0.operator('fdh.foot_lock',text='Analyze').option=0
row_flock.label(text='Markers')
row_flock_sub = row_flock.row(align=True)
row_flock_sub.operator('fdh.foot_lock_marker',text='Start').option=0
row_flock_sub.operator('fdh.foot_lock_marker',text='End').option=1
# row_flock = row_flock.column(align=True)
# row_flock.label(text='Apply')
row_flock_col = row_flock.row(align=True)
row_flock_col.operator('fdh.foot_lock',text='Apply').option=1
row_flock_col.operator('fdh.foot_lock',text='Original Data').option=2
row_flock.operator('fdh.foot_lock_marker',text='REMOVE MARKERS').option=-1
if fourd_prop.bool_export_panel:
row_export = layout.box()
row_export = row_export.column(align=True)
row_export.label(text='Export Tools')
row_export_col = row_export.row(align=True)
row_export_col.operator('fdh.zero_frame_t_pose',text='T Pose F0')
row_export_col.operator('fdh.remove_location_animation',text='Remove Location')
if fourd_prop.bool_nla_action_panel:
#checka se ja existe alguma janela com nla_view
scr = bpy.context.window.screen
nla_window = 0
for area in scr.areas:
if area.type == 'NLA_EDITOR':
nla_window = 1
row_view = layout.box()
row_view = row_view.column(align=True)
if nla_window ==1:
row_view.enabled = False
else:
row_view.enabled = True
row_view.label(text='Open NLA View')
row_view.operator('fdh.open_nla_view')
row_nla = layout.box()
row_nla = row_nla.column(align=True)
row_nla.label(text='NLA Actions')
row_nla_col = row_nla.row(align=True)
row_nla_col.prop(fourd_prop,'str_nla_name')
row_nla_col_paste = row_nla_col.column(align=True)
if fourd_prop.str_videopath == '' and fourd_prop.str_pklpath == '':
row_nla_col_paste.enabled = False
else:
row_nla_col_paste.enabled = True
row_nla_col_paste.operator('fdh.nla_copy_name_to_nla',icon='PASTEDOWN',text='')
#pega dados do objeto na cena
##########################
# rows = 4
scn = context.scene
#load name of action that is active
# ob = bpy.context.object
if len(bpy.context.selected_objects) >0:
ob = bpy.context.selected_objects[0]
else:
ob = None
###########################
row_nla_create = row_nla.column(align=True)
if ob is not None and ob.type == 'ARMATURE' and ob.animation_data.action is not None:
row_nla_create.enabled = True
else:
row_nla_create.enabled = False
row_nla_create.operator('fdh.nla_create_strip',text='Set Name')
# row = layout.box()
# row = row.column(align=True)
row = row_nla
if ob is not None:
action_name = (ob.animation_data.action.name if ob.animation_data is not None and ob.animation_data.action is not None else "")
else:
action_name = ''
if ob is not None and ob.animation_data is not None and len(ob.animation_data.nla_tracks)>0:
strip = ob.animation_data.nla_tracks[0]
else:
strip = None
# row.label(text='idx: '+str(scn.active_action_index))
# row.label(text='Editing: '+action_name)
# row.label(text=action_name)
rows = 4
row.template_list("ACTION_UL_list","",bpy.data,"actions",scn,"active_action_index",rows=rows)
row.operator('fdh.nla_load_action',text='Load')
row_act_col = row.row(align=True)
row_act_col.operator('fdh.set_no_action',text='Unload')
row_act_del = row_act_col.column(align=True)
if scn.active_action_index > len(bpy.data.actions)-1:
row_act_del.enabled = False
else:
row_act_del.enabled = True
row_act_del.operator('fdh.nla_delete_action',text='Delete')
row.separator()
row.operator('fdh.create_ref')
if fourd_prop.bool_nla_track_panel:
#pega dados do objeto na cena
##########################
# rows = 4
scn = context.scene
#load name of action that is active
# ob = bpy.context.object
if len(bpy.context.selected_objects) >0:
ob = bpy.context.selected_objects[0]
else:
ob = None
###########################
if ob is not None and ob.animation_data is not None and len(ob.animation_data.nla_tracks)>0:
strip = ob.animation_data.nla_tracks[0]
else:
strip = None
#checka se ja existe alguma janela com nla_view
scr = bpy.context.window.screen
nla_window = 0
for area in scr.areas:
if area.type == 'NLA_EDITOR':
nla_window = 1
row_strip = layout.box()
row_strip = row_strip.column(align=True)
row_strip.label(text='NLA Track Actions')
strips_check = ob and ob.animation_data is not None and len(ob.animation_data.nla_tracks) == 0
if ob is not None and ob.type == 'ARMATURE':
row_strip.enabled = True
else:
row_strip.enabled = False
if strips_check:
row_strip.operator('fdh.nla_add_track')
else:
# row_strip.label(text='Action')
row_strip_col_act = row_strip.row(align=True)
row_strip_col_act.operator('fdh.add_action_to_track',text='Add')
row_strip_col_act.operator('fdh.add_action_to_track_w_transition',text='Add w Transition').option=0
row_strip.label(text='Transition')
# row_strip.prop(fourd_prop,'int_frames_transition')
row_strip_col_trans = row_strip.row(align=True)
row_strip_col_trans_lt = row_strip_col_trans.column(align=True)
row_strip_col_trans_gt = row_strip_col_trans.column(align=True)
#pega nome da action selecionada na strip
if ob is not None and ob.animation_data is not None and len(ob.animation_data.nla_tracks)>0 and len(ob.animation_data.nla_tracks[0].strips)>0 and scn.active_track_index >=0:
act_type_on_strip = ob.animation_data.nla_tracks[0].strips[scn.active_track_index].type
if scn.active_track_index > 0:
act_type_on_strip_prev = ob.animation_data.nla_tracks[0].strips[scn.active_track_index-1].type
else:
act_type_on_strip_prev = None
if scn.active_track_index < len(ob.animation_data.nla_tracks[0].strips)-1:
act_type_on_strip_next = ob.animation_data.nla_tracks[0].strips[scn.active_track_index+1].type
else:
act_type_on_strip_next = None
else:
act_type_on_strip = None
act_type_on_strip_next = None
act_type_on_strip_prev = None
if (ob is not None and scn.active_track_index == 0) or (ob is not None and scn.active_track_index is not None and (act_type_on_strip=='TRANSITION' or act_type_on_strip_prev =='TRANSITION')):
row_strip_col_trans_lt.enabled = False
else:
row_strip_col_trans_lt.enabled = True
if (ob is not None and ob.animation_data is not None and len(ob.animation_data.nla_tracks)>0 and len(ob.animation_data.nla_tracks[0].strips)-1 == scn.active_track_index) or (ob is not None and ob.animation_data is not None and len(ob.animation_data.nla_tracks)>0 and scn.active_track_index is not None and (act_type_on_strip=='TRANSITION' or act_type_on_strip_next=='TRANSITION')):
row_strip_col_trans_gt.enabled = False
else:
row_strip_col_trans_gt.enabled = True
row_strip_col_trans_lt.operator('fdh.add_action_to_track_w_transition',icon='TRIA_LEFT',text='').option=1
row_strip_col_trans_gt.operator('fdh.add_action_to_track_w_transition',icon='TRIA_RIGHT',text='').option=2
row_strip_col_trans.prop(fourd_prop,'int_frames_transition')
row_strip.separator()
if nla_window ==1:
# row_strip.label(text='Select on NLA Editor')
row_strip.prop(fourd_prop,'bool_nla_selection_tools')
if fourd_prop.bool_nla_selection_tools:
# row_strip.operator('fdh.select_action_on_strip').option=0
row_strip_col_select = row_strip.row(align=True)
# row_strip_col_select.operator('fdh.select_action_on_strip',text='Single').option=0
row_strip_col_select.operator('fdh.select_action_on_strip',text='All').option=1
row_strip_col_select.operator('fdh.select_action_on_strip',text='None').option=2
row_strip.operator('fdh.match_to_prev_action')
if not strips_check :
rows = 4
row_strip.template_list("ACTION_STRIP_UL_list","",strip,"strips",scn,"active_track_index",rows=rows)
row_strip.operator('fdh.delete_action_from_track')
row_strip.operator('fdh.organize_strip')
# row_stage2 = layout.box()
# row_stage2= row_stage2.column(align=True)
# row_stage2.label(text='Stage2')
if fourd_prop.bool_retarget_panel:
scn = context.scene
armature_mesh = context.scene.target_mesh
row_rest_pose = layout.box()
row_rest_pose = row_rest_pose.column(align=True)
row_rest_pose_col = row_rest_pose.row(align= True)
row_rest_pose_col.label(text='Change Tgt Rest Pose')
# row_rest_pose_col.operator('fdh.clear_tgt_mesh_shapekeys')
row_rest_pose.prop(scn,'target')
row_rest_pose.prop(scn,'target_mesh',text='Mesh')
row_rest_pose.operator('fdh.start_change_tgt_rest_pose')
row_rest_pose_alert = row_rest_pose.column(align=True)
row_rest_pose_alert.alert = True
if armature_mesh is not None and armature_mesh.type == 'MESH' and armature_mesh.data.shape_keys is not None: #shape_keys is not nonee para ver se tem shapekeys
_label_multiline(
context=context,
text='Executing this process will remove your shapekeys',
parent=row_rest_pose_alert
)
row_rest_pose.operator('fdh.end_change_tgt_rest_pose')
# row_rest_source_pose = row_rest_pose.column(align=1)
# row_rest_source_pose.label(text='Source Pose')
# row_rest_source_pose.operator('fdh.start_change_source_rest_pose')
# row_rest_source_pose.operator('fdh.end_change_source_rest_pose')
row_remap = layout.box()
row_remap= row_remap.column(align=True)
row_remap_col = row_remap.row(align=True)
row_remap_col.label(text='Retarget')
row_remap_choose_retarget = row_remap.column()
if fourd_prop.enum_list_rig == '-1':
row_remap_choose_retarget.alert=True
else:
row_remap_choose_retarget.alert=False
row_remap_choose_retarget.prop(fourd_prop,'enum_list_rig')
# row_remap_alert_prefix = row_remap.column()
# if fourd_prop.enum_list_rig.startswith('mixamo') and scn.target is not None and scn.target.type == 'ARMATURE':
# prefix = scn.target.data.bones[0].name.split(':')[0]
# if prefix+':' == fourd_prop.str_retarget_prefix:
# row_remap_alert_prefix.alert=False
# else:
# row_remap_alert_prefix.alert=True
# row_remap_alert_prefix.label(text='Prefix: '+prefix+':')
# row_remap_alert_prefix.prop(fourd_prop,'str_retarget_prefix')
row_remap.separator()
row_remap.prop(scn,'source')
row_remap.prop(scn,'target')
row_remap_retarget = row_remap.column()
if fourd_prop.enum_list_rig == '-1':
row_remap_retarget.enabled = False
else:
row_remap_retarget.enabled = True
row_remap_retarget.operator('fdh.retarget',text='Bind').option=0 #bind
row_remap_unbind = row_remap.column()
if scn.target is not None and scn.target.get('bind') is not None and scn.target['bind'] == 1:
row_remap_unbind.enabled = True
else:
row_remap_unbind.enabled = False
row_remap_unbind.operator('fdh.retarget',text='Unbind').option=1 #unbind
row_remap_unbind.separator()
row_remap_apply_retarget = row_remap.column()
if scn.target is not None and scn.target.get('bind') is not None and scn.target['bind'] == 1:
row_remap_apply_retarget.enabled = True
else:
row_remap_apply_retarget.enabled = False
row_remap_apply_retarget.prop(fourd_prop,'bool_retarget_hide_source')
row_remap_apply_retarget.operator('fdh.retarget',text='Apply Retarget').option=2 #apply
if fourd_prop.bool_extract_marked_frames_panel:
rowb = layout.row(align=True).box()
rowb = rowb.column(align=True)
rowb_extract_col = rowb.row(align=True)
rowb_extract_col.label(text='Extract Marked Frames')
if context.active_object is not None and context.active_object.type == 'ARMATURE':
rowb_extract_col.operator('fdh.optimize_marker_view')
rowb_extract_marker = rowb.column()
if len(bpy.context.scene.timeline_markers) == 0:
rowb_extract_marker.enabled = False
else:
rowb_extract_marker.enabled = True
rowb_extract_marker.operator('fdh.extract_marked_frames',text='Entire Character')
if context.active_object is not None and context.active_object.mode == 'POSE' and len(context.selected_pose_bones) > 0 :
rowb_extract_marker.operator('fdh.extract_marked_frames_for_selected_bones')
rowb_extract_marker.operator('fdh.clear_markers')
row_quicksave = rowb
row_quicksave.label(text='Quick Save/Load')
row_quicksave.prop(fourd_prop,'bool_clear_before_load_quickload')
row_qs_ql = row_quicksave.row(align=True)
row_qs_ql.operator('fdh.quick_save_markers',text='QS 1').option=1
row_ql = row_qs_ql.row(align=True)
row_ql.enabled = False if fourd_prop.str_quick_save_marker1 == '' else True
row_ql.operator('fdh.quick_load_markers',text='QL 1').option=1
row_ql.operator('fdh.quick_save_markers_clear',text='X').option=1
row_qs_ql = row_quicksave.row(align=True)
row_qs_ql.operator('fdh.quick_save_markers',text='QS 2').option=2
row_ql = row_qs_ql.row(align=True)
row_ql.enabled = False if fourd_prop.str_quick_save_marker2 == '' else True
row_ql.operator('fdh.quick_load_markers',text='QL 2').option=2
row_ql.operator('fdh.quick_save_markers_clear',text='X').option=2
row_qs_ql = row_quicksave.row(align=True)
row_qs_ql.operator('fdh.quick_save_markers',text='QS 3').option=3
row_ql = row_qs_ql.row(align=True)
row_ql.enabled = False if fourd_prop.str_quick_save_marker3 == '' else True
row_ql.operator('fdh.quick_load_markers',text='QL 3').option=3
row_ql.operator('fdh.quick_save_markers_clear',text='X').option=3
row_qs_ql = row_quicksave.row(align=True)
row_qs_ql.operator('fdh.quick_save_markers',text='QS 4').option=4
row_ql = row_qs_ql.row(align=True)
row_ql.enabled = False if fourd_prop.str_quick_save_marker4 == '' else True
row_ql.operator('fdh.quick_load_markers',text='QL 4').option=4
row_ql.operator('fdh.quick_save_markers_clear',text='X').option=4
row_qs_ql = row_quicksave.column(align=True)
row_qs_ql.separator()
row_qs_ql.operator('fdh.quick_save_markers_clear').option=0 #limpa tudo
# row = layout.box()
# scn = context.scene
# row.operator('fdh.append_stg2')
# row.prop(scn,'target_stg2')
# row.operator('fdh.stg2_retarget')
# row.operator('fdh.mr_switch_snap_anim')
# row = layout.box()
# row.operator('fdh.stg2_full')
if fourd_prop.bool_wham:
row = layout.box()
row = row.column(align=True)
row.operator('fdh.add_video_wham')
text_path = 'Video Path: '+fourd_prop.str_videopath
_label_multiline(
context=context,
text=text_path,
parent=row
)
row_execute_wham = row.column(align=1)
if not os.path.exists(flag_video_wham):
row_execute_wham.enabled = False
else:
row_execute_wham.enabled = True
row_execute_wham.prop(fourd_prop,'bool_wham_simplify')
row_execute_wham.operator('fdh.execute_wham')
row_execute_wham.separator()
row_execute_wham.operator('fdh.load_video_3dview')
row = layout.box()