Well, I shouldn't have, but I did.
Since my teaching contracts are all signed, I've decided to teach myself Python.
I've seen
really a lot of requests on Blender forums asking for an understanding of how to use quaternions, which supposedly are the way to go for multiple rotated axes (which is what my custom rig needs).
Now, I apologize for using late Cretaceous software, but that's what runs best on my rack servers, and Blender 2.49b really gets along well with Yafaray. There, apology finished.
Now, for those nasty quaternions. You can get all kinds of technical (very!) explanations off the net, so I won't go into that here.
What I will show you is how to control them.
The easist way is to go to:
http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/install Java for your browser (if it isn't already installed) and do the calculations there.
Many thanks for Thomas for his lipsync script.
Here is some ancient Python, but I bet this won't be too hard to update:
=============BEGIN ANCIENT PYTHON=========================def setBoneRotation(Jaw):
amtOb = Object.Get('humanRig')
amtOb.sel = True
pose = amtOb.getPose()
pbones = pose.bones
pbones['Jaw'].quat[:] = 1.0,0.25,0.00,0.00
pose.update()
Window.PoseMode(0)
Window.PoseMode(1)
meshOb = Object.Get('humanMesh')
meshOb.sel = True
Window.EditMode(1)
Window.EditMode(0)
amtOb.sel = True
Draw.Redraw(-1)
return
===============END ANCIENT PYTHON==========================And this is what it looks like in action:
And, finally this is what complete control looks like. I always add an 'innerJaw' to situate the lower dentures properly.
The design principle is: "one function for each viseme".
"""
'AH' : [('Jaw', (0,.1,0)), ('tongueBase', (0,0,0)), ('tongueTip', (0,0,0)), ('innerJaw', (0,-.1,0)), ('lipRing', (0,0,0)),('upperLip_R',(0,0,0)),('upperLipMiddle',(0,0,0)),('upperLip_L',(0,0,0)),('lowerLip_R',(0,0,0)),('lowerLipMiddle',(0,0,0)),('lowerLip_L',(0,0,0)),('mouthCorner_R',(0,0,0)),('mouthCorner_L',(0,0,0))], \
"""
===============BEGIN ANCIENT PYTHON==========================# one function for each viseme
def setBoneRotation(Jaw):
amtOb = Object.Get('humanRig')
amtOb.sel = True
pose = amtOb.getPose()
pbones = pose.bones
pbones['Jaw'].quat[:] = 1.0,0.15,0.00,0.00
pbones['innerJaw'].quat[:] = 1.0,-0.15,0.00,0.00
for (b, (x,y,z)) in Visemes['AH']:
loc = Vector(float(x),(float(y)),float(z))
pbones[b].loc = loc
pose.update()
Window.PoseMode(0)
Window.PoseMode(1)
meshOb = Object.Get('humanMesh')
meshOb.sel = True
Window.EditMode(1)
Window.EditMode(0)
amtOb.sel = True
Draw.Redraw(-1)
return
===============END ANCIENT PYTHON==========================Also:
Remember to Delete All Actions in your Action Editor before running this script (or a variation of it); otherwise, the 'Rest' position will be determined by the action at that frame.