Skip to content

Commit

Permalink
added 'merge double-jointed knee' functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
wikid24 committed Feb 11, 2023
1 parent 92780d4 commit 60ebb43
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ffxiv_mmd_tools_helper/add_foot_leg_ik.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ def create_MMD_limit_rotation_constraint(bone_name,use_limit_x,use_limit_y,use_l
bone.constraints["Limit Rotation"].owner_space = owner_space
bone.constraints["Limit Rotation"].name = "mmd_ik_limit_override"


#fixes axis issue on bone roll
bpy.ops.object.mode_set(mode='EDIT')
bpy.context.active_object.data.edit_bones[bone_name].roll = 0
bpy.ops.object.mode_set(mode='POSE')
Expand Down
57 changes: 57 additions & 0 deletions ffxiv_mmd_tools_helper/bone_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from . import import_csv
from mmd_tools.core.bone import FnBone
import mmd_tools.core.model as mmd_model
from . import miscellaneous_tools


def correct_root_center():
Expand Down Expand Up @@ -530,6 +531,57 @@ def add_shoulder_control_bones():
else:
print("Rename bones to MMD_English and then try again.")


def merge_double_jointed_knee(armature):


if model.is_mmd_english() == True:

bpy.ops.object.mode_set(mode='POSE')

#get the bones
knee_L = bpy.context.active_object.pose.bones['knee_L']
knee_R = bpy.context.active_object.pose.bones['knee_R']
j_asi_c_l = bpy.context.active_object.pose.bones['j_asi_c_l']
j_asi_c_r = bpy.context.active_object.pose.bones['j_asi_c_r']

for pbone in armature.pose.bones:
pbone.bone.select = False

knee_L.bone.select = True
j_asi_c_l.bone.select = True

bpy.context.view_layer.objects.active = model.findArmature(bpy.context.active_object)
parent_bone_name, child_bone_name = miscellaneous_tools.analyze_selected_parent_child_bone_pair()
if parent_bone_name is not None:
if child_bone_name is not None:
miscellaneous_tools.combine_2_vg_1_vg(parent_bone_name, child_bone_name)
miscellaneous_tools.combine_2_bones_1_bone(parent_bone_name, child_bone_name)

bpy.ops.object.mode_set(mode='POSE')

for pbone in armature.pose.bones:
pbone.bone.select = False

knee_R.bone.select = True
j_asi_c_r.bone.select = True

bpy.context.view_layer.objects.active = model.findArmature(bpy.context.active_object)
parent_bone_name, child_bone_name = miscellaneous_tools.analyze_selected_parent_child_bone_pair()
if parent_bone_name is not None:
if child_bone_name is not None:
miscellaneous_tools.combine_2_vg_1_vg(parent_bone_name, child_bone_name)
miscellaneous_tools.combine_2_bones_1_bone(parent_bone_name, child_bone_name)





else:
print("Rename bones to MMD_English and then try again.")



def get_csv_metadata_by_bone_type(metadata_column, bone_types):

csv_data = import_csv.use_csv_bone_metadata_ffxiv_dictionary()
Expand Down Expand Up @@ -852,6 +904,10 @@ def main(context):
bpy.context.view_layer.objects.active = model.findArmature(bpy.context.active_object)
armature = bpy.context.view_layer.objects.active
add_breast_tip_bones(armature)
if selected_bone_tool == "merge_double_jointed_knee":
bpy.context.view_layer.objects.active = model.findArmature(bpy.context.active_object)
armature = bpy.context.view_layer.objects.active
merge_double_jointed_knee(armature)

@register_wrap
class BoneTools(bpy.types.Operator):
Expand All @@ -873,6 +929,7 @@ class BoneTools(bpy.types.Operator):
, ("add_shoulder_control_bones", "Add Shoulder Control Bones", "Add Shoulder Control Bones")\
, ("add_extra_finger_bones", "Add Extra Finger Bones", "Add Extra Finger Bones")\
, ("add_breast_tip_bones", "Add Extra Breast Tip Bones", "Add Extra Breast Tip Bones")\
, ("merge_double_jointed_knee", "Merge Double-Jointed Knee (FFXIV PMX Export Only)", "Merge Double-Jointed Knee (FFXIV PMX Export Only)")\
], name = "", default = 'none')

@classmethod
Expand Down

0 comments on commit 60ebb43

Please sign in to comment.