forked from Grim-es/material-combiner-addon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extend_types.py
183 lines (171 loc) · 5.75 KB
/
extend_types.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
import bpy
from bpy.props import *
from . import addon_updater_ops
class CombineList(bpy.types.PropertyGroup):
ob = PointerProperty(
name='Current Object',
type=bpy.types.Object,
)
ob_id = IntProperty(default=0)
mat = PointerProperty(
name='Current Object Material',
type=bpy.types.Material,
)
layer = IntProperty(
name='Material Layers',
description='Materials with the same number will be merged together.'
'\nUse this to create multiple materials linked to the same atlas file',
min=1,
max=99,
step=1,
default=1,
)
used = BoolProperty(default=True)
type = IntProperty(default=0)
class UpdatePreferences(bpy.types.AddonPreferences):
bl_idname = __package__
auto_check_update = BoolProperty(
name='Auto-check for Update',
description='If enabled, auto-check for updates using an interval',
default=True,
)
updater_intrval_months = bpy.props.IntProperty(
name='Months',
description='Number of months between checking for updates',
default=0,
min=0
)
updater_intrval_days = IntProperty(
name='Days',
description='Number of days between checking for updates',
default=1,
min=1
)
updater_intrval_hours = IntProperty(
name='Hours',
description='Number of hours between checking for updates',
default=0,
min=0,
max=0
)
updater_intrval_minutes = IntProperty(
name='Minutes',
description='Number of minutes between checking for updates',
default=0,
min=0,
max=0
)
def draw(self, context: bpy.types.Context):
addon_updater_ops.update_settings_ui(self, context)
def register() -> None:
bpy.types.Scene.smc_ob_data = CollectionProperty(type=CombineList)
bpy.types.Scene.smc_ob_data_id = IntProperty(default=0)
bpy.types.Scene.smc_list_id = IntProperty(default=0)
bpy.types.Scene.smc_size = EnumProperty(
name='Atlas size',
items=[
('PO2', 'Power of 2', 'Combined image size is power of 2'),
('QUAD', 'Quadratic', 'Combined image has same width and height'),
('AUTO', 'Automatic', 'Combined image has minimal size'),
('CUST', 'Custom', 'Combined image has proportionally scaled to fit in custom size'),
('STRICTCUST', 'Strict Custom', 'Combined image has exact custom width and height'),
],
description='Select atlas size',
default='QUAD',
)
bpy.types.Scene.smc_size_width = IntProperty(
name='Max width (px)',
description='Select max width for combined image',
min=8,
max=8192,
step=1,
default=4096,
)
bpy.types.Scene.smc_size_height = IntProperty(
name='Max height (px)',
description='Select max height for combined image',
min=8,
max=8192,
step=1,
default=4096,
)
bpy.types.Scene.smc_crop = BoolProperty(
name='Crop outside images by UV',
description='Crop images by UV if materials UV outside of bounds',
default=True,
)
bpy.types.Scene.smc_pixel_art = BoolProperty(
name='Pixel Art / Small Textures',
description='Avoids 1-pixel UV scaling for small textures.'
'\nDisable for larger textures to avoid blending with nearby pixels',
default=False,
)
bpy.types.Scene.smc_diffuse_size = IntProperty(
name='Size of materials without image',
description='Select the size of materials that only consist of a color',
min=8,
max=256,
step=1,
default=32,
)
bpy.types.Scene.smc_gaps = IntProperty(
name='Size of gaps between images',
description='Select size of gaps between images',
min=0,
max=32,
step=200,
default=0,
options={'HIDDEN'},
)
bpy.types.Scene.smc_save_path = StringProperty(
description='Select the directory in which the generated texture atlas will be saved',
default='',
)
bpy.types.Material.root_mat = PointerProperty(
name='Material Root',
type=bpy.types.Material,
)
bpy.types.Material.smc_diffuse = BoolProperty(
name='Multiply image with diffuse color',
description='Multiply the materials image with its diffuse color.'
'\nINFO: If this color is white the final image will be the same',
default=True,
)
bpy.types.Material.smc_size = BoolProperty(
name='Custom image size',
description='Select the max size for this materials image in the texture atlas',
default=False,
)
bpy.types.Material.smc_size_width = IntProperty(
name='Max width (px)',
description='Select max width for material image',
min=8,
max=8192,
step=1,
default=2048,
)
bpy.types.Material.smc_size_height = IntProperty(
name='Max height (px)',
description='Select max height for material image',
min=8,
max=8192,
step=1,
default=2048,
)
def unregister() -> None:
del bpy.types.Scene.smc_ob_data
del bpy.types.Scene.smc_ob_data_id
del bpy.types.Scene.smc_list_id
del bpy.types.Scene.smc_size
del bpy.types.Scene.smc_size_width
del bpy.types.Scene.smc_size_height
del bpy.types.Scene.smc_crop
del bpy.types.Scene.smc_pixel_art
del bpy.types.Scene.smc_diffuse_size
del bpy.types.Scene.smc_gaps
del bpy.types.Scene.smc_save_path
del bpy.types.Material.root_mat
del bpy.types.Material.smc_diffuse
del bpy.types.Material.smc_size
del bpy.types.Material.smc_size_width
del bpy.types.Material.smc_size_height