Monday, May 27, 2013

Example simple Lip Rig using Curve Influence And Blendshapes

Happy Monday,

There are still some issues with this setup. No inner lip, lack of corner control, teeth/tounge  …
- used bottom of sphere to start the lip shape.
- basically used two cubic curve (each with ~6 spans).
- made an up lip blendshape and a bottom lip blendshape.  Each has its own curve. One uses top curve and has all lower verts weighted to a static joint.  The other uses a bottom curve and has all upper verts weighted to a static joint.
-there is just one joint bound to each blendshape. It is at origin.  Its used so I could add curve as an influence.

some other tips.. for short scripts it was faster to type them in script editor and drag to shelf then writing a new function (proc,def…)

Here are a couple I wrote:
//toggle vis on all clusters
//toggles non animated visibility of all clusters
for($arg in `ls -type clusterHandle`){ select -r $arg; string $clusterAr[] = `pickWalk -d "up"`;  int $vis = `getAttr ($clusterAr[0]+"."+"visibility")`;  setAttr ($clusterAr[0]+"."+"visibility") (1-$vis); };

//remove vis keys on all clusters
for($arg in `ls -type clusterHandle`){ select -r $arg; string $clusterAr[] = `pickWalk -d "up"`; cutKey -cl -t ":" -f ":" -at "v" $clusterAr[0];  };

cluster all selected or each,  joint on selected, locator on selected tools I use for rigging and they help me in modeling to.

Also modeling sectional blendshapes and transfering the section to a whole face may be helpful.  This was helpful in isolating the region I was rigging which could later integrate with the whole face.  This one doesn't work perfectly yet (it needs setting the max distance with the wrap.. right now the full created blendshape may have some unwanted vertices moving on the opposite side of mesh) but its an okay start.   I wrote this one today.

//requires sections selected on scene, input is full shape, and the overlapping section shape. assumes section does not have blendshapes. if shape look off change wrap options max dist to 0.01
global proc facerigMakeSelSectionIntoFullBlendshape(string $full, string $section )
    string $full, $section;
    string $sectionShapes[] = {};
    //$section =  "polySurface217";
    //$full =  "polySurface216";
    //$sectionShapes = {"lt_browLowerer","lt_innerBrowRaiser","lt_outerBrowRaiser"};
    $sectionShapes = `ls -sl`;
    //section should move full face
    select -cl;
    select -r $full;
    select -add $section;
    //deformer -type wrap $full; //there is some maya bug using this
    //so we're not affecting mirrored side
    //setAttr ($wrapName+"."+"maxDistance") 0.01;
    //make shapes moving section
    select -r $sectionShapes;
    select -add $section;
    //$blendName = "tmp_bnd";
    string $blendNameAr[] = `blendShape`; //make sure blendnode not on scene
    $blendName = $blendNameAr[0];
    //---make section moving full face, section needs to be at default
    for($blend in $sectionShapes){ setAttr ($blendName+"."+$blend) 0;}
    //select -r polySurface216 ;
    //select -add polySurface217 ;
    //deformer -type wrap polySurface216;
    //--get our full faces
    for($blendShape in $sectionShapes){
        for($arg in $sectionShapes){ setAttr ($blendName+"."+$arg) 0;}//first reset all shapes
        setAttr ($blendName+"."+$blendShape) 1.0;
        duplicate -n ($blendShape+"_full") -rr $full;
    for($blend in $sectionShapes){ setAttr ($blendName+"."+$blend) 0;}//put back to default
    delete -ch $full;//clean history
    delete -ch $section;//clean history

Hope this was helpful.