-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproject_panel.py
More file actions
2225 lines (1849 loc) · 75.2 KB
/
project_panel.py
File metadata and controls
2225 lines (1849 loc) · 75.2 KB
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
"""
______ __ __ __ __
/\ == \ /\ \/\ \ /\ "-.\ \
\ \ __< \ \ \_\ \\ \ \-. \
\ \_\ \_\\ \_____\\ \_\\"\_\
\/_/ /_/ \/_____/ \/_/ \/_/
______ __ ______ ______ ______
/\ ___\/\ \ /\ == \ /\ ___\ /\__ _\
\ \ __\\ \ \\ \ __< \ \___ \\/_/\ \/
\ \_\ \ \_\\ \_\ \_\\/\_____\ \ \_\
\/_/ \/_/ \/_/ /_/ \/_____/ \/_/
"""
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (C) 2022, Mark Elek, David Elek
import bpy
import contextlib
from bpy.props import EnumProperty, BoolProperty, FloatProperty, FloatVectorProperty
from bpy.types import Panel
BASIC_INSTANCE_KW = "_BI"
EXTRA_INSTANCE_KW = "_EI"
EXTRA_GLASS_KW = "_EG"
EXTRA_PLANE_KW = "_EP"
FRAME_KW = "_FR"
FLOOR_KW = "_FL"
class BASE_PANEL:
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "Project Settings"
class VIEW3D_PT_viewport_optimization_settings(BASE_PANEL, Panel):
bl_label = "Viewport Optimization"
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
scene = context.scene
layout = self.layout
if scene.use_instances_only or scene.use_frustum_culling or scene.cycles.use_fast_gi:
layout.label(text="", icon='MODIFIER_ON')
else:
layout.label(text="", icon='MODIFIER_OFF')
def draw(self, context):
settings = bpy.data.objects["Plane"].modifiers["Settings"]
if settings:
# Frustum Culling settings box
layout = self.layout
scene = context.scene
box = layout.box()
row = box.row()
row.label(text="Frustum Culling Settings:")
row = box.row()
row.prop(scene, 'use_frustum_culling',
text="Frustum Culling", toggle=True)
row = box.row()
row.prop_search(scene, "culling_camera",
bpy.data, "cameras", text="")
row.enabled = scene.use_frustum_culling
box = layout.box()
row = box.row()
row.label(text="Proxy Settings:")
row = box.row()
row.prop(scene, 'base_proxy_object', text="")
row = box.row()
row.prop(scene, 'use_base_proxy_object',
text="Use Base Proxy Object", toggle=True)
row = box.row()
row.prop(scene, 'extra_proxy_object', text="")
row = box.row()
row.prop(scene, 'use_extra_proxy_object',
text="Use Extra Proxy Object", toggle=True)
row = box.row()
box = layout.box()
row = box.row()
row.label(text="Other Settings:")
row = box.row()
row.prop(scene, 'use_instances_only',
text="Use Instances Only", toggle=True)
row = box.row()
row.prop(scene, 'realize_on_render',
text="Realize on Render", toggle=True)
row = box.row()
row.label(text="Preview Pixel Size:")
row = box.row()
row.prop(scene.render, 'preview_pixel_size', text="")
row = box.row()
row.prop(scene.cycles, 'use_fast_gi',
text="Fast Global Illumination", toggle=True)
class VIEW3D_PT_quick_settings(BASE_PANEL, Panel):
bl_label = "Quick Settings"
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon='SOLO_ON')
def draw(self, context):
scene = context.scene
gm_color_img_texture = bpy.data.node_groups["Plane Setup Nodes"].nodes["Image Texture"]
gm_height_img_texture = bpy.data.node_groups["Instancing Nodes"].nodes["Image Texture"]
gm_inst_object_info_node = bpy.data.node_groups["Instancing Nodes"].nodes["Object Info"]
layout = self.layout
box = layout.box()
row = box.row()
row.prop(scene, 'detail_size', text="Base Scale XY", slider=True)
row = box.row()
row.prop(scene, 'render_detail_size',
text="Render Base Scale XY", slider=True)
row = box.row()
row.prop(scene, 'detail_height', text="Base Height", slider=True)
row = box.row()
row.label(text="Base Object Material:")
row = box.row()
row.prop(scene, 'base_material', text="", icon='MATERIAL')
row = box.row()
row.label(text="Height Texture:")
row = box.row()
row.template_ID(gm_height_img_texture.inputs['Image'],
"default_value", new="image.new", open="image.open")
row = box.row()
row.label(text="Color Texture:")
row = box.row()
if scene.shading_mode == 'VERTEX':
if gm_color_img_texture is None or "Invisible" in scene.base_material.name:
row.label(text="No Texture in Material:", icon='ERROR')
else:
row.template_ID(gm_color_img_texture.inputs['Image'],
"default_value", new="image.new", open="image.open")
else:
try:
mat = scene.base_material
img_texture = mat.node_tree.nodes.get("Image Texture")
if img_texture is None:
row.label(text="No Texture in Material:", icon='ERROR')
else:
row.template_ID(
img_texture, 'image', new="image.new", open="image.open")
row = box.row()
row.label(text="Projection:")
row = box.row()
row.prop(img_texture, 'projection', text="")
except AttributeError:
row.label(text="No Base Material!", icon='ERROR')
row = box.row()
row.label(text="Base Object:")
row = box.row()
row.prop(scene, 'active_base_object', text="")
row = layout.row()
row = box.row()
row.label(text="Sampling Channel (Height):")
row = box.row()
row.prop(scene, 'sampling_mode', text="")
row = box.row()
class VIEW3D_PT_grid_settings(BASE_PANEL, Panel):
bl_label = "Grid Settings"
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon='LIGHTPROBE_GRID')
def draw(self, context):
settings = bpy.data.objects["Plane"].modifiers["Settings"]
if settings:
layout = self.layout
scene = context.scene
box = layout.box()
row = box.row()
row.prop(scene, 'gap_size', text="Gap Size", slider=True)
row = box.row()
row.prop(scene, 'sparse_grid_x', text="Sparse Grid X", slider=True)
row = box.row()
row.prop(scene, 'sparse_grid_y', text="Sparse Grid Y", slider=True)
class VIEW3D_PT_instance_objects(BASE_PANEL, Panel):
bl_label = "Instance Objects"
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon='OBJECT_DATA')
def draw(self, context):
settings = bpy.data.objects["Plane"].modifiers["Settings"]
if settings:
layout = self.layout
scene = context.scene
box = layout.box()
row = box.row()
row.label(text="Base Object:")
row = box.row()
row.prop(scene, 'active_base_object', text="")
box = layout.box()
row = box.row()
row.label(text="Extra Object:")
row = box.row()
row.prop(scene, 'active_extra_object', text="")
row = layout.row()
row.prop(scene, 'use_extra_object',
text="Use Extra Object", toggle=True)
row = layout.row()
row = box.row()
row.prop(scene, 'extra_object_threshold',
text="Height threshold", slider=True)
row = box.row()
row.label(text="Height threshold Mode:")
row = box.row()
row.prop(scene, 'threshold_mode', text="")
class VIEW3D_PT_base_scale(BASE_PANEL, Panel):
bl_label = "Base Scale"
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon='ORIENTATION_VIEW')
def draw(self, context):
settings = bpy.data.objects["Plane"].modifiers["Settings"]
if settings:
gm_height_img_texture = bpy.data.node_groups["Instancing Nodes"].nodes["Image Texture"]
layout = self.layout
scene = context.scene
box = layout.box()
row = box.row()
row.prop(scene, 'detail_size', text="Base Scale XY", slider=True)
row = box.row()
row.prop(scene, 'render_detail_size',
text="Render Base Scale XY", slider=True)
row = box.row()
row.prop(scene, 'detail_height', text="Base Height", slider=True)
row = box.row()
row.prop(scene, 'detail_height_multiplier',
text="Base Height Multiplier", slider=True)
row = box.row()
row.prop(scene, 'negative_size_x',
text="Subtract Scale X", slider=True)
row = box.row()
row.prop(scene, 'negative_size_y',
text="Subtract Scale Y", slider=True)
row = box.row()
row.label(text="Sampling Channel (Height):")
row = box.row()
row.prop(scene, 'sampling_mode', text="")
row.enabled = not scene.keep_base_height
row = box.row()
row.label(text="Height Texture:")
row = box.row()
row.template_ID(gm_height_img_texture.inputs['Image'],
"default_value", new="image.new", open="image.open")
row.enabled = not scene.keep_base_height
row = box.row()
row.prop(scene, 'keep_base_height',
toggle=True, text="Keep Base Height")
class VIEW3D_PT_base_rotation(BASE_PANEL, Panel):
bl_label = "Base Rotation"
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon='ORIENTATION_GIMBAL')
def draw(self, context):
settings = bpy.data.objects["Plane"].modifiers["Settings"]
if settings:
layout = self.layout
scene = context.scene
box = layout.box()
row = box.row()
row.label(text="Look At Object:")
row = box.row()
row.prop(scene, 'look_at_object', text="")
row = box.row()
row.prop(scene, 'use_look_at_rotation',
text="Use Look At Rotation", toggle=True)
box = layout.box()
row = box.row()
row.prop(scene, 'use_random_rotation',
text="Use Random Rotation", toggle=True)
row.enabled = not scene.use_look_at_rotation
row = box.row()
row.prop(scene, 'snap_rotation',
text="90 Degree Increments", toggle=True)
row.enabled = scene.use_random_rotation
class VIEW3D_PT_base_shading(BASE_PANEL, Panel):
bl_label = "Base Shading"
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon='SHADING_RENDERED')
def draw(self, context):
settings = bpy.data.objects["Plane"].modifiers["Settings"]
if settings:
gm_color_img_texture = bpy.data.node_groups["Plane Setup Nodes"].nodes["Image Texture"]
scene = context.scene
layout = self.layout
box = layout.box()
row = box.row()
row = box.row()
row.label(text="Base Object Material:")
row = box.row()
row.prop(scene, 'base_material', text="", icon='MATERIAL')
row = box.row()
row.label(text="Shading Mode:")
row = box.row()
row.prop(scene, 'shading_mode', text="")
row.enabled = not scene.use_instances_only
row = box.row()
row.prop(scene, 'bevel_size', text="Bevel Size:", slider=True)
plane_settings = bpy.data.objects["Plane"].modifiers["Plane Setup"]
if plane_settings:
row = box.row()
row.label(text="Color Texture:")
row = box.row()
if scene.shading_mode == 'VERTEX':
if gm_color_img_texture is None or "Invisible" in scene.base_material.name:
row.label(text="No Texture in Material:", icon='ERROR')
else:
row.template_ID(gm_color_img_texture.inputs['Image'],
"default_value", new="image.new", open="image.open")
else:
try:
mat = scene.base_material
shader_img_texture = mat.node_tree.nodes.get(
"Image Texture")
if shader_img_texture is None:
row.label(text="No Texture in Material!",
icon='ERROR')
else:
row.template_ID(
shader_img_texture, 'image', new="image.new", open="image.open")
row = box.row()
row.label(text="Projection:")
row = box.row()
row.prop(shader_img_texture, 'projection', text="")
row = box.row()
row.prop(scene, 'use_pixelation',
text="Use Pixelation", toggle=True)
row.enabled = scene.shading_mode == 'TEXTURED'
row = box.row()
row.prop(scene, 'pixelation',
text="Pixelation:", slider=True)
row.enabled = scene.shading_mode == 'TEXTURED' and scene.use_pixelation
except AttributeError:
row.label(text="No Base Material!", icon='ERROR')
class VIEW3D_PT_environment(BASE_PANEL, Panel):
bl_label = "Environment"
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon='WORLD')
def draw(self, context):
settings = bpy.data.objects["Plane"].modifiers["Settings"]
if settings:
scene = context.scene
layout = self.layout
box = layout.box()
row = box.row()
row.label(text="Background Mode:")
row = box.row()
row.prop(scene, 'background_mode', text="")
row = box.row()
if scene.background_mode == 'COLOR':
row.label(text="Background Color:")
row = box.row()
row.prop(scene, 'background_color', text="")
elif scene.background_mode == 'TEXTURE':
row.label(text="Environment Texture:")
row = box.row()
environment_texture_node = bpy.data.worlds["World"].node_tree.nodes["Environment Texture"]
row.template_ID(environment_texture_node, 'image',
new="image.new", open="image.open")
row = box.row()
row.label(text="HDRI Lighting:")
row = box.row()
hdri_texture_node = bpy.data.worlds["World"].node_tree.nodes["HDRI Lighting"]
row.template_ID(hdri_texture_node, 'image',
new="image.new", open="image.open")
class VIEW3D_PT_extra_scale(BASE_PANEL, Panel):
bl_label = "Extra Scale"
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon='ADD')
def draw(self, context):
settings = bpy.data.objects["Plane"].modifiers["Settings"]
if settings:
layout = self.layout
scene = context.scene
box = layout.box()
row = box.row()
row.prop(scene, 'keep_extra_scale',
text="Keep Extra Scale Z", toggle=True)
row = box.row()
row.label(text="Extra Scale Offset:")
row = box.row()
row.prop(scene, 'extra_scale_offset', text="")
row.enabled = not scene.use_extra_random_scale
row = box.row()
row.label(text="Extra Random Scale Min:")
row = box.row()
row.prop(scene, 'extra_random_scale_min', text="", slider=True)
row.enabled = scene.use_extra_random_scale
row = box.row()
row.label(text="Extra Random Scale Max:")
row = box.row()
row.prop(scene, 'extra_random_scale_max', text="", slider=True)
row.enabled = scene.use_extra_random_scale
row = box.row()
row.prop(scene, 'use_extra_random_scale',
text="Use Extra Random Scale", toggle=True)
row = box.row()
row.prop(scene, 'offset_z', text="Offset Z", slider=True)
class VIEW3D_PT_extra_rotation(BASE_PANEL, Panel):
bl_label = "Extra Rotation"
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon='ADD')
def draw(self, context):
settings = bpy.data.objects["Plane"].modifiers["Settings"]
if settings:
layout = self.layout
scene = context.scene
box = layout.box()
row = box.row()
row.label(text="Extra Look At Object:")
row = box.row()
row.prop(scene, 'extra_look_at_object', text="")
row = box.row()
row.prop(scene, 'use_extra_look_at_rotation',
text="Use Extra Look At Rotation", toggle=True)
box = layout.box()
row = box.row()
row.prop(scene, 'use_extra_random_rotation',
text="Use Extra Random Rotation", toggle=True)
row.enabled = not scene.use_extra_look_at_rotation
row = box.row()
row.prop(scene, 'extra_snap_rotation',
text="Extra 90 Degree Increments", toggle=True)
row.enabled = scene.use_extra_random_rotation
class VIEW3D_PT_extra_location(BASE_PANEL, Panel):
bl_label = "Extra Location"
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon='ADD')
def draw(self, context):
settings = bpy.data.objects["Plane"].modifiers["Settings"]
if settings:
layout = self.layout
scene = context.scene
box = layout.box()
row = box.row()
row.prop(scene, 'extra_location_offset_z',
text="Extra Location Offset Z", slider=True)
class VIEW3D_PT_extra_shading(BASE_PANEL, Panel):
bl_label = "Extra Shading"
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon='ADD')
def draw(self, context):
settings = bpy.data.objects["Plane"].modifiers["Settings"]
layout = self.layout
scene = context.scene
box = layout.box()
row = box.row()
row.label(text="Extra Shading Mode:")
row = box.row()
row.prop(scene, 'extra_shading_mode', text="")
row = box.row()
row.prop(scene, 'extra_bevel_size',
text="Extra Bevel Size:", slider=True)
if settings:
gm_extra_color_img_texture = bpy.data.node_groups[
"Plane Setup Nodes"].nodes["Image Texture.001"]
row = box.row()
row.label(text="Extra Color Texture:")
row = box.row()
if scene.extra_shading_mode == 'VERTEX':
row.template_ID(gm_extra_color_img_texture.inputs['Image'],
"default_value", new="image.new", open="image.open")
else:
try:
mat = scene.extra_material
extra_shader_img_texture = mat.node_tree.nodes["Image Texture"]
row.template_ID(
extra_shader_img_texture, 'image', new="image.new", open="image.open")
row = box.row()
row.label(text="Extra Projection:")
row = box.row()
row.prop(extra_shader_img_texture, 'projection', text="")
row = box.row()
except AttributeError:
row.label(text="No Extra Material!", icon='ERROR')
row = box.row()
row.prop(scene, 'use_extra_pixelation',
text="Use Extra Pixelation", toggle=True)
row.enabled = scene.extra_shading_mode == 'TEXTURED'
row = box.row()
row.prop(scene, 'extra_pixelation', text="Pixelation:", slider=True)
row.enabled = scene.extra_shading_mode == 'TEXTURED' and scene.use_extra_pixelation
row = box.row()
row.label(text="Extra Object Material:")
row = box.row()
row.prop(scene, 'extra_material', text="", icon='MATERIAL')
class VIEW3D_PT_extra_glass(BASE_PANEL, Panel):
bl_label = "Extra Glass"
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon='ADD')
def draw(self, context):
extra_glass_gm_mat_node = bpy.data.node_groups["Extra Glass Nodes"].nodes["Set Material"]
settings = bpy.data.objects["Plane"].modifiers["Settings"]
layout = self.layout
scene = context.scene
box = layout.box()
row = box.row()
if settings and extra_glass_gm_mat_node:
row.label(text="Extra Glass Settings:")
row = box.row()
row.prop(scene, 'extra_glass_material', text="")
row.enabled = scene.use_extra_glass
row = box.row()
row.label(text="Glass Color:")
row = box.row()
mat = scene.extra_glass_material
glass_material_node = mat.node_tree.nodes.get("RGB")
if glass_material_node:
row.prop(scene, 'extra_glass_color', text="")
row.enabled = scene.use_extra_glass
else:
row.label(text="No 'RGB' node in material!", icon='ERROR')
row = box.row()
row.prop(scene, 'extra_glass_width',
text="Extra Glass Width", slider=True)
row.enabled = scene.use_extra_glass
row = box.row()
row.prop(scene, 'use_extra_glass',
text="Use Extra Glass", toggle=True)
class VIEW3D_PT_extra_plane(BASE_PANEL, Panel):
bl_label = "Extra Plane"
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon='ADD')
def draw(self, context):
settings = bpy.data.objects["Plane"].modifiers["Settings"]
if settings:
layout = self.layout
scene = context.scene
box = layout.box()
row = box.row()
row.label(text="Extra Plane Settings:")
row = box.row()
row.prop(scene, 'extra_plane_material', text="")
row.enabled = scene.use_extra_plane
row = box.row()
row.label(text="Extra Plane Color:")
row = box.row()
mat = scene.extra_plane_material
plane_material_node = mat.node_tree.nodes.get("RGB")
if plane_material_node:
row.prop(scene, 'extra_plane_color', text="")
row.enabled = scene.use_extra_plane
else:
row.label(text="No 'RGB' node in material!", icon='ERROR')
row = box.row()
row.prop(scene, 'use_extra_plane',
text="Use Extra Plane", toggle=True)
class VIEW3D_PT_boolean_settings(BASE_PANEL, Panel):
bl_label = "Boolean Settings"
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon='SELECT_SUBTRACT')
def draw(self, context):
scene = context.scene
boolean_modifier = bpy.data.objects["Plane"].modifiers["Boolean"]
layout = self.layout
box = layout.box()
row = box.row()
row.label(text="Boolean Object:")
row = box.row()
row.prop(scene, 'active_boolean_object', text="")
row = box.row()
row.label(text="Boolean Operation:")
row = box.row()
row.prop(scene, 'boolean_operation', text="")
row = box.row()
row.label(text="Solver:")
row = box.row()
row.prop(boolean_modifier, 'solver', text="")
row = box.row()
row.prop(scene, 'use_boolean', text="Use Boolean Modifier", toggle=True)
class VIEW3D_PT_frame_settings(BASE_PANEL, Panel):
bl_label = "Frame Settings"
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon='SELECT_SET')
def draw(self, context):
scene = context.scene
layout = self.layout
box = layout.box()
row = box.row()
row.label(text="Frame Object:")
row = box.row()
row.prop(scene, 'active_frame_object', text="")
row = box.row()
row.prop(scene, 'frame_scale_offset',
text="Frame Scale Offset", slider=True)
row = box.row()
row.label(text="Frame Material:")
row = box.row()
row.prop(scene, 'frame_material', text="", icon='MATERIAL')
row.enabled = scene.active_frame_object is not None
row = box.row()
row.label(text="Frame Color:")
row = box.row()
mat = scene.frame_material
frame_material_node = mat.node_tree.nodes.get("RGB")
if frame_material_node:
row.prop(scene, 'frame_color', text="")
row.enabled = scene.active_frame_object is not None
else:
row.label(text="No 'RGB' node in material!", icon='ERROR')
row = box.row()
class VIEW3D_PT_floor_settings(BASE_PANEL, Panel):
bl_label = "Floor Settings"
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon='MESH_PLANE')
def draw(self, context):
scene = context.scene
layout = self.layout
box = layout.box()
row = box.row()
row.label(text="Floor Material:")
row = box.row()
row.prop(scene, 'floor_material', text="", icon='MATERIAL')
row = box.row()
row.label(text="Floor Color:")
row = box.row()
mat = scene.floor_material
floor_material_node = mat.node_tree.nodes.get("RGB")
if floor_material_node:
row.prop(scene, 'floor_color', text="")
else:
row.label(text="No 'RGB' node in material!", icon='ERROR')
row = box.row()
class VIEW3D_PT_about(BASE_PANEL, Panel):
bl_label = "About"
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon='URL')
def draw(self, context):
layout = self.layout
row = layout.row()
# TODO check for updates
row.operator(
"wm.url_open", text="Documentation (URL)").url = "https://3d-pixels.readthedocs.io/en/latest/"
def sampling_mode_enum_set(self, context):
scene = bpy.context.scene
sampling_mode = scene.sampling_mode
plane = bpy.data.objects["Plane"]
settings = plane.modifiers["Settings"]
if sampling_mode == 'ALL':
settings["Input_8"] = 0
elif sampling_mode == 'RED':
settings["Input_8"] = 1
elif sampling_mode == 'GREEN':
settings["Input_8"] = 2
else:
settings["Input_8"] = 3
plane.update_tag()
def shading_mode_enum_set(self, context):
scene = bpy.context.scene
plane = bpy.data.objects["Plane"]
plane_settings = plane.modifiers["Settings"]
shading_mode = scene.shading_mode
gm_color_img_texture = bpy.data.node_groups["Plane Setup Nodes"].nodes["Image Texture"]
if shading_mode == 'VERTEX':
plane_settings["Input_31"] = 0
mat = scene.base_material
texture_node = mat.node_tree.nodes["Image Texture"]
gm_color_img_texture.inputs['Image'].default_value = texture_node.image
plane.update_tag()
elif shading_mode == 'TEXTURED':
plane_settings["Input_31"] = 1
with contextlib.suppress(Exception):
# loop all materials
materials = [
mat for mat in bpy.data.materials
if contains_keyword(BASIC_INSTANCE_KW, mat.name)
and not contains_keyword(EXTRA_INSTANCE_KW, mat.name)]
for mat in materials:
texture_node = mat.node_tree.nodes["Image Texture"]
texture_node.image = gm_color_img_texture.inputs['Image'].default_value
plane.update_tag()
def extra_shading_mode_enum_set(self, context):
scene = bpy.context.scene
plane = bpy.data.objects["Plane"]
plane_settings = plane.modifiers["Settings"]
shading_mode = scene.extra_shading_mode
gm_color_img_texture = bpy.data.node_groups["Plane Setup Nodes"].nodes["Image Texture.001"]
if shading_mode == 'VERTEX':
plane_settings["Input_32"] = 0
mat = scene.extra_material
texture_node = mat.node_tree.nodes["Image Texture"]
gm_color_img_texture.inputs['Image'].default_value = texture_node.image
if scene.use_extra_object:
plane.update_tag()
elif shading_mode == 'TEXTURED':
plane_settings["Input_32"] = 1
with contextlib.suppress(Exception):
# loop all materials
materials = [
mat for mat in bpy.data.materials
if contains_keyword(EXTRA_INSTANCE_KW, mat.name)
and not contains_keyword(BASIC_INSTANCE_KW, mat.name)]
for mat in materials:
texture_node = mat.node_tree.nodes["Image Texture"]
texture_node.image = gm_color_img_texture.inputs['Image'].default_value
if scene.use_extra_object:
plane.update_tag()
def use_extra_glass_bool_set(self, context):
scene = bpy.context.scene
plane = bpy.data.objects["Plane"]
plane_settings = plane.modifiers["Settings"]
plane_settings["Input_4"] = 1 if scene.use_extra_glass else 0
plane.update_tag()
def extra_glass_material_set(self, context):
scene = bpy.context.scene
plane = bpy.data.objects["Plane"]
extra_glass_gm_mat_node = bpy.data.node_groups["Extra Glass Nodes"].nodes["Set Material"]
extra_glass_gm_mat_node.inputs['Material'].default_value = scene.extra_glass_material
mat = scene.extra_glass_material
glass_material_node = mat.node_tree.nodes.get("RGB")
scene.extra_glass_color = glass_material_node.outputs[0].default_value
plane.update_tag()
def extra_glass_material_poll(self, material):
return contains_keyword(EXTRA_GLASS_KW, material.name)
def extra_plane_material_set(self, context):
scene = bpy.context.scene
plane = bpy.data.objects["Plane"]
extra_plane_gm_mat_node = extra_plane_gm_mat_node = bpy.data.node_groups[
"Extra Glass Nodes"].nodes["Set Material.001"]
extra_plane_gm_mat_node.inputs['Material'].default_value = scene.extra_plane_material
mat = scene.extra_plane_material
extra_plane_material_node = mat.node_tree.nodes.get("RGB")
scene.extra_plane_color = extra_plane_material_node.outputs[0].default_value
plane.update_tag()
def extra_plane_material_poll(self, material):
return contains_keyword(EXTRA_PLANE_KW, material.name)
def use_extra_plane_bool_set(self, context):
scene = bpy.context.scene
plane = bpy.data.objects["Plane"]
plane_settings = plane.modifiers["Settings"]
plane_settings["Input_30"] = 1 if scene.use_extra_plane else 0
plane.update_tag()
def pixelation_float_set(self, context):
scene = bpy.context.scene
plane = bpy.data.objects["Plane"]
plane_settings = plane.modifiers["Settings"]
plane_settings["Input_33"] = scene.pixelation
plane.update_tag()
def extra_pixelation_float_set(self, context):
scene = bpy.context.scene
plane = bpy.data.objects["Plane"]
plane_settings = plane.modifiers["Settings"]
plane_settings["Input_34"] = scene.extra_pixelation
if scene.use_extra_object:
plane.update_tag()
def detail_size_float_set(self, context):
scene = bpy.context.scene
plane = bpy.data.objects["Plane"]
plane_settings = plane.modifiers["Settings"]
plane_settings["Input_2"] = scene.detail_size
plane.update_tag()
# plane.modifiers["Settings"].update_tag()
def render_detail_size_float_set(self, context):
scene = bpy.context.scene
plane = bpy.data.objects["Plane"]
plane_settings = plane.modifiers["Settings"]
plane_settings["Input_40"] = scene.render_detail_size
plane.update_tag()
def detail_height_float_set(self, context):
scene = bpy.context.scene
plane = bpy.data.objects["Plane"]
plane_settings = plane.modifiers["Settings"]
plane_settings["Input_3"] = scene.detail_height
plane.update_tag()
def detail_height_multiplier_float_set(self, context):
scene = bpy.context.scene
plane = bpy.data.objects["Plane"]
plane_settings = plane.modifiers["Settings"]
plane_settings["Input_62"] = scene.detail_height_multiplier
plane.update_tag()
def extra_glass_width_float_set(self, context):
scene = bpy.context.scene
plane = bpy.data.objects["Plane"]
plane_settings = plane.modifiers["Settings"]
plane_settings["Input_5"] = scene.extra_glass_width
if scene.use_extra_glass:
plane.update_tag()
def use_pixelation_set(self, context):
scene = bpy.context.scene
plane = bpy.data.objects["Plane"]
plane_settings = plane.modifiers["Settings"]
plane_settings["Input_16"] = 1 if scene.use_pixelation else 0
plane.update_tag()
def use_extra_pixelation_set(self, context):
scene = bpy.context.scene
plane = bpy.data.objects["Plane"]
plane_settings = plane.modifiers["Settings"]
plane_settings["Input_25"] = 1 if scene.use_extra_pixelation else 0
if scene.use_extra_object:
plane.update_tag()
def extra_object_threshold_float_set(self, context):
scene = bpy.context.scene
plane = bpy.data.objects["Plane"]
plane_settings = plane.modifiers["Settings"]
plane_settings["Input_17"] = scene.extra_object_threshold
if scene.use_extra_object:
plane.update_tag()
def use_extra_object_set(self, context):
scene = bpy.context.scene
plane = bpy.data.objects["Plane"]
plane_settings = plane.modifiers["Settings"]
plane_settings["Input_18"] = 1 if scene.use_extra_object else 0
plane.update_tag()
def gap_size_float_set(self, context):
scene = bpy.context.scene
plane = bpy.data.objects["Plane"]
plane_settings = plane.modifiers["Settings"]
plane_settings["Input_21"] = scene.gap_size
plane.update_tag()
def negative_size_x_float_set(self, context):
scene = bpy.context.scene
plane = bpy.data.objects["Plane"]
plane_settings = plane.modifiers["Settings"]
plane_settings["Input_19"] = scene.negative_size_x
plane.update_tag()