more fixes
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
bl_info = {
|
||||
"name": "Mabulig Rigger Plugin",
|
||||
"author": "Fritz Villahermosa",
|
||||
"version": (1, 0),
|
||||
"version": (1, 1),
|
||||
"blender": (5, 2, 0),
|
||||
"location": "View3D > Sidebar > Mabulig Rigger",
|
||||
"description": "Frog rigging made simple!",
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,27 @@
|
||||
# Position of Ctrl bone when Armature Adjust
|
||||
bones_ik_data = [
|
||||
{
|
||||
"bone_name": "ctrl_ik_arm_target_l",
|
||||
"pos_helper": "elbow_l"
|
||||
},
|
||||
{
|
||||
"bone_name": "ctrl_ik_arm_target_r",
|
||||
"pos_helper": "elbow_r"
|
||||
},
|
||||
{
|
||||
"bone_name": "ctrl_ik_hand_l",
|
||||
"pos_helper": "wrist_l"
|
||||
},
|
||||
{
|
||||
"bone_name": "ctrl_ik_hand_r",
|
||||
"pos_helper": "wrist_r"
|
||||
},
|
||||
{
|
||||
"bone_name": "ctrl_ik_foot_l",
|
||||
"pos_helper": "heel_l"
|
||||
},
|
||||
{
|
||||
"bone_name": "ctrl_ik_foot_r",
|
||||
"pos_helper": "heel_r"
|
||||
}
|
||||
]
|
||||
@@ -148,5 +148,25 @@ bones_data = [
|
||||
"bone_name": "feet_r",
|
||||
"head_helper": "heel_r",
|
||||
"tail_helper": "foot_r"
|
||||
},
|
||||
{
|
||||
"bone_name": "mouth_01_l",
|
||||
"head_helper": "mouth_01_l",
|
||||
"tail_helper": "mouth_02_l"
|
||||
},
|
||||
{
|
||||
"bone_name": "mouth_02_l",
|
||||
"head_helper": "mouth_02_l",
|
||||
"tail_helper": "mouth_tip"
|
||||
},
|
||||
{
|
||||
"bone_name": "mouth_01_r",
|
||||
"head_helper": "mouth_01_r",
|
||||
"tail_helper": "mouth_02_r"
|
||||
},
|
||||
{
|
||||
"bone_name": "mouth_02_r",
|
||||
"head_helper": "mouth_02_r",
|
||||
"tail_helper": "mouth_tip"
|
||||
}
|
||||
]
|
||||
@@ -5,6 +5,7 @@ from . import ctrl_bones_shape_struct
|
||||
from . import ctrl_bones_color_struct
|
||||
from . import ik_bones_struct
|
||||
from . import deform_bones_struct
|
||||
from . import ctrl_ik_struct
|
||||
|
||||
|
||||
# Modify Control Bone Shape Function
|
||||
@@ -41,6 +42,9 @@ def addIK(bone_name, ik_target, ik_pole_target, ik_chain, armature):
|
||||
pose_bone = armature.pose.bones.get(bone_name)
|
||||
|
||||
if pose_bone:
|
||||
for constraint in list(pose_bone.constraints):
|
||||
pose_bone.constraints.remove(constraint)
|
||||
|
||||
ik_constraint = pose_bone.constraints.new(type='IK')
|
||||
ik_constraint.target = armature
|
||||
ik_constraint.subtarget = ik_target
|
||||
@@ -58,11 +62,30 @@ def addCopyScale(bone_name, parent_bone, parent_influence, armature):
|
||||
pose_bone = armature.pose.bones.get(bone_name)
|
||||
|
||||
if pose_bone:
|
||||
for constraint in list(pose_bone.constraints):
|
||||
pose_bone.constraints.remove(constraint)
|
||||
|
||||
constraint = pose_bone.constraints.new(type='COPY_SCALE')
|
||||
constraint.target = armature
|
||||
constraint.subtarget = parent_bone
|
||||
constraint.power = parent_influence
|
||||
print(f"Successfully added Copy Scale constraint to {bone_name}")
|
||||
constraint.influence = parent_influence
|
||||
# print(f"Successfully added Copy Scale constraint to {bone_name}")
|
||||
|
||||
|
||||
# Add IK Controller Function
|
||||
def addIKcontroller(bone_name, ctrl_empt, armature):
|
||||
pose_bone = armature.pose.bones.get(bone_name)
|
||||
|
||||
if pose_bone:
|
||||
for constraint in list(pose_bone.constraints):
|
||||
pose_bone.constraints.remove(constraint)
|
||||
|
||||
ik_ctrl_constraint = pose_bone.constraints.new(type='CHILD_OF')
|
||||
ik_ctrl_constraint.target = armature
|
||||
ik_ctrl_constraint.subtarget = ctrl_empt
|
||||
print(f"Successfully added ChildOf constraint to {bone_name}")
|
||||
# # Calculate and apply the inverse matrix so the object doesn't jump position
|
||||
# ik_ctrl_constraint.inverse_matrix = ctrl_empt.matrix_world.inverted()
|
||||
|
||||
|
||||
|
||||
@@ -89,7 +112,7 @@ def generatecontrolrig():
|
||||
shape_color = item["color"]
|
||||
shape_width = float(item["width"])
|
||||
|
||||
print(f"Modifying Bone Shape for: {b_name}")
|
||||
# print(f"Modifying Bone Shape for: {b_name}")
|
||||
modifyctrlbone(b_name, rotation_x, rotation_y, rotation_z, shape_scale, shape_obj, shape_width, shape_color, new_amt_obj) # Call Modify Control Bone Shape Function
|
||||
|
||||
|
||||
@@ -100,9 +123,19 @@ def generatecontrolrig():
|
||||
b_name = item["bone_name"]
|
||||
shape_color = item["color"]
|
||||
|
||||
print(f"Modifying Bone Color for: {b_name}")
|
||||
# print(f"Modifying Bone Color for: {b_name}")
|
||||
modifyctrlbonecolor(b_name, shape_color, new_amt_obj) # Call Modify Bone Function
|
||||
|
||||
# =========== Setup IK Controls ===========
|
||||
|
||||
IK_controls = ctrl_ik_struct.ctrl_ik_data
|
||||
|
||||
for item in IK_controls:
|
||||
b_name = item["bone_name"]
|
||||
ctrl_name = item["ctrl_controller"]
|
||||
|
||||
print(f"Adding Child constraint for bone: {b_name}")
|
||||
addIKcontroller(b_name, ctrl_name, new_amt_obj) # Call Add IK Controller Function
|
||||
|
||||
# =========== Setup IK Bones ===========
|
||||
IK_bones = ik_bones_struct.IK_bones_data
|
||||
@@ -114,7 +147,7 @@ def generatecontrolrig():
|
||||
ik_chain = int(item["chain"])
|
||||
|
||||
|
||||
print(f"Adding IK constraint for bone: {b_name}")
|
||||
# print(f"Adding IK constraint for bone: {b_name}")
|
||||
addIK(b_name, ik_target, ik_pole_target, ik_chain, new_amt_obj) # Call Add IK Function
|
||||
|
||||
|
||||
@@ -127,7 +160,7 @@ def generatecontrolrig():
|
||||
parent_influence = float(item["influence"])
|
||||
|
||||
|
||||
print(f"Adding copy scale constraint for bone: {b_name}")
|
||||
# print(f"Adding copy scale constraint for bone: {b_name}")
|
||||
addCopyScale(b_name, parent_bone, parent_influence, new_amt_obj) # Call Copy Scale constraints Function
|
||||
|
||||
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
bone_shape_data = [
|
||||
{
|
||||
"bone_name": "hand_l",
|
||||
"rot_X": "20",
|
||||
"rot_Y": "0",
|
||||
"rot_Z": "4",
|
||||
"bone_name": "ctrl_ik_hand_l",
|
||||
"rot_X": "0",
|
||||
"rot_Y": "90",
|
||||
"rot_Z": "0",
|
||||
"scale": "0.750",
|
||||
"shape": "rig_shape_circle",
|
||||
"color": "THEME09",
|
||||
"width": "3"
|
||||
},
|
||||
{
|
||||
"bone_name": "hand_r",
|
||||
"rot_X": "20",
|
||||
"rot_Y": "0",
|
||||
"rot_Z": "-4",
|
||||
"bone_name": "ctrl_ik_hand_r",
|
||||
"rot_X": "0",
|
||||
"rot_Y": "90",
|
||||
"rot_Z": "0",
|
||||
"scale": "0.750",
|
||||
"shape": "rig_shape_circle",
|
||||
"color": "THEME09",
|
||||
"width": "3"
|
||||
},
|
||||
{
|
||||
"bone_name": "feet_l",
|
||||
"rot_X": "12",
|
||||
"rot_Y": "0",
|
||||
"rot_Z": "-5",
|
||||
"bone_name": "ctrl_ik_foot_l",
|
||||
"rot_X": "0",
|
||||
"rot_Y": "90",
|
||||
"rot_Z": "0",
|
||||
"scale": "1.0",
|
||||
"shape": "rig_shape_circle",
|
||||
"color": "THEME09",
|
||||
"width": "3"
|
||||
},
|
||||
{
|
||||
"bone_name": "feet_r",
|
||||
"rot_X": "12",
|
||||
"rot_Y": "0",
|
||||
"rot_Z": "5",
|
||||
"bone_name": "ctrl_ik_foot_r",
|
||||
"rot_X": "0",
|
||||
"rot_Y": "90",
|
||||
"rot_Z": "0",
|
||||
"scale": "1.0",
|
||||
"shape": "rig_shape_circle",
|
||||
"color": "THEME09",
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# Positioning of Ctrl Bones for Hand and Foot
|
||||
ctrl_ik_data = [
|
||||
{
|
||||
"bone_name": "hand_l",
|
||||
"ctrl_controller": "ctrl_ik_hand_l"
|
||||
},
|
||||
{
|
||||
"bone_name": "hand_r",
|
||||
"ctrl_controller": "ctrl_ik_hand_r"
|
||||
},
|
||||
{
|
||||
"bone_name": "feet_l",
|
||||
"ctrl_controller": "ctrl_ik_foot_l"
|
||||
},
|
||||
{
|
||||
"bone_name": "feet_r",
|
||||
"ctrl_controller": "ctrl_ik_foot_r"
|
||||
}
|
||||
]
|
||||
@@ -1,25 +1,26 @@
|
||||
#Apply IK constraints
|
||||
IK_bones_data = [
|
||||
{
|
||||
"bone_name": "lowerarm_l",
|
||||
"target": "hand_l",
|
||||
"target": "ctrl_ik_hand_l",
|
||||
"pole_target": "ctrl_ik_arm_target_l",
|
||||
"chain": "2"
|
||||
},
|
||||
{
|
||||
"bone_name": "lowerarm_r",
|
||||
"target": "hand_r",
|
||||
"target": "ctrl_ik_hand_r",
|
||||
"pole_target": "ctrl_ik_arm_target_r",
|
||||
"chain": "2"
|
||||
},
|
||||
{
|
||||
"bone_name": "tarsus_l",
|
||||
"target": "feet_l",
|
||||
"target": "ctrl_ik_foot_l",
|
||||
"pole_target": "none",
|
||||
"chain": "5"
|
||||
},
|
||||
{
|
||||
"bone_name": "tarsus_r",
|
||||
"target": "feet_r",
|
||||
"target": "ctrl_ik_foot_r",
|
||||
"pole_target": "none",
|
||||
"chain": "5"
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -5,6 +5,7 @@ from . import bones_skel_struct
|
||||
from . import bones_fingers_struct
|
||||
from . import bones_toes_struct
|
||||
from . import bones_web_struct
|
||||
from . import bones_ik_struct
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +21,7 @@ def modifybone(bone, head_empt, tail_empt, armature, matrixworldinv):
|
||||
allowtail = False
|
||||
alloweditbone = False
|
||||
|
||||
print(f"modifying bone: {edit_bone}")
|
||||
# print(f"modifying bone: {edit_bone}")
|
||||
|
||||
# Fetch world coordinates of the empties
|
||||
if empty_head:
|
||||
@@ -50,7 +51,23 @@ def fixbonestretching(bone, armature):
|
||||
if constaint.type == 'STRETCH_TO':
|
||||
constaint.rest_length = 0.0
|
||||
|
||||
|
||||
|
||||
# Setup IK Bones
|
||||
def setupIKbones(bone, helper_name, armature, matrixworldinv):
|
||||
bpy.context.view_layer.objects.active = armature
|
||||
bpy.ops.object.mode_set(mode='EDIT')
|
||||
|
||||
edit_bone = armature.data.edit_bones.get(bone)
|
||||
helper_empt = bpy.data.objects.get(helper_name)
|
||||
|
||||
if edit_bone:
|
||||
target_length = 0.025
|
||||
direction = (edit_bone.tail - edit_bone.head).normalized()
|
||||
|
||||
empty_pos = helper_empt.matrix_world.translation
|
||||
edit_bone.head = matrixworldinv @ empty_pos
|
||||
edit_bone.tail = edit_bone.head + direction * target_length
|
||||
|
||||
|
||||
|
||||
def startAutoRig():
|
||||
@@ -256,6 +273,17 @@ def startAutoRig():
|
||||
|
||||
|
||||
|
||||
# =========== IK Bones ===========
|
||||
|
||||
bones_ik_data_list = bones_ik_struct.bones_ik_data
|
||||
|
||||
for item in bones_ik_data_list:
|
||||
b_name = item["bone_name"]
|
||||
pos_helper = item["pos_helper"]
|
||||
|
||||
setupIKbones(b_name, pos_helper, new_amt_obj, matrix_world_inv) # Call Setup IK Bone Function
|
||||
|
||||
|
||||
|
||||
# Returns 'helpers' collection to restore hide state prior to bone modification
|
||||
if ishelperscollhidden:
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user