-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path__init__.py
245 lines (210 loc) · 7.21 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
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
import bpy
import sys
import re
from pathlib import Path
from bpy.types import Panel
from .Tools import (
model_utils,
importer,
exporter,
hoyofbx,
convertGIPC,
convertGIW,
convertHSRPC,
convertHI3PC,
convertNPC,
convertWWPC,
convertZZZ,
)
from . import settings
bl_info = {
"name": "Hoyo2VRC X",
"author": "Meliodas",
"version": (4, 5, 1),
"blender": (4, 0, 2),
"location": "3D View > Sidebar > Hoyo2VRC",
"description": "Convert Hoyoverse and Wuthering Waves models to VRChat usable models.",
"warning": "Requires Wuthering Waves/Hoyoverse Datamined Assets",
"doc_url": "https://docs.hoyotoon.com",
"support": "COMMUNITY",
"category": "VRC",
"tracker_url": "",
}
class Hoyo2VRCModelPanel(Panel):
bl_idname = "hoyo2vrc_PT_model_panel"
bl_label = "Model Conversion"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "Hoyo2VRC"
def draw(self, context):
layout = self.layout
# Get the version number from bl_info
version = bl_info["version"]
version_str = ".".join(map(str, version))
# Create a box for the version number
box = layout.box()
box.label(text="Hoyo2VRC Version:" + version_str, icon="INFO")
# Add a box section for the model
box = layout.box()
box.label(text="Model Conversions", icon="MESH_DATA")
# Add a row for importing and exporting the model
row = box.row()
row.operator(operator="hoyo2vrc.import", text="Import Model", icon="IMPORT")
# Initialize Model to None
Model = None
# Iterate over all objects in the scene
for obj in bpy.context.scene.objects:
# Check if the object is a valid model
if model_utils.IsValidModel(obj):
Model = obj
break
if Model:
# Add a row for exporting the model
row.operator(operator="hoyo2vrc.export", text="Export Model", icon="EXPORT")
# Add a row for converting the avatar
row = box.row()
# Identify the model
game, body_type, model_name = model_utils.IdentifyModel(Model.name)
# Define a dictionary to map game names to operator functions and display texts
games = {
"Genshin Impact": ("hoyo2vrc.convertgpc", "Convert GI Avatar"),
"Genshin Weapon": ("hoyo2vrc.convertgiw", "Convert GI Weapon"),
"Honkai Star Rail": ("hoyo2vrc.converthsrpc", "Convert HSR Avatar"),
"Honkai Impact": ("hoyo2vrc.converthi3pc", "Convert HI3 Avatar"),
"Wuthering Waves": ("hoyo2vrc.convertwuwa", "Convert WuWa Avatar"),
#"Zenless Zone Zero": ("hoyo2vrc.convertzzz", "Convert ZZZ Avatar"),
# "NPC": ("hoyo2vrc.convertnpc", "Convert NPC"),
}
# Get the operator function and display text for the current game
operator_func, display_text = games.get(game, (None, None))
# If the operator function exists, call it with the appropriate parameters
if operator_func:
operator = row.operator(
operator=operator_func, text=display_text, icon="PLAY"
)
elif game == "NPC":
row.label(text="NPC is not supported", icon="ERROR")
elif game == "Converted":
row.label(text="Model already converted", icon="ERROR")
class Hoyo2VRCConversionSettingsPanel(Panel):
bl_label = "Conversion Settings"
bl_idname = "hoyo2vrc_PT_Settings_Panel"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "Hoyo2VRC"
bl_options = {"DEFAULT_CLOSED"}
def draw(self, context):
layout = self.layout
# Add a box section for the Mesh settings
box = layout.box()
# Add a row for the "Merge Meshes" option
row = box.row()
row.prop(
context.scene,
"merge_all_meshes",
text="Merge Meshes",
icon="CHECKBOX_HLT" if context.scene.merge_all_meshes else "CHECKBOX_DEHLT",
)
row = box.row()
row.prop(
context.scene,
"connect_chest_to_neck",
text="Connect Chest to Neck",
icon=(
"CHECKBOX_HLT"
if context.scene.connect_chest_to_neck
else "CHECKBOX_DEHLT"
),
)
row = box.row()
row.prop(
context.scene,
"connect_twist_to_limbs",
text="Connect Twists to Limbs",
icon=(
"CHECKBOX_HLT"
if context.scene.connect_twist_to_limbs
else "CHECKBOX_DEHLT"
),
)
row = box.row()
row.prop(
context.scene,
"reconnect_armature",
text="Reconnect Armature",
icon=(
"CHECKBOX_HLT" if context.scene.reconnect_armature else "CHECKBOX_DEHLT"
),
)
row = box.row()
row.prop(
context.scene,
"humanoid_armature_fix",
text="Humanoid Armature Fixing",
icon=(
"CHECKBOX_HLT"
if context.scene.humanoid_armature_fix
else "CHECKBOX_DEHLT"
),
)
# Add after humanoid_armature_fix option
row = box.row()
row.prop(
context.scene,
"fbt_leg_fixes",
text="FBT Leg Fixes",
icon=(
"CHECKBOX_HLT"
if context.scene.fbt_leg_fixes
else "CHECKBOX_DEHLT"
),
)
# Add a row for the "Generate Shape Keys" option
row = box.row()
row.prop(
context.scene,
"generate_shape_keys",
text="Generate Shape Keys",
icon=(
"CHECKBOX_HLT"
if context.scene.generate_shape_keys
else "CHECKBOX_DEHLT"
),
)
# Add a row for the "Keep Star Eye Mesh" option
row = box.row()
row.prop(
context.scene,
"keep_star_eye_mesh",
text="Keep Star Eye Mesh",
icon=(
"CHECKBOX_HLT"
if context.scene.keep_star_eye_mesh
else "CHECKBOX_DEHLT"
),
)
# Add a separator for better visual organization
box.separator()
classes = [
convertGIPC.ConvertGenshinPlayerCharacter,
convertGIW.ConvertGenshinWeapon,
convertHI3PC.ConvertHonkaiImpactPlayerCharacter,
convertHSRPC.ConvertHonkaiStarRailPlayerCharacter,
convertNPC.ConvertNonePlayerCharacter,
convertWWPC.ConvertWutheringWavesPlayerCharacter,
convertZZZ.ConvertZenlessZoneZeroPlayerCharacter,
importer.Hoyo2VRCImportFbx,
exporter.Hoyo2VRCExportFbx,
hoyofbx.Hoyo2VRCImport,
hoyofbx.Hoyo2VRCExport,
Hoyo2VRCModelPanel,
Hoyo2VRCConversionSettingsPanel,
]
def register():
settings.register_settings()
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
settings.unregister_settings()
for cls in reversed(classes):
bpy.utils.unregister_class(cls)