"""Render a walking loop from the editable Blender source, for art review."""
import bpy
from pathlib import Path

root = Path(__file__).resolve().parents[2]
source = root / 'tools/character-art/source'
frames = root / '_backups/intro-cook-review/walk-frames'
frames.mkdir(parents=True, exist_ok=True)
bpy.ops.wm.open_mainfile(filepath=str(source / 'intro_cook.blend'))
rig = bpy.data.objects['IntroCookRig']
action = bpy.data.actions['Walking']
rig.animation_data.action = action
rig.animation_data.action_slot = action.slots[0]
scene = bpy.context.scene
scene.render.resolution_x = 504
scene.render.resolution_y = 560
scene.cycles.samples = 12
for index in range(13):
    scene.frame_set(index * 2)
    scene.render.filepath = str(frames / f'{index:02d}.png')
    bpy.ops.render.render(write_still=True)
print('INTRO_COOK_WALK_PREVIEW', frames)
