global proc asPicker () { if (`exists workspaceControl`) { if (`workspaceControl -ex asPickerWorkspaceControl`) deleteUI asPickerWorkspaceControl; workspaceControl -initialHeight 360 -initialWidth 360 -l Picker -retain false -floating true -uiScript ("asPickerUI();") asPickerWorkspaceControl; } else { if (`window -q -ex asPicker`) { asPopulateNameSpaceMenu asPicker; asShowSelJob; asSelChange; showWindow asPicker; return; } window -t picker asPicker; showWindow; asPickerUI; } } asPicker; global proc asPickerUI () { string $sel[]=`ls -sl`; int $tabNr; string $asScriptLocation=`asPickerScriptLocation`; string $tempString[]; string $pickerSceneFiles[]=`getFileList -fs "*.ma" -fld ($asScriptLocation+"pickerFiles/scenes/")`; string $existingRefs[]=`file -q -r`; string $pickerTabs[]={"biped"}; for ($i=0;$i=2011) $ext=".png"; if (`about -linux`) $ext=".xpm"; string $currImage,$buttonImageFile,$buttonImageFileOnK0,$buttonImageFileOnK1,$buttonImageFileOffK0,$buttonImageFileOffK1; string $windows[]=`lsUI -windows`; string $layout; for ($window in $windows) { $layout=""; if (size($window)>11) $layout="asSelector"+`substring $window 11 999`+"FormLayout"; if (!`formLayout -q -ex $layout`) continue; $numLetters=size($layout); $name=`substring $layout 11 ($numLetters-10)`; $ctls=`formLayout -q -ca $layout`; for ($ctl in $ctls) { if (!`iconTextButton -q -ex $ctl`) continue; if (`optionVar -q asShowSelection` && !$asSelChangeSwitching) $selState="On"; else $selState="Off"; $keyed=0; $ann=`iconTextButton -q -ann $ctl`; $numTok=`tokenize $ann ";" $buffer`; for ($i=0;$i<$numTok;$i++) { $obj=`asSelectorResolveNameSpace $name $buffer[$i]`; if (!`stringArrayCount $obj $sel`) $selState="Off"; if (`optionVar -q asShowKeyed` && !$asSelChangeSwitching && `objExists $obj`) { $connections=`listConnections -s 1 -d 0 $obj`; for ($node in $connections) { $nodeType=`objectType $node`; if (`gmatch $nodeType "animCurve*"`) $keyed=1; } } } $currImage=`iconTextButton -q -i1 $ctl`; if ($currImage=="") return; $numTok=`tokenize $currImage "_" $buffer`; if ($numTok<3) continue; $projectName=$buffer[0]; for ($b=1;$b $chrNs { $chrCtrl=`substitute $picNs $sel[$i] $chrNs`; if (`optionVar -q asShowExtra`) $chrCtrl=`substitute "FK" $chrCtrl "FKExtra"`; if (`objExists $chrCtrl` && `optionVar -q asShowSelection`) { select -d $sel[$i]; select -add $chrCtrl; if (`optionVar -q asShowKeyed` && `asHaveAnimation $chrCtrl`) $overrideColor=13; setAttr ($sel[$i]+".overrideColor") $overrideColor; } else print ("// "+$chrCtrl+" not found.\n"); } if (`gmatch $sel[$i] ($chrNs+"*")`) // $chrNs > $picNs { if ($chrNs=="") $picCtrl=$picNs+$sel[$i]; else $picCtrl=`substitute $chrNs $sel[$i] $picNs`; if (`optionVar -q asShowExtra`) { if (!`gmatch $picCtrl "*Extra*"`) continue; $picCtrl=`substitute "FKExtra" $picCtrl "FK"`; } if (`objExists $picCtrl`) setAttr ($picCtrl+".overrideColor") $overrideColor; } } if ($undoState) undoInfo -stateWithoutFlush 1; } global proc asFL () { string $framLayouts[]=`lsUI -type frameLayout`; for ($i=0;$i2) { $extraObj=`substring $obj 1 2`+"Extra"+`substring $obj 3 99`; if (`gmatch $obj "*RootX*"`) $extraObj=`substring $obj 1 4`+"Extra"+`substring $obj 5 99`; if (`objExists ($nameSpace+$extraObj)`) return ($nameSpace+$extraObj); } return ($nameSpace+$obj); } global proc asSelect (string $name, string $objs[]) { for ($i=0;$i>`; $tempFloat[1]=`mag<<$posA[0]-$posB[0],$posA[1]-$posB[1],$posA[2]-$posB[2]>>`; setAttr ($nameSpace+"IK"+$IK+$side+".Lenght1") (($tempFloat[0]/(`getAttr ($nameSpace+"IKX"+$middleJoint+$side+"_IKLenght"+$side+".input2X")`*$b))/`getAttr ("IKX"+$middleJoint+$side+"_IKmessureDiv"+$side+".input1X")`); setAttr ($nameSpace+"IK"+$IK+$side+".Lenght2") (($tempFloat[1]/(`getAttr ($nameSpace+"IKX"+$endJoint+$side+"_IKLenght"+$side+".input2X")`*$b))/`getAttr ("IKX"+$middleJoint+$side+"_IKmessureDiv"+$side+".input1X")`); } } if ($W2K=="FK2IK" && $isSplineIK) { //first do Start and End IkCtrls $tempFloat=`xform -q -ws -t ($nameSpace+"AlignIKTo"+$chainJoints[0])`; xform -ws -t $tempFloat[0] $tempFloat[1] $tempFloat[2] ($nameSpace+"IK"+$IK+"1"+$side); $roo=`xform -q -roo ($nameSpace+"IK"+$IK+"1"+$side)`; xform -p 1 -roo $roo ($nameSpace+"AlignIKTo"+$chainJoints[0]); $tempFloat=`xform -q -ws -ro ($nameSpace+"AlignIKTo"+$chainJoints[0])`; xform -ws -ro $tempFloat[0] $tempFloat[1] $tempFloat[2] ($nameSpace+"IK"+$IK+"1"+$side); $tempFloat=`xform -q -ws -t ($nameSpace+"AlignIKTo"+$chainJoints[size($chainJoints)-1])`; xform -ws -t $tempFloat[0] $tempFloat[1] $tempFloat[2] ($nameSpace+"IK"+$IK+$numIkCtrls+$side); $roo=`xform -q -roo ($nameSpace+"IK"+$IK+$numIkCtrls+$side)`; xform -p 1 -roo $roo ($nameSpace+"AlignIKTo"+$chainJoints[size($chainJoints)-1]); $tempFloat=`xform -q -ws -ro ($nameSpace+"AlignIKTo"+$chainJoints[size($chainJoints)-1])`; xform -ws -ro $tempFloat[0] $tempFloat[1] $tempFloat[2] ($nameSpace+"IK"+$IK+$numIkCtrls+$side); $curveCmd="curve -n FK2IKCurve -d 1"; for ($i=0;$i0.01) { //volume $tempFloat=`getAttr ($nameSpace+$startJoint+$side+".s")`; setAttr ($nameSpace+"FK"+$startJoint+$side+".s") -type float3 $tempFloat[0] $tempFloat[1] $tempFloat[2]; $tempFloat=`getAttr ($nameSpace+$middleJoint+$side+".s")`; setAttr ($nameSpace+"FK"+$middleJoint+$side+".s") -type float3 $tempFloat[0] $tempFloat[1] $tempFloat[2]; //position $tempFloat=`xform -q -ws -t ($nameSpace+"IKX"+$middleJoint+$side)`; xform -ws -t $tempFloat[0] $tempFloat[1] $tempFloat[2] ($nameSpace+"FK"+$middleJoint+$side); $tempFloat=`xform -q -ws -t ($nameSpace+"IKX"+$endJoint+$side)`; xform -ws -t $tempFloat[0] $tempFloat[1] $tempFloat[2] ($nameSpace+"FK"+$endJoint+$side); } //toesAim if (`attributeExists toesAim ($nameSpace+"IK"+$IK+$side)`) { $tempString=`listConnections -s 0 -d 1 ($nameSpace+"IK"+$IK+"RollToesAimReverse"+$side+".outputX")`; $toesAim=`substitute ($nameSpace+"RollToesAim") $tempString[0] ""`; $toesAim=`substitute ($side+"_aimConstraint1") $toesAim ""`; if (`getAttr ($nameSpace+"IK"+$IK+$side+".toesAim")`>0) { $tempFloat=`xform -q -ws -ro ($nameSpace+"IKX"+$toesAim+$side)`; xform -ws -ro $tempFloat[0] $tempFloat[1] $tempFloat[2] ($nameSpace+"FK"+$toesAim+$side); // print ("// "+$nameSpace+"IK"+$IK+$side+".toesAim is On, The FKIK will not correctly Align, for better results, turn Off the \"toesAim\" attribute.\n"); } } //qToes // for ($i=0;$i-1;$i--) { $tempFloat=`xform -q -ws -t ($nameSpace+"IKX"+$qToesJoints[$i]+$side)`; xform -ws -t $tempFloat[0] $tempFloat[1] $tempFloat[2] ($nameSpace+"FK"+$qToesJoints[$i]+$side); $tempFloat=`xform -q -ws -ro ($nameSpace+"IKX"+$qToesJoints[$i]+$side)`; xform -ws -ro $tempFloat[0] $tempFloat[1] $tempFloat[2] ($nameSpace+"FK"+$qToesJoints[$i]+$side); } } if ($W2K=="IK2FK" && $isSplineIK) { for ($i=0;$i0) // $rot=`xform -q -ws -roo $roo -ro ($nameSpace+$chainJoints[$i]+"Part"+$numParts+$side)`; //Root Override, FKRoot_M can not `swing along` a Tail like IKSpine1_M can, so maybe RootX_M should be part of the switch ? xform -ws -t $pos[0] $pos[1] $pos[2] -ro $rot[0] $rot[1] $rot[2] ($nameSpace+"FK"+$chainJoints[$i]); } } if ($autoKey) autoKeyframe -st 1; if (!$autoKey && $asBakeFKIK) autoKeyframe -st 0; select $sel; } global proc asSwitchFKIK (string $nameSpace, string $IK, string $side, string $W2K) { string $sel[]=`ls -sl`; //string $nameSpace=`asSelectorResolveNameSpace $name ""`; //backwards compatibility, 1st arg used to be $name (e.g \"biped\") if (!`gmatch $nameSpace "*:*"`) $nameSpace=`asSelectorResolveNameSpace $nameSpace ""`; string $controlCurve=$nameSpace+"FKIK"+$IK+$side; string $poleCurve=$nameSpace+"Pole"+$IK+$side; if (!`objExists $controlCurve`) error ("Object:\""+$controlCurve+"\" does not exists !"); string $startJoint=`getAttr ($controlCurve+".startJoint")`; string $middleJoint=`getAttr ($controlCurve+".middleJoint")`; string $endJoint=`getAttr ($controlCurve+".endJoint")`; string $chainJoints[],$tempString[],$tempString2[]; string $toesJoint=`asGetToesJoint $nameSpace $endJoint $side`; //string $qToesJoints[]=`asGetQToesJoints $nameSpace $endJoint $side`; string $childLabel,$fkLegAim,$legAimRotCmd; float $legAimRot[]; int $isSplineIK,$numIkCtrls; if (!`objExists ($nameSpace+"Pole"+$IK+$side)`) $isSplineIK=1; string $requiredObj[]={($nameSpace+"Main"),($nameSpace+"FKX"+$startJoint+$side),($nameSpace+"IKX"+$startJoint+$side),($nameSpace+"IKX"+$middleJoint+$side)}; if ($isSplineIK) { $chainJoints=`asgetChainJoints ($nameSpace+$startJoint) ($nameSpace+$endJoint)`; for ($i=0;$i0) { warning ("Could not switch FK2IK, because \"FKIKBlend\" is not \"0\"\n"); return; } if ($W2K=="IK2FK" && `getAttr ($controlCurve+".FKIKBlend")`<10) { warning ("Could not switch IK2FK, because \"FKIKBlend\" is not \"10\"\n"); return; } //LegAim if (`attributeExists legAim ($nameSpace+"IK"+$IK+$side)`) { $tempString=`listConnections -s 0 -d 1 ($nameSpace+"IK"+$IK+"LegAimReverse"+$side)`; $fkLegAim=`substitute ($nameSpace+"LegAim") $tempString[0] ""`; $fkLegAim="FK"+`substitute ($side+"_orientConstraint1") $fkLegAim ""`; $legAimRot=`xform -q -ws -ro ($nameSpace+$fkLegAim+$side)`; $legAimRotCmd="xform -ws -ro "+$legAimRot[0]+" "+$legAimRot[1]+" "+$legAimRot[2]+" "+$nameSpace+$fkLegAim+$side; } int $autoKey=`autoKeyframe -q -st`; currentTime (`currentTime -q` -1); setAttr ($controlCurve+".FKIKBlend") $BlendInverse; for ($a=0;$a<2;$a++) { if ($autoKey) { if (!$isSplineIK) { setKeyframe ($controlCurve+".FKIKBlend"); // setKeyframe ($poleCurve+".follow"); setKeyframe ($nameSpace+"FK"+$startJoint+$side+".rotate"); setKeyframe ($nameSpace+"FK"+$startJoint+$side+".scale"); setKeyframe ($nameSpace+"FK"+$middleJoint+$side+".translate"); setKeyframe ($nameSpace+"FK"+$middleJoint+$side+".rotate"); setKeyframe ($nameSpace+"FK"+$middleJoint+$side+".scale"); setKeyframe ($nameSpace+"FK"+$endJoint+$side+".translate"); setKeyframe ($nameSpace+"FK"+$endJoint+$side+".rotate"); setKeyframe ($nameSpace+"FK"+$endJoint+$side+".scale"); if (`objExists ($nameSpace+$toesJoint)` && `objExists ($nameSpace+"FKToes"+$side)`) setKeyframe ($nameSpace+"FKToes"+$side+".rotate"); setKeyframe ($nameSpace+"IK"+$IK+$side+".translate"); setKeyframe ($nameSpace+"IK"+$IK+$side+".rotate"); setKeyframe ($nameSpace+"IK"+$IK+$side+".scale"); setKeyframe ($nameSpace+"Pole"+$IK+$side+".translate"); $tempString=`listAttr -ud ($nameSpace+"IK"+$IK+$side)`; for ($i=0;$i-1;$z--) { if ($tempString4[$z]==($nameSpace+$endJoint)) break; $qToesJoints[size($qToesJoints)]=`substitute $nameSpace $tempString4[$z] ""`; } } } } } return $qToesJoints; } global proc string[] asgetChainJoints (string $startJoint, string $endJoint) { int $startJointIsParentNr; string $chainJoints[]; string $tempString[]=`ls -l $endJoint`; tokenize $tempString[0] "|" $tempString; for ($i=size($tempString)-1;$i>-1;$i--) { $startJointIsParentNr=$i; if ($tempString[$i]==$startJoint) { break; } } for ($i=$startJointIsParentNr;$i0)) $attrs=$selectedAttrs; else $attrs=$allKeyableAttrs; for ($attr in $attrs) for ($allKeyableAttr in $allKeyableAttrs) { if (`getAttr -l ($nameSpace+$obj+"."+$attr)`) continue; if ($attr==$allKeyableAttr) { if (!$anim) $cmd+=$obj+"."+$attr+" "+`getAttr ($nameSpace+$obj+"."+$attr)`+";"; else { //Animation $animCurves=`listConnections -type animCurve -s 1 -d 0 ($nameSpace+$obj+"."+$attr)`; for ($y=0;$y0)) $attrs=$selectedAttrs; else $attrs=$allKeyableAttrs; for ($attr in $attrs) for ($allKeyableAttr in $allKeyableAttrs) { if (`getAttr -l ($nameSpace+$obj+"."+$attr)`) continue; if ($attr==$allKeyableAttr) { if (!$anim) $cmd+="setAttr "+$obj+"."+$attr+" "+`getAttr ($nameSpace+$obj+"."+$attr)`+";"; if ($anim) { //Animation $animCurves=`listConnections -type animCurve -s 1 -d 0 ($nameSpace+$obj+"."+$attr)`; for ($y=0;$y0;$x--) for ($i=0;$i0) { if (`gmatch $controls[$i] ($nameSpace+"FK*_L")` || `gmatch $controls[$i] ($nameSpace+"FK*_R")` || `gmatch $controls[$i] ($nameSpace+"Bend*_L")` || `gmatch $controls[$i] ($nameSpace+"Bend*_R")` || `attributeExists ikLocal $controls[$i]` || $isClusterLocalOrientControl) { if ($destAttr=="tx" || $destAttr=="ty" || $destAttr=="tz") $flip=-1; } else if ($destAttr=="tz" || $destAttr=="rx" || $destAttr=="ry") $flip=-1; } if ($isFaceControl) $flip=1; /* if (($controls[$i]==$nameSpace+"Eye_R" || $controls[$i]==$nameSpace+"Eye_L") && $destAttr== "ry") $flip=-1;//special case for eyes, as we dont need `crosseyed` */ $wsXformAttr=0; if ($wsScales[2]>0) if (`gmatch $controls[$i] ($nameSpace+"IK*")` || `gmatch $controls[$i] ($nameSpace+"Pole*")` || `gmatch $controls[$i] ($nameSpace+"Roll*")` || `gmatch $controls[$i] ($nameSpace+"RootX_M*")` || ($isClusterControl && !$isClusterLocalOrientControl)) if ((!`gmatch $controls[$i] ($nameSpace+"IKLocal*")`) && !`attributeExists ikLocal $controls[$i]`) if (!`gmatch $controls[$i] ($nameSpace+"IKhybrid*")`) if (!`gmatch $controls[$i] ($nameSpace+"IK*Toes*")`) $wsXform[$i]=1; if (`gmatch $controls[$i] ($nameSpace+"Aim*")`) continue; if ($destAttr=="tx" || $destAttr=="ty" || $destAttr=="tz" ||$destAttr=="rx" || $destAttr=="ry" || $destAttr=="rz") if ($wsXform[$i]) $wsXformAttr=1; if (!$wsXformAttr) if (`getAttr -se ($dest+"."+$destAttr)`) $cmd+="setAttr "+$dest+"."+$destAttr+" "+(`getAttr ($source+"."+$allKeyableAttrs[$y])`*$flip)+";"; } if ($wsXform[$i]) { $tempString=`spaceLocator`; $loc1=$tempString[0]; $tempString=`spaceLocator`; $loc2=$tempString[0]; parent $loc2 $loc1; parent $loc1 $source; xform -os -t 0 0 0 -ro 0 0 0 $loc1; setAttr ($loc1+".rotateOrder") `getAttr ($source+".rotateOrder")`; setAttr ($loc2+".rotateOrder") `getAttr ($source+".rotateOrder")`; setAttr ("flipGroup.scale"+$flipAxis) 1; parent $loc1 flipGroup; setAttr ("flipGroup.scale"+$flipAxis) -1; setAttr ($loc1+".scaleX") -1; $pos=`xform -q -ws -t $loc2`; $rot=`xform -q -ws -ro $loc2`; $pos2=`getAttr ($source+".t")`; $rot2=`getAttr ($source+".r")`; $cmd+="xform -ws -t "+$pos[0]+" "+$pos[1]+" "+$pos[2]+" -ro "+$rot[0]+" "+$rot[1]+" "+$rot[2]+" "+$dest+";"; } if (`attributeExists "mirror" $controls[$i]`) setAttr ($controls[$i]+".mirror") 0; } delete flipGroup; if ($cmd!="") eval ($cmd); select $sel; } global proc asGoToBuildPoseOptions (string $nameSpace, string $controlSet) { if (`objExists asGoToBuildPoseOptions`) delete asGoToBuildPoseOptions; createNode -n asGoToBuildPoseOptions transform; addAttr -ln nameSpace -dt "string" asGoToBuildPoseOptions; setAttr -type "string" asGoToBuildPoseOptions.nameSpace $nameSpace; addAttr -ln controlSet -dt "string" asGoToBuildPoseOptions; setAttr -type "string" asGoToBuildPoseOptions.controlSet $controlSet; asGoToBuildPose bodySetup; } global proc asGoToBuildPose (string $uiName) { int $ctrlButton; if ((`getModifiers`/4) % 2) $ctrlButton=1; string $nameSpace; string $controlSets[]; string $sel[]=`ls -sl`; if (`asHotKeyCheck "asGoToBuildPose \"\""`) return; $nameSpace=`asNameSpaceFromUIName $uiName`; $controlSets=`asNameControlSetsFromUiName $uiName`; if (!size($controlSets)) error "No controlSets detected. select a controller"; if (`objExists asGoToBuildPoseOptions`) { $nameSpace=`getAttr asGoToBuildPoseOptions.nameSpace`; $controlSets[0]=`getAttr asGoToBuildPoseOptions.controlSet`; delete asGoToBuildPoseOptions; } string $buildPose="buildPose"; if (`gmatch $controlSets[0] "*FaceControlSet"`) $buildPose="faceBuildPose"; string $tempString[],$tempString2[],$buffer[]; string $setAttrCmd,$cmd; $setAttrCmd=`getAttr ($nameSpace+$buildPose+".udAttr")`; if (`attributeExists udExtraAttr ($nameSpace+$buildPose)`) $setAttrCmd+=`getAttr ($nameSpace+$buildPose+".udExtraAttr")`; tokenize $setAttrCmd ";" $tempString; for ($y=0;$y0) { $tempString[0]=`pairBlend -nd $connectTo -at tx -at ty -at tz`; rename $tempString[0] ("parBlendT"+$dynJoints[$i]); connectAttr -f ($dynJoints[$i]+".translate") ("parBlendT"+$dynJoints[$i]+".inTranslate2"); connectAttr ($sorted[0]+".blend") ("parBlendT"+$dynJoints[$i]+".weight"); } $tempString[0]=`pairBlend -nd $connectTo -at rx -at ry -at rz`; rename $tempString[0] ("parBlendR"+$dynJoints[$i]); connectAttr -f ($dynJoints[$i]+".rotate") ("parBlendR"+$dynJoints[$i]+".inRotate2"); connectAttr ($sorted[0]+".blend") ("parBlendR"+$dynJoints[$i]+".weight"); } setAttr -l 1 ("DynIKHandle"+$name+".v") 0; print "// Dynamics added.\n"; select $sorted[0]; } global proc asDynSetInitialState (string $uiName) { if (`asHotKeyCheck "asDynSetInitialState \"\""`) return; evalEcho saveInitialState -all; } global proc asDynSetInteractivePlayback (string $uiName) { if (`asHotKeyCheck "asDynSetInteractivePlayback \"\""`) return; evalEcho InteractivePlayback; } global proc asParentAdd (string $uiName, int $extra) { string $sel[]=`ls -sl`; string $child; string $tempString[]; if (`asHotKeyCheck ("asParentAdd \"\" "+$extra)`) return; if (size($sel)<2) error "Select at least 2 objects"; string $parent=$sel[size($sel)-1]; for ($i=0;$i1) { for ($y=0;$y0 && $curFKIKBlend<5) setAttr ($fkIkCtrls[$i]+".FKIKBlend") 0; if ($curFKIKBlend>5 && $curFKIKBlend<10) setAttr ($fkIkCtrls[$i]+".FKIKBlend") 10; if ($curFKIKBlend>5) $ik2fk="IK2FK"; else $ik2fk="FK2IK"; // asSwitchFKIK $fkIkCtrls[$i] `substitute "FKIK" $fkIkCtrl ""` $side $ik2fk; asSwitchFKIK $nameSpace `substitute "FKIK" $fkIkCtrl ""` $side $ik2fk; //global proc asSwitchFKIK (string $nameSpace, string $IK, string $side, string $W2K) } } global proc asAutoSwitchPivot () { string $target,$control,$extraControl; string $sel[]=`ls -sl`; string $tempString[]; if (`asHotKeyCheck "asAutoSwitchPivot"`) return; if (size($sel)!=2) error "Select 1 target object + 1 control"; $target=$sel[0]; $control=$sel[1]; if (!`gmatch $control "*_*"` && `gmatch $target "*_*"`)//selection order was reversed { $target=$sel[1]; $control=$sel[0]; } if (`gmatch $control "*Extra*"`)//extraControl was selected { $tempString=`listRelatives -c -type transform $control`; $control=$tempString[0]; } $tempString=`listRelatives -p $control`; $extraControl=$tempString[0]; if (!`objExists $extraControl`) error ("parent of \""+$control+"\" is not a valid ExtraControl"); float $pos[]=`xform -q -ws -t $control`; float $rot[]=`xform -q -ws -ro $control`; float $extraPos[]=`xform -q -ws -t $extraControl`; float $extraRot[]=`xform -q -ws -ro $extraControl`; float $targetPos[]=`xform -q -ws -t $target`; float $targetRot[]=`xform -q -ws -ro $target`; //print "asAutoSwitchPivot;\n"; int $autoKey=`autoKeyframe -q -st`; if ($autoKey) autoKeyframe -st 0; currentTime (`currentTime -q` -1); setKeyframe ($extraControl+".t") ($extraControl+".r") ($control+".t") ($control+".r"); currentTime (`currentTime -q` +1); xform -ws -t $targetPos[0] $targetPos[1] $targetPos[2] -ro $targetRot[0] $targetRot[1] $targetRot[2] $extraControl; xform -ws -t $pos[0] $pos[1] $pos[2] -ro $rot[0] $rot[1] $rot[2] $control; setKeyframe ($extraControl+".t") ($extraControl+".r") ($control+".t") ($control+".r"); if ($autoKey) autoKeyframe -st 1; select $extraControl; print ("// \""+$extraControl+"\" aligned to \""+$target+"\".\n"); } global proc asQuickIK () { int $otherEndJointAssumed; float $dist; float $posA[],$posB[]; string $startJoint,$endJoint,$ctrlPrefix,$startJointParent,$rotateAxis,$name,$ctrl; string $sel[]=`ls -sl`; string $joints[],$tempString[],$chainJointsReverse[],$chainJoints[],$chainJointNames[]; if (`asHotKeyCheck "asQuickIK"`) return; if (size($sel)!=2) error "Select Start control + End control"; for ($i=0;$i<2;$i++) { $joints[$i]=$sel[$i]; $tempString[0]=`substitute "FK" $joints[$i] ""`;//Fk control if (`objExists $tempString[0]`) { $joints[$i]=$tempString[0]; $ctrlPrefix="FK"; } $tempString[0]=`substitute "_" $joints[$i] "Joint_"`;// Face control e.g tongue if (`objExists $tempString[0]`) { $joints[$i]=$tempString[0]; $ctrlPrefix=""; } } $tempString=`listRelatives -ad -type joint $joints[0]`; if (`stringArrayCount $joints[1] $tempString`) { $startJoint=$joints[0]; $endJoint=$joints[1]; } $tempString=`listRelatives -ad -type joint $joints[1]`; if (`stringArrayCount $joints[0] $tempString`) { $startJoint=$joints[1]; $endJoint=$joints[0]; } if ($startJoint=="" || $endJoint=="") error "Unable to find Start & End joint for the IK, make sure to select 2 control that are in the same hierarchy.\n"; $name=`substituteAllString $startJoint ":" "_"`; $tempString=`listRelatives -p $startJoint`; $startJointParent=$tempString[0]; //if childJoint of $endJoint is a `actual` endJoint, then assume this was meant to be used. $tempString=`listRelatives -ad -type joint $endJoint`; if (size ($tempString)==1) { $endJoint=$tempString[0]; $otherEndJointAssumed=1; } //determine $chainJoints $tempString=`ls -l $endJoint`; tokenize $tempString[0] "|" $tempString; for ($i=size($tempString)-1;$i>-1;$i--) { $chainJointsReverse[size($chainJointsReverse)]=$tempString[$i]; if ($tempString[$i]==$startJoint) break; } for ($i=size($chainJointsReverse)-1;$i>-1;$i--) $chainJoints[size($chainJoints)]=$chainJointsReverse[$i]; for ($i=0;$i0) parent ("QuickIKjoint_"+$chainJointNames[$i]) ("QuickIKjoint_"+$chainJointNames[$i-1]); } parent ("QuickIKjoint_"+$name) ("QuickIK_"+$name+"Group"); parentConstraint -mo $startJointParent ("QuickIKjoint_"+$name); $posA=`xform -q -ws -t $startJoint`; $posB=`xform -q -ws -t $endJoint`; $dist=`mag<<$posA[0]-$posB[0],$posA[1]-$posB[1],$posA[2]-$posB[2]>>`; spaceLocator -n ("QuickIK_"+$name); parent ("QuickIK_"+$name) ("QuickIK_"+$name+"Group"); setAttr ("QuickIK_"+$name+"Shape.overrideEnabled") 1; setAttr ("QuickIK_"+$name+"Shape.overrideColor") 13; setAttr ("QuickIK_"+$name+"Shape.localScale") -type float3 ($dist/2.0) ($dist/2.0) ($dist/2.0); duplicate -n ("QuickPoleVector_"+$name) ("QuickIK_"+$name); setAttr ("QuickPoleVector_"+$name+"Shape.localScale") -type float3 ($dist/4.0) ($dist/4.0) ($dist/4.0); xform -ws -t $posB[0] $posB[1] $posB[2] ("QuickIK_"+$name); ikHandle -n ("QuickIK_"+$name+"Handle") -ns 2 -sol "ikRPsolver" -sj ("QuickIKjoint_"+$chainJointNames[0]) -ee ("QuickIKjoint_"+$chainJointNames[size($chainJointNames)-1]); parent ("QuickIK_"+$name+"Handle") ("QuickIK_"+$name); setAttr ("QuickIK_"+$name+"Handle.v") 0; parent ("QuickPoleVector_"+$name) $startJoint; xform -os -t 0 0 0 -ro 0 0 0 ("QuickPoleVector_"+$name); if ($rotateAxis=="y") setAttr ("QuickPoleVector_"+$name+".tz") $dist; if ($rotateAxis=="z") setAttr ("QuickPoleVector_"+$name+".ty") $dist; //poleVector poleVectorConstraint ("QuickPoleVector_"+$name) ("QuickIK_"+$name+"Handle"); $tempString[0]=`createNode annotationShape`; $tempString=`listRelatives -p $tempString[0]`; rename $tempString[0] ("QuickPoleAnnotation_"+$name); setAttr ("QuickPoleAnnotation_"+$name+"Shape.overrideEnabled") 1; setAttr ("QuickPoleAnnotation_"+$name+"Shape.overrideDisplayType") 2; parent ("QuickPoleAnnotation_"+$name) ("QuickIK_"+$name); xform -os -t 0 0 0 -ro 0 0 0 ("QuickPoleAnnotation_"+$name); connectAttr ("QuickPoleVector_"+$name+"Shape.worldMatrix[0]") ("QuickPoleAnnotation_"+$name+"Shape.dagObjectMatrix[0]"); //move forward to match IkHandle pos setAttr ("QuickPoleVector_"+$name+".tx") `getAttr ("QuickIK_"+$name+".tx")`; //Offsets createNode -n ("QuickIKOffset_"+$name) -p ("QuickIK_"+$name) transform; parent ("QuickIKOffset_"+$name) ("QuickIK_"+$name+"Group"); parent ("QuickIK_"+$name) ("QuickIKOffset_"+$name); createNode -n ("QuickPoleVectorOffset_"+$name) -p ("QuickPoleVector_"+$name) transform; parent ("QuickPoleVectorOffset_"+$name) ("QuickIK_"+$name); parent ("QuickPoleVector_"+$name) ("QuickPoleVectorOffset_"+$name); //connect for ($i=0;$i-2;$b=$b-2) { if ($b==1) {$side="_R";$leftRight="Right";$oppositeSide="_L";} if ($b==-1) {$side="_L";$leftRight="Left";$oppositeSide="_R";} if ($arShapes[$i]=="eyeBlink"+$leftRight) asDsSdk ($bs+"."+$attr) ($nameSpace+"ctrlEye"+$side+".blink") $v 10; if ($arShapes[$i]=="eyeLookDown"+$leftRight) asDsSdk ($bs+"."+$attr) ($nameSpace+"ctrlEye"+$side+".ty") $v -1; if ($arShapes[$i]=="eyeLookIn"+$leftRight) asDsSdk ($bs+"."+$attr) ($nameSpace+"ctrlEye"+$side+".tx") $v (1*$b); if ($arShapes[$i]=="eyeLookOut"+$leftRight) asDsSdk ($bs+"."+$attr) ($nameSpace+"ctrlEye"+$side+".tx") $v (-1*$b); if ($arShapes[$i]=="eyeLookUp"+$leftRight) asDsSdk ($bs+"."+$attr) ($nameSpace+"ctrlEye"+$side+".ty") $v 1; if ($arShapes[$i]=="eyeSquint"+$leftRight) asDsSdk ($bs+"."+$attr) ($nameSpace+"ctrlEye"+$side+".squint") $v 10; if ($arShapes[$i]=="eyeWide"+$leftRight) asDsSdk ($bs+"."+$attr) ($nameSpace+"ctrlEye"+$side+".blink") $v -2; if ($arShapes[$i]=="mouthDimple"+$leftRight) asDsSdk ($bs+"."+$attr) ($nameSpace+"ctrlMouthCorner"+$side+".tx") $v 0.3; if ($arShapes[$i]=="browOuterUp"+$leftRight) asDsSdk ($bs+"."+$attr) ($nameSpace+"ctrlBrow"+$side+".outerUpDown") $v 7.5; if ($arShapes[$i]=="noseSneer"+$leftRight) asDsSdk ($bs+"."+$attr) ($nameSpace+"ctrlNose"+$side+".ty") $v 0.5; //AdvSkel has Center ctrl for these side attrs if ($arShapes[$i]=="mouth"+$leftRight) if (`attributeExists lipSide ctrlMouth_M`)//backwards compataqbility for rigs-2;$b=$b-2) { if ($b==1) {$side="_R";$leftRight="right";$LeftRight="Right";} if ($b==-1) {$side="_L";$leftRight="left";$LeftRight="Left";} setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX."+$leftRight+"EyeTransformRotateY") ($nameSpace+"ctrlEye"+$side+".tx"); setDrivenKeyframe -itt "linear" -ott "linear" -v 1 -dv 30 -cd ("MocapX."+$leftRight+"EyeTransformRotateY") ($nameSpace+"ctrlEye"+$side+".tx"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX."+$leftRight+"EyeTransformRotateX") ($nameSpace+"ctrlEye"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 1 -dv -30 -cd ("MocapX."+$leftRight+"EyeTransformRotateX") ($nameSpace+"ctrlEye"+$side+".ty"); setAttr ("ctrlEye"+$side+"_translateX.preInfinity") 4; setAttr ("ctrlEye"+$side+"_translateX.postInfinity") 4; setAttr ("ctrlEye"+$side+"_translateY.preInfinity") 4; setAttr ("ctrlEye"+$side+"_translateY.postInfinity") 4; setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.eyeBlink"+$side) ($nameSpace+"ctrlEye"+$side+".blink"); setDrivenKeyframe -itt "linear" -ott "linear" -v 10 -dv 1 -cd ("MocapX.eyeBlink"+$side) ($nameSpace+"ctrlEye"+$side+".blink"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd MocapX.browInnerUp ($nameSpace+"EyeBrowInner"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 1 -dv 1 -cd MocapX.browInnerUp ($nameSpace+"EyeBrowInner"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.browDown"+$side) ($nameSpace+"EyeBrowInner"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v -0.5 -dv 1 -cd ("MocapX.browDown"+$side) ($nameSpace+"EyeBrowInner"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.browDown"+$side) ($nameSpace+"EyeBrowInner"+$side+".tx"); setDrivenKeyframe -itt "linear" -ott "linear" -v -0.5 -dv 1 -cd ("MocapX.browDown"+$side) ($nameSpace+"EyeBrowInner"+$side+".tx"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.browOuterUp"+$side) ($nameSpace+"EyeBrowOuter"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 1 -dv 1 -cd ("MocapX.browOuterUp"+$side) ($nameSpace+"EyeBrowOuter"+$side+".ty"); if (`attributeExists EyeBrowMid2Joint ($nameSpace+"EyeBrowOuter"+$side)`) setAttr ($nameSpace+"EyeBrowOuter"+$side+".EyeBrowMid2Joint") .75; if (`attributeExists EyeBrowMid1Joint ($nameSpace+"EyeBrowInner"+$side)`) setAttr ($nameSpace+"EyeBrowInner"+$side+".EyeBrowMid1Joint") .75; setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.eyeSquint"+$side) ($nameSpace+"lowerLid"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 1 -dv 1 -cd ("MocapX.eyeSquint"+$side) ($nameSpace+"lowerLid"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.eyeWide"+$side) ($nameSpace+"ctrlEye"+$side+".blink"); setDrivenKeyframe -itt "linear" -ott "linear" -v -1 -dv 1 -cd ("MocapX.eyeWide"+$side) ($nameSpace+"ctrlEye"+$side+".blink"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd MocapX.cheekPuff ($nameSpace+"Cheek"+$side+".tx"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0.5 -dv 1 -cd MocapX.cheekPuff ($nameSpace+"Cheek"+$side+".tx"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd MocapX.cheekPuff ($nameSpace+"Cheek"+$side+".tz"); setDrivenKeyframe -itt "linear" -ott "linear" -v 1 -dv 1 -cd MocapX.cheekPuff ($nameSpace+"Cheek"+$side+".tz"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.cheekSquint"+$side) ($nameSpace+"ctrlEye"+$side+".squint"); setDrivenKeyframe -itt "linear" -ott "linear" -v 3 -dv 1 -cd ("MocapX.cheekSquint"+$side) ($nameSpace+"ctrlEye"+$side+".squint"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.noseSneer"+$side) ($nameSpace+"NoseCorner"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0.5 -dv 1 -cd ("MocapX.noseSneer"+$side) ($nameSpace+"NoseCorner"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.noseSneer"+$side) ($nameSpace+"NoseCorner"+$side+".tx"); setDrivenKeyframe -itt "linear" -ott "linear" -v -0.2 -dv 1 -cd ("MocapX.noseSneer"+$side) ($nameSpace+"NoseCorner"+$side+".tx"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.noseSneer"+$side) ($nameSpace+"EyeBrowInner"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v -0.5 -dv 1 -cd ("MocapX.noseSneer"+$side) ($nameSpace+"EyeBrowInner"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd MocapX.jawForward ($nameSpace+"Jaw_M.tz"); setDrivenKeyframe -itt "linear" -ott "linear" -v 1 -dv 1 -cd MocapX.jawForward ($nameSpace+"Jaw_M.tz"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd MocapX.jawLeft ($nameSpace+"Jaw_M.tx"); setDrivenKeyframe -itt "linear" -ott "linear" -v 1 -dv 1 -cd MocapX.jawLeft ($nameSpace+"Jaw_M.tx"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd MocapX.jawRight ($nameSpace+"Jaw_M.tx"); setDrivenKeyframe -itt "linear" -ott "linear" -v -1 -dv 1 -cd MocapX.jawRight ($nameSpace+"Jaw_M.tx"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.mouth"+$LeftRight) ($nameSpace+"ctrlMouthCorner"+$side+".tx"); setDrivenKeyframe -itt "linear" -ott "linear" -v 1 -dv 1 -cd ("MocapX.mouth"+$LeftRight) ($nameSpace+"ctrlMouthCorner"+$side+".tx"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.mouth"+$LeftRight) ($nameSpace+"ctrlMouthCorner"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0.3 -dv 1 -cd ("MocapX.mouth"+$LeftRight) ($nameSpace+"ctrlMouthCorner"+$side+".ty"); if (`attributeExists ("zipLips"+$side) ($nameSpace+"ctrlMouth_M")`) { setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd MocapX.mouthClose ($nameSpace+"ctrlMouth_M.zipLips"+$side); setDrivenKeyframe -itt "linear" -ott "linear" -v 10 -dv 1 -cd MocapX.mouthClose ($nameSpace+"ctrlMouth_M.zipLips"+$side); } setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.mouthSmile"+$side) ($nameSpace+"ctrlMouthCorner"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0.75 -dv 1 -cd ("MocapX.mouthSmile"+$side) ($nameSpace+"ctrlMouthCorner"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.mouthFrown"+$side) ($nameSpace+"ctrlMouthCorner"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v -0.75 -dv 1 -cd ("MocapX.mouthFrown"+$side) ($nameSpace+"ctrlMouthCorner"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.mouthDimple"+$side) ($nameSpace+"ctrlMouthCorner"+$side+".tx"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0.75 -dv 1 -cd ("MocapX.mouthDimple"+$side) ($nameSpace+"ctrlMouthCorner"+$side+".tx"); if (`objExists ($nameSpace+"upperLipA"+$side)`) //does not exist for Simplified FaceSetup { setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.mouthUpperUp"+$side) ($nameSpace+"upperLipA"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0.5 -dv 1 -cd ("MocapX.mouthUpperUp"+$side) ($nameSpace+"upperLipA"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.mouthLowerDown"+$side) ($nameSpace+"lowerLipA"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v -0.5 -dv 1 -cd ("MocapX.mouthLowerDown"+$side) ($nameSpace+"lowerLipA"+$side+".ty"); } setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.mouthUpperUp"+$side) ($nameSpace+"upperLip_M.ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0.2 -dv 1 -cd ("MocapX.mouthUpperUp"+$side) ($nameSpace+"upperLip_M.ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.mouthLowerDown"+$side) ($nameSpace+"lowerLip_M.ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v -0.2 -dv 1 -cd ("MocapX.mouthLowerDown"+$side) ($nameSpace+"lowerLip_M.ty"); // setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.mouthPress"+$side) ?; setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd ("MocapX.mouthStretch"+$side) ($nameSpace+"ctrlMouthCorner"+$side+".ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v -0.75 -dv 1 -cd ("MocapX.mouthStretch"+$side) ($nameSpace+"ctrlMouthCorner"+$side+".ty"); } //setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd MocapX.mouthFunnel ?; setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd MocapX.mouthPucker ($nameSpace+"ctrlMouth_M.tx"); setDrivenKeyframe -itt "linear" -ott "linear" -v -1 -dv 1 -cd MocapX.mouthPucker ($nameSpace+"ctrlMouth_M.tx"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd MocapX.jawOpen ($nameSpace+"ctrlMouth_M.ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v -2 -dv 1 -cd MocapX.jawOpen ($nameSpace+"ctrlMouth_M.ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd MocapX.mouthRollUpper ($nameSpace+"ctrlMouth_M.upperRoll"); setDrivenKeyframe -itt "linear" -ott "linear" -v -5 -dv 1 -cd MocapX.mouthRollUpper ($nameSpace+"ctrlMouth_M.upperRoll"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd MocapX.mouthRollLower ($nameSpace+"ctrlMouth_M.lowerRoll"); setDrivenKeyframe -itt "linear" -ott "linear" -v -5 -dv 1 -cd MocapX.mouthRollLower ($nameSpace+"ctrlMouth_M.lowerRoll"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd MocapX.mouthShrugUpper ($nameSpace+"upperLip_M.ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0.5 -dv 1 -cd MocapX.mouthShrugUpper ($nameSpace+"upperLip_M.ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0 -dv 0 -cd MocapX.mouthShrugLower ($nameSpace+"lowerLip_M.ty"); setDrivenKeyframe -itt "linear" -ott "linear" -v 0.5 -dv 1 -cd MocapX.mouthShrugLower ($nameSpace+"lowerLip_M.ty"); connectAttr MocapX.transformRotateX AdvancedSkeletonHeadOffset.rx; connectAttr MocapX.transformRotateY AdvancedSkeletonHeadOffset.ry; connectAttr MocapX.transformRotateZ AdvancedSkeletonHeadOffset.rz; print ("// MocapX connected.\n"); } global proc asAutoLipSyncDownload (string $uiName) { string $zipFileUrl="https://github.com/MontrealCorpusTools/Montreal-Forced-Aligner/releases/download/v1.1.0-beta.2/montreal-forced-aligner_win64.zip"; if (`about -mac`) $zipFileUrl="https://github.com/MontrealCorpusTools/Montreal-Forced-Aligner/releases/download/v1.1.0-beta.2/montreal-forced-aligner_macosx.zip"; string $libriSpeechLexiconUrl="https://www.openslr.org/resources/11/librispeech-lexicon.txt"; string $sLoc=`asGetScriptLocation`; string $curl=$sLoc+"/AdvancedSkeleton5Files/bin/curl.e"; string $zip=$sLoc+"/AdvancedSkeleton5Files/bin/7za.e"; string $binDir=$sLoc+"/AdvancedSkeleton5Files/bin"; string $downloadDir=$sLoc+"/AdvancedSkeleton5Files/bin/download"; string $tempString[]; tokenize $zipFileUrl "/" $tempString; string $downloadedZipFile=$tempString[size($tempString)-1]; string $downloadedZipFilePath=$downloadDir+"/"+$downloadedZipFile; string $cmd; if (!`file -q -ex $downloadDir`) sysFile -md $downloadDir; //download Montreal-Forced-Aligner if (`about -mac` || `about -linux`) { $cmd="\"curl -L -o "+$downloadDir+"/"+$downloadedZipFile+" "+$zipFileUrl+"\""; evalEcho ("system("+$cmd+")"); } else { $cmd="start\/wait/I \"Downloading\" \""+$curl+"\" -L -o \""+$downloadDir+"/"+$downloadedZipFile+"\" "+$zipFileUrl; print ("// Starting Download:"+$cmd+"\n"); system ($cmd); } //download librispeech-lexicon if (`about -mac` || `about -linux`) { $cmd="\"curl -L -o "+$downloadDir+"/librispeech-lexicon.txt "+$libriSpeechLexiconUrl+"\""; evalEcho ("system("+$cmd+")"); } else { $cmd="start\/wait/I \"Downloading\" \""+$curl+"\" -L -o \""+$downloadDir+"/librispeech-lexicon.txt\" "+$libriSpeechLexiconUrl; print ("// Starting Download:"+$cmd+";\n"); system ($cmd); } //confirm downloads if (`file -q -ex $downloadedZipFilePath`) print ("// Downloaded sucessfully:"+$downloadedZipFilePath+";\n"); else error ("// Download failed, could not find:"+$downloadedZipFilePath+";\n"); if (`file -q -ex ($downloadDir+"/librispeech-lexicon.txt")`) print ("// Downloaded sucessfully:"+$downloadDir+"/librispeech-lexicon.txt;\n"); else error ("// Download failed, could not find:"+$downloadDir+"/librispeech-lexicon.txt;\n"); //unzip if (`about -mac` || `about -linux`) $cmd="unzip "+$downloadedZipFilePath+" -d "+$binDir; else $cmd="start\/wait/I \"Unzipping\" \""+$zip+"\" x \""+$downloadedZipFilePath+"\" -o\""+$binDir+"\""; print ("// Starting Unzip:"+$cmd+";\n"); system($cmd); //confirm unzip if (`file -q -ex ($binDir+"/montreal-forced-aligner")`) print ("// Unzipped sucessfully:"+$downloadedZipFile+";\n"); else error ("// Unzipp failed, could not find:"+$binDir+"/montreal-forced-aligner\n"); //Delete download if (`filetest -f $downloadedZipFilePath`) sysFile -del $downloadedZipFilePath; //Delete montreal-forced-aligner_win64.zip (1kb file that comes with the zip) if (`filetest -f ($binDir+"/montreal-forced-aligner_win64.zip")`) sysFile -del ($binDir+"/montreal-forced-aligner_win64.zip"); //Move librispeech-lexicon.txt sysFile -ren ($binDir+"/montreal-forced-aligner/bin/librispeech-lexicon.txt") ($downloadDir+"/librispeech-lexicon.txt"); asAutoLipSyncUI $uiName; } global proc asAutoLipSyncFfmpegDownload () { //ffmpeg for $segmentReplacing string $zipFileUrl="https://www.advancedskeleton.com/download/div/ffmpeg.7z"; string $ffmpegFile="ffmpeg.e"; if (`about -mac`) { $zipFileUrl="https://www.advancedskeleton.com/download/div/ffmpeg_mac.7z"; $ffmpegFile="ffmpeg"; } string $sLoc=`asGetScriptLocation`; string $curl=$sLoc+"/AdvancedSkeleton5Files/bin/curl.e"; string $zip=$sLoc+"/AdvancedSkeleton5Files/bin/7za.e"; string $forceAlignerBinDir=$sLoc+"/AdvancedSkeleton5Files/bin/montreal-forced-aligner/bin"; string $downloadDir=$sLoc+"/AdvancedSkeleton5Files/bin/download"; string $tempString[]; tokenize $zipFileUrl "/" $tempString; string $downloadedZipFile=$tempString[size($tempString)-1]; string $downloadedZipFilePath=$downloadDir+"/"+$downloadedZipFile; string $cmd; if (!`file -q -ex $downloadDir`) sysFile -md $downloadDir; //download if (`about -mac` || `about -linux`) { $cmd="\"curl -k -o "+$downloadedZipFilePath+" "+$zipFileUrl+"\""; evalEcho ("system("+$cmd+")"); } else { $cmd="start\/wait/I \"Downloading\" \""+$curl+"\" -k -o \""+$downloadedZipFilePath+"\" "+$zipFileUrl; print ("// Starting Download:"+$cmd+";\n"); system ($cmd); } //confirm downloads if (`file -q -ex $downloadedZipFilePath`) print ("// Downloaded sucessfully:"+$downloadedZipFilePath+";\n"); else error ("// Download failed, could not find:"+$downloadedZipFilePath+"\n"); //unzip if (`about -mac` || `about -linux`) $cmd="unzip "+$downloadedZipFilePath+" -d "+$forceAlignerBinDir; else $cmd="start\/wait/I \"Unzipping\" \""+$zip+"\" x \""+$downloadedZipFilePath+"\" -o\""+$forceAlignerBinDir+"\""; print ("// Starting Unzip:"+$cmd+";\n"); system($cmd); //confirm unzip if (`file -q -ex ($forceAlignerBinDir+"/"+$ffmpegFile)`) print ("// Unzipped sucessfully:"+$downloadedZipFile+";\n"); else error ("// Unzipp failed, could not find:"+$forceAlignerBinDir+"/"+$ffmpegFile+"\n"); //Delete download if (`filetest -f $downloadedZipFilePath`) sysFile -del $downloadedZipFilePath; } global proc asAutoLipSyncUI (string $uiName) { asEnsureAsGetScriptLocation; string $nameSpace; string $alignerDir=`asGetScriptLocation`+"/AdvancedSkeleton5Files/bin/montreal-forced-aligner"; string $aligner=$alignerDir+"/bin/mfa_align"; if (`about -win`) $aligner=$alignerDir+"/bin/mfa_align.exe"; int $haveAligner=`file -q -ex $aligner`; string $languages[]=`asAutoLipSyncLanguages`; stringArrayInsertAtIndex 1 $languages "English"; string $language="English"; if (`optionVar -ex asAutoLipSyncLanguage`) $language=`optionVar -q asAutoLipSyncLanguage`; if (`asHotKeyCheck "asAutoLipSyncUI \"\""`) return; if (`window -q -ex asAutoLipSyncUI`) deleteUI asAutoLipSyncUI; window -t AutoLipSync -w 300 -h 200 asAutoLipSyncUI; formLayout asAutoLipSyncUIFormLayout; columnLayout asAutoLipSyncUIColumnLayout; if (!$haveAligner) { separator -h 5 -st none; text -l "To run AutoLipSync,"; text -l "first download \"Montreal-Forced-Aligner\""; separator -h 5 -st none; button -l "Download Montreal-Forced-Aligner" -c ("asAutoLipSyncDownload "+$uiName); showWindow; print ("// Montreal-Forced-Aligner tool must be downloaded first\n"); print ("// If the automatic download does not work, you can manually download from:\n"); print ("// https://github.com/MontrealCorpusTools/Montreal-Forced-Aligner/releases\n"); print ("// download and extract the files, so you get this available file-path:\n"); print ("// "+$aligner+"\n"); print ("\n"); return; } text -m 0 -l $aligner asAutoLipSyncAlignerText; separator -h 10 -st none; columnLayout; text -l "Add Idle motions:"; rowLayout -nc 5; checkBox -l "Blink" -v 1 asAutoLipSyncBlinkCheckBox; checkBox -l "Glimpse" -v 1 asAutoLipSyncGlimpseCheckBox; checkBox -l "EyeBrows" -v 1 asAutoLipSyncEyeBrowsCheckBox; checkBox -l "Head" -v 1 asAutoLipSyncHeadCheckBox; setParent..; setParent..; separator -h 20 -st none; setParent..; scrollField -wordWrap false -text "Dialog text here" asAutoLipSyncUIScrollField; button -m 0 -l "Open text editor, for non-latin alphabet" -c asAutoLipOpenTextEditor asAutoLipSyncUIButton; frameLayout -w 300 -cll 1 -cl 0 -l "advanced options" asAutoLipSyncUIFrameLayout; columnLayout -adj 0; rowLayout -nc 3; optionMenu -l "language:" -cc asAutoLipSyncLanguageChanged asAutoLipSyncLanguageOptionMenu; for ($i=0;$i1) $segmentReplacing=1; float $currentTimeUnitToFPS=`currentTimeUnitToFPS`; if ($currentTimeUnitToFPS<1) $currentTimeUnitToFPS=1; string $nameSpace=`asNameSpaceFromUIName $uiName`; string $mfaDir,$cmd,$genDictCmd,$ffMpegCmd,$pythonCmd,$uniDecoded; string $tempString[]; string $languageMenuValue=`optionMenu -q -v asAutoLipSyncLanguageOptionMenu`; string $language=`tolower $languageMenuValue`; string $aligner=`text -q -l asAutoLipSyncAlignerText`; $mfaDir=`asStripPath $aligner 2`; string $lexicon=$mfaDir+"bin/librispeech-lexicon.txt"; string $ffmpeg=$mfaDir+"bin/ffmpeg.e"; if (`about -mac`) $ffmpeg=$mfaDir+"bin/ffmpeg"; string $mfaGD=$mfaDir+"bin/mfa_generate_dictionary"; string $g2pFile=$mfaDir+"pretrained_models/"+$language+"_g2p.zip"; string $languageZipFile=$mfaDir+"pretrained_models/"+$language+".zip"; string $tempDir=`asGetTempDirectory`+"AdvancedSkeleton/autoLipSync/"; string $audioNode = `timeControl -q -s $gPlayBackSlider`; if (!`objExists $audioNode`) error "No sound found. Make sure to import a sound file first"; string $soundFile=`getAttr ($audioNode+".filename")`; tokenize $soundFile "/" $tempString; string $soundFileBaseName=$tempString[size($tempString)-1]; tokenize $soundFile "." $tempString; string $soundFileExt=$tempString[size($tempString)-1]; string $forceSoundFile=$tempDir+"input/align."+$soundFileExt; string $forceTextFile=$tempDir+"input/align.txt"; string $textGridFile=$tempDir+"output/align.TextGrid"; string $forceText=`scrollField -q -tx asAutoLipSyncUIScrollField`; if (!`objExists ($nameSpace+"FaceControlSet")`) error "No controlSets detected. select a controller"; if (!`objExists ($nameSpace+"ctrlPhonemes_M")`) error ($nameSpace+"ctrlPhonemes_M not found"); //non-english needs to mfa_generate_dictionary (lexicon) first //use the g2p to make the dict, and then the zip (Pretrained acoustic models) to align if ($language!="english") { $lexicon=$tempDir+"sessionLexicon.txt"; if (`about -mac` || `about -linux`) $genDictCmd="\""+$mfaGD+"\" \""+$g2pFile+"\" \""+$tempDir+"input/\" \""+$lexicon+"\""; else $genDictCmd="start\/wait/I \"Generating Dictionary\" \""+$mfaGD+"\" \""+$g2pFile+"\" \""+$tempDir+"input/\" \""+$lexicon+"\""; } if (`about -mac` || `about -linux`) { $cmd="\""+$aligner+"\" -c \""+$tempDir+"input/\" \""+$lexicon+"\" "+$language+" \""+$tempDir+"output/\""; $ffMpegCmd="start\/wait/I \"Coding Audio\" \""+$ffmpeg+"\" -y -i \""+$soundFile+"\""; } else { $cmd="start\/wait/I \"Force Aligning\" \""+$aligner+"\" -c \""+$tempDir+"input/\" \""+$lexicon+"\" "+$language+" \""+$tempDir+"output/\""; $ffMpegCmd="start\/wait/I \"Coding Audio\" \""+$ffmpeg+"\" -y -i \""+$soundFile+"\""; } if (!`file -q -ex $soundFile`) error "Not a valid sound file"; //Remove old results $tempString=`getFileList -fld ($tempDir+"output")`; for ($i=0;$i strip_accents > save file, in Py, so we do not need to pass the text as variable $forceText=`substituteAllString $forceText "`" ""`; $forceText=`substituteAllString $forceText "'" " "`; $forceText=`substituteAllString $forceText "\n" " "`; $pythonCmd+="import unicodedata\n"; $pythonCmd+="def strip_accents(s):\n"; $pythonCmd+=" return ''.join(c for c in unicodedata.normalize('NFD', s)\n"; $pythonCmd+=" if unicodedata.category(c) != 'Mn')\n"; python ($pythonCmd); $uniDecoded=`python ("strip_accents(u'"+$forceText+"')")`; $fileId=`fopen $forceTextFile "w"`; fprint $fileId $uniDecoded; fclose $fileId; if ($uniDecoded!=$forceText) scrollField -e -tx $uniDecoded asAutoLipSyncUIScrollField; } //non-english needs to mfa_generate_dictionary (lexicon) first //use the g2p to make the dict, and then the zip (Pretrained acoustic models) to align if ($language!="english") { print ("// Starting Generating Dictionary:"+$genDictCmd+"\n"); if (`file -q -ex $lexicon`) sysFile -del $lexicon; system ($genDictCmd); if (!`file -q -ex $lexicon`) error ("Failed to create dictionary:\""+$lexicon+"\""); } if ($forceText!="") { print ("// Starting Force Aligning:"+$cmd+"\n"); system ($cmd); } else { $fileId=`fopen $textGridFile "w"`; fprint $fileId ""; fclose $fileId; } if (`file -q -ex $textGridFile`) print ("// Successfully created:\""+$textGridFile+"\".\n"); else { if (`file -q -ex ($tempDir+"output/unaligned.txt")`) { $fileId=`fopen ($tempDir+"output/unaligned.txt") "r"`; $tempString[0]=`fread $fileId $tempString[0]`; print ($tempString[0]+"\n"); fclose $fileId; } //Try with ffmpeg if (!$alwaysReCode) { if (`confirmDialog -title "Confirm" -message "Force Align Failed.\nThis could be a compatibility issues with the sound-file.\nTry to re-code sound-file?" -button "Yes" -button "No" -defaultButton "Yes" -cancelButton "No" -dismissString "No"`=="Yes") { checkBox -e -v 1 asAutoLipSyncAlwaysReCodeCheckBox; asAutoLipSyncForceAlign $nameSpace; return; } } //Try re-download language files, since at some point g2p files was moved to a "1.0" folder https://github.com/MontrealCorpusTools/mfa-models/tree/master/g2p/1.0 if (`confirmDialog -title "Confirm" -message "Force Align Failed.\nThe language files might be incorrect,\nTry to re-download language files?" -button "Yes" -button "No" -defaultButton "Yes" -cancelButton "No" -dismissString "No"`=="Yes") { sysFile -del $languageZipFile; sysFile -del $g2pFile; asAutoLipSyncLanguageChanged; asAutoLipSyncForceAlign $nameSpace; return; } error ("Failed to create:\""+$textGridFile+"\".\n"); } asAutoLipSyncImport $nameSpace; } global proc asAutoLipSyncImport (string $nameSpace) { global string $gMainProgressBar; global string $gPlayBackSlider; global string $gCurrentTimeCmdValueTable[]; int $segmentReplacing=0; float $timeRangeArray[]=`timeControl -q -rangeArray $gPlayBackSlider`; int $nonLatin=`checkBox -q -v asAutoLipSyncNonLatinCheckBox`; int $wordsSection,$phonesSection,$fileId; int $autoBlink=`checkBox -q -v asAutoLipSyncBlinkCheckBox`; int $autoGlimpse=`checkBox -q -v asAutoLipSyncGlimpseCheckBox`; int $autoEyeBrows=`checkBox -q -v asAutoLipSyncEyeBrowsCheckBox`; int $autoHead=`checkBox -q -v asAutoLipSyncHeadCheckBox`; int $lastKeyFrameNr,$nextBlinkTriggFrameNr,$nextGlipseTriggFrameNr,$nextHeadTriggFrameNr,$wordNr; if (!`objExists ($nameSpace+"FKHead_M")`) $autoHead=0; float $prePhoneTime=`floatField -q -v asAutoLipSyncPhonemeInFloatField`; float $postPhoneTime=`floatField -q -v asAutoLipSyncPhonemeOutFloatField`; float $sequenceStart=-1; float $sequenceEnd=-1; float $wordSpace=0.25; float $scale=1.5; float $currentTimeUnitToFPS=`currentTimeUnitToFPS`; if ($currentTimeUnitToFPS<1) $currentTimeUnitToFPS=1; float $xMin,$xMax,$segRepOffset,$keyValue,$previousKeyTime; float $wordStarts[],$wordEnds[],$phoneStarts[],$phoneEnds[],$bb[],$keyTimes[],$pos[],$pos1[],$pos2[]; string $aligner=`text -q -l asAutoLipSyncAlignerText`; string $tempDir=`asGetTempDirectory`+"AdvancedSkeleton/autoLipSync/"; string $textGridFile=$tempDir+"output/align.TextGrid"; string $nextLine,$para,$value,$imConvertCmd,$pythonCmd,$fileRead,$font; string $tempString[],$words[],$phones[],$missingPhoneParts[],$letters[],$deleteObjs[],$texts[],$chars[]; string $currentTimeUnit=`currentUnit -q -t`; string $audioNode = `timeControl -q -s $gPlayBackSlider`; string $languageMenuValue=`optionMenu -q -v asAutoLipSyncLanguageOptionMenu`; string $language=`tolower $languageMenuValue`; float $offset=`getAttr ($audioNode+".offset")`/$currentTimeUnitToFPS; if (!`objExists ($nameSpace+"ctrlPhonemes_M")`) error ($nameSpace+"ctrlPhonemes_M not found"); if (`objExists ($nameSpace+"FaceFitSkeletonHeightShape")`) { $pos1=`xform -q -ws -t ($nameSpace+"FaceFitSkeletonHeightShape.cv[5]")`; $pos2=`xform -q -ws -t ($nameSpace+"FaceFitSkeletonShape.cv[5]")`; $scale=$pos1[1]-$pos2[1]; } if (($timeRangeArray[1]-$timeRangeArray[0])>1 && `objExists ($nameSpace+"subTitles")`) $segmentReplacing=1; if ($segmentReplacing) { //Remove all subtitles in segment (and onwards select -cl; $pos=`xform -q -ws -t ($nameSpace+"subTitlesArrowShape.cv[3]")`; $texts=`listRelatives -c ($nameSpace+"subTitlesRoller")`; currentTime $timeRangeArray[0]; $previousKeyTime=`findKeyframe -which previous ($nameSpace+"subTitlesRoller.tx")`; for ($i=0;$i0) { $line=`strip $nextLine`; tokenize $line " = " $tempString; $para=$tempString[0]; $value=$tempString[1]; if ($sequenceStart==-1 && $para=="xmin") $sequenceStart=$value; if ($sequenceEnd==-1 && $para=="xmax") $sequenceEnd=$value; if ($para=="name" && $value=="\"words\"") $wordsSection=1; if ($para=="name" && $value=="\"phones\"") {$phonesSection=1;$wordsSection=0;} if ($para=="xmin") $xMin=$value; if ($para=="xmax") $xMax=$value; if ($wordsSection && $para=="text") { $tempString[0]=`substituteAllString $value "\"" ""`; if ($tempString[0]!="") { $words[size($words)]=$tempString[0]; $wordStarts[size($wordStarts)]=$xMin+$segRepOffset+$offset; $wordEnds[size($wordEnds)]=$xMax+$segRepOffset+$offset; } } if ($phonesSection && $para=="text") { $tempString[0]=`substituteAllString $value "\"" ""`; if ($tempString[0]!="") { $phones[size($phones)]=$tempString[0]; $phoneStarts[size($phoneStarts)]=$xMin+$segRepOffset+$offset; $phoneEnds[size($phoneEnds)]=$xMax+$segRepOffset+$offset; } } $nextLine=`fgetline $fileId`; } fclose $fileId; for ($i=0;$i") $words[$i]="***"; if (!$segmentReplacing) playbackOptions -min ($sequenceStart+$offset) -ast ($sequenceStart+$offset) -aet ($sequenceEnd+$offset) -max ($sequenceEnd+$offset); //ensure key of value 0 at frame 0 setKeyframe -itt linear -ott linear -t 0 -v 0 ($nameSpace+"subTitlesRoller.tx"); for ($i=0;$i<9999;$i++) if (!`objExists ($nameSpace+"text"+$i)`) break; $wordNr=$i; //render non supported symbols, from utf-8 format text files if ($nonLatin) { if (!`file -q -ex ($tempDir+"render")`) sysFile -md ($tempDir+"render"); $pythonCmd=""; $pythonCmd+="wordsSection = 0\n"; $pythonCmd+="wordNr = "+$wordNr+"\n"; $pythonCmd+="searchfile = open('"+$textGridFile+"','r')\n"; $pythonCmd+="for line in searchfile:\n"; $pythonCmd+=" if line.find('name = \"words\"') != -1:\n"; $pythonCmd+=" wordsSection = 1\n"; $pythonCmd+=" if line.find('name = \"phones\"') != -1:\n"; $pythonCmd+=" wordsSection = 0\n"; $pythonCmd+=" if wordsSection == 1:\n"; $pythonCmd+=" if line.find('text = ') != -1:\n"; $pythonCmd+=" word = line.split()[2].replace('\"','')\n"; $pythonCmd+=" if word == '':\n"; $pythonCmd+=" continue\n"; $pythonCmd+=" wordFile = open ('"+$tempDir+"render/word'+str(wordNr)+'.txt','w')\n"; $pythonCmd+=" wordFile.write (word)\n"; $pythonCmd+=" wordFile.close ()\n"; $pythonCmd+=" wordNr = wordNr + 1\n"; $pythonCmd+="searchfile.close()\n"; python ($pythonCmd); } evalDeferred ("progressBar -e -ep "+$gMainProgressBar); progressBar -e -st "Reading Data" -bp -ii 1 -min 0 -max (size($words)+1) $gMainProgressBar; for ($i=0;$i0) { $line=`strip $nextLine`; tokenize $line "=" $tempString; $para=$tempString[0]; $value=$tempString[1]; if ($para=="sideRight") textFieldGrp -e -tx $value asMappingUISideRightTextFieldGrp; if ($para=="sideLeft") textFieldGrp -e -tx $value asMappingUISideLeftTextFieldGrp; if ($para=="sideMiddle") textFieldGrp -e -tx $value asMappingUISideMiddleTextFieldGrp; if ($para=="sideBeforeName") eval ("checkBox -e -v "+$value+" asMappingUISideBeforeNameCheckBox"); if ($para=="sideUnderScore") eval ("checkBox -e -v "+$value+" asMappingUISideUnderScoreCheckBox"); if ($section==2) { if ($para=="") { $nextLine=`fgetline $fileId`; continue; } asMappingUIAddJoint; textField -e -tx $para ("asMappingUIJointsTextFieldA"+$nr); textField -e -tx $value ("asMappingUIJointsTextFieldB"+$nr); $nr++; } if ($para=="" && $value=="") $section++; $nextLine=`fgetline $fileId`; } fclose $fileId; asMappingUISideOptionChanged; } global proc asMappingUIExport (string $tool) { string $fDet,$a,$b; string $asScriptLocation=`asGetScriptLocationFromSelector`; string $tempString[],$existingMenuItems[],$existingFiles[]; string $return[] = `fileDialog2 -fileFilter "*.txt" -dialogStyle 2 -dir ($asScriptLocation+"/AdvancedSkeleton5Files/"+$tool+"s/")`; string $file=$return[0]; if ($file=="") return; $fDet+="sideRight="+`textFieldGrp -q -tx asMappingUISideRightTextFieldGrp`+"\n"; $fDet+="sideLeft="+`textFieldGrp -q -tx asMappingUISideLeftTextFieldGrp`+"\n"; $fDet+="sideMiddle="+`textFieldGrp -q -tx asMappingUISideMiddleTextFieldGrp`+"\n"; $fDet+="sideBeforeName="+`checkBox -q -v asMappingUISideBeforeNameCheckBox`+"\n"; $fDet+="sideUnderScore="+`checkBox -q -v asMappingUISideUnderScoreCheckBox`+"\n"; $fDet+="\n"; for ($nr=1;$nr<999;$nr++) { if (!`rowLayout -q -ex ("asMappingUIJointsRowLayout"+$nr)`) break; $a=`textField -q -tx ("asMappingUIJointsTextFieldA"+$nr)`; $b=`textField -q -tx ("asMappingUIJointsTextFieldB"+$nr)`; $fDet+=$a+"="+$b+"\n"; } int $fileId=`fopen $file "w"`; fprint $fileId $fDet; fclose $fileId; tokenize $return[0] "/" $tempString; tokenize $tempString[size($tempString)-1] "." $tempString; $existingMenuItems=`optionMenu -q -ill asMappingUIFiles`; for ($i=0;$i1) { warning "Found multiple objects called \"hip\", this is probably a export from DAZ, now attemting to merge all the DAZ skeletons.."; for ($i=0;$i$maxNumChildJoints) { $longHipToKeep=$tempString[$i]; $maxNumChildJoints=$numChilJoints; } } } //rename to unique names for ($i=0;$i0.001 || $pos[0]<-0.001) $isMiddleJoint=0; //find $bResolved $underS=""; if ($sideUnderScore) $underS="_"; if ($isMiddleJoint && $sideMiddle=="")//special case, no middleSuffix, so no underscore $underS=""; if ($sideBeforeName) { if ($isMiddleJoint) $bResolved=$sideMiddle+$underS+$b; else $bResolved=$sideRight+$underS+$b; } else { if ($isMiddleJoint) $bResolved=$b+$underS+$sideMiddle; else $bResolved=$b+$underS+$sideRight; } if ($nameSpaceB!="") $bResolved=$nameSpaceB+":"+$bResolved; if (!`objExists $bResolved`) { warning ("Other Joint \""+$bResolved+"\" not found"); textField -e -bgc 1.0 0.5 0.5 ("asMappingUIJointsTextFieldB"+$nr); $numMissing++; continue; } else textField -e -bgc $bgc[0] $bgc[1] $bgc[2] ("asMappingUIJointsTextFieldB"+$nr); $pos=`xform -q -ws -t $bResolved`; xform -ws -t $pos[0] $pos[1] $pos[2] $aLong; } if ($numMissing) frameLayout -e -cl 1 -bgc 1.0 0.5 0.5 asMappingUIJointsFrameLayout; else frameLayout -e -bgc $bgc2[0] $bgc2[1] $bgc2[2] asMappingUIJointsFrameLayout; asFitModeManualUpdate; //special case, MetaHuman have no fingerEndJoints if ($file=="MetaHuman") { setAttr ThumbFinger3.jo -type float3 0 0 0; setAttr IndexFinger3.jo -type float3 0 0 0; setAttr MiddleFinger3.jo -type float3 0 0 0; setAttr RingFinger3.jo -type float3 0 0 0; setAttr PinkyFinger3.jo -type float3 0 0 0; } select FitSkeleton; } global proc asMappingUIFunction (string $function) { int $sideBeforeName=`checkBox -q -v asMappingUISideBeforeNameCheckBox`; int $sideUnderScore=`checkBox -q -v asMappingUISideUnderScoreCheckBox`; int $numChar,$numChar2,$numConnectedJoints; float $height=10; if (`objExists "Main"`) $height=`getAttr "Main.height"`; string $fk="FK"; if (`checkBox -q -ex asMappingUIFKExtraCheckBox`) if (`checkBox -q -v asMappingUIFKExtraCheckBox`) $fk="FKExtra"; string $target,$source,$dest; string $underS=""; string $sideRight=`textFieldGrp -q -tx asMappingUISideRightTextFieldGrp`; string $sideLeft=`textFieldGrp -q -tx asMappingUISideLeftTextFieldGrp`; string $sideMiddle=`textFieldGrp -q -tx asMappingUISideMiddleTextFieldGrp`; string $nameSpaceA=`textField -q -tx asMappingUINameSpacesTextFieldA1`; string $nameSpaceB=`textField -q -tx asMappingUINameSpacesTextFieldB1`; string $tempString[],$as[],$bs[]; string $deformJoints[]=`listRelatives -type joint -ad ($nameSpaceA+"DeformationSystem")`; if ($function=="MoCapConnect" && `objExists MoCapConstraints`) error "MoCapConstraints object already exists, which means MoCap skeleton is already connected"; for ($nr=1;$nr<999;$nr++) { if (!`rowLayout -q -ex ("asMappingUIJointsRowLayout"+$nr)`) break; $as[$nr-1]=`textField -q -tx ("asMappingUIJointsTextFieldA"+$nr)`; $bs[$nr-1]=`textField -q -tx ("asMappingUIJointsTextFieldB"+$nr)`; } for ($i=0;$i "+$target+"\n"); select $target; if (`objExists ($target+"_parentConstraint1")`) delete ($target+"_parentConstraint1"); if (`objExists ($target+"_scaleConstraint1")`) delete ($target+"_scaleConstraint1"); parentConstraint -mo $deformJoints[$i] $target; scaleConstraint $deformJoints[$i] $target; } //MoCapConnect if ($function=="MoCapConnect") { if ($nameSpaceA!="") $dest=`substitute $nameSpaceA $deformJoints[$i] ($nameSpaceA+$fk)`; else $dest=$fk+$deformJoints[$i]; if (`gmatch $dest "*Root_M"`) {//Use RootX instead of Root, as Root may have `inbetween` joint $dest=`substitute "FKRoot_M" $dest "RootX_M"`; if ($fk=="FKExtra") $dest=`substitute "FKExtraRoot_M" $dest "RootExtraX_M"`; } if (!`objExists $dest`) continue; if (!`objExists $target`) { if (!`objExists MoCapConstraints`) error ("Unable to find \""+$target+"\", Maybe the NameSpace is not defined ?\n"); else { print ("\""+$target+"\" not found, Skipping.\n"); continue; } } print ($target+" -> "+$dest+"\n"); //if MoCap-joint-name clashes with FitSkeleton-joint-name (e.g Head, Neck) //we will update $target to have `fullPath` $tempString=`ls -l $target`; if (size($tempString)>1) { for ($y=0;$y "+$dest+"\n"); } if (!`objExists MoCapConstraints`) { createNode -n MoCapConstraints transform; asLockAttr MoCapConstraints 1 1 1 1; } if (!`attributeExists disableConstraints MoCapConstraints`) addAttr -k 1 -ln "disableConstraints" -at bool MoCapConstraints; if ($deformJoints[$i]==$nameSpaceA+"Root_M") { $tempString=`pointConstraint -mo $target $dest`; // parent $tempString[0] MoCapConstraints; connectAttr MoCapConstraints.disableConstraints ($tempString[0]+".nodeState"); } $tempString=`orientConstraint -mo $target $dest`; // parent $tempString[0] MoCapConstraints; connectAttr MoCapConstraints.disableConstraints ($tempString[0]+".nodeState"); $numConnectedJoints++; } //MoCapZeroOut if ($function=="MoCapZeroOut") { if (!`objExists $target`) continue; catchQuiet (`setAttr ($target+".r") -type float3 0 0 0`); $numConnectedJoints++; } } //blendShapes if ($function=="CreateBSControl") { $tempString=`ls -type blendShape`; for ($i=0;$i1) $nameSpace=$tempString[0]; } print ("// nameSpace \""+$nameSpace+"\" detected, and updated in the \"NameSpaces\" section.\n"); textField -e -tx $nameSpace asMappingUINameSpacesTextFieldB1; } global proc asMoCapMatcherScan () { asMoCapMatcherNameSpaceDetect; } global proc asMoCapMatcherDisconnect () { string $tempString[]; if (`objExists MoCapConstraints`) { if (`attributeExists disableConstraints MoCapConstraints`) $tempString=`listConnections -s 0 -d 1 MoCapConstraints.disableConstraints`; for ($i=0;$i0) { $line=`strip $nextLine`; tokenize $line $tempString; if (`gmatch $line "Subject #*"`) $subjects[size($subjects)]=$line; $nextLine=`fgetline $fileId`; } fclose $fileId; setParent -menu asMCLCNU1OptionMenu; for ($i=0;$i0) { $line=`strip $nextLine`; tokenize $line $tempString; if (`gmatch $line "Subject #*"`) { if ($line==$subject) $subjectMatch=1; else $subjectMatch=0; } if ($subjectMatch && `gmatch $line "[0-9][0-9]*"`) $clips[size($clips)]=$line; $nextLine=`fgetline $fileId`; } fclose $fileId; setParent -menu asMCLCNU2OptionMenu; for ($i=0;$i-2;$b=$b-2) { if ($b==1) {$side="_R";$rightLeft="Right";$rotA[0]=0;$rotA[1]=0;$rotA[2]=180;$rotB[0]=90;$rotB[1]=0;$rotB[2]=180;} if ($b==-1) {$side="_L";$rightLeft="Left";$rotA[0]=0;$rotA[1]=0;$rotA[2]=0;$rotB[0]=-90;$rotB[1]=0;$rotB[2]=180;} xform -ws -ro $rotA[0] $rotA[1] $rotA[2] ($moCapNs+":"+$rightLeft+"Arm"); xform -ws -ro $rotA[0] $rotA[1] $rotA[2] ($moCapNs+":"+$rightLeft+"Hand"); if (`objExists ("FKShoulder"+$side)`) asSetWSOrient $rotB[0] $rotB[1] $rotB[2] ("FKShoulder"+$side); if (`objExists ("FKWrist"+$side)`) asSetWSOrient $rotB[0] $rotB[1] $rotB[2] ("FKWrist"+$side); } $constraintObjs={"RootX_M","FKRoot_M","FKSpine1_M","FKChest_M","FKNeck_M","FKHead_M"}; $constraintToObjs={"Hips","Spine","Spine1","Spine3","Neck","Head"}; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) {$side="_R";$rightLeft="Right";} if ($b==-1) {$side="_L";$rightLeft="Left";} $tempString={("IKLeg"+$side),("IKToes"+$side),("FKScapula"+$side),("FKShoulder"+$side),("FKElbow"+$side),("FKWrist"+$side)}; $constraintObjs=`stringArrayCatenate $tempString $constraintObjs`; $tempString={($rightLeft+"Foot"),($rightLeft+"ToeBase"),($rightLeft+"Shoulder"),($rightLeft+"Arm"),($rightLeft+"ForeArm"),($rightLeft+"Hand")}; $constraintToObjs=`stringArrayCatenate $tempString $constraintToObjs`; } for ($i=0;$i-2;$b=$b-2) { if ($b==1) {$side="_R";$rightLeft="Right";} if ($b==-1) {$side="_L";$rightLeft="Left";} for ($y=0;$y-2;$b=$b-2) { if ($b==1) {$side="_R";$rightLeft="Right";} if ($b==-1) {$side="_L";$rightLeft="Left";} // $tempString={("IKLeg"+$side),("IKToes"+$side),("FKScapula"+$side),("FKShoulder"+$side),("FKElbow"+$side),("FKWrist"+$side)}; // $tempString={("FKHip"+$side),("FKKnee"+$side),("FKAnkle"+$side),("FKToes"+$side),("FKScapula"+$side),("FKShoulder"+$side),("FKElbow"+$side),("FKWrist"+$side)}; $tempString={("IKLeg"+$side),("IKToes"+$side),("FKHip"+$side),("FKKnee"+$side),("FKAnkle"+$side),("FKToes"+$side),("FKScapula"+$side),("FKShoulder"+$side),("FKElbow"+$side),("FKWrist"+$side)}; $constraintObjs=`stringArrayCatenate $tempString $constraintObjs`; // $tempString={($rightLeft+"Foot"),($rightLeft+"ToeBase"),($rightLeft+"Shoulder"),($rightLeft+"Arm"),($rightLeft+"ForeArm"),($rightLeft+"Hand")}; // $tempString={($rightLeft+"UpLeg"),($rightLeft+"Leg"),($rightLeft+"Foot"),($rightLeft+"ToeBase"),($rightLeft+"Shoulder"),($rightLeft+"Arm"),($rightLeft+"ForeArm"),($rightLeft+"Hand")}; $tempString={($rightLeft+"Foot"),($rightLeft+"ToeBase"),($rightLeft+"UpLeg"),($rightLeft+"Leg"),($rightLeft+"Foot"),($rightLeft+"ToeBase"),($rightLeft+"Shoulder"),($rightLeft+"Arm"),($rightLeft+"ForeArm"),($rightLeft+"Hand")}; $constraintToObjs=`stringArrayCatenate $tempString $constraintToObjs`; } for ($i=0;$i-2;$b=$b-2) { if ($b==1) {$side="_R";$rightLeft="Right";} if ($b==-1) {$side="_L";$rightLeft="Left";} // $tempString={("IKLeg"+$side),("IKToes"+$side),("FKScapula"+$side),("FKShoulder"+$side),("FKElbow"+$side),("FKWrist"+$side)}; // $tempString={("FKHip"+$side),("FKKnee"+$side),("FKAnkle"+$side),("FKToes"+$side),("FKScapula"+$side),("FKShoulder"+$side),("FKElbow"+$side),("FKWrist"+$side)}; $tempString={("IKLeg"+$side),("IKToes"+$side),("FKHip"+$side),("FKKnee"+$side),("FKAnkle"+$side),("FKToes"+$side),("FKScapula"+$side),("FKShoulder"+$side),("FKElbow"+$side),("FKWrist"+$side)}; $constraintObjs=`stringArrayCatenate $tempString $constraintObjs`; // $tempString={($rightLeft+"Foot"),($rightLeft+"ToeBase"),($rightLeft+"Shoulder"),($rightLeft+"Arm"),($rightLeft+"ForeArm"),($rightLeft+"Hand")}; // $tempString={($rightLeft+"UpLeg"),($rightLeft+"Leg"),($rightLeft+"Foot"),($rightLeft+"ToeBase"),($rightLeft+"Shoulder"),($rightLeft+"Arm"),($rightLeft+"ForeArm"),($rightLeft+"Hand")}; $tempString={($rightLeft+"Foot"),($rightLeft+"ToeBase"),($rightLeft+"UpLeg"),($rightLeft+"Leg"),($rightLeft+"Foot"),($rightLeft+"ToeBase"),($rightLeft+"Shoulder"),($rightLeft+"Arm"),($rightLeft+"ForeArm"),($rightLeft+"Hand")}; $constraintToObjs=`stringArrayCatenate $tempString $constraintToObjs`; } for ($i=0;$i "+$driven+" ("+$drivenValue+")\n"); setDrivenKeyframe -itt "linear" -ott "linear" -dv 0 -v 0 -cd $driver $driven; setDrivenKeyframe -itt "linear" -ott "linear" -dv $driverValue -v $drivenValue -cd $driver $driven; //pre post infinity string $nodes[]=`listConnections -s 1 -d 0 -scn 1 $driven`; for ($i=0;$i