-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpac_export_menu.py
More file actions
228 lines (190 loc) · 6.16 KB
/
pac_export_menu.py
File metadata and controls
228 lines (190 loc) · 6.16 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
import bpy
from bpy_extras.io_utils import ExportHelper
from bpy.props import StringProperty, BoolProperty, EnumProperty, IntProperty
from bpy.types import Operator, Panel
from .export_pac import export
class ExportPac(Operator, ExportHelper):
"""Export Monster Hunter PAC files."""
bl_idname = "export_mh.pac"
bl_label = "Export PAC"
filename_ext = ".pac"
filter_glob: StringProperty(
default="*.pac",
options={'HIDDEN'},
maxlen=255, # Max internal buffer length, longer would be clamped.
)
type: EnumProperty(
name="Format Version",
description="Choose pmo format version",
items=(
('1.0', "MHFU", "Export MHFU models"),
('1.2', "MHP3rd", "Export MHP3rd models"),
),
default='1.2',
)
export_target: EnumProperty(
name="Export target",
description="Select target for exporting",
items=(
("scene", "Scene", "Export all mesh objects in the scene"),
("visible", "Visible", "Export all visible mesh objects"),
("selection", "Selection", "Export all selected mesh objects"),
("active", "Active", "Export active mesh object")
),
default="visible",
)
prep_pmo: EnumProperty(
name="Prepare PMO",
description="Triangulate mesh and split vertex for normals/uvs. (Same as pressing 'Prepare PMO' but won't have a permanent effect on the model)",
items=(
("none", "None", "Do not run any prep script"),
("simple", "Simple", "Just split seams and sharp edges"),
("*&", "*&'s", "Run *&'s script"),
("xenthos", "Xenthos'", "Run Xenthos' script"),
),
default="simple"
)
cleanup_vg: BoolProperty(
name="Clean Up VG",
description="Remove vertex group assignments wich are not required",
default=False
)
do_fix_vg: BoolProperty(
name="Merge Submeshes",
description="Attempts to reduce submeshes by merging them based on material and bones",
default=False
)
upper_face: BoolProperty(
name="Forehead",
default=True
)
lower_face: BoolProperty(
name="Jaw",
default=True
)
ears: BoolProperty(
name="Ears",
default=True
)
eyes: BoolProperty(
name="Eyes",
default=True
)
nose: BoolProperty(
name="Nose",
default=True
)
nape: BoolProperty(
name="Nape",
default=True
)
makeup1: BoolProperty(
name="Makeup 1",
default=True
)
makeup2: BoolProperty(
name="Makeup 2",
default=True
)
phys_id: IntProperty(
name="Physics ID",
default=0
)
hairflags: IntProperty(
name="Hair Flags",
description="Seems to be incomplete\nSCALP = 1\nFRONT = 2\nFRONT_2 = 4\nBACK_1 = 8\nBACK_2 = 16\nBACK_3 = 32",
default=255
)
p3rd_helmet: BoolProperty(
name="Is P3rd helmet",
description="Export as p3rd helmet. Following properties are ignored if not",
default=False
)
apply_modifiers: BoolProperty(
name="Apply Modifiers",
description="Apply modifiers before exporting",
default=False
)
hard_tristripification: BoolProperty(
name="Hard Tristripification",
description="Create as few tristrips as possible",
default=False
)
def execute(self, context):
face = (self.upper_face, self.ears, self.nape, self.lower_face, self.nose, self.eyes, self.makeup1, self.makeup2)
return export(
context,
filepath=self.filepath,
version=self.type,
target=self.export_target,
prepare_pmo=self.prep_pmo,
cleanup_vg=self.cleanup_vg,
p3rd_helmet=self.p3rd_helmet,
face_flags=face,
hairflags=self.hairflags,
phys_id=self.phys_id,
app_modifiers=self.apply_modifiers,
hard_tristripification=self.hard_tristripification,
do_fix_vg=self.do_fix_vg
)
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False # No animation
layout.prop(self, 'type')
layout.prop(self, 'export_target')
layout.prop(self, 'prep_pmo')
layout.prop(self, 'cleanup_vg')
layout.prop(self, 'do_fix_vg')
layout.prop(self, 'apply_modifiers')
layout.prop(self, 'hard_tristripification')
class FaceFlags(Panel):
bl_space_type = 'FILE_BROWSER'
bl_region_type = 'TOOL_PROPS'
bl_label = "P3rd Helmet"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
sfile = context.space_data
operator = sfile.active_operator
return operator.bl_idname == "EXPORT_MH_OT_pac"
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False # No animation.
sfile = context.space_data
operator = sfile.active_operator
row = layout.row()
row.prop(operator, 'p3rd_helmet')
row = layout.row()
row.prop(operator, 'upper_face')
row.prop(operator, 'lower_face')
row = layout.row()
row.prop(operator, 'nose')
row.prop(operator, 'eyes')
row = layout.row()
row.prop(operator, 'ears')
row.prop(operator, 'nape')
row = layout.row()
row.prop(operator, 'makeup1')
row.prop(operator, 'makeup2')
row = layout.row()
row.prop(operator, 'hairflags')
row = layout.row()
row.prop(operator, 'phys_id')
def menu_func_export(self, context):
self.layout.operator(ExportPac.bl_idname, text="PSP MH PAC")
classes = (
ExportPac,
FaceFlags
)
def register():
for c in classes:
bpy.utils.register_class(c)
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
def unregister():
for c in classes:
bpy.utils.register_class(c)
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
if __name__ == "__main__":
register()