-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
177 lines (152 loc) · 5.45 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
bl_info = {
"name": "Asset Packer",
"author": "Daniel Dehne",
"description": "Decimate, PBR Setup and export multiple texture resolutions",
"blender": (4, 0, 0),
"version": (0, 0, 1),
"location": "",
"warning": "",
"category": "Generic",
}
import bpy
from bpy.types import PropertyGroup, Image, Object
from bpy.props import (
FloatProperty,
PointerProperty,
StringProperty,
BoolProperty,
EnumProperty,
CollectionProperty,
)
from .gui.main_panel import AP_PT_MainPanel
from .gui.decimate_tab import AP_PT_TabDecimate
from .gui.export_tab import AP_PT_ExportTab
from .operators.import_fbx import ImportFbxOperator
from .operators.export_textures import TextureExporterOperator
LAYOUTS = (AP_PT_MainPanel, AP_PT_TabDecimate, AP_PT_ExportTab)
OPERATORS = (ImportFbxOperator, TextureExporterOperator)
# Define a property groups
class GeneralSettings(PropertyGroup):
import_folder: StringProperty(
name="texture_import_folder",
description="Folder to look for textures when importing.",
default="textures/",
)
decimate_on_import: BoolProperty(
name="decimate_on_import",
description="Apply decimate modifier on LODs automatically.",
default=True,
)
class SuffixSettings(PropertyGroup):
albedo: StringProperty(
name="albedeo",
description="Suffix for albedo texture.",
default="albedo",
)
metallic: StringProperty(
name="metallic", description="Suffix for metallic texture.", default="metallic"
)
ao: StringProperty(
name="ao_suffix", description="Suffix for AO texture.", default="ao"
)
normal: StringProperty(
name="normal_suffix", description="Suffix for normal texture.", default="normal"
)
emission: StringProperty(
name="emission_suffix",
description="Suffix for emission texture.",
default="emission",
)
displacement: StringProperty(
name="displacement_suffix",
description="Suffix for displacement texture.",
default="displacement",
)
roughness: StringProperty(
name="roughness_suffix",
description="Suffix for roughness texture.",
default="roughness",
)
opacity: StringProperty(
name="opacity_suffix",
description="Suffix for opacity texture.",
default="opacity",
)
class DecimateSettings(PropertyGroup):
lod_ratio_1: FloatProperty(
name="lod_ratio_1",
description="This sets the ratio for LOD 1",
default=0.7,
min=0.0,
max=1.0,
)
lod_ratio_2: FloatProperty(
name="LOD ratio 2",
description="This sets the ratio for LOD 2",
default=0.4,
min=0.0,
max=1.0,
)
lod_ratio_3: FloatProperty(
name="LOD ratio 3",
description="This sets the ratio for LOD 1",
default=0.2,
min=0.0,
max=1.0,
)
lod_mesh_0: PointerProperty(name="lod0", type=Object)
lod_mesh_1: PointerProperty(name="lod1", type=Object)
lod_mesh_2: PointerProperty(name="lod2", type=Object)
lod_mesh_3: PointerProperty(name="lod3", type=Object)
class PBRTexturesSettings(PropertyGroup):
albedo: PointerProperty(name="Base Color", type=Image)
metallic: PointerProperty(name="Metallic", type=Image)
normal: PointerProperty(name="Normal", type=Image)
emission: PointerProperty(name="Emission", type=Image)
displacement: PointerProperty(name="Displacement", type=Image)
ao: PointerProperty(name="Ambient Occlusion", type=Image)
roughness: PointerProperty(name="Roughness", type=Image)
opacity: PointerProperty(name="Opacity", type=Image)
folder_export_path: StringProperty(name="folder_export_path", default="export/")
export_lods: BoolProperty(name="export_lods", default=True)
export_resolutions: EnumProperty(
name="export_resolutions",
items=[
("4096", "4k", "4096x4096"),
("2048", "2k", "2048x2048"),
("1024", "1k", "1024x1024"),
("512", "512", "512x512"),
],
options={"ENUM_FLAG"},
default={"4096", "2048", "1024", "512"},
)
folder_export_base_path: StringProperty(name="folder_export_base_path")
def register():
# move settings to its own file
bpy.utils.register_class(SuffixSettings)
bpy.types.Scene.suffix_settings = bpy.props.PointerProperty(type=SuffixSettings)
bpy.utils.register_class(GeneralSettings)
bpy.types.Scene.general_settings = bpy.props.PointerProperty(type=GeneralSettings)
bpy.utils.register_class(DecimateSettings)
bpy.types.Scene.decimate_settings = bpy.props.PointerProperty(type=DecimateSettings)
bpy.utils.register_class(PBRTexturesSettings)
bpy.types.Scene.pbr_textures_settings = bpy.props.PointerProperty(
type=PBRTexturesSettings
)
for item in LAYOUTS:
bpy.utils.register_class(item)
for operator in OPERATORS:
bpy.utils.register_class(operator)
def unregister():
bpy.utils.unregister_class(SuffixSettings)
del bpy.types.Scene.suffix_settings
bpy.utils.unregister_class(GeneralSettings)
del bpy.types.Scene.general_settings
bpy.utils.unregister_class(PBRTexturesSettings)
del bpy.types.Scene.pbr_textures_settings
bpy.utils.unregister_class(DecimateSettings)
del bpy.types.Scene.decimate_settings
for item in LAYOUTS:
bpy.utils.unregister_class(item)
for operator in OPERATORS:
bpy.utils.unregister_class(operator)