diff --git a/Tools/armature_utils.py b/Tools/armature_utils.py index 6f3f304..1a43928 100644 --- a/Tools/armature_utils.py +++ b/Tools/armature_utils.py @@ -252,6 +252,52 @@ def GetGameData(game): "RFinger4": "LittleFinger1_R", "RFinger41": "LittleFinger2_R", "RFinger42": "LittleFinger3_R", + "RightLeg": "Right leg", + "LeftLeg": "Left leg", + "RightArm": "Right arm", + "LeftArm": "Left arm", + "RightWrist": "Right wrist", + "LeftWrist": "Left wrist", + "RightElbow": "Right elbow", + "LeftElbow": "Left elbow", + "RightShoulder": "Right shoulder", + "LeftShoulder": "Left shoulder", + "LeftKnee": "Left knee", + "RightKnee": "Right knee", + "RightAnkle": "Right ankle", + "LeftAnkle": "Left ankle", + "RightToe": "Right toe", + "LeftToe": "Left toe", + "LFinger0": "Thumb1_L", + "LFinger01": "Thumb2_L", + "LFinger02": "Thumb3_L", + "L": "IndexFinger1_L", + "L_001": "IndexFinger2_L", + "L_002": "IndexFinger3_L", + "L_003": "MiddleFinger1_L", + "L_004": "MiddleFinger2_L", + "L_005": "MiddleFinger3_L", + "L_006": "RingFinger1_L", + "L_007": "RingFinger2_L", + "L_008": "RingFinger3_L", + "L_009": "LittleFinger1_L", + "L_010": "LittleFinger2_L", + "L_011": "LittleFinger3_L", + "RFinger0": "Thumb1_R", + "RFinger01": "Thumb2_R", + "RFinger02": "Thumb3_R", + "R": "IndexFinger1_R", + "R_001": "IndexFinger2_R", + "R_002": "IndexFinger3_R", + "R_003": "MiddleFinger1_R", + "R_004": "MiddleFinger2_R", + "R_005": "MiddleFinger3_R", + "R_006": "RingFinger1_R", + "R_007": "RingFinger2_R", + "R_008": "RingFinger3_R", + "R_009": "LittleFinger1_R", + "R_010": "LittleFinger2_R", + "R_011": "LittleFinger3_R", }, "starts_with": { "_": "", diff --git a/Tools/convertHI3PC.py b/Tools/convertHI3PC.py index 74ca9a9..2cfbd85 100644 --- a/Tools/convertHI3PC.py +++ b/Tools/convertHI3PC.py @@ -290,7 +290,11 @@ def Run(): if bpy.context.scene.reconnect_armature: ConnectArmature() ReparentBones() - model_utils.MergeFaceByDistance("Face", ["Eyebrow", "EyeShape"], "A") + # Check if 'Face' object has shape keys + if shapekey_utils.GetShapeKey("Face", "A") is None: + model_utils.MergeFaceByDistance("Face", ["Eyebrow", "EyeShape"], "None") + else: + model_utils.MergeFaceByDistance("Face", ["Eyebrow", "EyeShape"], "A") model_utils.MergeMeshes() Run() diff --git a/Tools/model_utils.py b/Tools/model_utils.py index c08ee6a..41d92f4 100644 --- a/Tools/model_utils.py +++ b/Tools/model_utils.py @@ -138,7 +138,7 @@ def JoinObjects(target_obj): blender_utils.ChangeMode("OBJECT") -def MergeFaceByDistance(target_obj_name, obj_names_to_merge, shapekey_name): +def MergeFaceByDistance(target_obj_name, obj_names_to_merge, shapekey_name=None): # Get the target object target_obj = bpy.data.objects.get(target_obj_name) if target_obj is None: @@ -165,16 +165,18 @@ def MergeFaceByDistance(target_obj_name, obj_names_to_merge, shapekey_name): # Join the selected objects into the active object bpy.ops.object.join() - # Store the current active shape key index - current_active_shape_key_index = target_obj.active_shape_key_index + # If shapekey_name is not None and target object has shape keys, apply the shapekey + if shapekey_name is not None and target_obj.data.shape_keys is not None: + # Store the current active shape key index + current_active_shape_key_index = target_obj.active_shape_key_index - # Set the active shape key to the specified one - target_obj.active_shape_key_index = ( - target_obj.data.shape_keys.key_blocks.keys().index(shapekey_name) - ) + # Set the active shape key to the specified one + target_obj.active_shape_key_index = ( + target_obj.data.shape_keys.key_blocks.keys().index(shapekey_name) + ) - # Set the shape key value - target_obj.data.shape_keys.key_blocks[shapekey_name].value = 1.0 + # Set the shape key value + target_obj.data.shape_keys.key_blocks[shapekey_name].value = 1.0 # Switch to edit mode blender_utils.ChangeMode("EDIT") @@ -191,11 +193,13 @@ def MergeFaceByDistance(target_obj_name, obj_names_to_merge, shapekey_name): # Switch back to object mode blender_utils.ChangeMode("OBJECT") - # Reset the shape key value to 0 - target_obj.data.shape_keys.key_blocks[shapekey_name].value = 0 + # If shapekey_name is not None and target object has shape keys, reset the shape key value and restore the active shape key index + if shapekey_name is not None and target_obj.data.shape_keys is not None: + # Reset the shape key value to 0 + target_obj.data.shape_keys.key_blocks[shapekey_name].value = 0 - # Restore the active shape key index - target_obj.active_shape_key_index = current_active_shape_key_index + # Restore the active shape key index + target_obj.active_shape_key_index = current_active_shape_key_index def MergeMeshes(): diff --git a/__init__.py b/__init__.py index 748a8e4..bf57e31 100644 --- a/__init__.py +++ b/__init__.py @@ -20,7 +20,7 @@ bl_info = { "name": "Hoyo2VRC", "author": "Meliodas", - "version": (3, 0, 2), + "version": (3, 0, 3), "blender": (4, 0, 2), "location": "3D View > Sidebar > Hoyo2VRC", "description": "Convert Hoyoverse models to VRChat usable models.",