forked from specoolar/Blender-BakeLab2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bakelab_properties.py
184 lines (178 loc) · 5.6 KB
/
bakelab_properties.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
import bpy
from bpy.types import (
Operator,
PropertyGroup,
Panel
)
from bpy.props import (
IntProperty,
EnumProperty,
BoolProperty,
FloatProperty,
StringProperty,
PointerProperty,
CollectionProperty
)
from os.path import expanduser
def updateAdaptiveImageMinSize(self, context):
self.image_min_size = min(self.image_min_size, self.image_max_size)
def updateAdaptiveImageMaxSize(self, context):
self.image_max_size = max(self.image_min_size, self.image_max_size)
def updateSavePath(self, context):
if bpy.data.is_saved:
self.save_path = bpy.path.abspath(self.save_path)
class BakeLabProperties(PropertyGroup):
bake_state: EnumProperty(
items = (
("NONE", "None", ""),
("BAKING", "Baking", ""),
("BAKED", "Baked", "")
),
default = "NONE"
)
bake_mode: EnumProperty(
name = "Mode",
description = 'Baking mode',
items = (
("INDIVIDUAL", "Individual Objects", "", "PIVOT_INDIVIDUAL", 1),
("ALL_TO_ONE", "All To One Image", "", "PROP_ON", 2),
("TO_ACTIVE", "Selected to active", "", "PIVOT_ACTIVE", 3)
),
default = "INDIVIDUAL"
)
cage_extrusion : FloatProperty(
name = 'Cage Extrusion', default = 0.05,
min = 0, soft_max = 1
)
pre_join_mesh : BoolProperty(
name = 'Pre-Join Meshes', default = False,
description = 'Create one merged mesh and bake to it using ray-tracing',
)
image_size : EnumProperty(
name = 'Image Size',
items = (
('FIXED', 'Fixed', "Fixed image size"),
('ADAPTIVE', 'Adaptive', "Image size by object's surface area")
),
default = 'FIXED'
)
adaptive_image_Settings : BoolProperty(
name = '',
default = True
)
texel_per_unit : FloatProperty(
name = 'Texels Per Unit',
default = 100,
min = 0
)
image_min_size : IntProperty(
name = 'Min Size',
default = 32,
min = 1,
update=updateAdaptiveImageMaxSize
)
image_max_size : IntProperty(
name = 'Max Size',
default = 2048,
min = 1,
update=updateAdaptiveImageMinSize
)
round_adaptive_image : BoolProperty(
name = 'Round to power of two',
default = True
)
anti_alias : IntProperty(
name = 'Anti-aliasing', default = 1,
description = 'Anti-aliasing (1 = No Anti-aliasing)',
min = 1, soft_max = 8
)
bake_margin : IntProperty(
name = 'Bake Margin',
description = 'Extends the baked result as a post process filter',
default = 4,
min = 0,
soft_max = 64
)
global_image_name : StringProperty(
name = 'Image Name',
description = 'Names of baked images',
default = "Atlas",
)
compute_device : EnumProperty(
name = 'Device',
description = 'Compute Device',
items = (
('GPU','GPU Compute',''),
('CPU','CPU','')
)
)
save_or_pack : EnumProperty(
name = 'Output',
items = (
('PACK','Pack',''),
('SAVE','Save','')
),
default = 'PACK'
)
create_folder : BoolProperty(
name="Create folder",
description="Automatically creates a folder named after the object(s)",
default = True
)
folder_name : StringProperty(
name = 'Folder name',
description = 'Name of the folder',
default = "Selection",
)
save_path : StringProperty(
default=expanduser("~"),
name="Folder",
subtype="DIR_PATH",
update=updateSavePath
)
show_bake_settings : BoolProperty(name = '', default = False)
show_map_settings : BoolProperty(name = '', default = False)
show_file_settings : BoolProperty(name = '', default = False)
apply_only_selected : BoolProperty(
name = 'Apply only to Selected',
description = 'Apply only to selected objects',
default = True
)
make_single_user : BoolProperty(
name = 'Make single user',
description = 'Make data single user',
default = True
)
# Display
baking_obj_count : IntProperty(
name = 'Baking object count',
default = 0
)
baking_obj_index : IntProperty(
name = 'Current baking object',
default = 0
)
baking_obj_name : StringProperty(
name = 'Current baking object',
default = ""
)
baking_map_count : IntProperty(
name = 'Baking map count',
default = 0
)
baking_map_index : IntProperty(
name = 'Current baking map',
default = 0
)
baking_map_type : StringProperty(
name = 'Current baking map type',
default = ""
)
baking_map_name : StringProperty(
name = 'Current baking image',
default = ""
)
baking_map_size : StringProperty(
name = 'Current baking size',
default = ""
)