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')
Labels:
blender,
mirror cycle,
python,
rigging,
walk cycle
Saturday, 27 November 2010
Au Soleil at the London Underground Film Festival (LUFF)
I'm really happy to have heard from the London Underground Film Festival that my short 'Au Soleil' will be screening at the Horse Hospital next Saturday the 4th December, as part of their programme Around the Compass Rose: Human Geographies on Film. 'Au Soleil' was nominated for the technical achievement award at CAM*ERA earlier in the year. It seems like ages since I finished work on this film, and though with hindsight some of the technical work isn't as strong as I would have liked, I hope it goes some way to proving that as a medium animation has more to offer than just tired/banal overworked childrens' entertainment. Tickets available here £5 or £3 concessions, showing with 'Wild West', 'Faith Hope and Greenland', and 'Those Who Live Off the Dead'.
In completely unrelated news, Campbell Barton did a terrific job last week of bringing blender's rigging tools slightly further out of the stone age by fixing the infamous bone roll bug (which has been in blender for nearly as long as I can remember). It seems that all of the devs have been completely oblivious to it, and no riggers have ever got round to reporting it as it was fixed just hours after I reported it! Not only that, but Campbell has also added a few more options to the menu giving a choice of which axis to align to (+Y for a leg IK chain for example). Commit notes are here for anyone interested: 1 2 3.Friday, 26 November 2010
Rigging the Sidewinder Desert Snake
The desert snake basically has a continuous sine wave running throughout its body, apart from the tail and the head which are partially free - the head tends to stay fairly level but still inherits some of the rotation from the body wheras the tail flips loose. For the continuous sine wave, rather than using a wave modifier on a curve and relying on keying the speed (clumsy at best - I'd rather key the offset but then with speed set to 0 the wave disappears and further adjusting wave width during the animation isn't possible, unless you choose to scale the curve to change the wave width but then you get into more problems!) I drew a simple sine wave with a path, arrayed it many times, curve deformed it into a circle then applied the circular curve deform and set the path to be cyclic (on U). I then converted my circular wavy path to polygons and extruded it out (with shift-Z to constrain scale to X and Y only). I built a simple FK armature each of whose bones began and ended on the wavy surface, running round with a slight circular bend. Below the start and end of each bone I put an empty which was shrinkwrapped with Z project to the wavy surface. Each bone then has a track to constraint aimed at the empty nearest its tail.
I then use a second of chains of bones to convert this wavy (but curved) motion into a wave in a wave in a leaning plane (roughly the XZ plane rotated 45 degrees about Y) by copying only their local X rotation and making sure the bones in my second chain have their Z axes pointing towards the vector (0,1,1). Then a third chain of bones tracks to the tail of its double in the second chain with maintain Z up set. A fourth chain is used to add a user specified rotation in the world Z to each bone (for example a curve in the snake). This has to be done in a separate chain containing copies of the third chain's bones rotations as rotating any bone in the third chain disrupts all of its children's track to constraints!)
A final few bones are used to add non-automated animation to the head and tail. The width and height of the waves can be controlled by scaling (the parent of) the large rotating wavy disk in the world X or Z axis (there are some empties in between with maintain volume constraints to move the chain of empties which the first chain tracks to into the right position), and the rate of progress of the wave down the snake's body is controlled by rotating the wavy disk.
Now down to animating, at long last.
Labels:
blender,
constraints,
desert snake,
rigging,
shrinkwrap,
sidewinder,
snake
Wednesday, 24 November 2010
Birds and Fish
Quick Crow Flight Cycle
Might give it another go with a simpler setup when I get a moment. Its still a struggle to get the wings completely folded up. Rerigged the shark with a much simpler setup to get the simple sine wave propagating nicely, he's still a little dead for now though!
Updated - thanks to Frankie Swan for some great tips.
Monday, 22 November 2010
Bone Roll in Blender
It's well known that setting bone roll to Z-axis up in blender often doesn't work well, if at all. If you find yourself having to set bone roll manually using Ctrl+R then this script might help you out. Tab into bone edit mode, select the bones you want to roll, copy and paste the below script to a text editor, set your target roll vector as new_z_axis_vector in the script below (at the moment its set for z up) and hit run script.
import bpy,mathutils,math
new_z_axis_vector=mathutils.Vector((0,0,1))
for each_bone in bpy.context.selected_bones:
new_x_axis=each_bone.y_axis.copy().cross(new_z_axis_vector)
if new_x_axis.copy().angle(each_bone.x_axis)>90:
new_x_axis=(-1)*new_x_axis
previous_z_angle=each_bone.z_axis.angle(new_z_axis_vector)
roll_adjust=each_bone.x_axis.angle(new_x_axis)
each_bone.roll+=roll_adjust
if each_bone.x_axis.angle(new_x_axis)>0.01:
each_bone.roll-=2*roll_adjust
Of course the correct rigging practice is to make sure the bone roll of all the bones in a chain is such that the z axes vectors of all the bones are in the same plane so you might want to set new_z_axis_vector to something other than (0,0,1) or world z, for example a leg IK chain might need a value of (0,1,0) to make all the bone z-axes point forward.
import bpy,mathutils,math
new_z_axis_vector=mathutils.Vector((0,0,1))
for each_bone in bpy.context.selected_bones:
new_x_axis=each_bone.y_axis.copy().cross(new_z_axis_vector)
if new_x_axis.copy().angle(each_bone.x_axis)>90:
new_x_axis=(-1)*new_x_axis
previous_z_angle=each_bone.z_axis.angle(new_z_axis_vector)
roll_adjust=each_bone.x_axis.angle(new_x_axis)
each_bone.roll+=roll_adjust
if each_bone.x_axis.angle(new_x_axis)>0.01:
each_bone.roll-=2*roll_adjust
Of course the correct rigging practice is to make sure the bone roll of all the bones in a chain is such that the z axes vectors of all the bones are in the same plane so you might want to set new_z_axis_vector to something other than (0,0,1) or world z, for example a leg IK chain might need a value of (0,1,0) to make all the bone z-axes point forward.
Saturday, 20 November 2010
Getting Renderman Shader Editing on Windows
With renderman exporters for blender 2.5 on the horizon I thought I'd get a head start by learning the renderman shading system. Sadly on windows its not quite as easy as it should be get a shader editor going. The original Shaderman runs fine but its a little dated, and I'd previously tried getting shaderman.next to run to no avail. Instead I tried Sler which like shaderman.next is written in python. Some of the links to sler's dependencies are broken so I tried searching around the internet and installed the dependencies as listed on sler's download page. Sadly, according to this blog post on superjazz it seems that many of the recent compiles of gtk are incompatible with recent compiles of python. If you're getting lots of these errors you've probably hit the same problem I did:
ImportError: DLL load failed: The specified module could not be found.
Sler-v0.2beta
python-2.5.4
gtk-dev-2.12.9-win32
pygtk-2.12.1-3.win32-py2.5
pygobject-2.14.2-2.win32-py2.5
pycairo-1.4.12-2.win32-py2.5
aqsis-setup-1.6.0 - for preview rendering
ImportError: DLL load failed: The specified module could not be found.
To get round this you need to install an older version of python. On top of that you need GTK with glade (which for some reason doesn't always seem to be included) - if you're getting errors about a missing libglade-2.0-0.dll then you've only got plain GTK without the glade. The exact files which worked for me are:
Sler-v0.2beta
python-2.5.4
gtk-dev-2.12.9-win32
pygtk-2.12.1-3.win32-py2.5
pygobject-2.14.2-2.win32-py2.5
pycairo-1.4.12-2.win32-py2.5
aqsis-setup-1.6.0 - for preview rendering
Just unzip Sler to a clean folder then inside the bin subfolder create a new batch file with something like the following to set your path and start sler:
set PATH=C:\Program Files\GTK2-Runtime\bin;C:\Python25;C:\Program Files\GTK2-Runtime\lib;C:\Program Files\GTK2-Runtime\;C:\Program Files\Aqsis;C:\Program Files\Aqsis\bin
@set GTK2R_PREFIX=G:\Program Files\GTK2-Runtime\bin
@echo set PATH=%GTK2R_PREFIX%;%%PATH%%
@set PATH=%GTK2R_PREFIX%;%PATH%
python runsler.py
pause
Best of luck, let me know if you have any problems.
Thursday, 18 November 2010
Disco Guy - Character for the mood change walk exercise
Disco Guy: Rig and Wire
Some of the texture painting's not perfect but in the end I was pretty happy with how the rig turned out. I have IK/FK switching on arms and legs, free/fixed hip choice, stretchy IK body with volume preservation and a nice B-bone torso, as well as clavicle deformers to keep the chest shape. On the hands I have palm fan controls and finger spread/fist controls as well as individual finger curls. Not too bad for half a days rigging and weighting.
Shape keys yet to come, only the eye controls are done for the face so far. Not sure if I'll bother with custom bones as I know the rig inside out and spent a while sorting out layers. Sadly the 32-bit PC in the studio can't cope with deep shadow buffers and hair without running out of RAM very quickly.
Subscribe to:
Posts (Atom)




