auto_walk/panels.py

96 lines
3.5 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
settings = context.scene.anim_cycle_settings
if not settings.path_to_follow:
layout.operator('anim.create_curve_path', text='Create Curve at Root Position', icon='CURVE_BEZCURVE')
# need to know root orientation forward)
## know direction to evaluate feet moves
## Define Constraint axis (depend on root orientation)
layout.prop(settings, "forward_axis")
layout.operator("uac.autoset_axis", text='Auto-Set Axis')
#-# path and ground objects
layout.prop_search(settings, "path_to_follow", context.scene, "objects")
layout.prop_search(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
## Put this in a setting popup or submenu
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')
col=layout.column()
col.prop(settings, "start_frame", text='Start')
# col.prop(settings, "foot_axis", text='Foot Axis')
col.operator('anim.animate_path', text='Animate Path (select foot)', icon='ANIM')
row=layout.row()
row.operator('anim.adjust_animation_length', icon='MOD_TIME')
## Bake cycle (on selected)
row=layout.row()
row.prop(settings, "linear", text='Linear')
row.prop(settings, "expand_on_selected_bones")
layout.operator('anim.bake_cycle_and_step', text='Bake key and step path', icon='SHAPEKEY_DATA')
# 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 = "Tools"
def draw(self, context):
layout = self.layout
layout.operator('anim.contact_to_ground', text='Ground selected feet', icon='SNAP_OFF')
row = layout.row()
row.operator('anim.world_space_copy', text='Copy Pose', icon='COPYDOWN')
row.operator('anim.world_space_paste', text='Paste', icon='PASTEDOWN')
row = layout.row()
row.operator('anim.world_space_paste_next', text='Paste Prev', icon='PASTEDOWN').prev = True
row.operator('anim.world_space_paste_next', text='Paste Next', icon='PASTEDOWN').prev = False
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)