forked from JoseConseco/GoB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
preferences.py
450 lines (395 loc) · 17.4 KB
/
preferences.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
# ##### BEGIN GPL LICENSE BLOCK #####
#
# 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 2
# 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
# MERCHANTABILITY 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, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
if "bpy" in locals():
import importlib
importlib.reload(GoB)
importlib.reload(addon_updater)
else:
from . import GoB
from . import addon_updater
"""Addon preferences"""
import bpy
import os
from bpy.types import AddonPreferences
from bpy.props import ( StringProperty,
BoolProperty,
FloatProperty,
EnumProperty)
preferences_tabs = [
("OPTIONS", "Options", ""),
("IMPORT", "Import", ""),
("EXPORT", "Export", ""),
("UPDATE", "Update", ""),
("HELP", "Troubleshooting", "")
]
class GoB_Preferences(AddonPreferences):
bl_idname = __package__
tabs: EnumProperty(name="Tabs", items=preferences_tabs, default="OPTIONS")
# ADDON UPDATER
repository_path: StringProperty(
name="Project",
description="Github Project url example: https://github.com/JoseConseco/GoB",
subtype='DIR_PATH',
default="https://github.com/JoseConseco/GoB")
zip_filename: StringProperty(
name="zip_filename",
description="zip_filename",
subtype='FILE_PATH',
default="blender_addon_updater.zip")
auto_update_check: BoolProperty(
name="Check for updates automaticaly",
description="auto_update_check",
default=False)
experimental_versions: BoolProperty(
name="Experimental Verions",
description="Check for experimental verions",
default=False)
############################################
#GLOBAL
zbrush_exec: StringProperty(
name="ZBrush Path",
description="Select Zbrush executable (C:\Program Files\Pixologic\ZBrush\ZBrush.exe). "
"\nIf not specified the system default for Zscript (.zsc) files will be used",
subtype='FILE_PATH',
default="")
project_path: StringProperty(
name="Project Path",
description="Folder where Zbrush and Blender will store the exported content",
subtype='DIR_PATH',
default=os.path.join(f"{GoB.PATH_GOZ}/GoZProjects/Default/"))
clean_project_path: BoolProperty(
name="Clean Project Files",
description="Removes files in the project path to keep your GoZ bridge clean and your SSD happy",
default=False)
use_scale: EnumProperty(
name="Scale",
description="Create Material",
items=[('MANUAL', 'Manual', 'Use Manual Factor for Scaling'),
('BUNITS', 'Blender Units', 'Changes Scale depending on Blenders Unit Scale '),
('ZUNITS', 'ZBrush Units', 'Scale single Object to ZBrush Units'),
],
default='BUNITS')
zbrush_scale: FloatProperty(
name="ZBrush Scale",
description="Target ZBrush Scale",
default=2.0,
min = 0.1,
soft_max=10,
step=1.0,
precision=1,
subtype='FACTOR')
manual_scale: FloatProperty(
name="Scale Factor",
description="Change Scale in Zbrush",
default=1.0,
min = 0.1,
soft_max=10,
step=1.0,
precision=1,
subtype='FACTOR')
flip_up_axis: BoolProperty(
name="Flip up axis",
description="Flip the up axis on Import/Export",
default=False)
flip_forward_axis: BoolProperty(
name="Flip forward axis",
description="Flip the forward axis on Import/Export",
default=False)
show_button_text: BoolProperty(
name="Show Buttons Text",
description="Show Text on the Import/Export Buttons",
default=True)
performance_profiling: BoolProperty(
name="[Dev] Debug performance",
description="Show timing output in console, note this will slow down the GoZ transfer if enabled!",
default=False)
debug_output: BoolProperty(
name="[Dev] debug_output",
description="Show debug output in console, note this will slow down the GoZ transfer if enabled!",
default=False)
"""
texture_format: EnumProperty(
name="Image Format",
description=" Output image format",
items=[ ('TIFF', '.tif', ' Output image in TIFF format'),
('BMP', '.bmp', ' Output image in BMP format'),
('JPEG', '.jpg', ' Output image in JPEG format'),
('PNG', '.png', ' Output image in PNG format'),
],
default='BMP')
"""
# EXPORT
export_modifiers: EnumProperty(
name='Modifiers',
description='Modifiers Mode',
items=[('APPLY_EXPORT', 'Export and Apply', 'Apply Modifiers in Blender and Export them to ZBrush'),
('ONLY_EXPORT', 'Only Export', 'Export Modifiers to ZBrush but do not apply them in Blender'),
('IGNORE', 'Ignore', 'Do not export modifiers')
],
default='ONLY_EXPORT')
export_polygroups: EnumProperty(
name="Polygroups",
description="Create Polygroups",
items=[ ('FACE_MAPS', 'from Face Maps', 'Create Polygroups from Face Maps'),
#('MATERIALS', 'from Materials', 'Create Polygroups from Materials'),
('VERTEX_GROUPS', 'from Vertex Groups', 'Create Polygroups from Vertex Groups'),
('NONE', 'None', 'Do not Create Polygroups'),
],
default='FACE_MAPS')
export_weight_threshold: FloatProperty(
name="Weight Threshold",
description="Only vertex weight higher than the threshold are converted to polygroups",
default=0.1,
min=0.01,
max=1.0,
step=0.01,
precision=2,
subtype='FACTOR')
export_clear_mask: BoolProperty(
name="Clear Mask",
description="When enabled Masks will not be exported an cleared in ZBrush",
default=False)
export_remove_internal_faces: BoolProperty(
name="Delete non manifold faces",
description="Delete non manifold faces",
default=True)
export_merge: BoolProperty(
name="Merge Vertices of Curves, Surfaces, Fonts and Meta Objects",
description="Merges vertices of mesh type 'SURFACE', 'CURVE', 'FONT', 'META' that are in a given distance to each other",
default=True)
export_merge_distance: FloatProperty(
name="Vertex Merge Threshold",
description="Vertex Merge Threshold",
default=0.0001,
soft_min=0.0001,
soft_max=0.01,
step=0.0001,
precision=4,
subtype='DISTANCE')
# IMPORT
import_timer: FloatProperty(
name="Update interval",
description="Interval (in seconds) to look for changes in GoZ_ObjectList.txt",
default=0.5,
min = 0.1,
soft_max=2.0,
step=0.1,
precision=1,
subtype='FACTOR')
import_material: EnumProperty(
name="Material",
description="Create Material",
items=[('TEXTURES', 'from Textures', 'Create Mateial inputs from Textures'), #TODO: fix export to zbrush
('POLYPAINT', 'from Polypaint', 'Create Material from Polypaint'),
('NONE', 'None', 'No additional material inputs are created'),
],
default='POLYPAINT')
import_method: EnumProperty(
name="Import Button Method",
description="Manual Mode requires to press the import every time you send a model from zbrush to import it.",
items=[('MANUAL', 'Manual', 'Manual Mode requires to press the import every time you send a model from zbrush to import it.'),
('AUTOMATIC', 'Automatic', 'Automatic Mode'),
],
default='AUTOMATIC')
import_polypaint: BoolProperty(
name="Polypaint",
description="Import Polypaint as Vertex Color",
default=True)
import_polypaint_name: StringProperty(
name="Vertex Color",
description="Set name for Vertex Color Layer",
default="Col")
import_polygroups_to_vertexgroups: BoolProperty(
name="Polygroups to Vertex Groups",
description="Import Polygroups as Vertex Groups",
default=False)
import_polygroups_to_facemaps: BoolProperty(
name="Polygroups to Face Maps",
description="Import Polygroups as Face Maps",
default=True)
apply_facemaps_to_facesets: BoolProperty(
name="Apply Face Maps to Face Sets",
description="apply_facemaps_to_facesets",
default=False)
import_mask: BoolProperty(
name="Mask",
description="Import Mask to Vertex Group",
default=True)
import_uv: BoolProperty(
name="UV Map",
description="Import Uv Map from ZBrush",
default=True)
import_uv_name: StringProperty(
name="UV Map",
description="Set name for the UV Map",
default="UVMap")
import_diffuse_suffix: StringProperty(
name="Base Color",
description="Set Suffix for Base Color Map",
default="_diff")
import_diffuse_colorspace: EnumProperty(
name="",
description="diffuse_colorspace",
items=[('Filmic Log', 'Filmic Log', 'Log based filmic shaper with 16.5 stops of latitude, and 25 stops of dynamic range'),
('Linear', 'Linear', 'Rec. 709 (Full Range), Blender native linear space'),
('Linear ACES', 'Linear ACES', 'ACES linear space'),
('Non-Color', 'Non-Color', 'Color space used for images which contains non-color data (i,e, normal maps)'),
('Raw', 'Raw', 'Raw'),
('sRGB', 'sRGB ', 'Standard RGB Display Space'),
('XYZ', 'XYZ ', 'XYZ'),
],
default='sRGB')
import_displace_suffix: StringProperty(
name="Displacement Map",
description="Set Suffix for Displacement Map",
default="_disp")
import_displace_colorspace: EnumProperty(
name="",
description="displace_colorspace",
items=[('Filmic Log', 'Filmic Log', 'Log based filmic shaper with 16.5 stops of latitude, and 25 stops of dynamic range'),
('Linear', 'Linear', 'Rec. 709 (Full Range), Blender native linear space'),
('Linear ACES', 'Linear ACES', 'ACES linear space'),
('Non-Color', 'Non-Color', 'Color space used for images which contains non-color data (i,e, normal maps)'),
('Raw', 'Raw', 'Raw'),
('sRGB', 'sRGB ', 'Standard RGB Display Space'),
('XYZ', 'XYZ ', 'XYZ'),
],
default='Linear')
import_normal_suffix: StringProperty(
name="Normal Map",
description="Set Suffix for Normal Map",
default="_norm")
import_normal_colorspace: EnumProperty(
name="",
description="normal_colorspace",
items=[('Filmic Log', 'Filmic Log', 'Log based filmic shaper with 16.5 stops of latitude, and 25 stops of dynamic range'),
('Linear', 'Linear', 'Rec. 709 (Full Range), Blender native linear space'),
('Linear ACES', 'Linear ACES', 'ACES linear space'),
('Non-Color', 'Non-Color', 'Color space used for images which contains non-color data (i,e, normal maps)'),
('Raw', 'Raw', 'Raw'),
('sRGB', 'sRGB ', 'Standard RGB Display Space'),
('XYZ', 'XYZ ', 'XYZ'),
],
default='Non-Color')
def draw_options(self, box):
# GoB General Options
box.use_property_split = True
box.label(text='GoB General Options', icon='PREFERENCES')
col = box.column(align=True)
col.prop(self, 'zbrush_exec')
col.prop(self, 'project_path')
col.prop(self, 'clean_project_path')
col.prop(self, 'flip_up_axis')
col.prop(self, 'flip_forward_axis')
col.prop(self, 'use_scale')
if self.use_scale == 'MANUAL':
col.prop(self, 'manual_scale')
if self.use_scale == 'ZUNITS':
col.prop(self, 'zbrush_scale')
col.prop(self, 'show_button_text')
col.prop(self, 'performance_profiling')
col.prop(self, 'debug_output')
#col.prop(self, 'texture_format')
def draw_import(self, box):
# GoB Import Options
box.use_property_split = True
#box = layout.box()
box.label(text='GoB Import Options', icon='IMPORT')
col = box.column(align=True)
#box.prop(self, 'import_method') #TODO: disabled: some bugs when switching
col.prop(self, 'import_timer') #TODO: disabled: some bugs when switching
col.prop(self, 'import_material')
#col = box.column(align=True) #TODO: add heading ="" in 2.9
col.prop(self, 'import_mask')
col.prop(self, 'import_uv')
col.prop(self, 'import_polypaint')
col.prop(self, 'import_polygroups_to_vertexgroups')
col.prop(self, 'import_polygroups_to_facemaps')
#col.prop(self, 'apply_facemaps_to_facesets')
row = box.row(align=True)
row.prop(self, 'import_diffuse_suffix')
row.prop(self, 'import_diffuse_colorspace')
row = box.row(align=True)
row.prop(self, 'import_normal_suffix')
row.prop(self, 'import_normal_colorspace')
row = box.row(align=True)
row.prop(self, 'import_displace_suffix')
row.prop(self, 'import_displace_colorspace')
col = box.column(align=True)
col.prop(self, 'import_uv_name')
col.prop(self, 'import_polypaint_name')
def draw_export(self, box):
# GoB Export Options
box.use_property_split = True
box.label(text='GoB Export Options', icon='EXPORT')
col = box.column(align=True)
col.prop(self, 'export_modifiers')
col.prop(self, 'export_polygroups')
if self.export_polygroups == 'VERTEX_GROUPS':
col.prop(self, 'export_weight_threshold')
col.prop(self, 'export_clear_mask')
col.prop(self, 'export_merge')
if self.export_merge:
col.prop(self, 'export_merge_distance')
col.prop(self, 'export_remove_internal_faces')
def draw_help(self, box):
# GoB Troubleshooting
box.use_property_split = True
#box = layout.box()
box.label(text='GoB Troubleshooting', icon='QUESTION')
import platform
if platform.system() == 'Windows':
icons = GoB.preview_collections["main"]
box.operator( "gob.install_goz", text="Install GoZ", icon_value=icons["GOZ_SEND"].icon_id )
def draw_update(self, box):
box.use_property_split = True
box.label(text='Addon Updater', icon='PREFERENCES')
col = box.column(align=False)
row = col.row(align=False)
row.operator("au.check_updates", text="Check for Updates", icon='ERROR', depress=False).button_input = 0
if addon_updater.update_available == False:
row.operator("au.check_updates", text="Addon is up to date", icon='IMPORT', emboss=True, depress=True).button_input = -1
elif addon_updater.update_available == None:
row.operator("au.check_updates", text="nothing to show", icon='ERROR', emboss=False, depress=True).button_input = -1
elif addon_updater.update_available == 'TIME':
row.operator("au.check_updates", text="Limit exceeded! Try again later", icon='COLORSET_01_VEC', emboss=False, depress=True).button_input = -1
else:
row.operator("au.check_updates", text="Download: " + addon_updater.update_available, icon='COLORSET_03_VEC').button_input = 1
col = box.column(align=False)
col.prop(self, 'repository_path')
#col.prop(self, 'zip_filename')
col.prop(self, 'experimental_versions')
#col.prop(self, 'auto_update_check')
def draw(self, context):
layout = self.layout
# TAB BAR
layout.use_property_split = False
column = layout.column(align=True)
row = column.row()
row.prop(self, "tabs", expand=True)
box = column.box()
if self.tabs == "OPTIONS":
self.draw_options(box)
elif self.tabs == "EXPORT":
self.draw_export(box)
elif self.tabs == "IMPORT":
self.draw_import(box)
elif self.tabs == "HELP":
self.draw_help(box)
elif self.tabs == "UPDATE":
self.draw_update(box)