auto_walk/panels.py

79 lines
2.7 KiB
Python

import bpy
from . import fn
class UAC_PT_walk_cycle_anim_panel(bpy.types.Panel):
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "Anim"
bl_label = "Walk Cycle anim"
def draw(self, context):
layout = self.layout
if not context.scene.anim_cycle_settings.path_to_follow:
layout.operator('anim.create_curve_path', text='Create Curve at Root Position', icon='CURVE_BEZCURVE')
#-# path and ground objects
layout.prop_search(context.scene.anim_cycle_settings, "path_to_follow", context.scene, "objects")
layout.prop_search(context.scene.anim_cycle_settings, "gnd", context.scene, "objects")
prefs = fn.get_addon_prefs()
ob = context.object
# Determine if already has a constraint (a bit too much condition in a panel...)
constrained = False
if ob and ob.type == 'ARMATURE':
pb = ob.pose.bones.get(prefs.tgt_bone)
if pb:
follow = pb.constraints.get('Follow Path')
if follow and follow.target:
layout.label(text=f'{pb.name} -> {follow.target.name}', icon='CON_FOLLOWPATH')
constrained = True
if not constrained:
## Créer automatiquement le follow path TODO et l'anim de base
layout.operator('anim.create_follow_path', text='Add follow path constraint', icon='CON_FOLLOWPATH')
layout.operator('anim.snap_curve_to_ground', text='Snap curve to ground', icon='SNAP_ON')
row=layout.row()
row.operator('anim.animate_path', text='Animate Path (select foot)', icon='ANIM')
row.prop(context.scene.anim_cycle_settings, "start_frame", text='start')
row=layout.row()
row.operator('anim.adjust_animation_length', icon='MOD_TIME')
## Bake cycle (on selected)
row=layout.row()
row.operator('anim.bake_cycle_and_step', text='Bake key and step path', icon='SHAPEKEY_DATA')
row.prop(context.scene.anim_cycle_settings, "expand_on_selected_bones")
# Pin feet
layout.operator('anim.pin_feets', text='Pin feets', icon='PINNED')
class UAC_PT_anim_tools_panel(bpy.types.Panel):
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "Anim"
bl_label = "Unicorn Tools"
def draw(self, context):
layout = self.layout
layout.operator('anim.contact_to_ground', text='Ground selected feet', icon='SNAP_OFF')
classes=(
UAC_PT_walk_cycle_anim_panel,
UAC_PT_anim_tools_panel,
)
def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)