//This version of the smart blinks assumes your eye ball and eye lids have similar orientations and rotate up and down on the rz axis. //$control = the control object that will recieve the blinking attributes //$side = a string to indicate left of right (ex: L or R) //$maxBlink = determined by rotating the upper lid joint until it touched the lower lid joint - should be a negative number in the rotate z channel //$lowLidMvmt = how much you want the lower lid to move when there's a blink - should be a positive number //$threshold = the amount the eyeball joint can rotate before the cornea touches the lower eye lid and starts pushing the eye lid out of the way //$eyeJoint = the eyeball joint //$upperLidJnt = the upper eye lid joint //$lowerLidJnt = the lower eye lid joint //ex usage: JTDsmartBlinks("Eye_Cntrl", "R", -55, 5, -10, "R_eye_jnt", "R_eyeLid_up_01_jnt", "R_eyeLid_low_01_jnt"); //www.johndoublestein.com global proc JTDsmartBlinks(string $control, string $side, float $maxBlink, float $lowLidMvmt, float $threshold, string $eyeJnt, string $upperLidJnt, string $lowerLidJnt) { if(!objExists($control+".blink"+$side)) { addAttr -ln ("blink"+$side) -at double -min 0 -max 1 -dv 0 $control; setAttr -e -keyable true ($control+".blink"+$side); } if(!objExists($control+".upperLid"+$side)) { addAttr -ln ("upperLid"+$side) -at double $control; setAttr -e -keyable true ($control+".upperLid"+$side); } if(!objExists($control+".lowerLid"+$side)) { addAttr -ln ("lowerLid"+$side) -at double $control; setAttr -e -keyable true ($control+".lowerLid"+$side); } string $maxBlinkSetting = `createNode multiplyDivide -n ("maxBlinkSetting"+$side)`; setAttr ($maxBlinkSetting+".input1X") $maxBlink; string $blinkingRange = `createNode plusMinusAverage -n ("blinkingRange"+$side)`; connectAttr ($maxBlinkSetting+".outputX") ($blinkingRange+".input1D[0]"); string $mapUpperLid = `createNode remapValue -n ("mapUpperLid"+$side)`; connectAttr ($control+".blink"+$side) ($mapUpperLid+".inputValue"); connectAttr ($blinkingRange+".output1D") ($mapUpperLid+".outputMax"); string $lowBlinkMult = `createNode multiplyDivide -n ("lowBlinkMult"+$side)`; connectAttr ($control+".blink"+$side) ($lowBlinkMult+".input1X"); setAttr ($lowBlinkMult+".input2X") $lowLidMvmt; string $lowLidAdj = `createNode plusMinusAverage -n ("lowLidAdj"+$side)`; connectAttr ($control+".lowerLid"+$side) ($lowLidAdj+".input1D[0]"); connectAttr ($lowBlinkMult+".outputX") ($lowLidAdj+".input1D[1]"); connectAttr ($lowLidAdj+".output1D") ($blinkingRange+".input1D[1]"); string $upLidDamper = `createNode multiplyDivide -n ("upLidDamper"+$side)`; connectAttr ($eyeJnt+".rz") ($upLidDamper+".input1X"); setAttr ($upLidDamper+".input2X") 0.9; string $upLidAdj = `createNode plusMinusAverage -n ("upLidAdj"+$side)`; connectAttr ($upLidDamper+".outputX") ($upLidAdj+".input1D[0]"); connectAttr ($control+".upperLid"+$side) ($upLidAdj+".input1D[1]"); connectAttr ($upLidAdj+".output1D") ($mapUpperLid+".outputMin"); string $lowLidDamper = `createNode multiplyDivide -n ("lowLidDamper"+$side)`; connectAttr ($eyeJnt+".rz") ($lowLidDamper+".input1X"); setAttr ($lowLidDamper+".input2X") 0.75; string $thresholdAdj = `createNode plusMinusAverage -n ("thresholdAdj"+$side)`; connectAttr ($control+".lowerLid"+$side) ($thresholdAdj+".input1D[0]"); setAttr ($thresholdAdj+".input1D[1]") $threshold; string $thresholdRev = `createNode multiplyDivide -n ("thresholdRev"+$side)`; connectAttr ($thresholdAdj+".output1D") ($thresholdRev+".input1X"); setAttr ($thresholdRev+".input2X") -1; string $thresholdClamp = `createNode clamp -n ("thresholdClamp"+$side)`; connectAttr ($thresholdRev+".outputX") ($thresholdClamp+".inputR"); setAttr ($thresholdClamp+".maxR") (-1*$threshold); connectAttr ($thresholdClamp+".outputR") ($lowLidAdj+".input1D[2]"); string $lowLidPush = `createNode condition -n ("lowLidPush"+$side)`; setAttr ($lowLidPush+".operation") 4; connectAttr ($lowLidDamper+".outputX") ($lowLidPush+".firstTerm"); connectAttr ($thresholdAdj+".output1D") ($lowLidPush+".secondTerm"); connectAttr ($lowLidDamper+".outputX") ($lowLidPush+".colorIfTrueR"); connectAttr ($thresholdAdj+".output1D") ($lowLidPush+".colorIfFalseR"); connectAttr ($lowLidPush+".outColorR") ($lowLidAdj+".input1D[3]"); connectAttr ($mapUpperLid+".outValue") ($upperLidJnt+".rz"); connectAttr ($lowLidAdj+".output1D") ($lowerLidJnt+".rz"); }