-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy path__init__.py
6378 lines (5972 loc) · 432 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
# 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
# MERCHANTIBILITY 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, see <http://www.gnu.org/licenses/>.
bl_info = {
"name" : "3DGS Render by KIRI Engine",
"author" : "KIRI ENGINE TEAM",
"description" : "Import, edit, render and animate 3DGS scans",
"blender" : (4, 2, 0),
"version" : (2, 1, 0),
"location" : "",
"warning" : "Restart Blender after install/uninstall",
"doc_url": "",
"tracker_url": "",
"category" : "3D View"
}
import bpy
import bpy.utils.previews
import webbrowser
import os
from bpy.app.handlers import persistent
from bpy_extras.io_utils import ImportHelper, ExportHelper
from mathutils import Matrix
import math
import sys
from mathutils import Vector, Matrix
def string_to_int(value):
if value.isdigit():
return int(value)
return 0
def string_to_icon(value):
if value in bpy.types.UILayout.bl_rna.functions["prop"].parameters["icon"].enum_items.keys():
return bpy.types.UILayout.bl_rna.functions["prop"].parameters["icon"].enum_items[value].value
return string_to_int(value)
addon_keymaps = {}
_icons = None
kiri_3dgs_render__active_object_update = {'sna_apply_modifier_list': [], 'sna_in_camera_view': False, }
kiri_3dgs_render__collection_snippets = {'sna_collections_temp_list': [], }
kiri_3dgs_render__hq_mode = {'sna_hq_base_object_list': [], }
kiri_3dgs_render__import_ply = {'sna_dgs_lq_active': None, }
kiri_3dgs_render__omnisplat = {'sna_omniviewobjectsformerge': [], 'sna_omniviewbase': None, 'sna_omniviewmodifierlist': [], }
def sna_update_sna_kiri3dgs_active_object_update_mode_868D4(self, context):
sna_updated_prop = self.sna_kiri3dgs_active_object_update_mode
self['update_rot_to_cam'] = (sna_updated_prop == 'Enable Camera Updates')
self.modifiers['KIRI_3DGS_Render_GN']['Socket_50'] = (2 if (sna_updated_prop == 'Show As Point Cloud') else (1 if (sna_updated_prop != 'Enable Camera Updates') else 0))
bpy.context.view_layer.objects.active.modifiers['KIRI_3DGS_Render_GN'].show_viewport = (True if (sna_updated_prop != 'Disable Camera Updates') else False)
bpy.context.view_layer.objects.active.update_tag(refresh={'OBJECT'}, )
if bpy.context and bpy.context.screen:
for a in bpy.context.screen.areas:
a.tag_redraw()
def sna_update_sna_kiri3dgs_active_object_enable_active_camera_DE26E(self, context):
sna_updated_prop = self.sna_kiri3dgs_active_object_enable_active_camera
if sna_updated_prop:
bpy.context.area.spaces.active.region_3d.view_perspective = 'CAMERA'
bpy.context.view_layer.objects.active.modifiers['KIRI_3DGS_Render_GN']['Socket_54'] = sna_updated_prop
def delayed_214CF():
sna_dgs__update_camera_single_time_function_execute_9C695()
bpy.app.timers.register(delayed_214CF, first_interval=0.10000000149011612)
else:
bpy.context.view_layer.objects.active.modifiers['KIRI_3DGS_Render_GN']['Socket_54'] = sna_updated_prop
def sna_add_geo_nodes__append_group_2D522_F22B7(Append_Path, Node_Group_Name, Objects, Modifier_Name):
if property_exists("bpy.data.node_groups[Node_Group_Name]", globals(), locals()):
pass
else:
before_data = list(bpy.data.node_groups)
bpy.ops.wm.append(directory=Append_Path + r'\NodeTree', filename=Node_Group_Name, link=False)
new_data = list(filter(lambda d: not d in before_data, list(bpy.data.node_groups)))
appended_C35B3 = None if not new_data else new_data[0]
modifier_D540A = Objects.modifiers.new(name=Modifier_Name, type='NODES', )
modifier_D540A.node_group = bpy.data.node_groups[Node_Group_Name]
return modifier_D540A
def sna_update_sna_kiri3dgs_lq_mode__hq_mode_0B3A9(self, context):
sna_updated_prop = self.sna_kiri3dgs_lq_mode__hq_mode
if bool(bpy.data.materials.find('KIRI_3DGS_Render_Material')):
bpy.data.materials['KIRI_3DGS_Render_Material'].surface_render_method = ('BLENDED' if (sna_updated_prop == 'HQ Mode (Blended Alpha)') else 'DITHERED')
if (sna_updated_prop == 'HQ Mode (Blended Alpha)'):
for i_26967 in range(len(bpy.data.objects)):
if (property_exists("bpy.data.objects[i_26967].modifiers", globals(), locals()) and 'KIRI_3DGS_Sorter_GN' in bpy.data.objects[i_26967].modifiers):
bpy.data.objects[i_26967].modifiers['KIRI_3DGS_Sorter_GN'].show_viewport = True
bpy.data.objects[i_26967].modifiers['KIRI_3DGS_Sorter_GN'].show_render = True
bpy.data.objects[i_26967].update_tag(refresh={'DATA'}, )
if bpy.context and bpy.context.screen:
for a in bpy.context.screen.areas:
a.tag_redraw()
else:
for i_2A560 in range(len(bpy.data.objects)):
if (property_exists("bpy.data.objects[i_2A560].modifiers", globals(), locals()) and 'KIRI_3DGS_Sorter_GN' in bpy.data.objects[i_2A560].modifiers):
bpy.data.objects[i_2A560].modifiers['KIRI_3DGS_Sorter_GN'].show_viewport = False
bpy.data.objects[i_2A560].modifiers['KIRI_3DGS_Sorter_GN'].show_render = False
bpy.data.objects[i_2A560].update_tag(refresh={'DATA'}, )
if bpy.context and bpy.context.screen:
for a in bpy.context.screen.areas:
a.tag_redraw()
if (property_exists("bpy.context.scene.objects", globals(), locals()) and 'KIRI_HQ_Merged_Object' in bpy.context.scene.objects):
if (sna_updated_prop == 'HQ Mode (Blended Alpha)'):
for i_348A3 in range(len(bpy.context.scene.objects)):
if (bpy.context.scene.objects[i_348A3] == None):
pass
else:
if ((property_exists("bpy.context.scene.objects[i_348A3].material_slots", globals(), locals()) and 'KIRI_3DGS_Render_Material' in bpy.context.scene.objects[i_348A3].material_slots) or (property_exists("bpy.context.scene.objects[i_348A3].modifiers", globals(), locals()) and 'KIRI_3DGS_Sorter_GN' in bpy.context.scene.objects[i_348A3].modifiers)):
bpy.context.scene.objects[i_348A3].hide_viewport = True
bpy.context.scene.objects[i_348A3].hide_render = True
bpy.data.objects['KIRI_HQ_Merged_Object'].hide_viewport = False
bpy.data.objects['KIRI_HQ_Merged_Object'].hide_render = False
else:
bpy.data.objects['KIRI_HQ_Merged_Object'].hide_viewport = True
bpy.data.objects['KIRI_HQ_Merged_Object'].hide_render = True
for i_414C1 in range(len(bpy.context.scene.objects)):
if (bpy.context.scene.objects[i_414C1] == None):
pass
else:
if ((property_exists("bpy.context.scene.objects[i_414C1].material_slots", globals(), locals()) and 'KIRI_3DGS_Render_Material' in bpy.context.scene.objects[i_414C1].material_slots) or (property_exists("bpy.context.scene.objects[i_414C1].modifiers", globals(), locals()) and 'KIRI_3DGS_Sorter_GN' in bpy.context.scene.objects[i_414C1].modifiers)):
bpy.context.scene.objects[i_414C1].hide_viewport = False
bpy.context.scene.objects[i_414C1].hide_render = False
def sna_add_geo_nodes__append_group_2D522_0741E(Append_Path, Node_Group_Name, Objects, Modifier_Name):
if property_exists("bpy.data.node_groups[Node_Group_Name]", globals(), locals()):
pass
else:
before_data = list(bpy.data.node_groups)
bpy.ops.wm.append(directory=Append_Path + r'\NodeTree', filename=Node_Group_Name, link=False)
new_data = list(filter(lambda d: not d in before_data, list(bpy.data.node_groups)))
appended_C35B3 = None if not new_data else new_data[0]
modifier_D540A = Objects.modifiers.new(name=Modifier_Name, type='NODES', )
modifier_D540A.node_group = bpy.data.node_groups[Node_Group_Name]
return modifier_D540A
def sna_update_sna_kiri3dgs_hq_objects_overlap_DDF15(self, context):
sna_updated_prop = self.sna_kiri3dgs_hq_objects_overlap
if sna_updated_prop:
pass
else:
if (property_exists("bpy.context.scene.objects", globals(), locals()) and 'KIRI_HQ_Merged_Object' in bpy.context.scene.objects):
bpy.ops.sna.disable_hq_overlap_34678('INVOKE_DEFAULT', )
def sna_add_geo_nodes__append_group_2D522_BF551(Append_Path, Node_Group_Name, Objects, Modifier_Name):
if property_exists("bpy.data.node_groups[Node_Group_Name]", globals(), locals()):
pass
else:
before_data = list(bpy.data.node_groups)
bpy.ops.wm.append(directory=Append_Path + r'\NodeTree', filename=Node_Group_Name, link=False)
new_data = list(filter(lambda d: not d in before_data, list(bpy.data.node_groups)))
appended_C35B3 = None if not new_data else new_data[0]
modifier_D540A = Objects.modifiers.new(name=Modifier_Name, type='NODES', )
modifier_D540A.node_group = bpy.data.node_groups[Node_Group_Name]
return modifier_D540A
def sna_add_geo_nodes__append_group_2D522_91587(Append_Path, Node_Group_Name, Objects, Modifier_Name):
if property_exists("bpy.data.node_groups[Node_Group_Name]", globals(), locals()):
pass
else:
before_data = list(bpy.data.node_groups)
bpy.ops.wm.append(directory=Append_Path + r'\NodeTree', filename=Node_Group_Name, link=False)
new_data = list(filter(lambda d: not d in before_data, list(bpy.data.node_groups)))
appended_C35B3 = None if not new_data else new_data[0]
modifier_D540A = Objects.modifiers.new(name=Modifier_Name, type='NODES', )
modifier_D540A.node_group = bpy.data.node_groups[Node_Group_Name]
return modifier_D540A
def sna_add_geo_nodes__append_group_2D522_8E257(Append_Path, Node_Group_Name, Objects, Modifier_Name):
if property_exists("bpy.data.node_groups[Node_Group_Name]", globals(), locals()):
pass
else:
before_data = list(bpy.data.node_groups)
bpy.ops.wm.append(directory=Append_Path + r'\NodeTree', filename=Node_Group_Name, link=False)
new_data = list(filter(lambda d: not d in before_data, list(bpy.data.node_groups)))
appended_C35B3 = None if not new_data else new_data[0]
modifier_D540A = Objects.modifiers.new(name=Modifier_Name, type='NODES', )
modifier_D540A.node_group = bpy.data.node_groups[Node_Group_Name]
return modifier_D540A
def sna_add_geo_nodes__append_group_2D522_DDE79(Append_Path, Node_Group_Name, Objects, Modifier_Name):
if property_exists("bpy.data.node_groups[Node_Group_Name]", globals(), locals()):
pass
else:
before_data = list(bpy.data.node_groups)
bpy.ops.wm.append(directory=Append_Path + r'\NodeTree', filename=Node_Group_Name, link=False)
new_data = list(filter(lambda d: not d in before_data, list(bpy.data.node_groups)))
appended_C35B3 = None if not new_data else new_data[0]
modifier_D540A = Objects.modifiers.new(name=Modifier_Name, type='NODES', )
modifier_D540A.node_group = bpy.data.node_groups[Node_Group_Name]
return modifier_D540A
def sna_add_geo_nodes__append_group_2D522_EB4FD(Append_Path, Node_Group_Name, Objects, Modifier_Name):
if property_exists("bpy.data.node_groups[Node_Group_Name]", globals(), locals()):
pass
else:
before_data = list(bpy.data.node_groups)
bpy.ops.wm.append(directory=Append_Path + r'\NodeTree', filename=Node_Group_Name, link=False)
new_data = list(filter(lambda d: not d in before_data, list(bpy.data.node_groups)))
appended_C35B3 = None if not new_data else new_data[0]
modifier_D540A = Objects.modifiers.new(name=Modifier_Name, type='NODES', )
modifier_D540A.node_group = bpy.data.node_groups[Node_Group_Name]
return modifier_D540A
def sna_add_geo_nodes__append_group_2D522_592E9(Append_Path, Node_Group_Name, Objects, Modifier_Name):
if property_exists("bpy.data.node_groups[Node_Group_Name]", globals(), locals()):
pass
else:
before_data = list(bpy.data.node_groups)
bpy.ops.wm.append(directory=Append_Path + r'\NodeTree', filename=Node_Group_Name, link=False)
new_data = list(filter(lambda d: not d in before_data, list(bpy.data.node_groups)))
appended_C35B3 = None if not new_data else new_data[0]
modifier_D540A = Objects.modifiers.new(name=Modifier_Name, type='NODES', )
modifier_D540A.node_group = bpy.data.node_groups[Node_Group_Name]
return modifier_D540A
def sna_add_geo_nodes__append_group_2D522_B6203(Append_Path, Node_Group_Name, Objects, Modifier_Name):
if property_exists("bpy.data.node_groups[Node_Group_Name]", globals(), locals()):
pass
else:
before_data = list(bpy.data.node_groups)
bpy.ops.wm.append(directory=Append_Path + r'\NodeTree', filename=Node_Group_Name, link=False)
new_data = list(filter(lambda d: not d in before_data, list(bpy.data.node_groups)))
appended_C35B3 = None if not new_data else new_data[0]
modifier_D540A = Objects.modifiers.new(name=Modifier_Name, type='NODES', )
modifier_D540A.node_group = bpy.data.node_groups[Node_Group_Name]
return modifier_D540A
def sna_add_geo_nodes__append_group_2D522_5FBAE(Append_Path, Node_Group_Name, Objects, Modifier_Name):
if property_exists("bpy.data.node_groups[Node_Group_Name]", globals(), locals()):
pass
else:
before_data = list(bpy.data.node_groups)
bpy.ops.wm.append(directory=Append_Path + r'\NodeTree', filename=Node_Group_Name, link=False)
new_data = list(filter(lambda d: not d in before_data, list(bpy.data.node_groups)))
appended_C35B3 = None if not new_data else new_data[0]
modifier_D540A = Objects.modifiers.new(name=Modifier_Name, type='NODES', )
modifier_D540A.node_group = bpy.data.node_groups[Node_Group_Name]
return modifier_D540A
def sna_add_geo_nodes__append_group_2D522_74B9D(Append_Path, Node_Group_Name, Objects, Modifier_Name):
if property_exists("bpy.data.node_groups[Node_Group_Name]", globals(), locals()):
pass
else:
before_data = list(bpy.data.node_groups)
bpy.ops.wm.append(directory=Append_Path + r'\NodeTree', filename=Node_Group_Name, link=False)
new_data = list(filter(lambda d: not d in before_data, list(bpy.data.node_groups)))
appended_C35B3 = None if not new_data else new_data[0]
modifier_D540A = Objects.modifiers.new(name=Modifier_Name, type='NODES', )
modifier_D540A.node_group = bpy.data.node_groups[Node_Group_Name]
return modifier_D540A
def sna_add_geo_nodes__append_group_2D522_03222(Append_Path, Node_Group_Name, Objects, Modifier_Name):
if property_exists("bpy.data.node_groups[Node_Group_Name]", globals(), locals()):
pass
else:
before_data = list(bpy.data.node_groups)
bpy.ops.wm.append(directory=Append_Path + r'\NodeTree', filename=Node_Group_Name, link=False)
new_data = list(filter(lambda d: not d in before_data, list(bpy.data.node_groups)))
appended_C35B3 = None if not new_data else new_data[0]
modifier_D540A = Objects.modifiers.new(name=Modifier_Name, type='NODES', )
modifier_D540A.node_group = bpy.data.node_groups[Node_Group_Name]
return modifier_D540A
def sna_update_sna_kiri3dgs_modifier_enable_animate_1F5D0(self, context):
sna_updated_prop = self.sna_kiri3dgs_modifier_enable_animate
bpy.context.view_layer.objects.active.modifiers['KIRI_3DGS_Animate_GN'].show_viewport = sna_updated_prop
bpy.context.view_layer.objects.active.modifiers['KIRI_3DGS_Animate_GN'].show_render = sna_updated_prop
def sna_update_sna_kiri3dgs_modifier_enable_decimate_641A7(self, context):
sna_updated_prop = self.sna_kiri3dgs_modifier_enable_decimate
bpy.context.view_layer.objects.active.modifiers['KIRI_3DGS_Decimate_GN'].show_viewport = sna_updated_prop
bpy.context.view_layer.objects.active.modifiers['KIRI_3DGS_Decimate_GN'].show_render = sna_updated_prop
def sna_update_sna_kiri3dgs_modifier_enable_camera_cull_A98D6(self, context):
sna_updated_prop = self.sna_kiri3dgs_modifier_enable_camera_cull
bpy.context.view_layer.objects.active.modifiers['KIRI_3DGS_Camera_Cull_GN'].show_viewport = sna_updated_prop
bpy.context.view_layer.objects.active.modifiers['KIRI_3DGS_Camera_Cull_GN'].show_render = sna_updated_prop
def sna_update_sna_kiri3dgs_modifier_enable_crop_box_6FCA7(self, context):
sna_updated_prop = self.sna_kiri3dgs_modifier_enable_crop_box
bpy.context.view_layer.objects.active.modifiers['KIRI_3DGS_Crop_Box_GN'].show_viewport = sna_updated_prop
bpy.context.view_layer.objects.active.modifiers['KIRI_3DGS_Crop_Box_GN'].show_render = sna_updated_prop
def sna_update_sna_kiri3dgs_modifier_enable_colour_edit_1D6A1(self, context):
sna_updated_prop = self.sna_kiri3dgs_modifier_enable_colour_edit
bpy.context.view_layer.objects.active.modifiers['KIRI_3DGS_Colour_Edit_GN'].show_viewport = sna_updated_prop
bpy.context.view_layer.objects.active.modifiers['KIRI_3DGS_Colour_Edit_GN'].show_render = sna_updated_prop
def sna_update_sna_kiri3dgs_modifier_enable_remove_stray_488C9(self, context):
sna_updated_prop = self.sna_kiri3dgs_modifier_enable_remove_stray
bpy.context.view_layer.objects.active.modifiers['KIRI_3DGS_Remove_Stray_GN'].show_viewport = sna_updated_prop
bpy.context.view_layer.objects.active.modifiers['KIRI_3DGS_Remove_Stray_GN'].show_render = sna_updated_prop
def sna_add_geo_nodes__append_group_2D522_90019(Append_Path, Node_Group_Name, Objects, Modifier_Name):
if property_exists("bpy.data.node_groups[Node_Group_Name]", globals(), locals()):
pass
else:
before_data = list(bpy.data.node_groups)
bpy.ops.wm.append(directory=Append_Path + r'\NodeTree', filename=Node_Group_Name, link=False)
new_data = list(filter(lambda d: not d in before_data, list(bpy.data.node_groups)))
appended_C35B3 = None if not new_data else new_data[0]
modifier_D540A = Objects.modifiers.new(name=Modifier_Name, type='NODES', )
modifier_D540A.node_group = bpy.data.node_groups[Node_Group_Name]
return modifier_D540A
def sna_add_geo_nodes__append_group_2D522_9D3B3(Append_Path, Node_Group_Name, Objects, Modifier_Name):
if property_exists("bpy.data.node_groups[Node_Group_Name]", globals(), locals()):
pass
else:
before_data = list(bpy.data.node_groups)
bpy.ops.wm.append(directory=Append_Path + r'\NodeTree', filename=Node_Group_Name, link=False)
new_data = list(filter(lambda d: not d in before_data, list(bpy.data.node_groups)))
appended_C35B3 = None if not new_data else new_data[0]
modifier_D540A = Objects.modifiers.new(name=Modifier_Name, type='NODES', )
modifier_D540A.node_group = bpy.data.node_groups[Node_Group_Name]
return modifier_D540A
def sna_add_geo_nodes__append_group_2D522_E5645(Append_Path, Node_Group_Name, Objects, Modifier_Name):
if property_exists("bpy.data.node_groups[Node_Group_Name]", globals(), locals()):
pass
else:
before_data = list(bpy.data.node_groups)
bpy.ops.wm.append(directory=Append_Path + r'\NodeTree', filename=Node_Group_Name, link=False)
new_data = list(filter(lambda d: not d in before_data, list(bpy.data.node_groups)))
appended_C35B3 = None if not new_data else new_data[0]
modifier_D540A = Objects.modifiers.new(name=Modifier_Name, type='NODES', )
modifier_D540A.node_group = bpy.data.node_groups[Node_Group_Name]
return modifier_D540A
def sna_add_geo_nodes__append_group_2D522_9D9CF(Append_Path, Node_Group_Name, Objects, Modifier_Name):
if property_exists("bpy.data.node_groups[Node_Group_Name]", globals(), locals()):
pass
else:
before_data = list(bpy.data.node_groups)
bpy.ops.wm.append(directory=Append_Path + r'\NodeTree', filename=Node_Group_Name, link=False)
new_data = list(filter(lambda d: not d in before_data, list(bpy.data.node_groups)))
appended_C35B3 = None if not new_data else new_data[0]
modifier_D540A = Objects.modifiers.new(name=Modifier_Name, type='NODES', )
modifier_D540A.node_group = bpy.data.node_groups[Node_Group_Name]
return modifier_D540A
def property_exists(prop_path, glob, loc):
try:
eval(prop_path, glob, loc)
return True
except:
return False
def load_preview_icon(path):
global _icons
if not path in _icons:
if os.path.exists(path):
_icons.load(path, path, "IMAGE")
else:
return 0
return _icons[path].icon_id
class SNA_OT_Launch_Kiri_Site_D26Bf(bpy.types.Operator):
bl_idname = "sna.launch_kiri_site_d26bf"
bl_label = "Launch Kiri Site"
bl_description = "Launches a browser for the KIRI Engine main site"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
if bpy.app.version >= (3, 0, 0) and True:
cls.poll_message_set('')
return not False
def execute(self, context):
url = 'https://www.kiriengine.com/'
# Open the web browser and go to the specified URL
webbrowser.open(url)
print(f"Opening web browser to {url}")
return {"FINISHED"}
def invoke(self, context, event):
return self.execute(context)
class SNA_OT_Launch_Blender_Market_77F72(bpy.types.Operator):
bl_idname = "sna.launch_blender_market_77f72"
bl_label = "Launch Blender Market"
bl_description = "Launches a browser for the KIRI Engine Blender Market store"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
if bpy.app.version >= (3, 0, 0) and True:
cls.poll_message_set('')
return not False
def execute(self, context):
url = 'https://blendermarket.com/creators/blender-addon-from-kiri-engine'
# Open the web browser and go to the specified URL
webbrowser.open(url)
print(f"Opening web browser to {url}")
return {"FINISHED"}
def invoke(self, context, event):
return self.execute(context)
def sna_active_object_camera_update_interface_func_9588F(layout_function, ):
if (property_exists("bpy.context.view_layer.objects.active.modifiers", globals(), locals()) and 'KIRI_3DGS_Render_GN' in bpy.context.view_layer.objects.active.modifiers):
col_A4D20 = layout_function.column(heading='', align=False)
col_A4D20.alert = False
col_A4D20.enabled = True
col_A4D20.active = True
col_A4D20.use_property_split = False
col_A4D20.use_property_decorate = False
col_A4D20.scale_x = 1.0
col_A4D20.scale_y = 1.0
col_A4D20.alignment = 'Expand'.upper()
col_A4D20.operator_context = "INVOKE_DEFAULT" if True else "EXEC_DEFAULT"
col_A4D20.label(text='Active Object', icon_value=load_preview_icon(os.path.join(os.path.dirname(__file__), 'assets', 'bullet-point-4084289 - light blue.png')))
col_A4D20.separator(factor=1.0)
if (bpy.context.view_layer.objects.active.sna_kiri3dgs_active_object_update_mode == 'Enable Camera Updates'):
if bpy.context.view_layer.objects.active.sna_kiri3dgs_active_object_enable_active_camera:
pass
else:
if 'EDIT_MESH'==bpy.context.mode:
box_A6D9A = col_A4D20.box()
box_A6D9A.alert = False
box_A6D9A.enabled = True
box_A6D9A.active = True
box_A6D9A.use_property_split = False
box_A6D9A.use_property_decorate = False
box_A6D9A.alignment = 'Expand'.upper()
box_A6D9A.scale_x = 1.0
box_A6D9A.scale_y = 1.0
if not True: box_A6D9A.operator_context = "EXEC_DEFAULT"
row_6C7B3 = box_A6D9A.row(heading='', align=False)
row_6C7B3.alert = False
row_6C7B3.enabled = True
row_6C7B3.active = True
row_6C7B3.use_property_split = False
row_6C7B3.use_property_decorate = False
row_6C7B3.scale_x = 1.0
row_6C7B3.scale_y = 1.0
row_6C7B3.alignment = 'Expand'.upper()
row_6C7B3.operator_context = "INVOKE_DEFAULT" if True else "EXEC_DEFAULT"
op = row_6C7B3.operator('sna.align_active_to_x_axis_9b12e', text='X', icon_value=0, emboss=True, depress=False)
op = row_6C7B3.operator('sna.align_active_to_y_axis_9bd1f', text='Y', icon_value=0, emboss=True, depress=False)
op = row_6C7B3.operator('sna.align_active_to_z_axis_720a9', text='Z', icon_value=0, emboss=True, depress=False)
else:
box_D2CC1 = col_A4D20.box()
box_D2CC1.alert = False
box_D2CC1.enabled = True
box_D2CC1.active = True
box_D2CC1.use_property_split = False
box_D2CC1.use_property_decorate = False
box_D2CC1.alignment = 'Expand'.upper()
box_D2CC1.scale_x = 1.0
box_D2CC1.scale_y = 1.0
if not True: box_D2CC1.operator_context = "EXEC_DEFAULT"
op = box_D2CC1.operator('sna.align_active_to_view_88e3a', text='Update Active To View', icon_value=load_preview_icon(os.path.join(os.path.dirname(__file__), 'assets', 'eye-6926444-white.png')), emboss=True, depress=False)
col_A4D20.separator(factor=1.0)
col_F0A3B = col_A4D20.column(heading='', align=False)
col_F0A3B.alert = False
col_F0A3B.enabled = True
col_F0A3B.active = True
col_F0A3B.use_property_split = False
col_F0A3B.use_property_decorate = False
col_F0A3B.scale_x = 1.0
col_F0A3B.scale_y = 1.0
col_F0A3B.alignment = 'Expand'.upper()
col_F0A3B.operator_context = "INVOKE_DEFAULT" if True else "EXEC_DEFAULT"
col_F0A3B.prop(bpy.context.view_layer.objects.active, 'sna_kiri3dgs_active_object_update_mode', text='', icon_value=0, emboss=True, toggle=True)
if (bpy.context.view_layer.objects.active.sna_kiri3dgs_active_object_update_mode == 'Show As Point Cloud'):
attr_C8F44 = '["' + str('Socket_51' + '"]')
col_A4D20.prop(bpy.context.view_layer.objects.active.modifiers['KIRI_3DGS_Render_GN'], attr_C8F44, text='Point Radius', icon_value=0, emboss=True)
if (bpy.context.view_layer.objects.active.sna_kiri3dgs_active_object_update_mode == 'Enable Camera Updates'):
box_85B7C = col_A4D20.box()
box_85B7C.alert = bpy.context.view_layer.objects.active.sna_kiri3dgs_active_object_enable_active_camera
box_85B7C.enabled = (not (bpy.context.scene.camera == None))
box_85B7C.active = True
box_85B7C.use_property_split = False
box_85B7C.use_property_decorate = False
box_85B7C.alignment = 'Expand'.upper()
box_85B7C.scale_x = 1.0
box_85B7C.scale_y = 1.0
if not True: box_85B7C.operator_context = "EXEC_DEFAULT"
if (bpy.context.scene.camera == None):
box_9DBDD = box_85B7C.box()
box_9DBDD.alert = True
box_9DBDD.enabled = True
box_9DBDD.active = True
box_9DBDD.use_property_split = False
box_9DBDD.use_property_decorate = False
box_9DBDD.alignment = 'Expand'.upper()
box_9DBDD.scale_x = 1.0
box_9DBDD.scale_y = 1.0
if not True: box_9DBDD.operator_context = "EXEC_DEFAULT"
box_9DBDD.label(text='No active camera in scene', icon_value=load_preview_icon(os.path.join(os.path.dirname(__file__), 'assets', 'warning-7381086-red.png')))
box_85B7C.prop(bpy.context.view_layer.objects.active, 'sna_kiri3dgs_active_object_enable_active_camera', text='Use Active Camera', icon_value=load_preview_icon(os.path.join(os.path.dirname(__file__), 'assets', 'camera-7391968-white.png')), emboss=True, toggle=True)
col_58BF4 = layout_function.column(heading='', align=False)
col_58BF4.alert = False
col_58BF4.enabled = True
col_58BF4.active = True
col_58BF4.use_property_split = False
col_58BF4.use_property_decorate = False
col_58BF4.scale_x = 1.0
col_58BF4.scale_y = 1.0
col_58BF4.alignment = 'Expand'.upper()
col_58BF4.operator_context = "INVOKE_DEFAULT" if True else "EXEC_DEFAULT"
op = col_58BF4.operator('sna.apply_3dgs_modifiers_e67a2', text='Apply Modifiers', icon_value=load_preview_icon(os.path.join(os.path.dirname(__file__), 'assets', 'checked-5690873-white.png')), emboss=True, depress=False)
op.sna_apply_3dgs_render_modifier = False
op.sna_apply_decimate_modifier = False
op.sna_apply_camera_cull_modifier = False
op.sna_apply_crop_box_modifier = False
op.sna_apply_colour_edit_modifier = False
op.sna_apply_remove_stray_modifier = False
op.sna_apply_animate_modifier = False
class SNA_OT_Apply_3Dgs_Modifiers_E67A2(bpy.types.Operator):
bl_idname = "sna.apply_3dgs_modifiers_e67a2"
bl_label = "Apply 3DGS Modifiers"
bl_description = "Applies selected modifiers."
bl_options = {"REGISTER", "UNDO"}
sna_apply_3dgs_render_modifier: bpy.props.BoolProperty(name='Apply 3DGS Render Modifier', description='', default=True)
sna_apply_decimate_modifier: bpy.props.BoolProperty(name='Apply Decimate Modifier', description='', default=False)
sna_apply_camera_cull_modifier: bpy.props.BoolProperty(name='Apply Camera Cull Modifier', description='', default=False)
sna_apply_crop_box_modifier: bpy.props.BoolProperty(name='Apply Crop Box Modifier', description='', default=False)
sna_apply_colour_edit_modifier: bpy.props.BoolProperty(name='Apply Colour Edit Modifier', description='', default=False)
sna_apply_remove_stray_modifier: bpy.props.BoolProperty(name='Apply Remove Stray Modifier', description='', default=False)
sna_apply_animate_modifier: bpy.props.BoolProperty(name='Apply Animate Modifier', description='', default=False)
@classmethod
def poll(cls, context):
if bpy.app.version >= (3, 0, 0) and True:
cls.poll_message_set('')
return not False
def execute(self, context):
kiri_3dgs_render__active_object_update['sna_apply_modifier_list'] = []
if self.sna_apply_3dgs_render_modifier:
bpy.context.view_layer.objects.active.modifiers['KIRI_3DGS_Render_GN']['Socket_57'] = True
if self.sna_apply_animate_modifier:
bpy.context.view_layer.objects.active.modifiers['KIRI_3DGS_Animate_GN']['Socket_35'] = True
bpy.context.view_layer.objects.active.update_tag(refresh={'OBJECT'}, )
if bpy.context and bpy.context.screen:
for a in bpy.context.screen.areas:
a.tag_redraw()
if self.sna_apply_3dgs_render_modifier:
kiri_3dgs_render__active_object_update['sna_apply_modifier_list'].append('KIRI_3DGS_Render_GN')
if self.sna_apply_decimate_modifier:
kiri_3dgs_render__active_object_update['sna_apply_modifier_list'].append('KIRI_3DGS_Decimate_GN')
if self.sna_apply_camera_cull_modifier:
kiri_3dgs_render__active_object_update['sna_apply_modifier_list'].append('KIRI_3DGS_Camera_Cull_GN')
if self.sna_apply_crop_box_modifier:
kiri_3dgs_render__active_object_update['sna_apply_modifier_list'].append('KIRI_3DGS_Crop_Box_GN')
if self.sna_apply_colour_edit_modifier:
kiri_3dgs_render__active_object_update['sna_apply_modifier_list'].append('KIRI_3DGS_Colour_Edit_GN')
if self.sna_apply_remove_stray_modifier:
kiri_3dgs_render__active_object_update['sna_apply_modifier_list'].append('KIRI_3DGS_Remove_Stray_GN')
if self.sna_apply_animate_modifier:
kiri_3dgs_render__active_object_update['sna_apply_modifier_list'].append('KIRI_3DGS_Animate_GN')
for i_E1E08 in range(len(kiri_3dgs_render__active_object_update['sna_apply_modifier_list'])):
object_name = bpy.context.view_layer.objects.active.name
modifier_name = kiri_3dgs_render__active_object_update['sna_apply_modifier_list'][i_E1E08]
obj = bpy.data.objects.get(object_name)
if obj:
modifier = obj.modifiers.get(modifier_name)
if modifier:
if not modifier.show_viewport:
# Simply remove the modifier if it's hidden
obj.modifiers.remove(modifier)
print(f"Removed hidden modifier '{modifier_name}' from object '{object_name}'.")
else:
# Apply normally if visible
bpy.ops.object.modifier_apply(modifier=modifier_name)
print(f"Applied visible modifier '{modifier_name}' to object '{object_name}'.")
else:
print(f"Modifier '{modifier_name}' not found on object '{object_name}'.")
else:
print(f"Object '{object_name}' not found.")
return {"FINISHED"}
def draw(self, context):
layout = self.layout
col_DFD19 = layout.column(heading='', align=False)
col_DFD19.alert = False
col_DFD19.enabled = True
col_DFD19.active = True
col_DFD19.use_property_split = False
col_DFD19.use_property_decorate = False
col_DFD19.scale_x = 1.0
col_DFD19.scale_y = 1.0
col_DFD19.alignment = 'Expand'.upper()
col_DFD19.operator_context = "INVOKE_DEFAULT" if True else "EXEC_DEFAULT"
box_34FDC = col_DFD19.box()
box_34FDC.alert = True
box_34FDC.enabled = True
box_34FDC.active = True
box_34FDC.use_property_split = False
box_34FDC.use_property_decorate = False
box_34FDC.alignment = 'Expand'.upper()
box_34FDC.scale_x = 1.0
box_34FDC.scale_y = 1.0
if not True: box_34FDC.operator_context = "EXEC_DEFAULT"
box_34FDC.label(text='This is a destructive act.', icon_value=load_preview_icon(os.path.join(os.path.dirname(__file__), 'assets', 'warning-7381086-red.png')))
box_34FDC.label(text=' If the 3DGS Render modifier is applied, faces will no longer be updated.', icon_value=0)
col_DFD19.separator(factor=1.0)
box_4F8F8 = col_DFD19.box()
box_4F8F8.alert = False
box_4F8F8.enabled = True
box_4F8F8.active = True
box_4F8F8.use_property_split = False
box_4F8F8.use_property_decorate = False
box_4F8F8.alignment = 'Expand'.upper()
box_4F8F8.scale_x = 1.0
box_4F8F8.scale_y = 1.0
if not True: box_4F8F8.operator_context = "EXEC_DEFAULT"
if (property_exists("bpy.context.view_layer.objects.active.modifiers", globals(), locals()) and 'KIRI_3DGS_Render_GN' in bpy.context.view_layer.objects.active.modifiers):
row_FB27E = box_4F8F8.row(heading='', align=False)
row_FB27E.alert = False
row_FB27E.enabled = True
row_FB27E.active = True
row_FB27E.use_property_split = False
row_FB27E.use_property_decorate = False
row_FB27E.scale_x = 1.0
row_FB27E.scale_y = 1.0
row_FB27E.alignment = 'Expand'.upper()
row_FB27E.operator_context = "INVOKE_DEFAULT" if True else "EXEC_DEFAULT"
row_FB27E.label(text='Apply 3DGS Render Modifier', icon_value=0)
row_FB27E.prop(self, 'sna_apply_3dgs_render_modifier', text='', icon_value=0, emboss=True)
if (property_exists("bpy.context.view_layer.objects.active.modifiers", globals(), locals()) and 'KIRI_3DGS_Decimate_GN' in bpy.context.view_layer.objects.active.modifiers):
row_274B0 = box_4F8F8.row(heading='', align=False)
row_274B0.alert = False
row_274B0.enabled = True
row_274B0.active = True
row_274B0.use_property_split = False
row_274B0.use_property_decorate = False
row_274B0.scale_x = 1.0
row_274B0.scale_y = 1.0
row_274B0.alignment = 'Expand'.upper()
row_274B0.operator_context = "INVOKE_DEFAULT" if True else "EXEC_DEFAULT"
row_274B0.label(text='Apply Decimate Modifier', icon_value=0)
row_274B0.prop(self, 'sna_apply_decimate_modifier', text='', icon_value=0, emboss=True)
if (property_exists("bpy.context.view_layer.objects.active.modifiers", globals(), locals()) and 'KIRI_3DGS_Camera_Cull_GN' in bpy.context.view_layer.objects.active.modifiers):
row_DCB98 = box_4F8F8.row(heading='', align=False)
row_DCB98.alert = False
row_DCB98.enabled = True
row_DCB98.active = True
row_DCB98.use_property_split = False
row_DCB98.use_property_decorate = False
row_DCB98.scale_x = 1.0
row_DCB98.scale_y = 1.0
row_DCB98.alignment = 'Expand'.upper()
row_DCB98.operator_context = "INVOKE_DEFAULT" if True else "EXEC_DEFAULT"
row_DCB98.label(text='Apply Camera Cull Modifier', icon_value=0)
row_DCB98.prop(self, 'sna_apply_camera_cull_modifier', text='', icon_value=0, emboss=True)
if (property_exists("bpy.context.view_layer.objects.active.modifiers", globals(), locals()) and 'KIRI_3DGS_Crop_Box_GN' in bpy.context.view_layer.objects.active.modifiers):
row_D27A7 = box_4F8F8.row(heading='', align=False)
row_D27A7.alert = False
row_D27A7.enabled = True
row_D27A7.active = True
row_D27A7.use_property_split = False
row_D27A7.use_property_decorate = False
row_D27A7.scale_x = 1.0
row_D27A7.scale_y = 1.0
row_D27A7.alignment = 'Expand'.upper()
row_D27A7.operator_context = "INVOKE_DEFAULT" if True else "EXEC_DEFAULT"
row_D27A7.label(text='Apply Crop Box Modifier', icon_value=0)
row_D27A7.prop(self, 'sna_apply_crop_box_modifier', text='', icon_value=0, emboss=True)
if (property_exists("bpy.context.view_layer.objects.active.modifiers", globals(), locals()) and 'KIRI_3DGS_Colour_Edit_GN' in bpy.context.view_layer.objects.active.modifiers):
row_ECA62 = box_4F8F8.row(heading='', align=False)
row_ECA62.alert = False
row_ECA62.enabled = True
row_ECA62.active = True
row_ECA62.use_property_split = False
row_ECA62.use_property_decorate = False
row_ECA62.scale_x = 1.0
row_ECA62.scale_y = 1.0
row_ECA62.alignment = 'Expand'.upper()
row_ECA62.operator_context = "INVOKE_DEFAULT" if True else "EXEC_DEFAULT"
row_ECA62.label(text='Apply Colour Edit Modifier', icon_value=0)
row_ECA62.prop(self, 'sna_apply_colour_edit_modifier', text='', icon_value=0, emboss=True)
if (property_exists("bpy.context.view_layer.objects.active.modifiers", globals(), locals()) and 'KIRI_3DGS_Remove_Stray_GN' in bpy.context.view_layer.objects.active.modifiers):
row_E5905 = box_4F8F8.row(heading='', align=False)
row_E5905.alert = False
row_E5905.enabled = True
row_E5905.active = True
row_E5905.use_property_split = False
row_E5905.use_property_decorate = False
row_E5905.scale_x = 1.0
row_E5905.scale_y = 1.0
row_E5905.alignment = 'Expand'.upper()
row_E5905.operator_context = "INVOKE_DEFAULT" if True else "EXEC_DEFAULT"
row_E5905.label(text='Apply Remove Stray Modifier', icon_value=0)
row_E5905.prop(self, 'sna_apply_remove_stray_modifier', text='', icon_value=0, emboss=True)
if (property_exists("bpy.context.view_layer.objects.active.modifiers", globals(), locals()) and 'KIRI_3DGS_Animate_GN' in bpy.context.view_layer.objects.active.modifiers):
row_CAA60 = box_4F8F8.row(heading='', align=False)
row_CAA60.alert = False
row_CAA60.enabled = True
row_CAA60.active = True
row_CAA60.use_property_split = False
row_CAA60.use_property_decorate = False
row_CAA60.scale_x = 1.0
row_CAA60.scale_y = 1.0
row_CAA60.alignment = 'Expand'.upper()
row_CAA60.operator_context = "INVOKE_DEFAULT" if True else "EXEC_DEFAULT"
row_CAA60.label(text='Apply Animate Modifier', icon_value=0)
row_CAA60.prop(self, 'sna_apply_animate_modifier', text='', icon_value=0, emboss=True)
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self, width=500)
class SNA_OT_Align_Active_To_X_Axis_9B12E(bpy.types.Operator):
bl_idname = "sna.align_active_to_x_axis_9b12e"
bl_label = "Align Active To X Axis"
bl_description = "Updates the 3DGS_Render modifier once to the X axis for the active object."
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
if bpy.app.version >= (3, 0, 0) and True:
cls.poll_message_set('')
return not False
def execute(self, context):
sna_align_active_values_to_x_function_execute_03E8D()
return {"FINISHED"}
def invoke(self, context, event):
return self.execute(context)
class SNA_OT_Align_Active_To_Y_Axis_9Bd1F(bpy.types.Operator):
bl_idname = "sna.align_active_to_y_axis_9bd1f"
bl_label = "Align Active To Y Axis"
bl_description = "Updates the 3DGS_Render modifier once to the Y axis for the active object."
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
if bpy.app.version >= (3, 0, 0) and True:
cls.poll_message_set('')
return not False
def execute(self, context):
sna_align_active_values_to_y_function_execute_89335()
return {"FINISHED"}
def invoke(self, context, event):
return self.execute(context)
class SNA_OT_Align_Active_To_Z_Axis_720A9(bpy.types.Operator):
bl_idname = "sna.align_active_to_z_axis_720a9"
bl_label = "Align Active To Z Axis"
bl_description = "Updates the 3DGS_Render modifier once to the Z axis for the active object."
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
if bpy.app.version >= (3, 0, 0) and True:
cls.poll_message_set('')
return not False
def execute(self, context):
sna_align_active_values_to_z_function_execute_62C4D()
return {"FINISHED"}
def invoke(self, context, event):
return self.execute(context)
class SNA_OT_Align_Active_To_View_88E3A(bpy.types.Operator):
bl_idname = "sna.align_active_to_view_88e3a"
bl_label = "Align Active To View"
bl_description = "Updates the 3DGS_Render modifier once to the current view for the active object."
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
if bpy.app.version >= (3, 0, 0) and True:
cls.poll_message_set('')
return not False
def execute(self, context):
ObjectName = bpy.context.view_layer.objects.active.name
from mathutils import Matrix
# Define helper function for updating the geometry node sockets
def update_gaussian_splat_camera(obj, view_matrix, proj_matrix, window_width, window_height):
geometryNodes_modifier = obj.modifiers.get('KIRI_3DGS_Render_GN')
if not geometryNodes_modifier:
print(f"Error: GeometryNodes modifier not found on object '{obj.name}'.")
return False
# Update view matrix
geometryNodes_modifier['Socket_2'] = view_matrix[0][0]
geometryNodes_modifier['Socket_3'] = view_matrix[1][0]
geometryNodes_modifier['Socket_4'] = view_matrix[2][0]
geometryNodes_modifier['Socket_5'] = view_matrix[3][0]
geometryNodes_modifier['Socket_6'] = view_matrix[0][1]
geometryNodes_modifier['Socket_7'] = view_matrix[1][1]
geometryNodes_modifier['Socket_8'] = view_matrix[2][1]
geometryNodes_modifier['Socket_9'] = view_matrix[3][1]
geometryNodes_modifier['Socket_10'] = view_matrix[0][2]
geometryNodes_modifier['Socket_11'] = view_matrix[1][2]
geometryNodes_modifier['Socket_12'] = view_matrix[2][2]
geometryNodes_modifier['Socket_13'] = view_matrix[3][2]
geometryNodes_modifier['Socket_14'] = view_matrix[0][3]
geometryNodes_modifier['Socket_15'] = view_matrix[1][3]
geometryNodes_modifier['Socket_16'] = view_matrix[2][3]
geometryNodes_modifier['Socket_17'] = view_matrix[3][3]
# Update projection matrix
geometryNodes_modifier['Socket_18'] = proj_matrix[0][0]
geometryNodes_modifier['Socket_19'] = proj_matrix[1][0]
geometryNodes_modifier['Socket_20'] = proj_matrix[2][0]
geometryNodes_modifier['Socket_21'] = proj_matrix[3][0]
geometryNodes_modifier['Socket_22'] = proj_matrix[0][1]
geometryNodes_modifier['Socket_23'] = proj_matrix[1][1]
geometryNodes_modifier['Socket_24'] = proj_matrix[2][1]
geometryNodes_modifier['Socket_25'] = proj_matrix[3][1]
geometryNodes_modifier['Socket_26'] = proj_matrix[0][2]
geometryNodes_modifier['Socket_27'] = proj_matrix[1][2]
geometryNodes_modifier['Socket_28'] = proj_matrix[2][2]
geometryNodes_modifier['Socket_29'] = proj_matrix[3][2]
geometryNodes_modifier['Socket_30'] = proj_matrix[0][3]
geometryNodes_modifier['Socket_31'] = proj_matrix[1][3]
geometryNodes_modifier['Socket_32'] = proj_matrix[2][3]
geometryNodes_modifier['Socket_33'] = proj_matrix[3][3]
# Update window dimensions
geometryNodes_modifier['Socket_34'] = window_width
geometryNodes_modifier['Socket_35'] = window_height
return True
# Main code for updating specific object
updated_objects = []
# Find view and projection matrices from the 3D view area
found_3d_view = False
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
view_matrix = area.spaces.active.region_3d.view_matrix
proj_matrix = area.spaces.active.region_3d.window_matrix
window_width = area.width
window_height = area.height
found_3d_view = True
break
if not found_3d_view:
print("Error: No 3D View found to update camera information.")
else:
# Update only specific object
target_object_name = ObjectName # Serpens Variable
obj = bpy.data.objects.get(target_object_name)
if obj and obj.visible_get():
print(f"Attempting to update object: {obj.name}") # Debugging print
if update_gaussian_splat_camera(obj, view_matrix, proj_matrix, window_width, window_height):
updated_objects.append(obj.name) # Add to updated list
# Print or output the list of updated objects
print("Updated objects:", updated_objects)
bpy.context.view_layer.objects.active.update_tag(refresh={'OBJECT'}, )
if bpy.context and bpy.context.screen:
for a in bpy.context.screen.areas:
a.tag_redraw()
return {"FINISHED"}
def invoke(self, context, event):
return self.execute(context)
class SNA_OT_Dgs__Start_Camera_Update_001Bd(bpy.types.Operator):
bl_idname = "sna.dgs__start_camera_update_001bd"
bl_label = "3DGS - Start Camera Update"
bl_description = "Starts updating the 3DGS_Render modifier for all enabled objects in the scene."
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
if bpy.app.version >= (3, 0, 0) and True:
cls.poll_message_set('')
return not False
def execute(self, context):
input_update_method = bpy.context.scene.sna_kiri3dgs_scene_camera_refresh_mode.replace('Frame Change', 'frame_change')
from mathutils import Matrix
def update_gaussian_splat_camera(obj, view_matrix, proj_matrix, window_width, window_height):
geometryNodes_modifier = obj.modifiers.get('KIRI_3DGS_Render_GN')
if not geometryNodes_modifier:
print(f"Error: GeometryNodes modifier not found on object '{obj.name}'.")
return False
# Update view matrix
geometryNodes_modifier['Socket_2'] = view_matrix[0][0]
geometryNodes_modifier['Socket_3'] = view_matrix[1][0]
geometryNodes_modifier['Socket_4'] = view_matrix[2][0]
geometryNodes_modifier['Socket_5'] = view_matrix[3][0]
geometryNodes_modifier['Socket_6'] = view_matrix[0][1]
geometryNodes_modifier['Socket_7'] = view_matrix[1][1]
geometryNodes_modifier['Socket_8'] = view_matrix[2][1]
geometryNodes_modifier['Socket_9'] = view_matrix[3][1]
geometryNodes_modifier['Socket_10'] = view_matrix[0][2]
geometryNodes_modifier['Socket_11'] = view_matrix[1][2]
geometryNodes_modifier['Socket_12'] = view_matrix[2][2]
geometryNodes_modifier['Socket_13'] = view_matrix[3][2]
geometryNodes_modifier['Socket_14'] = view_matrix[0][3]
geometryNodes_modifier['Socket_15'] = view_matrix[1][3]
geometryNodes_modifier['Socket_16'] = view_matrix[2][3]
geometryNodes_modifier['Socket_17'] = view_matrix[3][3]
# Update projection matrix
geometryNodes_modifier['Socket_18'] = proj_matrix[0][0]
geometryNodes_modifier['Socket_19'] = proj_matrix[1][0]
geometryNodes_modifier['Socket_20'] = proj_matrix[2][0]
geometryNodes_modifier['Socket_21'] = proj_matrix[3][0]
geometryNodes_modifier['Socket_22'] = proj_matrix[0][1]
geometryNodes_modifier['Socket_23'] = proj_matrix[1][1]
geometryNodes_modifier['Socket_24'] = proj_matrix[2][1]
geometryNodes_modifier['Socket_25'] = proj_matrix[3][1]
geometryNodes_modifier['Socket_26'] = proj_matrix[0][2]
geometryNodes_modifier['Socket_27'] = proj_matrix[1][2]
geometryNodes_modifier['Socket_28'] = proj_matrix[2][2]
geometryNodes_modifier['Socket_29'] = proj_matrix[3][2]
geometryNodes_modifier['Socket_30'] = proj_matrix[0][3]
geometryNodes_modifier['Socket_31'] = proj_matrix[1][3]
geometryNodes_modifier['Socket_32'] = proj_matrix[2][3]
geometryNodes_modifier['Socket_33'] = proj_matrix[3][3]
# Update window dimensions
geometryNodes_modifier['Socket_34'] = window_width
geometryNodes_modifier['Socket_35'] = window_height
geometryNodes_modifier.show_on_cage = True
geometryNodes_modifier.show_on_cage = False
return True
def update_all_gaussian_splats(scene, force_update=False):
if not scene.get('gaussian_splat_updates_active', False):
return
current_frame = scene.frame_current
last_updated_frame = scene.get('last_updated_frame', -1)
# Update if forced or if the frame has changed
if not force_update and current_frame == last_updated_frame:
return
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
view_matrix = area.spaces.active.region_3d.view_matrix
proj_matrix = area.spaces.active.region_3d.window_matrix
window_width = area.width
window_height = area.height
break
else:
print("Error: No 3D View found to update camera information.")
return
updated_count = 0
for obj in scene.objects:
if obj.visible_get() and obj.get('update_rot_to_cam', False):
if update_gaussian_splat_camera(obj, view_matrix, proj_matrix, window_width, window_height):
updated_count += 1
print(f"Updated {updated_count} Gaussian Splat object(s) at frame {current_frame}")
scene['last_updated_frame'] = current_frame