2021-04-05 01:35:12 +02:00
|
|
|
import bpy
|
2021-04-06 18:30:25 +02:00
|
|
|
from . import fn
|
2021-04-05 01:35:12 +02:00
|
|
|
|
2021-04-05 01:39:27 +02:00
|
|
|
class UAC_PT_walk_cycle_anim_panel(bpy.types.Panel):
|
2021-04-05 01:35:12 +02:00
|
|
|
bl_space_type = "VIEW_3D"
|
|
|
|
bl_region_type = "UI"
|
|
|
|
bl_category = "Anim"
|
|
|
|
bl_label = "Walk Cycle anim"
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2021-04-06 18:30:25 +02:00
|
|
|
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')
|
2021-04-05 01:35:12 +02:00
|
|
|
#-# 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")
|
|
|
|
|
2021-04-06 18:30:25 +02:00
|
|
|
|
|
|
|
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')
|
2021-04-05 01:35:12 +02:00
|
|
|
|
|
|
|
|
2021-04-08 19:25:05 +02:00
|
|
|
# row=layout.row()
|
|
|
|
layout.prop(context.scene.anim_cycle_settings, "start_frame", text='Start')
|
|
|
|
layout.operator('anim.animate_path', text='Animate Path (select foot)', icon='ANIM')
|
2021-04-05 01:35:12 +02:00
|
|
|
|
2021-04-06 18:30:25 +02:00
|
|
|
row=layout.row()
|
|
|
|
row.operator('anim.adjust_animation_length', icon='MOD_TIME')
|
2021-04-05 01:35:12 +02:00
|
|
|
|
2021-04-06 18:30:25 +02:00
|
|
|
## Bake cycle (on selected)
|
|
|
|
row=layout.row()
|
2021-04-08 19:25:05 +02:00
|
|
|
row.prop(context.scene.anim_cycle_settings, "linear", text='Linear')
|
2021-04-06 18:30:25 +02:00
|
|
|
row.prop(context.scene.anim_cycle_settings, "expand_on_selected_bones")
|
2021-04-08 19:25:05 +02:00
|
|
|
layout.operator('anim.bake_cycle_and_step', text='Bake key and step path', icon='SHAPEKEY_DATA')
|
2021-04-05 01:35:12 +02:00
|
|
|
|
|
|
|
# Pin feet
|
2021-04-06 18:30:25 +02:00
|
|
|
layout.operator('anim.pin_feets', text='Pin feets', icon='PINNED')
|
|
|
|
|
|
|
|
|
2021-04-05 01:35:12 +02:00
|
|
|
|
2021-04-06 18:30:25 +02:00
|
|
|
class UAC_PT_anim_tools_panel(bpy.types.Panel):
|
|
|
|
bl_space_type = "VIEW_3D"
|
|
|
|
bl_region_type = "UI"
|
|
|
|
bl_category = "Anim"
|
2021-04-08 19:25:05 +02:00
|
|
|
bl_label = "Tools"
|
2021-04-06 18:30:25 +02:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
layout.operator('anim.contact_to_ground', text='Ground selected feet', icon='SNAP_OFF')
|
2021-04-08 19:25:05 +02:00
|
|
|
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
|
|
|
|
|
2021-04-05 01:35:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
classes=(
|
2021-04-05 01:39:27 +02:00
|
|
|
UAC_PT_walk_cycle_anim_panel,
|
2021-04-06 18:30:25 +02:00
|
|
|
UAC_PT_anim_tools_panel,
|
2021-04-05 01:35:12 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
def register():
|
|
|
|
for cls in classes:
|
|
|
|
bpy.utils.register_class(cls)
|
|
|
|
|
|
|
|
def unregister():
|
|
|
|
for cls in reversed(classes):
|
|
|
|
bpy.utils.unregister_class(cls)
|