Skip to content

Commit a966c96

Browse files
committed
Update bone names in armature_utils.py, convertHI3PC.py, and model_utils.py + Hotfix OldFace models
1 parent 49b8abc commit a966c96

File tree

4 files changed

+69
-15
lines changed

4 files changed

+69
-15
lines changed

Tools/armature_utils.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,52 @@ def GetGameData(game):
252252
"RFinger4": "LittleFinger1_R",
253253
"RFinger41": "LittleFinger2_R",
254254
"RFinger42": "LittleFinger3_R",
255+
"RightLeg": "Right leg",
256+
"LeftLeg": "Left leg",
257+
"RightArm": "Right arm",
258+
"LeftArm": "Left arm",
259+
"RightWrist": "Right wrist",
260+
"LeftWrist": "Left wrist",
261+
"RightElbow": "Right elbow",
262+
"LeftElbow": "Left elbow",
263+
"RightShoulder": "Right shoulder",
264+
"LeftShoulder": "Left shoulder",
265+
"LeftKnee": "Left knee",
266+
"RightKnee": "Right knee",
267+
"RightAnkle": "Right ankle",
268+
"LeftAnkle": "Left ankle",
269+
"RightToe": "Right toe",
270+
"LeftToe": "Left toe",
271+
"LFinger0": "Thumb1_L",
272+
"LFinger01": "Thumb2_L",
273+
"LFinger02": "Thumb3_L",
274+
"L": "IndexFinger1_L",
275+
"L_001": "IndexFinger2_L",
276+
"L_002": "IndexFinger3_L",
277+
"L_003": "MiddleFinger1_L",
278+
"L_004": "MiddleFinger2_L",
279+
"L_005": "MiddleFinger3_L",
280+
"L_006": "RingFinger1_L",
281+
"L_007": "RingFinger2_L",
282+
"L_008": "RingFinger3_L",
283+
"L_009": "LittleFinger1_L",
284+
"L_010": "LittleFinger2_L",
285+
"L_011": "LittleFinger3_L",
286+
"RFinger0": "Thumb1_R",
287+
"RFinger01": "Thumb2_R",
288+
"RFinger02": "Thumb3_R",
289+
"R": "IndexFinger1_R",
290+
"R_001": "IndexFinger2_R",
291+
"R_002": "IndexFinger3_R",
292+
"R_003": "MiddleFinger1_R",
293+
"R_004": "MiddleFinger2_R",
294+
"R_005": "MiddleFinger3_R",
295+
"R_006": "RingFinger1_R",
296+
"R_007": "RingFinger2_R",
297+
"R_008": "RingFinger3_R",
298+
"R_009": "LittleFinger1_R",
299+
"R_010": "LittleFinger2_R",
300+
"R_011": "LittleFinger3_R",
255301
},
256302
"starts_with": {
257303
"_": "",

Tools/convertHI3PC.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,11 @@ def Run():
290290
if bpy.context.scene.reconnect_armature:
291291
ConnectArmature()
292292
ReparentBones()
293-
model_utils.MergeFaceByDistance("Face", ["Eyebrow", "EyeShape"], "A")
293+
# Check if 'Face' object has shape keys
294+
if shapekey_utils.GetShapeKey("Face", "A") is None:
295+
model_utils.MergeFaceByDistance("Face", ["Eyebrow", "EyeShape"], "None")
296+
else:
297+
model_utils.MergeFaceByDistance("Face", ["Eyebrow", "EyeShape"], "A")
294298
model_utils.MergeMeshes()
295299

296300
Run()

Tools/model_utils.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def JoinObjects(target_obj):
138138
blender_utils.ChangeMode("OBJECT")
139139

140140

141-
def MergeFaceByDistance(target_obj_name, obj_names_to_merge, shapekey_name):
141+
def MergeFaceByDistance(target_obj_name, obj_names_to_merge, shapekey_name=None):
142142
# Get the target object
143143
target_obj = bpy.data.objects.get(target_obj_name)
144144
if target_obj is None:
@@ -165,16 +165,18 @@ def MergeFaceByDistance(target_obj_name, obj_names_to_merge, shapekey_name):
165165
# Join the selected objects into the active object
166166
bpy.ops.object.join()
167167

168-
# Store the current active shape key index
169-
current_active_shape_key_index = target_obj.active_shape_key_index
168+
# If shapekey_name is not None and target object has shape keys, apply the shapekey
169+
if shapekey_name is not None and target_obj.data.shape_keys is not None:
170+
# Store the current active shape key index
171+
current_active_shape_key_index = target_obj.active_shape_key_index
170172

171-
# Set the active shape key to the specified one
172-
target_obj.active_shape_key_index = (
173-
target_obj.data.shape_keys.key_blocks.keys().index(shapekey_name)
174-
)
173+
# Set the active shape key to the specified one
174+
target_obj.active_shape_key_index = (
175+
target_obj.data.shape_keys.key_blocks.keys().index(shapekey_name)
176+
)
175177

176-
# Set the shape key value
177-
target_obj.data.shape_keys.key_blocks[shapekey_name].value = 1.0
178+
# Set the shape key value
179+
target_obj.data.shape_keys.key_blocks[shapekey_name].value = 1.0
178180

179181
# Switch to edit mode
180182
blender_utils.ChangeMode("EDIT")
@@ -191,11 +193,13 @@ def MergeFaceByDistance(target_obj_name, obj_names_to_merge, shapekey_name):
191193
# Switch back to object mode
192194
blender_utils.ChangeMode("OBJECT")
193195

194-
# Reset the shape key value to 0
195-
target_obj.data.shape_keys.key_blocks[shapekey_name].value = 0
196+
# If shapekey_name is not None and target object has shape keys, reset the shape key value and restore the active shape key index
197+
if shapekey_name is not None and target_obj.data.shape_keys is not None:
198+
# Reset the shape key value to 0
199+
target_obj.data.shape_keys.key_blocks[shapekey_name].value = 0
196200

197-
# Restore the active shape key index
198-
target_obj.active_shape_key_index = current_active_shape_key_index
201+
# Restore the active shape key index
202+
target_obj.active_shape_key_index = current_active_shape_key_index
199203

200204

201205
def MergeMeshes():

__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
bl_info = {
2121
"name": "Hoyo2VRC",
2222
"author": "Meliodas",
23-
"version": (3, 0, 2),
23+
"version": (3, 0, 3),
2424
"blender": (4, 0, 2),
2525
"location": "3D View > Sidebar > Hoyo2VRC",
2626
"description": "Convert Hoyoverse models to VRChat usable models.",

0 commit comments

Comments
 (0)