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"
|
2022-03-29 18:46:33 +02:00
|
|
|
bl_label = "Walk Cycle Anim"
|
2021-04-05 01:35:12 +02:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2022-03-29 18:46:33 +02:00
|
|
|
settings = context.scene.anim_cycle_settings
|
|
|
|
# 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')
|
2022-03-31 17:07:04 +02:00
|
|
|
|
|
|
|
box = layout.box()
|
|
|
|
if not settings.path_to_follow:
|
|
|
|
box.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
|
2022-03-31 17:07:04 +02:00
|
|
|
box.prop_search(settings, "path_to_follow", context.scene, "objects")
|
|
|
|
box.prop_search(settings, "gnd", context.scene, "objects")
|
2021-04-05 01:35:12 +02:00
|
|
|
|
2022-03-31 17:07:04 +02:00
|
|
|
row = box.row()
|
|
|
|
row.operator('anim.snap_curve_to_ground', text='Snap curve to ground', icon='SNAP_ON')
|
|
|
|
row.active = bool(settings.gnd)
|
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:
|
2022-03-31 17:07:04 +02:00
|
|
|
box.label(text=f'{pb.name} -> {follow.target.name}', icon='CON_FOLLOWPATH')
|
2021-04-06 18:30:25 +02:00
|
|
|
constrained = True
|
2022-03-29 18:46:33 +02:00
|
|
|
## Put this in a setting popup or submenu
|
2021-04-06 18:30:25 +02:00
|
|
|
|
|
|
|
if not constrained:
|
|
|
|
## Créer automatiquement le follow path TODO et l'anim de base
|
2022-03-31 17:07:04 +02:00
|
|
|
box.operator('anim.create_follow_path', text='Add follow path constraint', icon='CON_FOLLOWPATH')
|
2021-04-06 18:30:25 +02:00
|
|
|
|
|
|
|
|
2021-04-05 01:35:12 +02:00
|
|
|
|
2022-03-29 18:46:33 +02:00
|
|
|
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')
|
|
|
|
|
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()
|
2022-03-29 18:46:33 +02:00
|
|
|
row.prop(settings, "linear", text='Linear')
|
|
|
|
row.prop(settings, "expand_on_selected_bones")
|
2022-03-31 17:07:04 +02:00
|
|
|
|
|
|
|
txt = 'Bake keys' if settings.linear else 'Bake keys and step path'
|
|
|
|
layout.operator('anim.bake_cycle_and_step', text=txt, 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)
|