Wednesday, March 5, 2014

Tip: Using MEL to preview single activated blendshapes

Happy Wednesday,

I wanted a way to quickly preview some blendshapes so here are some ideas to use scripting to set keyframes on timeline so we can quickly preview a few blendshapes.  a limitation is that it just activates one blendshape at a time .. hope you find it helpful:




///
//put blendshape targets given all at zero --- on next frame put only one of them on

string $blendNode = "SINGLE_TEST"; //PUT BLEND NODE NAME HERE
string $blendShapeToSetKey[] = {"test_1","test_3","test_7"}; //PUT IN NAMES FOR ALL BLENDSHAPES WE WANT TO KEY

int $timeToKey[] = {1,10,20,30,40,50}; //CHANGE TO 1,10,20 to get 10 frame hold on each shape
int $numBlendToKey = size($blendShapeToSetKey);


for( $i = 0; $i < $numBlendToKey; $i++ ){

//put them all at zero
currentTime $timeToKey[$i];
for( $arg in $blendShapeToSetKey){
setAttr ($blendNode+"."+$arg) 0;//setAttr "TEST_BLEND.polySurface6" 0;
setKeyframe ($blendNode+"."+$arg);//setKeyframe  "TEST_BLEND.polySurface6";
}

//put only one of them on
currentTime ($timeToKey[$i]+1);
$blendShapeToActivate = $blendShapeToSetKey[$i];
setAttr ($blendNode+"."+$blendShapeToActivate) 1;//setAttr "TEST_BLEND.polySurface6" 1;
setKeyframe ($blendNode+"."+$blendShapeToActivate);

//if at last shape put it at zero at end
if($i == ($numBlendToKey-1)){
currentTime ($timeToKey[$i]+10);
$blendShapeToActivate = $blendShapeToSetKey[$i];
setAttr ($blendNode+"."+$blendShapeToActivate) 0;//setAttr "TEST_BLEND.polySurface6" 1;
setKeyframe ($blendNode+"."+$blendShapeToActivate);
}

}

currentTime 1;
select -r $blendNode;
///





(follow up to smooth preview with no wireframe discussion: A small follow up to the smooth preview previous post i made via connecting inmesh to outmesh.. is that sometimes the smooth preview using 3 key took some time to update sometimes,  so another approach to preview a smooth mesh is to use a blendshape where the output mesh  can have added ontop a mesh> smooth operation... the only thing about this is that changing the topology of the mesh were sculpting on wouldn't cleanly change the topology of the blendshape target mesh with mesh smooth)

Also here are a couple sketches i made today:



(in sketching these i really enjoyed just seeing shapes then sketching .. it kind of allowed me to change the size of the drawings...  i also found it very helpful to take breaks in between sketching like say 15minutes with an alarm... and i recommend to have fun sketching .. i sometimes found i was forcing sketching and it became not fun but then when i started to have fun with the shapes it became more fun and enjoyable ... Happy sketching to you .. You can do it! )



Thanks for visiting,
Cheers,
-Nate