Using armatures to build shape keys - possible?

Hey there. I’m reading this awesome book called "Stop Staring" by Jason Osipa. It’s all about modeling and animating a head. When building certain shape keys for the mouth, he uses an armature bone (you know, in Maya) to get the vertices in approximate position, and then “bakes” that into the mesh so he can tweak the verts further, and build them into a vertex key.

Is this possible to do in Blender? I haven’t been able to figure it out. That functionality would be very useful. Thanks.

–Colin

You could use Alt-C >> Keep Original on each armature deform. Give each of the resulting Meshes a Shape key. Then two-by-two use RVK1 to RVK2 script to copy them all to one Mesh.

I think Toloban wrote a script to do this but If I downloaded it I lost it somehow.

It was actually CJD with Toloban’s input:

http://blenderartists.org/forum/showthread.php?t=70372
http://h1.ripway.com/CJD/Scripts/copy_all_shapes.py

%<

1 Like

Thanks a lot Fligh (and the creators of that script) - it worked well. However.

It only seemed to work for the first key. After I have added shapes to the model, the armature deformation will disappear after using Alt - C. It reverts back to the Basis shape. Is there a workaround?

Huh? Does the model have Shape Curves other than the Basis one? If so have you Keyed them with the Sliders in the Action window?

%<

Yeah, the model at the moment has a Basis key and one other vertex key. They have not been animated at all (nothing in the action window). In the shapes tab I have the Basis one viewed when I change the armature (rotating bones and whatnot). When I try Alt-C, the new mesh doesn’t save the armature deformation. It looks like just the basis key alone. Am I doing something wrong?

–Colin

I see. I fiddled with CJD’s script and can’t get any joy out of it and I also hit troubles with Alt-C (though I can’t find out why). So, instead of Alt-C use the “Apply Deformation” script. I take it you’re doing LipSync so use the armature to set the mesh for a Phoneme then apply def. Give that new mesh a ShapeKey and move it out of your way to another layer then move onto the next phoneme and repeat. Each of those meshes only need a Basis Key.

When you’re done pick one mesh thats going to get all your Keys (it helps if you rename each new mesh with the phoneme it was deformed to and the name you’ll give your shapekey). Then select that mesh and Shft-Select (make it the Active mesh) the mesh you’ll copy the key from (this is important because it’s counter to everything else in Blender). Then run “RVK1 to RVK2”. Do the same with all subsequent deformed meshes.

%<

Thanks so much for the help, Fligh. I’ll try to do exactly that - sounds like that’ll work.

–Colin

That is too much complication, when you can use a simple script that combines “Apply Deformation” and “RVK1 to RVK2”.

Only one catch: Delete the subsurf modifier before running, create a new one after adding the keys.


#To Add the currently deformed mesh as new Shape key.
#Delete subsurf modifier before running this script.
import Blender

ob = Blender.Object.GetSelected()[0]
mesh = ob.getData()
defmesh = Blender.NMesh.GetRawFromObject(ob.name)

if not mesh.key:
    mesh.insertKey()
    mesh.update()
    
for i in range(len(defmesh.verts)):
    mesh.verts[i].co.x = defmesh.verts[i].co.x
    mesh.verts[i].co.y = defmesh.verts[i].co.y
    mesh.verts[i].co.z = defmesh.verts[i].co.z

mesh.update()
mesh.insertKey()
mesh.update()

In my opinion adding bones to move vertices in a face is just too complicated.

Thanks toloban!

No problem, just a quick script.

I forgot to mention it is so simplified it assumes the selected object is centered and has size and rotation applied. Better do a ctrl+A before adding keys.

In your script is there any way that the shape key Name should also be given using Python?

You could give every new key a default name

mesh.key.blocks[-1].name = "(whatever)"
mesh.update()

But that would always be the same name and that doesn’t really make sense, so rename them from the panel or the action editor.

Thanks
Thanks

Man, tolobán - I go away for a few days, figure out the most efficient way to apply the deformation, involving a number of steps, make a video tutorial of it (cause it seems like this is something that people would want to do), come back and revisit this thread to see a simple python script that works beautifully - doing the same thing in a fraction of the time. This is why I must learn python. How cool!

Thanks so much.

–Colin

Hello Guys
I’m trying to replicate the osipa rig in Blender. My main problem now (efter building all the shapes) is that I have NO CLUE on how to create expressions (IPO drivers) as I can do it in Maya.

ex. (in maya).

open_jaw shape has this expression

faceshapes.open_jaw = clamp(-0.3, 1, Ctrl_Sync.TranslateY)

So this would force my openJaw shape to go between -0.3 and 1 when I move the Sync up and down (and clamp the numbers to that).
Any tutorials or wiki pages that you guys can refeer to so that I can learn it?

best regards
stefan andersson

Such slightly off topic questions have great chances to get burried forever in this vast forum if you don’t ask them as a new thread. This after you checked if nobody has ever asked it before (as it actually is the case with yours) via the search menu.
anyway, you could get a short answer here: http://wiki.blender.org/index.php/BlenderDev/PyDrivers
afterwards, use the forum tools, they are great :wink: