Código:
bl_info = {
"name": "Falda Rig",
"author": "Ignacio Noreña",
"version": (0, 0, 1),
"blender": (4, 0, 0),
"location": "3D Viewport > Sidebar > FALDA RIG",
"description": "Custom Cloth IK/FK Rig",
"category": "Testing",
}
import bpy
# Propiedades del Panel
ARMATURE_NAME = "FAUST"
PANEL_NAME = "FALDA RIG"
# Panel para colecciones
class RIG_PT_Collections_Panel(bpy.types.Panel):
bl_label = "Bone Collections"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = PANEL_NAME
def draw(self, context):
ARMATURE = bpy.data.objects[ARMATURE_NAME]
collections = ARMATURE.data.collections
layout = self.layout
layout.prop(collections["Falda"], 'is_visible', toggle=True, text='FALDA')
layout.prop(collections["Falda.F (IK)"], 'is_visible', toggle=True, text='FALDA.F (IK)')
layout.prop(collections["Falda.B (IK)"], 'is_visible', toggle=True, text='FALDA.B (IK)')
layout.prop(collections["Falda.F (FK)"], 'is_visible', toggle=True, text='FALDA.F (FK)')
layout.prop(collections["Falda.B (FK)"], 'is_visible', toggle=True, text='FALDA.B (FK)')
layout.prop(collections["Paper.L (IK)"], 'is_visible', toggle=True, text='Paper.L (IK)')
layout.prop(collections["Paper.R (IK)"], 'is_visible', toggle=True, text='Paper.R (IK)')
layout.prop(collections["Paper.L (FK)"], 'is_visible', toggle=True, text='Paper.L (FK)')
layout.prop(collections["Paper.R (FK)"], 'is_visible', toggle=True, text='Paper.R (FK)')
# Panel para el switch de IK/FK
class RIG_PT_IKFK_Panel(bpy.types.Panel):
bl_label = "IK/FK SWITCH"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = PANEL_NAME
def draw(self, context):
ARMATURE = bpy.data.objects[ARMATURE_NAME]
root = ARMATURE.pose.bones["root"]
layout = self.layout
layout.prop(root, '["Falda_IK_Influence"]', text="IK_Influence", slider=True)
# Operador para el Snap IK to FK
class RIG_OT_IK_to_FK(bpy.types.Operator):
bl_idname = "rig.ik_to_fk"
bl_label = "IK to FK Snap"
bl_description = "Snapea los huesos IK a FK"
def execute(self, context):
ARMATURE = bpy.data.objects[ARMATURE_NAME]
# Define los huesos IK y FK
IK_bones = [
'FFR_IK_007', 'FC_IK_007', 'FFL_IK_007', 'FBL_IK_007',
'FBR_IK_007', 'FBC_IK_007', 'PaperL_IK_005', 'PaperR_IK_005'
]
FK_bones = [
'FFR_FK_007', 'FC_FK_007', 'FFL_FK_007', 'FBL_FK_007',
'FBR_FK_007', 'FBC_FK_007', 'PaperL_FK_005', 'PaperR_FK_005'
]
# Asigna la matriz de cada hueso IK al correspondiente FK
for ik_bone, fk_bone in zip(IK_bones, FK_bones):
ARMATURE.pose.bones[ik_bone].matrix = ARMATURE.pose.bones[fk_bone].matrix
return {'FINISHED'}
# Panel para el snap de IK/FK
class RIG_PT_Snaping_Panel(bpy.types.Panel):
bl_label = "IK/FK SNAPPING"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = PANEL_NAME
def draw(self, context):
layout = self.layout
layout.operator("rig.ik_to_fk", text="IK SNAP")
# Registro y desregistro de clases
def register():
bpy.utils.register_class(RIG_PT_Collections_Panel)
bpy.utils.register_class(RIG_PT_IKFK_Panel)
bpy.utils.register_class(RIG_PT_Snaping_Panel)
bpy.utils.register_class(RIG_OT_IK_to_FK)
def unregister():
bpy.utils.unregister_class(RIG_PT_Collections_Panel)
bpy.utils.unregister_class(RIG_PT_IKFK_Panel)
bpy.utils.unregister_class(RIG_PT_Snaping_Panel)
bpy.utils.unregister_class(RIG_OT_IK_to_FK)
if __name__ == "__main__":
register()