Showing posts with label walk cycle. Show all posts
Showing posts with label walk cycle. Show all posts

Thursday, 14 July 2011

Slow Dog Walk - Animation Reference

I was struggling with a dog walk in my short so I thought it best to try to find some live action reference and rotoscope it.  When a dog walks slower its feet spend much more time on the ground than in the air, so the contact pose is not the same as the lift off pose as it might be in say a fast 9-frame stride cycle where both front feet might only be on the ground together for just one frame.

On a 15-frames/stride cycle it seems that both front feet are on the ground together for 3-5 frames, and both back feet are on the ground together for 5-7 frames.  In this way the feet spend roughly the same amount of time in the air if the dog is walking fast or slow (around 5-7 frames in the air).  When a walk slows up, the dog takes smaller steps and spends more time with its feet on the ground.  Hence...


F per stride F on the ground  F in the air  F both feet on the ground 
9 ~4-5 ~4-5 ~1
12 ~6-8 ~5 ~2 (front) ~3 (back)
15 ~8-10 ~5-7 3-5 (front) 5-7 (back)

If you leave the feet hanging round in the air too long the walk starts to look stiff, like the dog is stuffed and artificially held in pose.  Remember the dog 'weighs' something and it needs to drop that leg to support itself on.

Here's some rotoscoping I did on a 15 frames/stride cycle.  I then adapted the the walk to a 17 frames/stride cycle which divides up much easier for 2D animators who don't have the computer to in-between on 5ths and 3rds.




Wednesday, 5 January 2011

Progress on the auto-walker



I spent most of yesterday just hitting dead ends.  My code became far too complex and it was almost impossible to find bugs.  I went for a full re-factor of the walking algorithm and now I'm getting much smoother motion.  It takes a few frames of pre-roll to get the legs in order - notice some jittering in the first second or so as legs are hurriedly placed to stabilise the bug.  By stabilisation I mean that if all the legs on one side of the bug (or in any given 'leg group' set by the user) become lifted then the algorithm will hurriedly place the leg which has been airborne the longest to keep the bug upright.  Still no body motion, but I've made a preliminary start on leg sequencing.

Wednesday, 1 December 2010

Python for Exaggerating and De-intensifying Poses

Sometimes my poses are just too strong and the animation ends up being very exaggerated and hard to follow, and sometimes they're too weak and need amplifying.  Joshua Leung's new push and relax features for pose bones in blender do a great job of handling in betweens and making them more or less similar to the neighbouring keys.  Often I find that before I even get to the inbetweening phase of animation I want to edit my key poses in a similar manner.  Especially with the spine and neck I want to be able to relax the bone's locations and rotations towards the rest pose (the same way I would smooth vertices when I'm modelling).  Here are two more python scripts I threw together this morning while working on another walk cycle...

Smooth Pose


import bpy,mathutils


amount=0.05


a=mathutils.Quaternion((1,0,0,0))
for each_bone in bpy.context.selected_pose_bones:
    each_bone.location=each_bone.location*(1-amount)
    if each_bone.rotation_mode=='QUATERNION':
        each_bone.rotation_quaternion=each_bone.rotation_quaternion*(1-amount)+(amount*a)
    elif each_bone.rotation_mode!='AXIS_ANGLE':
        each_bone.rotation_euler[0]=each_bone.rotation_euler[0]*(1-amount)
        each_bone.rotation_euler[1]=each_bone.rotation_euler[1]*(1-amount)
        each_bone.rotation_euler[2]=each_bone.rotation_euler[2]*(1-amount)

Exaggerate Pose


import bpy,mathutils


amount=0.05


a=mathutils.Quaternion((1,0,0,0))
for each_bone in bpy.context.selected_pose_bones:
    each_bone.location=each_bone.location*(1+amount)
    if each_bone.rotation_mode=='QUATERNION':
        each_bone.rotation_quaternion=each_bone.rotation_quaternion*(1-amount)-(amount*a)
    elif each_bone.rotation_mode!='AXIS_ANGLE':
        each_bone.rotation_euler[0]=each_bone.rotation_euler[0]*(1+amount)
        each_bone.rotation_euler[1]=each_bone.rotation_euler[1]*(1+amount)
        each_bone.rotation_euler[2]=each_bone.rotation_euler[2]*(1+amount)

At the moment the scripts only support quaternions and eulers as that's all I use in my rigs.  If you're an axis angle person please enlighten me as to what on earth its for!  Here's the walk cycle (crits welcome):



On another note I started hacking away at blender's source code last night trying to code smoother deforms for b-bones, which in my opinion look great until you turn on mesh display when it somehow manages to fold up the mesh in all sorts of nasty ways if you're using it for something wide (like a torso) rather than something skinny (like an arm).  While I haven't made much useful progress yet (other than beginning to understand the built in math libraries) I did stumble upon this very nice explanation of matrices, vectors and coordinate systems which I wish I'd found ages ago when I started diving into python in blender.

Tuesday, 30 November 2010

Quick Walk Cycle and Python to Mirror a Cycle



I started out aiming for John Travolta's Saturday Night Fever walk to staying alive but I quickly ended up with far too many keys and too snappy and exaggerated an action for a cycle.  I realised I needed to change the rig a bit to get the movements I needed so I stripped it right down and worked up this basic walk cycle just to test the changes work.

I also wanted to work with only half a cycle and be able to have a script mirror it for me.  I coded this quick python timesaver.  Basically just select all the bones you have animation on and enter the start and end frames into the script.  Eg. You have a stride on frames 1 to 21 and you want the mirrored stride to be placed on frames 21-41 so you enter start_frame=1 end_frame=21.  Be warned the script will purge any modifiers you have on fcurves (its lazy at the moment) and replace them with a simple cycle modifier so your pair of strides (on 1-41 in the example) continue looping forever.

import bpy

start_frame=1
end_frame=21


def set_frame(sf):
    bpy.context.scene.frame_set(frame=sf)
    bpy.context.active_object.update(scene=bpy.context.scene)
    bpy.context.scene.update()


for each_fcurve in bpy.context.active_object.animation_data.action.fcurves:
    for each_modifier in each_fcurve.modifiers:
        each_fcurve.modifiers.remove(each_modifier)

each_frame=start_frame
while each_frame<=end_frame:
    set_frame(sf=each_frame)
    bpy.ops.pose.copy()
    set_frame(sf=each_frame+(end_frame-start_frame))
    bpy.ops.pose.paste(flipped=True)
    print('copying '+str(each_frame)+' to '+str(bpy.context.scene.frame_current))
    bpy.ops.anim.keyframe_insert_menu(type=-4, confirm_success=False, always_prompt=False)
    if each_frame==end_frame:
        break
    set_frame(sf=each_frame)
    bpy.ops.screen.keyframe_jump(next=True)
    each_frame=bpy.context.scene.frame_current

#kill fcurve mods and add a cycle mod
for each_fcurve in bpy.context.active_object.animation_data.action.fcurves:
    each_fcurve.modifiers.new(type='CYCLES')