// AdvancedSkeleton // Version 5.830 // // // AdvancedSkeleton is is a collection of Maya tools for doing character setup. // // INSTALLATION: // drag`n`drop the "install.mel" file into Maya (drop in any viewport). // // For detailed instructions read the "install.txt" file // // Copyright (C)2021 Animation Studios // // email: support@animationstudios.com.au // Last Modified 31/07/2021 global proc AdvancedSkeleton5 () { global int $asBuilding; global int $asRebuilding; global int $asFaceIsResetting; global string $gMainProgressBar; global int $asFitModeScriptJobNr4,$asFitModeScriptJobNr5; global int $asSkipConfirm; string $evalManagerStats[]; string $m; string $currentUnitLinear=`currentUnit -q -f`; $m="Units currently set to: \""+$currentUnitLinear+"\"\nAdvancedSkeleton requires \"cm\".\nClick OK to switch"; if ($currentUnitLinear!="centimeter") if (`confirmDialog -t Confirm -m $m -b "Ok" -b "Cancel" -db "Ok"`=="Ok") currentUnit -l cm; int $animBlendingOpt=`optionVar -q animBlendingOpt`; if ($animBlendingOpt!=1) { optionVar -iv animBlendingOpt 1; print "// \"Animation Blending Option\" now switched to On.\n"; } if (`asMayaVersionAsFloat`>=2012) if (`manipMoveContext -q -ex Move`) if (!catchQuiet (`manipMoveContext -q -orientJointEnabled Move`)) if (`manipMoveContext -q -orientJointEnabled Move`) manipMoveContext -e -orientJointEnabled 0 Move; int $haveRanThisVersion=`optionVar -q asHaveRanThisVersion`; int $asDock=`optionVar -q asDock`; if (`exists dockControl`) if (!`optionVar -ex asDock`) $asDock=1; int $asWorkspace; int $modifier=`getModifiers`; catchQuiet (`editDisplayLayerGlobals -useCurrent 0`); $asBuilding=0; $asRebuilding=0; $asFitModeSkip=0; $asSkipConfirm=0; int $csm=0;//CorrectiveShapeMode string $boldFont="smallBoldLabelFont"; if (`asMayaVersionAsFloat`<2012) $boldFont="plainLabelFont"; string $asScriptLocation=`asGetScriptLocation`; string $xyz[]={"x","y","z"}; string $labels[]={"Root","Chest","Mid","Hip","Foot","Heel","Toes","ToesEnd","BigToe","PinkyToe","LegAim","QToes","Shoulder","Hand","0","1","2","3"}; string $attributes[]={"twist/bendy","inbetween","global","aim","wheel","freeOrient","worldOrient","flipOrient","noMirror","noFlip","noControl","noSkin", "ikLocal","centerBtwFeet","hipSwinger","follow","geoAttach","aimAt","curveGuide","rootOptions","segScaleComp","control"}; string $rootLevelObjects[]=`ls -as`; for ($i=0;$i=2012) toolButton -edit -tool $gBuffStr1 -toolImage1 $gBuffStr1 "kinJoint.png" $gBuffStr; toolButton -edit -tool $gBuffStr1 $gBuffStr; button -w 72 -l "ReSample" -c asFitResample; button -w 11 -l "?" -c "asHelpImage asFitCreate"; setParent..; separator; rowLayout -nc 1; text -h 10 -l "Auto-Orient:"; setParent..; rowLayout -nc 3 -cw3 106 120 15; optionMenu -l "Primary Axis:" -cc asAxisChanged asPrimaryAxisOptionMenu; menuItem -l "X"; menuItem -l "Y"; menuItem -l "Z"; menuItem -l "-X"; menuItem -l "-Y"; menuItem -l "-Z"; optionMenu -l "Secondary Axis:" -cc asAxisChanged asSecondaryAxisOptionMenu; menuItem -l "X"; menuItem -l "Y"; menuItem -l "Z"; menuItem -l "-X"; menuItem -l "-Y"; menuItem -l "-Z"; optionMenu -e -sl 2 asSecondaryAxisOptionMenu; button -w 11 -l "?" -c "asHelpImage asLocalOrientationAxis"; setParent..; rowLayout -h 18 -nc 3 -cw3 62 165 15; separator; checkBox -l "world-match" -cc asWorldMatchChanged asAutoOrientWorldMatchCheckBox; button -w 11 -l "?" -c "asHelpImage asWorldMatchAxis"; setParent..; rowLayout -nc 3 -cw3 62 165 15; separator -st none; button -w 156 -l FitMode -c asFitMode; button -w 11 -l "?" -c "asHelpImage asFitMode"; setParent..; separator -st none -h 5; rowLayout -nc 4 -cw4 82 62 81 15; separator -st none; text -l "Or, manual:"; button -w 72 -l "Update Now" -c asFitModeManualUpdate; button -w 11 -l "?" -c "asHelpImage asFitUpdateNow"; setParent..; separator; setParent..; setParent..; frameLayout -cll 1 -cl 1 -cc asFL -ec asFL -l " Build" asBodyBuildFrameLayout; columnLayout -adj 1; rowLayout -nc 4; separator -w 28 -st none; button -m 0 -w 60 -l "Delete Adv" -c asDeleteAdvanced asDelteAdvButton; separator -w 15 -st none; checkBox -l "Keep All" -v 1 -onc "columnLayout -e -m 0 asBodyKeepColumnLayout" -ofc "columnLayout -e -m 1 asBodyKeepColumnLayout" asKeepAllCheckBox; setParent..; columnLayout -m 0 asBodyKeepColumnLayout; rowLayout -nc 2 -cw2 5 100; separator -st none; columnLayout; checkBox -v 1 -l "keep custom control shape and color" asKeepCurveShapesCheckBox; checkBox -v 1 -l "keep custom stored buildPose" asKeepBuildPoseCheckBox; checkBox -v 1 -l "keep custom parenting" asKeepParentingCheckBox; checkBox -v 1 -l "keep custom parentConstraints" asKeepParentConstraintsCheckBox; checkBox -v 1 -l "keep custom lock/hide of attributes" asKeepLockHideCheckBox; checkBox -v 1 -l "keep custom added attributes" asKeepUserAttrsCheckBox; checkBox -v 1 -l "keep custom set transformLimits" asKeepLimitsCheckBox; checkBox -v 1 -l "keep deformations (connections)" asKeepSkinningCheckBox; setParent..; setParent..; setParent..; rowLayout -nc 4 -cw4 5 85 5 100; separator -w 5 -st none; button -l "Toggle Fit/Adv" -c asToggleFitAdvancedSkeleton asToggleFitSkeletonButton; separator -w 5 -st none; button -l "Build AdvancedSkeleton" -c asReBuildAdvancedSkeleton asBuildAdvancedSkeletonButton; setParent..; setParent..; setParent..; frameLayout -cll 1 -cl 1 -cc asFL -ec asFL -l " Deform (option1)" asBodyDeform1FrameLayout; columnLayout -adj 1; rowLayout -nc 3 -cw3 100 126 15; separator; text -l "Skinning:"; button -w 11 -l "?" -c "asHelpImage asDeformSkinning"; setParent..; rowLayout -nc 2 -cw2 60 100; separator -st "none"; columnLayout; text -l "Select objects to deform, then:"; separator -h 5 -st none; button -w 140 -l "+ Select DeformJoints" -c asSelectDeformJoints; separator -h 5 -st none; button -w 140 -l "Set Smooth Bind Options" -c asSetSmoothBindOptions; setParent..; setParent..; setParent..; setParent..; frameLayout -cll 1 -cl 1 -cc asFL -ec asFL -l " Deform (option2)" asBodyDeform2FrameLayout; columnLayout -adj 1; text -l "SkinCage:"; separator -st none -h 5; rowLayout -nc 4 -cw4 60 100 64 15; text -l "Cage:"; button -w 60 -l "Create" -c asCreateSkinCage; button -w 60 -l "Delete" -c asDeleteSkinCage; button -w 11 -l "?" -c "asHelpImage asDeformSkinCage"; setParent..; separator -st "none"; rowLayout -nc 4 -cw4 60 100 64 15; text -l "Mirror:"; button -w 60 -l "Left>Right" -c "asMirrorControlCurves 1 SkinCageCurvesSet"; button -w 60 -l "Right>Left" -c "asMirrorControlCurves 0 SkinCageCurvesSet"; button -w 11 -l "?" -c "asHelpImage asDeformSkinCageMirror"; setParent..; separator -h 5 -st "none"; rowLayout -nc 2 -cw2 70 100; separator; text -l "Select objects to deform, then:"; setParent..; columnLayout; rowLayout -nc 3 -cw3 60 165 15; separator; button -w 162 -l "Copy weights" -c asCopySkin; button -w 11 -l "?" -c "asHelpImage asDeformSkinCageCopyWeights"; setParent..; setParent..; separator -h 10 -st none; rowLayout -nc 4 -cw4 60 165 64 15; text -l "Adjust:"; button -w 162 -l "\"DeformationWidth\"" -c asSkinCurvesToWidth; button -w 11 -l "?" -c "asHelpImage asDeformSkinCageDWidth"; setParent..; rowLayout -nc 3 -cw3 60 165 15; separator; button -w 162 -l " Create Groin Locators" -c asCreateGroinLocators; button -w 11 -l "?" -c "asHelpImage asDeformSkinCageCreateGroinLocators"; setParent..; rowLayout -nc 3 -cw3 60 165 15; separator; button -w 162 -l " Adjust Groin area" -c asAdjustGroinArea; button -w 11 -l "?" -c "asHelpImage asDeformSkinCageAdjustGroinArea"; setParent..; separator -h 10 -st none; rowLayout -nc 4 -cw4 60 100 64 15; text -l "Sliders:"; button -w 60 -l "Create" -c asCreateSliders; button -w 60 -l "Delete" -c asDeleteSliders; button -w 11 -l "?" -c "asHelpImage asDeformSkinCageSliders"; setParent..; rowLayout -nc 3 -cw3 60 166 15; separator -st "none"; button -w 162 -l "Delete SkinCurves" -c asDeleteSkinCurves; button -w 11 -l "?" -c "asHelpImage asDeformSkinCageDeleteCurves"; setParent..; setParent..; setParent..; frameLayout -cll 1 -cl 1 -cc asFL -ec asFL -l " Deform (option3)" asBodyDeform3FrameLayout; columnLayout -adj 1; text -l "SubWrap:"; separator -st none -h 5; rowLayout -nc 4 -cw4 60 100 64 15; text -l "Cage:"; button -w 60 -l "Create" -c asCreateSkinSub; button -w 60 -l "Delete" -c asDeleteSkinSub; button -w 11 -l "?" -c "asHelpImage asDeformSubWrapCage"; setParent..; separator -h 5 -st none; rowLayout -nc 3 -cw3 60 166 15; separator -st "none"; text -l "Select objects to deform, then:"; setParent..; rowLayout -nc 3 -cw3 60 166 15; separator -st "none"; button -w 162 -l "Wrap selected mesh" -c asWrapSkin; button -w 11 -l "?" -c "asHelpImage asDeformSubWrapWrap"; setParent..; separator; rowLayout -nc 4 -cw4 60 100 64 15; separator; button -w 60 -l "Detach" -c asSkinSubDetach; button -w 60 -l "Attach" -c asSkinSubAttach; button -w 11 -l "?" -c "asHelpImage asDeformSubWrapAttach"; setParent..; rowLayout -nc 3 -cw3 60 166 15; separator -st "none"; button -w 162 -l "Exclude selected vertices" -c asWrapExlude; button -w 11 -l "?" -c "asHelpImage asDeformSubWrapExlude"; setParent..; setParent..; setParent..; frameLayout -cll 1 -cl 1 -cc asFL -ec asFL -l " Deform (option4)" asBodyDeform4FrameLayout; columnLayout -adj 1; text -l "SkinLoops:"; rowLayout -nc 2 -cw2 60 100; separator; text -l "Select EdgeLoop + FK control, then"; setParent..; rowLayout -nc 2 -cw2 120 100; separator; checkBox -v 1 -l "mirror" asCreateSkinLoopCheckBox; setParent..; rowLayout -nc 3 -cw3 60 166 15; separator; button -w 162 -l "Create New SkinLoop" -c "asCreateSkinLoop 0"; button -w 11 -l "?" -c "asHelpImage asDeformSkinLoopsCreate"; setParent..; rowLayout -nc 3 -cw3 60 166 15; separator; button -w 162 -l "Select All SkinLoops" -c asSelectAllSkinLoops; button -w 11 -l "?" -c "asHelpImage asDeformSkinLoopsSelectAll"; setParent..; separator -w 242 -h 15; rowLayout -nc 2 -cw2 60 100; separator; text -l "Select objects to deform, then:"; setParent..; rowLayout -nc 3 -cw3 60 166 15; separator; button -w 162 -l "Bind" -c "asBindSkinLoops 0"; button -w 11 -l "?" -c "asHelpImage asDeformSkinLoopsBind"; setParent..; separator -w 242 -h 15; rowLayout -nc 2 -cw2 60 100; separator; text -l "For cloth over skin, copy weighs.\nSelect cloth, then:"; setParent..; rowLayout -nc 3 -cw3 60 166 15; separator; button -w 162 -l "Copy" -c "asCopySkinLoopWeights"; button -w 11 -l "?" -c "asHelpImage asDeformSkinLoopsCopy"; setParent..; separator -w 242 -h 15; rowLayout -nc 2 -cw2 60 100; separator; text -l "Select objects to CutUp, then:"; setParent..; rowLayout -nc 4 -cw4 60 100 64 15; text -l "CutUp:"; button -w 60 -l "Create" -c "asBindSkinLoops 1"; button -w 60 -l "Delete" -c asDeleteCutUp; button -w 11 -l "?" -c "asHelpImage asDeformSkinLoopsCutUp"; setParent..; separator -w 242 -h 5; setParent..; setParent..; frameLayout -cll 1 -cl 1 -cc asFL -ec asFL -l " Deform (DeltaMush)" asBodyDeformDeltaMushFrameLayout; columnLayout -adj 1; text -l "Delta-Mush:"; rowLayout -nc 2 -cw2 70 100; separator; text -l "Select skinned objects, then:"; setParent..; columnLayout; rowLayout -nc 3 -cw3 60 165 15; separator; button -w 162 -l "Harden weights" -c asHardenWeights; button -w 11 -l "?" -c "asHelpImage asDeformDeltaMushHarden"; setParent..; rowLayout -nc 3 -cw3 60 165 15; separator; button -w 162 -l "Apply Delta Mush" -c asApplyDeltaMush; button -w 11 -l "?" -c "asHelpImage asDeformDeltaMushApply"; setParent..; if (`asMayaVersionAsFloat`>=2016) { rowLayout -nc 3 -cw3 80 165 15; separator; checkBox -l "use wbDeltaMush" wbDeltaMush; setParent..; } rowLayout -nc 3 -cw3 80 165 15; separator; text -l "Plugin by: Webber Huang\n"; setParent..; setParent..; setParent..; setParent..; frameLayout -cll 1 -cl 1 -cc asFL -ec asFL -l " Geometry (Skeleton)" asBodyGeometrySkeletonFrameLayout; columnLayout -adj 1; rowLayout -nc 4 -cw4 60 100 64 15; separator; button -w 60 -l "Create" -c asCreateSkeleton; button -w 60 -l "Delete" -c asDeleteSkeleton; button -w 11 -l "?" -c "asHelpImage asGeometrySkeletonCreate"; setParent..; rowLayout -nc 4 -cw4 60 100 64 15; text -l "Mirror:"; button -w 60 -l "Left>Right" -c "asMirrorGeometry Skeleton 1"; button -w 60 -l "Right>Left" -c "asMirrorGeometry Skeleton 0"; button -w 11 -l "?" -c "asHelpImage asGeometrySkeletonMirror"; setParent..; setParent..; setParent..; frameLayout -cll 1 -cl 1 -cc asFL -ec asFL -l " Geometry (Muscular)" asBodyGeometryMuscularFrameLayout; columnLayout -adj 1; text -l "Make sure to create Skeleton first."; separator -st none -h 5; rowLayout -nc 4 -cw4 60 100 64 15; text -l "Muscular:"; button -w 60 -l "Create" -c asCreateMuscular; button -w 60 -l "Delete" -c asDeleteMuscular; button -w 11 -l "?" -c "asHelpImage asGeometryMuscularCreate"; setParent..; setParent..; setParent..; frameLayout -cll 1 -cl 1 -cc asFL -ec asFL -l " Geometry (PolyBoxes)" asBodyGeometryPolyBoxesFrameLayout; columnLayout -adj 1; rowLayout -nc 4 -cw4 60 100 64 15; separator; button -w 60 -l "Create" -c asCreatePolyBoxes; button -w 60 -l "Delete" -c asDeletePolyBoxes; button -w 11 -l "?" -c "asHelpImage asGeometryPolyBoxesCreate"; setParent..; rowLayout -nc 4 -cw4 60 100 64 15; text -l "Mirror:"; button -w 60 -l "Left>Right" -c "asMirrorGeometry Boxes 1"; button -w 60 -l "Right>Left" -c "asMirrorGeometry Boxes 0"; button -w 11 -l "?" -c "asHelpImage asGeometryPolyBoxesMirror"; setParent..; separator -h 10; rowLayout -nc 4 -cw4 60 100 64 15; text -l "Boolean:"; button -w 60 -l "Create" -c asCreateBoolean; button -w 60 -l "Delete" -c asDeleteBoolean; button -w 11 -l "?" -c "asHelpImage asGeometryPolyBoxesBoolean"; setParent..; rowLayout -nc 4 -cw4 60 100 64 15; text -l "Warp:"; button -w 60 -l "Create" -c asCreateWarp; button -w 60 -l "Delete" -c asDeleteWarp; button -w 11 -l "?" -c "asHelpImage asGeometryPolyBoxesWarp"; setParent..; setParent..; setParent..; frameLayout -cll 1 -cl 1 -cc asFL -ec asFL -l " Geometry (Mannequin)" asBodyGeometryMannequinFrameLayout; columnLayout -adj 1; rowLayout -nc 4 -cw4 60 100 64 15; separator; button -w 60 -l "Create" -c asCreateMannequin; button -w 60 -l "Delete" -c asDeleteMannequin; button -w 11 -l "?" -c "asHelpImage asGeometryMannequinCreate"; setParent..; setParent..; setParent..; frameLayout -m 1 -cll 1 -cl 1 -cc asFL -ec asFL -l " Geometry (Retopology)" asBodyGeometryRetopologyFrameLayout; columnLayout -adj 1; text -l "Make sure to create SkinCage or SkinSub first."; separator -st none -h 5; rowLayout -nc 2 -cw2 70 100; separator; text -l "Select Hi-res model, then:"; setParent..; rowLayout -nc 4 -cw4 60 100 64 15; text -l "Retopo:"; button -w 60 -l "Create" -c asCreateRetopo; button -w 60 -l "Delete" -c asDeleteRetopo; button -w 11 -l "?" -c "asHelpImage asGeometryRetopoCreate"; setParent..; separator -st none -h 5; rowLayout -nc 2 -cw2 70 100; separator; text -l "Make any tweaks needed, then:"; setParent..; rowLayout -nc 4 -cw4 60 30 134 15; separator; separator; button -w 100 -l "Update selected" -c asUpdateRetopo; button -w 11 -l "?" -c "asHelpImage asGeometryRetopoUpdate"; setParent..; rowLayout -nc 4 -cw4 60 100 64 15; text -l "Mirror:"; button -w 60 -l "Left>Right" -c "asMirrorRetopo 1"; button -w 60 -l "Right>Left" -c "asMirrorRetopo 0"; button -w 11 -l "?" -c "asHelpImage asGeometryRetopoMirror"; setParent..; rowLayout -nc 4 -cw4 60 30 134 15; separator; separator; button -w 100 -l "Normal Map" -c asNormalMapRetopo; button -w 11 -l "?" -c "asHelpImage asGeometryRetopoNormalMap"; setParent..; rowLayout -nc 4 -cw4 60 100 64 15; text -l "Bind:"; button -w 60 -l "Bind" -c asBindRetopo; button -w 60 -l "UnBind" -c asUnBindRetopo; button -w 11 -l "?" -c "asHelpImage asGeometryRetopoBind"; setParent..; separator -h 15; rowLayout -nc 2 -cw2 130 100; separator -st none; text -h 20 -l "Face:"; setParent..; rowLayout -nc 2 -cw2 90 100; separator -st none; optionMenu asCreateFaceRetopoOptionMenu; setParent..; rowLayout -nc 4 -cw4 60 100 64 15; // text -l "Guides:"; separator -st none; button -w 60 -l "Create" -c asCreateFaceRetopo; button -w 60 -l "Delete" -c "asDeleteFaceRetopo 0"; button -w 11 -l "?" -c "asHelpImage asGeometryFaceRetopoCreate"; setParent..; rowLayout -nc 2 -cw2 70 100; separator; text -l "Make any tweaks needed, then:"; setParent..; separator -h 5 -st none; rowLayout -nc 4 -cw4 60 30 134 15; separator; separator; button -w 100 -l "Match guides" -c asMatchGuidesFaceRetopo; button -w 11 -l "?" -c "asHelpImage asGeometryFaceRetopoMatch"; setParent..; rowLayout -nc 2 -cw2 70 100; separator; text -l "Tweak further if needed."; setParent..; rowLayout -nc 4 -cw4 60 30 134 15; separator; separator; button -w 100 -l "Connect Body" -c asConnectBodyFaceRetopo; button -w 11 -l "?" -c "asHelpImage asGeometryFaceRetopoConnect"; setParent..; separator -h 10 -st none; rowLayout -nc 2 -cw2 90 100; text -l "Eyes:"; optionMenu asCreateFaceRetopoEyeBallOptionMenu; setParent..; rowLayout -nc 4 -cw4 60 100 64 15; separator -st none; button -w 60 -l "Create" -c asCreateEyesFaceRetopo; button -w 60 -l "Delete" -c "delete headTopologyEyes"; button -w 11 -l "?" -c "asHelpImage asGeometryFaceRetopoEyesCreate"; setParent..; rowLayout -nc 4 -cw4 60 30 134 15; separator; separator; button -w 100 -l "bind eyes" -c asBindEyesFaceRetopo; button -w 11 -l "?" -c "asHelpImage asGeometryFaceRetopoEyesBind"; setParent..; separator -h 10 -st none; rowLayout -nc 2 -cw2 90 100; text -l "Teeth:"; optionMenu asCreateFaceRetopoTeethOptionMenu; setParent..; rowLayout -nc 4 -cw4 60 100 64 15; separator -st none; button -w 60 -l "Create" -c asCreateTeethFaceRetopo; button -w 60 -l "Delete" -c "delete headTopologyTeeth"; button -w 11 -l "?" -c "asHelpImage asGeometryFaceRetopoTeethCreate"; setParent..; rowLayout -nc 4 -cw4 60 30 134 15; separator; separator; button -w 100 -l "bind teeth" -c asBindTeethFaceRetopo; button -w 11 -l "?" -c "asHelpImage asGeometryFaceRetopoTeethBind"; setParent..; separator -h 10 -st none; rowLayout -nc 4 -cw4 60 30 134 15; separator; separator; button -w 100 -l "Face rig prep" -c asFaceRigPrepRetopo; button -w 11 -l "?" -c "asHelpImage asGeometryFaceRetopoPrep"; setParent..; separator -h 5 -st none; text -l "You can now now Build Face Setup"; setParent..; setParent..; frameLayout -cll 1 -cl 1 -cc asFL -ec asFL -l " Custom Controllers" asBodyCustomControlsFrameLayout; // Runs the CustomControllers Twice, once for Body, and once for Face setParent..; frameLayout -cll 1 -cl 1 -cc asFL -ec asFL -l " Motion System" asBodyMotionSystemFrameLayout; columnLayout -adj 1; rowLayout -nc 2; separator -w 25 -st none; columnLayout; rowLayout -nc 2 -cw2 198 15; button -w 190 -l "Delete MotionSystem" -c asDeleteMotionSystem; button -w 11 -l "?" -c "asHelpImage asDeleteMotionSystem"; setParent..; separator -h 5 -st none; rowLayout -nc 2 -cw2 198 15; button -w 190 -l "Create HumanIK" -c asCreateHumanIK; button -w 11 -l "?" -c "asHelpImage asCreateHuamIK"; setParent..; separator -h 5 -st none; rowLayout -nc 2 -cw2 198 15; button -w 190 -l "Delete HumanIK" -c asDeleteHumanIK; setParent..; setParent..; setParent..; setParent..; setParent..; frameLayout -cll 1 -cl 1 -cc asFL -ec asFL -l " Control Curves" asBodyControlCurvesFrameLayout; columnLayout -adj 1; rowLayout -nc 4 -cw4 60 100 64 15; text -l "Mirror:"; button -w 60 -l "Left>Right" -c "asMirrorControlCurves 1 ControlSet"; button -w 60 -l "Right>Left" -c "asMirrorControlCurves 0 ControlSet"; button -w 11 -l "?" -c "asHelpImage asControlCurvesMirror"; setParent..; separator -h 10; rowLayout -nc 4 -cw4 60 100 64 15; text -l "Scale:"; floatField -v 1 -ann "set scale-factor" ScaleCCFloatField; button -w 60 -l "Scale" -c "asScaleControlCurves"; button -w 11 -l "?" -c "asHelpImage asControlCurvesScale"; setParent..; separator -h 10; rowLayout -nc 2 -cw2 60 100; text -l "Swap:"; text -l "First select Control(s) to replace,"; setParent..; rowLayout -nc 2 -cw2 60 100; separator; text -l "Then select (add) any custom curve,"; setParent..; rowLayout -nc 2 -cw2 60 100; separator; text -l "Then:"; setParent..; rowLayout -nc 4 -cw4 60 100 64 15; separator -st "none"; button -w 162 -l "Swap Curve" -c asSwapCurve; button -w 11 -l "?" -c "asHelpImage asControlCurvesSwap"; setParent..; separator -h 10; rowLayout -nc 2 -cw2 60 100; text -l "Color:"; int $cellHeight = 17, $cellWidth = 10; int $rows = 2, $columns = 16; palettePort -w ($columns * $cellWidth) -h ($rows * $cellHeight) -dim $columns $rows -ced 0 -td 1 asCurveColorPalettePort; float $colorComponentArray[]; palettePort -edit -rgbValue 0 0 0 0 asCurveColorPalettePort; for ($index = 1; $index <= 31; $index++) { $colorComponentArray = `colorIndex -query $index`; palettePort -edit -rgbValue $index $colorComponentArray[0] $colorComponentArray[1] $colorComponentArray[2] asCurveColorPalettePort; } if (`asMayaVersionAsFloat`>=2014) palettePort -e -ced 1 asCurveColorPalettePort; setParent..; rowLayout -nc 3 -cw3 60 90 50; separator; optionMenu asCurveColorTypeOptionMenu; menuItem -l "FK"; menuItem -l "IK"; menuItem -l "FKIK"; menuItem -l "Bend"; menuItem -l "Selected"; menuItem -l "*All"; menuItem -l "Face:A"; menuItem -l "Face:B"; menuItem -l "Face:C"; menuItem -l "Face:Aim"; menuItem -l "Face:Teeth"; menuItem -l "Face:Tongue"; menuItem -l "Face:Region"; menuItem -l "Face:Squash"; menuItem -l "Face:Custom"; optionMenu asCurveColorSideOptionMenu; menuItem -l "Right"; menuItem -l "Left"; menuItem -l "Middle"; menuItem -l "*All"; setParent..; rowLayout -nc 4 -cw4 60 100 64 15; separator -st "none"; button -w 162 -l "Set Color" -c asSetCurveColor; button -w 11 -l "?" -c "asHelpImage asControlCurvesColor"; setParent..; separator -h 10; rowLayout -nc 2 -cw2 60 100; text -l "Re-use:"; text -l "This will print in ScriptEditor:"; setParent..; rowLayout -nc 2 -cw2 60 100; separator; columnLayout; text -l "commands to set control curves to"; text -l "current shapes and colors."; button -w 162 -l "Script Editor" -c "ScriptEditor;"; button -w 162 -l "Clear History" -c "scriptEditorInfo -clearHistory"; rowLayout -nc 3; checkBox -l "shape" -v 1 asControlCurvesReUseShapeCheckBox; checkBox -l "color" -v 1 asControlCurvesReUseColorCheckBox; checkBox -l "`catch`" asControlCurvesReUseCatchCheckBox; setParent..; checkBox -l "SkinCurves" asControlCurvesReUseSkinCurvesCheckBox; checkBox -l "Face" asControlCurvesReUseFaceCheckBox; button -w 162 -l "Print Commands" -c asControlCurvesPrintInfo; setParent..; setParent..; setParent..; setParent..; frameLayout -cll 1 -cl 1 -cc asFL -ec asFL -l " Control Mesh" asBodyControlMeshFrameLayout; columnLayout -adj 1; rowLayout -nc 2 -cw2 60 100; columnLayout -adj 0; text -l "Create:"; setParent..; columnLayout -adj 0; text -l "First select the poly-faces to use"; text -l "Then select (add) the control,"; text -l "Then:"; checkBox -v 1 -l "mirror" asCreateControlMeshMirrorCheckBox; rowLayout -nc 3 -cw3 100 64 15; button -w 162 -l "Create ControlMesh" -c asCreateControlMesh; button -w 11 -l "?" -c "asHelpImage asControlMeshCreate"; setParent..; separator -h 5; text -l "Or, select mesh and auto-create"; rowLayout -nc 3 -cw3 100 64 15; button -w 162 -l "Create ControlMeshes" -c asCreateControlMeshes; button -w 11 -l "?" -c "asHelpImage asControlMeshesCreate"; setParent..; separator -h 5; text -l "IK controls & driving-systems"; rowLayout -nc 3 -cw3 100 64 15; button -w 162 -l "Create IK ControlMeshes" -c asCreateIKControlMeshes; button -w 11 -l "?" -c "asHelpImage asControlMeshesCreateIK"; setParent..; setParent..; setParent..; separator -h 10; rowLayout -nc 2 -cw2 60 100; columnLayout -adj 0; text -l "Delete:"; setParent..; columnLayout -adj 0; button -w 162 -l "Delete Selected" -c asDeleteControlMesh; separator -h 5; button -w 162 -l "Delete All" -c asDeleteAllControlMesh; setParent..; setParent..; setParent..; setParent..; frameLayout -cll 1 -cl 1 -cc asFL -ec asFL -l " Game Engine" asBodyGameEngineFrameLayout; columnLayout -adj 0; text -l "GameEngine scale behaviour: (for Unity)"; rowLayout -nc 4 -cw4 60 100 64 15; separator; button -w 60 -l "Enable" -c "asGameEngineScaling 1"; button -w 60 -l "Disable" -c "asGameEngineScaling 0"; button -w 11 -l "?" -c "asHelpImage asGameEngineScaleBehaviour"; setParent..; separator -h 10 -st none; text -l "Custom oriented GameSkeleton:"; rowLayout -nc 4 -cw4 60 100 64 15; separator; columnLayout; optionMenu -l "Space:" asCustomOrientJointsSpaceOptionMenu; menuItem -l "Local"; menuItem -l "World"; optionMenu -l "FrontAxis:" asCustomOrientJointsFrontOptionMenu; for ($z=0;$z0) continue; // if ($req[$c]) // menuItem -l ($sections[$c]+$parts[$a]) -p asFaceReqFitElementsOptionMenu; $checkValue=`objExists ("FaceFit"+$sections[$c]+$parts[$a])`; rowLayout -nc 7; button -w 100 -l ($sections[$c]+$parts[$a]) -c ("asCreateFaceFit "+$sections[$c]+" \""+$parts[$a]+"\" "+$upAndLo[$c]+" "+$mainAndOuter[$c]+" "+$isSphere[$c]+" \""+$shadingGroup[$c]+"\""); popupMenu; menuItem -l "re-select" -c ("asFaceFitReSelect "+$sections[$c]+" \""+$parts[$a]+"\"");//since $parts can be blank separator -w 5 -st none; checkBox -l "" -w 20 -ed $checkValue -v $checkValue -ofc ("asFaceDeleteFromCheckBox "+$sections[$c]+$parts[$a]) ("asFaceFit"+$sections[$c]+$parts[$a]); button -w 15 -l "?" -c ("asHelpImage fitFace"+$sections[$c]+$parts[$a]); if ($parts[$a]=="Inner") button -w 35 -l "assist" -c ("asFaceAssist "+$sections[$c]); else separator -w 35 -st none; if ($hideable || (($sections[$c]=="EyeLid" || $sections[$c]=="Lip") && $parts[$a]=="Inner")) button -l "hide" -c ("asFaceFitHide \""+$sections[$c]+"\" \""+$parts[$a]+"\""); setParent..; } } setParent..; setParent..; separator -h 7 -st none; setParent asFaceColumnLayout; frameLayout -cll 1 -cl 1 -cc asFL -ec asFL -l " Build" asFaceBuildFrameLayout; columnLayout -adj 1; rowLayout -nc 4; separator -w 28 -st none; button -m 0 -w 60 -l "Delete Adv" -c asDeleteAdvancedFace asDelteAdvFaceButton; separator -w 15 -st none; checkBox -m 0 -l "Keep All" -v 1 -onc "columnLayout -e -m 0 asFaceKeepColumnLayout" -ofc "columnLayout -e -m 1 asFaceKeepColumnLayout" asFaceKeepAllCheckBox; setParent..; columnLayout -m 0 asFaceKeepColumnLayout; rowLayout -nc 2 -cw2 5 100; separator -st none; columnLayout; checkBox -v 1 -l "keep Skin weights" asFaceKeepSkinWeightsCheckBox; checkBox -v 1 -l "keep HeadSquash" asFaceKeepHeadSquashCheckBox; checkBox -v 1 -l "keep DrivingSystems" asFaceKeepDrivingSystemsCheckBox; checkBox -v 0 -en 0 -l "keep BlendShapes" asFaceKeepBlendShapesCheckBox;//not yet available checkBox -v 1 -l "keep CorrectiveShapes" asFaceKeepCorrectiveShapesCheckBox;//not yet available checkBox -v 1 -l "keep custom control shape and color" asFaceKeepCurveShapesCheckBox; setParent..; setParent..; setParent..; rowLayout -nc 4 -cw4 5 85 20 100; separator -w 5 -st none; button -l "Toggle Fit/Adv" -c asToggleFitFace asToggleFitFaceButton; separator -w 20 -st none; button -l "Build AdvancedFace" -c asBuildAdvancedFace asBuildAdvancedFaceButton; setParent..; setParent..; setParent..; string $stepBuildText[]; $stepBuildText[size($stepBuildText)]=""; $stepBuildText[size($stepBuildText)]="Prep"; $stepBuildText[size($stepBuildText)]="CtrlBox"; $stepBuildText[size($stepBuildText)]="EyeBall"; $stepBuildText[size($stepBuildText)]="EyeLid"; $stepBuildText[size($stepBuildText)]="EyeBlink"; $stepBuildText[size($stepBuildText)]="EyeBrow"; // $stepBuildText[size($stepBuildText)]="LidBase"; $stepBuildText[size($stepBuildText)]="Squint"; $stepBuildText[size($stepBuildText)]="Lip"; $stepBuildText[size($stepBuildText)]="LipFalloff"; $stepBuildText[size($stepBuildText)]="LipCorner"; // $stepBuildText[size($stepBuildText)]="SmileLine"; $stepBuildText[size($stepBuildText)]="SmilePull"; $stepBuildText[size($stepBuildText)]="FrownPull"; $stepBuildText[size($stepBuildText)]="NarrowPull"; $stepBuildText[size($stepBuildText)]="Cheek"; $stepBuildText[size($stepBuildText)]="CheekRaiser"; $stepBuildText[size($stepBuildText)]="JawWeighing"; $stepBuildText[size($stepBuildText)]="JawOpen"; $stepBuildText[size($stepBuildText)]="Nose"; $stepBuildText[size($stepBuildText)]="Snarl"; $stepBuildText[size($stepBuildText)]="Tongue"; $stepBuildText[size($stepBuildText)]="Regions"; $stepBuildText[size($stepBuildText)]="EyeAim"; $stepBuildText[size($stepBuildText)]="UpMidLo"; $stepBuildText[size($stepBuildText)]="Phonemes"; $stepBuildText[size($stepBuildText)]="Emotions"; $stepBuildText[size($stepBuildText)]="Finish"; $stepBuildText[size($stepBuildText)]="RebuildRestore"; setParent asFaceColumnLayout; frameLayout -cll 1 -cl 1 -cc asFL -ec asFL -l " Build ..." asFaceStepBuildFrameLayout; columnLayout -adj 0 asStepBuildColumnLayout; separator -h 5; columnLayout ("asStepBuildColumnLayout0"); text -l "Step Builder:"; text -fn $boldFont -l "Use this section if normal Build had errors,"; text -fn $boldFont -l "or to modify the build result."; separator -h 5; rowLayout -nc 2 -cw2 159 80 ("asStepBuildRowLayout0"); setParent..; setParent..; for ($i=1;$i=2012) { rowLayout -nc 4 -cw4 60 50 70 100; text -l " Window:"; button -c "asDockWindow 1" -l " Dock "; button -c "asDockWindow 0" -l " UnDock "; button -c asCreateWorkspaceControl -l "Workspace" asWorkspaceButton; if (`asMayaVersionAsFloat`<2017) button -e -en 0 -ann "Workspace-controller requires Maya2017 or higher" asWorkspaceButton; setParent..; } separator -h 15; rowLayout -nc 5 -cw5 110 40 30 54 15; button -l "Check For Updates" -c asCheckForUpdates; text -l "found:"; text -m 1 -l "x.xxx" asUpdateFoundVersion; button -en 0 -l "Update" -c asUpdateVersion asUpdateVersionButton; button -w 11 -l "?" -c "asHelpImage asAboutUpdate"; setParent..; checkBox -m 0 -v 0 asBetaCheckBox; separator -h 15; rowLayout -nc 3 -cw3 80 158 15; text -l "current version:"; button -l `asGetScriptVersionAsString` -c "print \"// right click on button to change version.\\n\""; popupMenu asVersionsPopupMenu; button -w 11 -l "?" -c "asHelpImage asAboutCurrentVersion"; setParent..; separator -h 5; rowLayout -nc 3 -cw3 80 158 15; text -l "version history:"; button -l "download version history info" -c asVersionHistory; setParent..; separator -h 5; columnLayout -adj 0; text -l "For support, go to:\nwww.facebook.com/AdvancedSkeleton\nOr email: support@animationstudios.com.au\n\nFor license information, read the eula.txt file."; /* //Help section setParent asColumnLayout; frameLayout -w 270 -cll 1 -cl 0 -cc asFL -ec asFL -l "Help"; columnLayout -adj 1; text -al left -l ("" +"The main help information are the help-images.\n" +"These can opened by clicking on the ? buttons\n" +"(question-mark buttons)\n" +"that next to each of the functions in the UI"); separator -st none -h 5; text -al left -l "Also wathing the tutorial videos can be helpful:"; button -l "visit AdvancedSkeleton on YouTube" -c "showHelp -a \"https://www.youtube.com/user/AdvancedSkeleton/videos\""; separator -st none -h 5; text -al left -l "FaceBook:"; button -l "visit AdvancedSkeleton on FaceBook" -c "showHelp -a \"https://www.facebook.com/AdvancedSkeleton/\""; separator -st none -h 5; text -al left -l ("" +"If you have encoutered a Error,\n" +"feel free to email us at:\n" +"support@animationstudios.com.au\n" +"And if you have receive a reply,\n" +"asking to send your file\n" +"You can do that with this button\n"); button -l "Email MayaFile to support"; */ setParent asFormLayout; rowLayout -nc 2 -cw2 120 100 asRowLayout; columnLayout; rowLayout -nc 5 -cw5 30 90 10 30 90; text -l "body:" asBodyText; button -c "asGoToBuildPose bodySetup" -l "Go to Build Pose"; popupMenu; menuItem -l "set build pose" -c "asSetBuildPose bodySetup"; separator -w 10 -st none; text -l "face:" asFaceText; button -c "asGoToBuildPose faceSetup" -l "Go to Build Pose" asGoToBuildPoseFaceButton; popupMenu; menuItem -l "set build pose" -c "asSetBuildPose faceSetup"; setParent..; setParent..; formLayout -e -af asScrollLayout "right" 0 -af asScrollLayout "left" 0 -af asScrollLayout "top" 0 -ac asScrollLayout "bottom" 0 asRowLayout -af asRowLayout "bottom" 0 asFormLayout; if (!`control -q -ex asWorkspaceControl`) { if($asDock) { if (`asMayaVersionAsFloat`>=2012) dockControl -l AdvancedSkeleton -w 288 -fl 0 -floatChangeCommand asDockWindowChangeFloatingState -a "left" -con AdvancedSkeletonWindow -aa "left" -aa "right" AdvancedSkeletonDockControl; else dockControl -l AdvancedSkeleton -w 288 -fl 0 -a "left" -con AdvancedSkeletonWindow -aa "left" -aa "right" AdvancedSkeletonDockControl; if (`asMayaVersionAsFloat`>=2016) { //force left docking area to be matching size, as it might be bigger, if a crash-report has auto-docked dockControl -e -fixedWidth 1 AdvancedSkeletonDockControl; refresh; dockControl -e -fixedWidth 0 AdvancedSkeletonDockControl; } evalDeferred "dockControl -e -r AdvancedSkeletonDockControl;"; } else showWindow; } asUpdateLabelHelp; asUpdateAttributeHelp; asEnsureFitSkeletonAttributes; asUpdateButtonEnables; if (`window -q -ex AdvancedSkeletonWindow`) { window -e -w 296 AdvancedSkeletonWindow; if (`asMayaVersionAsFloat`<2012) window -e -w 309 AdvancedSkeletonWindow; if (!`windowPref -q -ex AdvancedSkeletonWindow`) window -e -h 500 AdvancedSkeletonWindow; } if ($asFaceIsResetting) $asFaceIsResetting=0; else asFaceUpdateInfo 1; //update UI from optionVars string $framLayouts[]=`lsUI -type frameLayout`; for ($i=0;$i-1;$i--) { if ($i==size($oldVersions)) { $label=`asGetLatestLocalVersionAsString`; $latestLocal=1; } else { $label=$oldVersions[$i]; $latestLocal=0; } $label=`substitute "AdvancedSkeleton_v" $label ""`; menuItem -l $label -c ("asSourceVersion \""+$label+"\" "+$latestLocal); } //Maya less than2012 limitations if (`asMayaVersionAsFloat`<2012) { string $childArray[]=`columnLayout -q -ca asFaceColumnLayout`; for ($i=0;$i 0 ) { $lineNr++; $nextLine = `fgetline $fileId`; if (`gmatch $nextLine "*Version*"`) { tokenize $nextLine $tempString; tokenize $tempString[2] "[.]" $tempString; for ($i=0;$i10) break; } fclose $fileId; } else warning "Unable to determine AdvancedSkeleton version number"; return $versionString; } global proc asSourceVersion (string $versionAsString, int $latestLocal) { global string $gShelfTopLevel; int $sucess; string $buttons[]; string $asFile,$iol,$image; string $latestLocalScriptLocation=`asGetLatestLocalScriptLocation`; if ($latestLocal) $asFile=$latestLocalScriptLocation+"/AdvancedSkeleton5.mel"; else { $asFile=$latestLocalScriptLocation+"/AdvancedSkeleton5Files/oldVersions/AdvancedSkeleton_v"+$versionAsString+"/AdvancedSkeleton5.mel"; $iol=$versionAsString; if (!`file -q -ex $asFile`) { warning ("attempted to source version: "+$versionAsString+", but could not find file:\""+$asFile+"\", so using latest installed version instead"); optionVar -iv asUseVersionLatestLocal 1; return; } } string $cmd="source \""+$asFile+"\";AdvancedSkeleton5;"; string $shelves[]=`tabLayout -q -ca $gShelfTopLevel`; for ($i=0;$i>`; if ($dist<$minDist) { $nearestJoint=$tempString[$y]; $minDist=$dist; } } setAttr ($nearestJoint+".drawLabel") 1; setAttr ($nearestJoint+".type") 18; setAttr -type "string" ($nearestJoint+".otherType") $labels[$i]; } asReLockAttrs $startJoint $startJointLocks; asReLockAttrs $endJoint $endJointLocks; asFitModeUpdateJoints $endJoint 0; delete tempIKCurve; if (`checkBox -q -ex asLockCenterJoints`) if (`checkBox -q -v asLockCenterJoints`) asFitModeLockCenterJoints; print ("// Joints Resampled\n"); catchQuiet (`select $sel`); } global proc int[] asUnLockAttrs (string $obj) { int $lockedAttrs[]; string $trs[]={"t","r","s"}; string $xyz[]={"x","y","z"}; for ($y=0;$y1) error ("More than one object matches name: "+$obj+"\n"); if (!`objExists $obj`) return "AA"; if (!`attributeExists "type" $obj`) return "BB"; int $labelNum=`getAttr ($obj+".type")`; if (!`getAttr ($obj+".drawLabel")`) return ""; $label=`asLabelCodeLookup $labelNum 0`; if ($labelNum==18) { $label=`getAttr ($obj+".otherType")`; } return $label; } global proc int asComponentToNr (string $component) { int $nr; string $tempString[]; tokenize $component "[" $tempString; tokenize $tempString[1] "]" $tempString; $nr=$tempString[0]; return $nr; } global proc asAddFitJointAttribute () { string $attr=`optionMenu -q -v asAttributeType`; string $sel[]=`ls -sl`; float $dv=1; string $meshObject,$curveObject; string $tempString[]; for ($i=0;$i5.732 $sdks=`listConnections -s 0 -d 1 -type animCurve ($tempString[0]+".output")`; //sort translate before rotate clear $sortedSdks; for ($z=0;$z1) for ($i=1;$i<99;$i++) if (!`objExists ($obj+$i)`) { $newName=$obj+$i; rename $tempString[0] $newName; break; } return $newName; } global proc asAxisChanged () { //since auto-orient is `Self-up-vectored`, in case of AsisChange, do manual re-orient here first int $numChar; int $primaryAxis=`optionMenu -q -sl asPrimaryAxisOptionMenu`-1; int $secondaryAxis=`optionMenu -q -sl asSecondaryAxisOptionMenu`-1; int $worldmatch=`checkBox -q -v asAutoOrientWorldMatchCheckBox`; int $previousPrimaryAxis=0; int $previousSecondaryAxis=1; float $rot[3]={0,0,0}; string $attr,$axis,$newAttr,$newSdk,$previousPriAxis,$previousSecAxis,$previousTerAxis,$fitJoint; string $absPriAxis,$absSecAxis,$absTerAxis,$previousAbsPriAxis,$previousAbsSecAxis,$previousAbsTerAxis; string $priAxis=`optionMenu -q -v asPrimaryAxisOptionMenu`; string $secAxis=`optionMenu -q -v asSecondaryAxisOptionMenu`; string $terAxis=`asGetTerAxis $priAxis $secAxis`; string $tempString[],$sdks[],$previousPriAxiss[],$previousSecAxiss[],$previousTerAxiss[]; string $sel[]=`ls -sl`; asEnsureFitSkeletonAttributes; if (!`objExists FitSkeleton` || !`attributeExists primaryAxis FitSkeleton` || !`attributeExists secondaryAxis FitSkeleton`) return; if ($secondaryAxis==$primaryAxis || $secondaryAxis==$primaryAxis+3 || $secondaryAxis==$primaryAxis-3) { print "// Primary and Secondary can not be the same, changing this now.\n"; if ($secondaryAxis==5) $secondaryAxis=0; else $secondaryAxis++; optionMenu -e -sl ($secondaryAxis+1) asSecondaryAxisOptionMenu; $secAxis=`optionMenu -q -v asSecondaryAxisOptionMenu`; $terAxis=`asGetTerAxis $priAxis $secAxis`; } $previousPrimaryAxis=`getAttr FitSkeleton.primaryAxis`; $previousSecondaryAxis=`getAttr FitSkeleton.secondaryAxis`; $previousPriAxis=`getAttr -asString FitSkeleton.primaryAxis`; $previousSecAxis=`getAttr -asString FitSkeleton.secondaryAxis`; $previousTerAxis=`asGetTerAxis $previousPriAxis $previousSecAxis`; $absPriAxis=`asAbsAxis $priAxis`; $absSecAxis=`asAbsAxis $secAxis`; $absTerAxis=`asAbsAxis $terAxis`; setAttr FitSkeleton.primaryAxis $primaryAxis; setAttr FitSkeleton.secondaryAxis $secondaryAxis; setAttr FitSkeleton.worldmatch $worldmatch; if ($previousPrimaryAxis==$primaryAxis && $previousSecondaryAxis==$secondaryAxis) return; //print ("Swap from: "+$previousPrimaryAxis+":"+$previousSecondaryAxis+" to "+$primaryAxis+":"+$secondaryAxis+" ("+$rot[0]+","+$rot[1]+","+$rot[2]+")\n"); if (`objExists SwappingAxisInfo`) delete SwappingAxisInfo; createNode -n SwappingAxisInfo transform; addAttr -ln primaryAxis -at "enum" -en "X:Y:Z:-X:-Y:-Z:" -dv $primaryAxis SwappingAxisInfo; addAttr -ln secondaryAxis -at "enum" -en "X:Y:Z:-X:-Y:-Z:" -dv $secondaryAxis SwappingAxisInfo; addAttr -ln previousPrimaryAxis -at "enum" -en "X:Y:Z:-X:-Y:-Z:" -dv $previousPrimaryAxis SwappingAxisInfo; addAttr -ln previousSecondaryAxis -at "enum" -en "X:Y:Z:-X:-Y:-Z:" -dv $previousSecondaryAxis SwappingAxisInfo; //If axis changed, then reBuild, Curves will not be correct as they are `attempted preserved`, so flag AxisChanged if (!`attributeExists axisChanged FitSkeleton`) addAttr -k 1 -ln axisChanged -at bool -dv 1 FitSkeleton; //get per joint PriSecTer PreviousAxis before running asFitModeManualUpdate (to get correct previousAxis when switching OFF worldOrient) if (!$worldmatch && `attributeExists drivingSystem FitSkeleton`) { $sdks=`listConnections -s 1 -d 0 -type animCurve FitSkeleton.drivingSystem`; for ($i=0;$i1) { $labelClash=1; for ($a=1;$a<99;$a++) { if (`gmatch $label "0*"`) $newLabel=$label+`asNrToLetter $a`; else $newLabel=$label+$a; if (!`stringArrayCount $newLabel $labelArray`) break; } } if ($labelClash) { setAttr ($fitJoints[$i]+".type") 18; setAttr -type "string" ($fitJoints[$i]+".otherType") $newLabel; $labelArray[size($labelArray)]=$newLabel; } } if (`attributeExists lockCenterJoints FitSkeleton`) if (`getAttr FitSkeleton.lockCenterJoints`) { $hadLockedCenterJoints=1; asFitModeLockCenterJoints; } asFitModeUpdateScale; //if (`objExists Root`) // asFitModeUpdateJoints Root 1; $tempString=`listRelatives -c -type joint FitSkeleton`; for ($i=0;$i1) // continue; $rlaParent=`asRlaParent $sel[$i]`; if (!`objExists $rlaParent`) continue; // string $parentOtherChildren[]=`listRelatives -c -type joint $rlaParent`; // $parentOtherChildren=`stringArrayRemove {$sel[$i]} $parentOtherChildren`; // if (size($parentOtherChildren) && $sel[$i]!="BackA") // continue; if (!`getAttr ($rlaParent+".displayLocalAxis")`) $asFitModeOffRLA[$i]=$rlaParent; setAttr ($rlaParent+".displayLocalAxis") 1; if ($aimParents!="") $aimParents+="@"; $aimParents+=$sel[$i]; } for ($i=0;$i$centerTolerance) continue; $tempString=`listRelatives -p -f $fitSkeletonJoints[$i]`; $parent=$tempString[0]; createNode -n transformSampler -p $parent transform; setAttr -type float3 transformSampler.t 1 0 0; $pos2=`xform -q -ws -t transformSampler`; if ($pos2[0]>0.5 || $pos2[0]<-0.5) setAttr -l 1 ($fitSkeletonJoints[$i]+".tx"); setAttr -type float3 transformSampler.t 0 1 0; $pos2=`xform -q -ws -t transformSampler`; if ($pos2[0]>0.5 || $pos2[0]<-0.5) setAttr -l 1 ($fitSkeletonJoints[$i]+".ty"); setAttr -type float3 transformSampler.t 0 0 1; $pos2=`xform -q -ws -t transformSampler`; if ($pos2[0]>0.5 || $pos2[0]<-0.5) setAttr -l 1 ($fitSkeletonJoints[$i]+".tz"); delete transformSampler; if ((`gmatch $priAxis "*X"` && `gmatch $secAxis "*Y"`) || (`gmatch $priAxis "*Y"` && `gmatch $secAxis "*X"`)) { setAttr -l 1 ($fitSkeletonJoints[$i]+".rx"); setAttr -l 1 ($fitSkeletonJoints[$i]+".ry"); } if ((`gmatch $priAxis "*X"` && `gmatch $secAxis "*Z"`) || (`gmatch $priAxis "*Z"` && `gmatch $secAxis "*X"`)) { setAttr -l 1 ($fitSkeletonJoints[$i]+".rx"); setAttr -l 1 ($fitSkeletonJoints[$i]+".rz"); } if ((`gmatch $priAxis "*Y"` && `gmatch $secAxis "*Z"`) || (`gmatch $priAxis "*Z"` && `gmatch $secAxis "*Y"`)) { setAttr -l 1 ($fitSkeletonJoints[$i]+".ry"); setAttr -l 1 ($fitSkeletonJoints[$i]+".rz"); } } select -ne $sel; } global proc asPlacementCopy () { global string $gMove; setToolTo $gMove; float $pos[]=`manipMoveContext -q -position "Move"`; button -e -en 1 -ann ($pos[0]+" "+$pos[1]+" "+$pos[2]) asPlacementPasteButton; } global proc asPlacementPaste () { int $editPivotMode=`manipMoveContext -q -editPivotMode Move`; string $sel[]=`ls -sl`; string $ann=`button -q -ann asPlacementPasteButton`; string $buffer[]; tokenize $ann $buffer; for ($i=0;$i-1;$i--) $jointsString+="@"+$tempString[$i]; } tokenize $jointsString "@" $joints; for ($joint in $joints) { if (size(`ls -ap $joint`)!=1) continue; $label=`asLabel $joint`; $rlaParent=`asRlaParent $joint`; $rlaParent=`asUniqueName $rlaParent`; $rlaParentLabel=`asLabel $rlaParent`; string $rlaChild=`asRlaChild $joint`; $rlaChild=`asUniqueName $rlaChild`; $jointChildren=`listRelatives -c -type joint $joint`; int $childNr=0; clear $rlaParentChildren; if ($rlaParent!="") { $rlaParentRlaChild=`asRlaChild $rlaParent`; $rlaParentChildren=`listRelatives -type joint -c $rlaParent`; if (size($rlaParentChildren)>1) for ($i=0;$i 5.792 if (`attributeExists worldOrientUp $rlaParent`) $worldOrientUp=`getAttr ($rlaParent+".worldOrientUp")`; $useWorldOrient=0; if ($worldOrientUp!=-1) $useWorldOrient=1; //update worldOrients if World-match if ($worldmatch && $useWorldOrient) $worldOrientUp=1; //update worldOrients if SwappingAxis, guestimate what will match with the new axis options if (`objExists SwappingAxisInfo` && $useWorldOrient) { if (($worldOrientUp==`getAttr SwappingAxisInfo.previousPrimaryAxis`) || (($worldOrientUp-3)==`getAttr SwappingAxisInfo.previousPrimaryAxis`)) { $worldOrientUp=`getAttr SwappingAxisInfo.primaryAxis`; if ($worldOrientUp<3) setAttr ($rlaParent+"."+$worldOrientUpAttrName) ($worldOrientUp+3);//always setting to `down` else setAttr ($rlaParent+"."+$worldOrientUpAttrName) $worldOrientUp; } //and guestimate `free-forward` $tempString=`listRelatives -c -type joint $rlaParent`; if (($worldOrientForward==-1 || $worldOrientForward==6) && size($tempString)) {//assuming correct `forward` of Parent, so aligning with that parent -w $tempString; setAttr ($rlaParent+".r") -type float3 0 0 0; setAttr ($rlaParent+".jointOrient") -type float3 0 0 0; parent $tempString $rlaParent; } } if (`attributeExists worldOrientForward $rlaParent` && $worldOrientForward!=6) if ($worldOrientForward==$worldOrientUp || $worldOrientForward==($worldOrientUp+3) || $worldOrientForward==($worldOrientUp-3)) { print ("// detected invalid WorldOrient options on object:\""+$rlaParent+"\", same axis defined as \"Forward\" and \"Up\", changing the value now.\n"); if ($worldOrientUp==5) setAttr ($rlaParent+".worldOrientForward") 0; else setAttr ($rlaParent+".worldOrientForward") ($worldOrientUp+1); } $flipOrient=0; $tempString=`ls -l $rlaParent`; tokenize $tempString[0] "|" $tempString; for ($i=0;$i-$centerTolerance && $pos[0]<$centerTolerance) $center=1; //Snap Center-joints to scene-center $iKStartJointCenter=0; if (`objExists $iKStartJoint`) { $pos2=`xform -q -ws -t $iKStartJoint`; if ($pos2[0]>-$centerTolerance && $pos2[0]<$centerTolerance) $iKStartJointCenter=1; if ($iKStartJointCenter && !$center) { $pos[0]=0; xform -ws -t $pos[0] $pos[1] $pos[2] $rlaParent; $center=1; } } if ($worldmatch) { createNode -n tempTransform1 -p $rlaParent transform; parent -w tempTransform1; setAttr tempTransform1.r -type float3 0 0 0; createNode -n tempTransform2 -p $joint transform; parent tempTransform2 tempTransform1; $pos2=`getAttr tempTransform2.t`; $maxT=0; if (abs($pos2[0])>$maxT) {$priAxis="X";$maxT=abs($pos2[0]);} if (abs($pos2[1])>$maxT) {$priAxis="Y";$maxT=abs($pos2[1]);} if (abs($pos2[2])>$maxT) {$priAxis="Z";$maxT=abs($pos2[2]);} if (`getAttr ("tempTransform2.translate"+$priAxis)`<0) $priAxis="-"+$priAxis; if ($useWorldOrient)//worldOrient with worldmatch, override, (assuming Ankle situation) $priAxis="-Y"; delete tempTransform1; $secAxis="Z"; if ($priAxis=="Z") $secAxis="-Y"; if ($priAxis=="-Z") $secAxis="Y"; if (!`attributeExists primaryAxis $rlaParent`) addAttr -ln primaryAxis -at "enum" -en "X:Y:Z:-X:-Y:-Z:" $rlaParent; if (!`attributeExists secondaryAxis $rlaParent`) addAttr -ln secondaryAxis -at "enum" -en "X:Y:Z:-X:-Y:-Z:" $rlaParent; setAttr ($rlaParent+".primaryAxis") `asAxisToAxisEnumValue $priAxis`; setAttr ($rlaParent+".secondaryAxis") `asAxisToAxisEnumValue $secAxis`; if (!size($jointChildren)) { if (!`attributeExists primaryAxis $joint`) addAttr -ln primaryAxis -at "enum" -en "X:Y:Z:-X:-Y:-Z:" $joint; if (!`attributeExists secondaryAxis $joint`) addAttr -ln secondaryAxis -at "enum" -en "X:Y:Z:-X:-Y:-Z:" $joint; setAttr ($joint+".primaryAxis") `asAxisToAxisEnumValue $priAxis`; setAttr ($joint+".secondaryAxis") `asAxisToAxisEnumValue $secAxis`; } } $terAxis=`asGetTerAxis $priAxis $secAxis`; $selfUpAxis=$secAxis; $selfUpMult=1; if (`objExists SwappingAxisInfo`) $selfUpAxis=`getAttr -asString SwappingAxisInfo.previousSecondaryAxis`; if (`gmatch $terAxis "*X"`) $terAxisNr=0; if (`gmatch $terAxis "*Y"`) $terAxisNr=1; if (`gmatch $terAxis "*Z"`) $terAxisNr=2; if (`gmatch $selfUpAxis "-*"`) {$selfUpAxis=`asAbsAxis $selfUpAxis`;$selfUpMult=-1;} $aimV=`asAxisToVector $priAxis`; $upV=`asAxisToVector $secAxis`; $upV2=`asAxisToVector $terAxis`; if ($flipOrient) { $upV[0]=$upV[0]*-1;$upV[1]=$upV[1]*-1;$upV[2]=$upV[2]*-1; $upV2[0]=$upV2[0]*-1;$upV2[1]=$upV2[1]*-1;$upV2[2]=$upV2[2]*-1; } $ikPlaneVectored=0; $hipFlip=1; if (!$useWorldOrient && !$freeOrient) { if ($iKStartJoint!="" && $iKEndJoint!="" && $iKSolver=="ikRPsolver" && $rlaParent!=$iKEndJoint && !`gmatch $label "*Toes*"`) // IK {//`Ik-plane-vectored` $ikPlaneVectored=1; //in some cases aimConstraint computes flipped (if parent-joint.jo==90,0,90), so unparent before aim $tempString=`listRelatives -p $rlaParent`; $rlaParentParent=$tempString[0]; $rlaParentParentChildren=`listRelatives -c -type transform $rlaParentParent`; parent -w $rlaParent; if ($rlaParent==$iKStartJoint) { $upVecObj=$iKEndJoint;//IKStartJoint upVectors to IK-plane $tempLabel=`asLabel $iKStartJoint`; if (`gmatch $tempLabel "*Hip*"`) {$upV[0]=$upV[0]*-1;$upV[1]=$upV[1]*-1;$upV[2]=$upV[2]*-1;$hipFlip=-1;} // $tempString=`aimConstraint -aimVector 1 0 0 -upVector $upV[0] $upV[1] $upV[2] -worldUpType "object" -worldUpObject $upVecObj $joint $rlaParent`; $tempString=`aimConstraint -aimVector $aimV[0] $aimV[1] $aimV[2] -upVector $upV[0] $upV[1] $upV[2] -worldUpType "object" -worldUpObject $upVecObj $joint $rlaParent`; //Arms/Legs with excatly 0 rotation, will get PreferredAngles set to rotZ if (`objExists tempTransform`) delete tempTransform; createNode -n tempTransform -p $joint transform; parent tempTransform $rlaParent; $rot=`getAttr tempTransform.r`; delete tempTransform; if ($rot[$terAxisNr]<0.001 && $rot[$terAxisNr]>-0.001 && `objExists $iKMiddleJoint` && !`objExists SwappingAxisInfo`) { print ("// Detected zero rotation of :"+$joint+".rotation"+$terAxis+", moving middle-ik-joint slightly, to to have default rotation in \""+$terAxis+"\" axis\n"); move -ws -r 0 0 ($pos[1]/-100.0) ($iKMiddleJoint+".rotatePivot"); /* createNode -n tempTransform -p $upVecObj transform; setAttr tempTransform.ty ($upV[1]*0.1); delete $tempString[0]; $tempString=`aimConstraint -aimVector 1 0 0 -upVector $upV[0] $upV[1] $upV[2] -worldUpType "object" -worldUpObject tempTransform $joint $rlaParent`; */ } } else { $upVecObj=$iKStartJoint; // $tempString=`aimConstraint -aimVector 1 0 0 -upVector $upV[0] $upV[1] $upV[2] -worldUpType "objectrotation" -worldUpObject $upVecObj -worldUpVector $upV[0] $upV[1] $upV[2] $joint $rlaParent`; $tempString=`aimConstraint -aimVector $aimV[0] $aimV[1] $aimV[2] -upVector $upV2[0] $upV2[1] $upV2[2] -worldUpType "objectrotation" -worldUpObject $upVecObj -worldUpVector $upV2[0] $upV2[1] $upV2[2] $joint $rlaParent`; } delete $tempString[0]; parent $rlaParent $rlaParentParent; //and preserve childOrder if (size($rlaParentParentChildren)>1) { if ($rlaParent==$rlaParentParentChildren[0]) reorder -front $rlaParent; else reorder -back $rlaParent; } if (`objExists tempTransform`) delete tempTransform; } else {//`Self-up-vectored` //setting to just local forward is not reliable if switching axis, changing away from `Self-up-vectored` //actually maybe changing back is possible... if ($center) { $tempString=`aimConstraint -aimVector $aimV[0] $aimV[1] $aimV[2] -upVector $upV2[0] $upV2[1] $upV2[2] -worldUpType "vector" -worldUpVector 1 0 0 $joint $rlaParent`; delete $tempString[0]; } else { //print ("Orienting:"+$rlaParent+"\n"); $upVecObj=`createNode -p $rlaParent transform`; if ($flipOrient) setAttr ($upVecObj+".translate"+$selfUpAxis) (-3*$selfUpMult); else setAttr ($upVecObj+".translate"+$selfUpAxis) (3*$selfUpMult); parent -w $upVecObj; $tempString=`listRelatives -p $upVecObj`; if (size($tempString)) $generatedTransform2=$tempString[0]; // if ($worldmatch) // $tempString=`aimConstraint -aimVector $aimV[0] $aimV[1] $aimV[2] -upVector 0 1 0 -worldUpType "scene" -worldUpVector 0 1 0 $joint $rlaParent`; // else $tempString=`aimConstraint -aimVector $aimV[0] $aimV[1] $aimV[2] -upVector $upV[0] $upV[1] $upV[2] -worldUpType "object" -worldUpObject $upVecObj $joint $rlaParent`; delete $upVecObj $tempString[0]; } } //Special case, LegAim if (`gmatch $rlaParentLabel "LegAim*"`) { $upVecObj=$joint; $tempString=`aimConstraint -aimVector $aimV[0] $aimV[1] $aimV[2] -upVector $upV2[0] $upV2[1] $upV2[2] -worldUpType "objectrotation" -worldUpVector $upV2[0] $upV2[1] $upV2[2] -worldUpObject $upVecObj $joint $rlaParent`; delete $tempString[0]; } //Special case, Cup if ($rlaParent=="Cup" && `objExists RingFinger1` && `objExists MiddleFinger1`) { $upVecObj=`asRlaParent $rlaParent`; $tempString=`aimConstraint -aimVector $aimV[0] $aimV[1] $aimV[2] -upVector $upV[0] $upV[1] $upV[2] -worldUpType "object" -worldUpObject $upVecObj RingFinger1 MiddleFinger1 $rlaParent`; delete $tempString[0]; } //Special case, Eyes if (`gmatch $rlaParent "Eye*"`) { $tempString=`aimConstraint -aimVector $aimV[0] $aimV[1] $aimV[2] -upVector ($upV[0]*-1) ($upV[1]*-1) ($upV[2]*-1) -worldUpVector 0 1 0 $joint $rlaParent`; delete $tempString[0]; } //Special case, Root with no centered child if ($rlaParent=="Root" && !$center) { setAttr -type float3 ($rlaParent+".rotate") 0 0 0; setAttr -type float3 ($rlaParent+".jointOrient") 90 0 90; } //Special case, AimAt if (`attributeExists aimAt $rlaParent`) { $aimAt=`getAttr -asString($rlaParent+".aimAt")`; $aimAxis=`getAttr ($rlaParent+".aimAxis")`; $aimUpAxis=`getAttr ($rlaParent+".aimUpAxis")`; if ($aimAxis==0) {$x=1;$y=0;$z=0;} if ($aimAxis==1) {$x=0;$y=1;$z=0;} if ($aimAxis==2) {$x=0;$y=0;$z=1;} if ($aimUpAxis==0) {$xUp=1;$yUp=0;$zUp=0;} if ($aimUpAxis==1) {$xUp=0;$yUp=1;$zUp=0;} if ($aimUpAxis==2) {$xUp=0;$yUp=0;$zUp=1;} if (`gmatch $priAxis "-*"`) {$x*=-1;$y*=-1;$z*=-1;} $tempString=`listRelatives -c $joint`; if (!size($tempString)) parent $joint $rlaParent; if (`objExists $aimAt`) delete `aimConstraint -offset 0 0 0 -aimVector $x $y $z -upVector $xUp $yUp $zUp -worldUpType "objectrotation" -worldUpVector 0 1 0 -worldUpObject $aimAt $aimAt $rlaParent`; if (!size($tempString)) parent -w $joint; } } if ($useWorldOrient) { $upVecObj=`createNode -n tempUpVector -p $joint transform`; parent -w $upVecObj; move -r -ws 0 1 0 $upVecObj; if ($worldOrientUp==0) $aimVector={-1,0,0}; if ($worldOrientUp==1) $aimVector={0,-1,0}; if ($worldOrientUp==2) $aimVector={0,0,-1}; if ($worldOrientUp==3) $aimVector={1,0,0}; if ($worldOrientUp==4) $aimVector={0,1,0}; if ($worldOrientUp==5) $aimVector={0,0,1}; if ($worldOrientForward==0) $aimUpV={1,0,0}; if ($worldOrientForward==1) $aimUpV={0,1,0}; if ($worldOrientForward==2) $aimUpV={0,0,1}; if ($worldOrientForward==3) $aimUpV={-1,0,0}; if ($worldOrientForward==4) $aimUpV={0,-1,0}; if ($worldOrientForward==4) $aimUpV={0,0,-1}; createNode -n tempAimAt -p $rlaParent transform; parent -w tempAimAt; move -r -ws 0 -1 0 tempAimAt; if ($worldOrientForward==-1 || $worldOrientForward==6)//forward==free $tempString=`aimConstraint -aimVector $aimVector[0] $aimVector[1] $aimVector[2] -upVector $upV[0] $upV[1] $upV[2] -worldUpType "object" -worldUpObject $upVecObj tempAimAt $rlaParent`; else //new way > v5.792 $tempString=`aimConstraint -aimVector $aimVector[0] $aimVector[1] $aimVector[2] -upVector $aimUpV[0] $aimUpV[1] $aimUpV[2] -worldUpType "vector" -worldUpVector 0 0 1 tempAimAt $rlaParent`; delete $tempString[0] $upVecObj tempAimAt; } //FitGeometry aim $upVecObj=$rlaParent; if (`objExists ($rlaParent+"Aim_aimConstraint1")`) delete ($rlaParent+"Aim_aimConstraint1"); if (`objExists ($rlaParent+"Aim")`) { if ($ikPlaneVectored) { if ($rlaParent==$iKStartJoint) aimConstraint -aimVector 1 0 0 -upVector 0 (1*$hipFlip) 0 -worldUpType "object" -worldUpObject $iKEndJoint $joint ($rlaParent+"Aim"); else aimConstraint -aimVector 1 0 0 -upVector 0 1 0 -worldUpType "objectrotation" -worldUpObject ($iKStartJoint+"Aim") -worldUpVector 0 1 0 $joint ($rlaParent+"Aim"); } else aimConstraint -aimVector 1 0 0 -upVector 0 1 0 -worldUpType "objectrotation" -worldUpObject $upVecObj -worldUpVector $upV[0] $upV[1] $upV[2] $joint ($rlaParent+"Aim"); } makeIdentity -a 1 -t 0 -r 1 -s 0 $rlaParent; if (size($parentOtherChildren)) { parent $parentOtherChildren $rlaParent; delete otherChildrenPlaceHolder; } parent $joint $rlaParent; //restore sibiling order if (size($rlaParentChildren)>1) { $newRlaParentChildren=`listRelatives -type joint -c $rlaParent`; for ($i=0;$i-1;$i--) { $label=`asLabel $tempString[$i]`; // if ($i-1;$i--) { $label=`asLabel $jointAllDescendents[$i]`; int $validLabelHit=0; if (`gmatch $label "*Hand*"` && `gmatch $IKParentJointLabel "*Shoulder*"`) $validLabelHit=1; if (`gmatch $label "*Foot*"` && `gmatch $IKParentJointLabel "*Hip*"`) $validLabelHit=1; if (`gmatch $label "*Toes*"` && `gmatch $IKParentJointLabel "*Hip*"`) $validLabelHit=1; if (`gmatch $label "*Chest*"` && `gmatch $IKParentJointLabel "*Root*"`) $validLabelHit=1; if ($validLabelHit) { $IKChildJoint=$jointAllDescendents[$i]; break; } if (`gmatch $label "0*"` && $jointAllDescendents[$i]!=$joint)//track $anotherSpineIkJoints, so $IKChildJoint is not from another SplineIK { $tempString=`listRelatives -allDescendents -type joint $jointAllDescendents[$i]`; $anotherSpineIkJoints=`stringArrayCatenate $anotherSpineIkJoints $tempString`; } if (`gmatch $label "*[1-9]*"` && `gmatch $IKParentJointLabel "*0*"` && !`stringArrayCount $jointAllDescendents[$i] $anotherSpineIkJoints`) $IKChildJoint=$jointAllDescendents[$i]; } if ($IKParentJoint!= "" && $IKChildJoint!="") { //Find $IKMiddleJoint $tempString=`ls -l $IKChildJoint`; tokenize $tempString[0] "|" $tempString; int $numIkJoints=0; for ($i=size($tempString)-1;$i>-1;$i--) { $numIkJoints++; if ($tempString[$i]==$IKParentJoint) break; } int $middleNr=$numIkJoints/2; $IKMiddleJoint=$tempString[size($tempString)-1-$middleNr]; //Find $IKNumCtrls $tempString=`ls -l $IKChildJoint`; tokenize $tempString[0] "|" $tempString; for ($i=size($tempString)-2;$i>-1;$i--) { if ($tempString[$i]==$IKParentJoint) break; $label=`asLabel $tempString[$i]`; if (`gmatch $label "*Mid*"` || `gmatch $label "[0-9]*"`) $IKNumCtrls++; } $IKSolver="ikRPsolver"; $label=`asLabel $IKParentJoint`; if (`gmatch $label "*Shoulder*"`) $ik="Arm"+`substitute "Shoulder" $label ""`; if (`gmatch $label "*Hip*"`) $ik="Leg"+`substitute "Hip" $label ""`; if (`gmatch $label "*Root*"`) { $ik="Spine"+`substitute "Root" $label ""`; $IKSolver="ikSplineSolver"; } if (`gmatch $label "*0*"`) { $ik="Spline"+`substitute "[0-9]*" $label ""`; $IKSolver="ikSplineSolver"; } $asFitJointIKInfo[0]=$ik; $asFitJointIKInfo[1]=$IKParentJoint; $asFitJointIKInfo[2]=$IKMiddleJoint; $asFitJointIKInfo[3]=$IKChildJoint; $asFitJointIKInfo[4]=$IKSolver; $asFitJointIKInfo[5]=$IKNumCtrls; } return $asFitJointIKInfo; } global proc string[] asGetIKJoints (string $IKStartJoint, string $IKEndJoint) { string $IKJoints[]; string $tempString[]=`ls -l $IKEndJoint`; tokenize $tempString[0] "|" $tempString; int $foundStartJoint=0; for ($i=0;$i$defaultValue+0.001 || $value<$defaultValue-0.001) { tokenize $tempString[1] "." $tempString2; $drivenObjs[size($drivenObjs)]=$tempString2[0]; $drivenAttrs[size($drivenAttrs)]=$tempString2[1]; $drivenDefaultValue[size($drivenDefaultValue)]=$defaultValue; $drivenValue[size($drivenValue)]=$value; } } } if (!size($drivenObjs)) error "Found No attributes changed from Default Pose"; string $suggestAttrName; if (`gmatch $drivenObjs[0] "*Finger*"` || `gmatch $drivenObjs[0] "*Toe*"`) { $suggestAttrName=`substitute "[0-9]" $drivenObjs[0] ""`; $suggestAttrName=`substitute "Finger" $suggestAttrName ""`; $suggestAttrName=`substitute "Toe" $suggestAttrName ""`; $suggestAttrNameFirstLetter=`substring $suggestAttrName 1 1`; $suggestAttrName=`tolower $suggestAttrNameFirstLetter`+`substring $suggestAttrName 2 99`+"Curl"; } $asFitSDKMessage="Create Set-Driven-Key for these ?\n\n"; for ($i=0;$i$maxTextLines) { $asFitSDKMessage=""; for ($i=0;$i<$maxTextLines;$i++) $asFitSDKMessage+=$tempString[$i]+"\n"; $asFitSDKMessage+="...And "+(size($tempString)-$maxTextLines)+" more.."; } columnLayout; text -l $asFitSDKMessage; separator -h 10 -st none; rowLayout -nc 3; text -w 100 -l "Attribute Name:"; textField -w 80 -tx $asFitSDKAttrName asFitSDKAttrNameTextField; setParent..; rowLayout -nc 3; text -w 100 -l "Attribute Value:"; floatField -w 50 -v $asFitSDKDriverValue -pre 1 asFitSDKDriverValueFloatField; setParent..; separator -st none -h 3; rowLayout -nc 3 -cw3 10 85 85; separator; checkBox -l "Min" -v 1 -onc "floatField -e -en 1 asFitSDKDriverMinFloatField" -ofc "floatField -e -en 0 asFitSDKDriverMinFloatField" asFitSDKDriverHasMinCheckBox; checkBox -l "Max" -v 1 -onc "floatField -e -en 1 asFitSDKDriverMaxFloatField" -ofc "floatField -e -en 0 asFitSDKDriverMaxFloatField" asFitSDKDriverHasMaxCheckBox; setParent..; rowLayout -nc 3 -cw3 10 85 85; separator; floatField -w 50 -v 0 -pre 1 asFitSDKDriverMinFloatField; floatField -w 50 -v $asFitSDKDriverValue -pre 1 asFitSDKDriverMaxFloatField; setParent..; separator -h 10 -st none; rowLayout -nc 4; separator -w 10 -st none; button -l "OK" -c "asFitSDKCreateAttributeGetName;layoutDialog -dismiss \"OK\";"; separator -w 10 -st none; button -l "Cancel" -c "layoutDialog -dismiss \"Cancel\""; setParent..; setParent..; } global proc asFitSDKCreateAttributeGetName () { global string $asFitSDKAttrName; global float $asFitSDKDriverValue; global int $asFitSDKDriverHasMin; global int $asFitSDKDriverHasMax; global float $asFitSDKDriverMin; global float $asFitSDKDriverMax; $asFitSDKAttrName=`textField -q -tx asFitSDKAttrNameTextField`; $asFitSDKDriverValue=`textField -q -tx asFitSDKDriverValueFloatField`; $asFitSDKDriverHasMin=`checkBox -q -v asFitSDKDriverHasMinCheckBox`; $asFitSDKDriverHasMax=`checkBox -q -v asFitSDKDriverHasMaxCheckBox`; $asFitSDKDriverMin=`floatField -q -v asFitSDKDriverMinFloatField`; $asFitSDKDriverMax=`floatField -q -v asFitSDKDriverMaxFloatField`; } global proc string asRlaParent (string $joint) { string $tempString[]=`listRelatives -p -type joint $joint`; string $rlaParent=$tempString[0]; return $rlaParent; } global proc string asRlaChild (string $joint) { float $scale=1; if (`objExists FitSkeleton`) $scale=`getAttr FitSkeleton.sx`; float $centerTolerance=0.01*$scale; string $children[]=`listRelatives -type joint -c $joint`; string $rlaChild=""; float $pos[3]=`xform -q -ws -t $joint`; int $center=0; if ($pos[0]>-$centerTolerance && $pos[0]<$centerTolerance) $center=1; for ($y=0;$y-$centerTolerance && $childPos[0]<$centerTolerance) $childCenter=1; if ($center && $childCenter) $rlaChild=$children[$y]; if (!$center && !$childCenter) $rlaChild=$children[$y]; //Use `first` child as $rlaChild if ($rlaChild!="") break; } //if (!$center && size($children)>1) // $rlaChild=""; //Preferred $rlaChild if (`gmatch $joint "*Head*"`) for ($y=0;$y0) $part="Part"+$y; createNode -n ($fitJoints[$i]+$part+"Geo") -p ($fitJoints[$i]+"Aim") transform; //box $tempString=`polyCube -n ($fitJoints[$i]+$part+"Box") -w 1.75 -h 1 -d 1.75 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 0`; $box=$tempString[0]; $geoObjs[size($geoObjs)]=$box; move -r 0 0.5 0 ($box+".vtx[0:7] "); sets -e -forceElement asRedSG ($box+".f[1]"); sets -e -forceElement asRed2SG ($box+".f[3]"); sets -e -forceElement asGreenSG ($box+".f[0]"); sets -e -forceElement asGreen2SG ($box+".f[2]"); sets -e -forceElement asBlueSG ($box+".f[4]"); sets -e -forceElement asBlue2SG ($box+".f[5]"); connectAttr FitSkeleton.visBoxes ($box+".v"); setAttr ($box+"Shape.overrideEnabled") 1; setAttr ($box+"Shape.overrideDisplayType") 2; parent $box ($fitJoints[$i]+$part+"Geo"); setAttr -type float3 ($box+".s") 1 1 1; rotate -r -p 0 0 0 -os 0 -90 -90 ($box+".vtx[0:7]"); //cylinder $tempString=`cylinder -n ($fitJoints[$i]+$part+"Cyl") -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r 1 -hr 1 -d 3 -ut 0 -tol 0.01 -s 8 -nsp 1 -ch 0`; $cyl=$tempString[0]; $geoObjs[size($geoObjs)]=$cyl; move -r 0 0.5 0 ($cyl+".cv[0:3][0:7]"); sets -e -forceElement asBlueSG ($cyl+".sf[0][7]") ($cyl+".sf[0][0]");//sf[0][1:2] sets -e -forceElement asGreenSG ($cyl+".sf[0][1:2]");//sf[0][3:4] sets -e -forceElement asBlue2SG ($cyl+".sf[0][3:4]");//sf[0][5:6] sets -e -forceElement asGreen2SG ($cyl+".sf[0][5:6]");//sf[0][7] connectAttr FitSkeleton.visCylinders ($cyl+".v"); setAttr ($cyl+"Shape.overrideEnabled") 1; setAttr ($cyl+"Shape.overrideDisplayType") 2; parent $cyl ($fitJoints[$i]+$part+"Geo"); setAttr -type float3 ($cyl+".s") 1 1 1; rotate -r -p 0 0 0 -os 0 -90 -90 ($cyl+".cv[0:3][0:7]"); } //sphere $tempString=`polyCube -n ($fitJoints[$i]+"Sphere") -w 2.5 -h 2.5 -d 2.5 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 0`; $sphere=$tempString[0]; sets -e -forceElement asRedSG ($sphere+".f[1]"); sets -e -forceElement asRed2SG ($sphere+".f[3]"); sets -e -forceElement asGreenSG ($sphere+".f[0]"); sets -e -forceElement asGreen2SG ($sphere+".f[2]"); sets -e -forceElement asBlueSG ($sphere+".f[4]"); sets -e -forceElement asBlue2SG ($sphere+".f[5]"); polySmooth -mth 0 -dv 2 -bnr 1 -c 1 -kb 1 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 1 -peh 0 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 0 $sphere; connectAttr FitSkeleton.visSpheres ($sphere+".v"); setAttr ($sphere+"Shape.overrideEnabled") 1; setAttr ($sphere+"Shape.overrideDisplayType") 2; parent $sphere ($fitJoints[$i]+"Aim"); setAttr -type float3 ($sphere+".s") 1 1 1; rotate -r -p 0 0 0 -os 0 -90 -90 ($sphere+".vtx[0:999]"); connectAttr ($fitJoints[$i]+".fat") ($sphere+".sy"); connectAttr ($fitJoints[$i]+".fat") ($sphere+".sz"); connectAttr ($fitJoints[$i]+".fat") ($sphere+".sx"); //bones $bone=$fitJoints[$i]+"Bone"; if ($fitJoints[$i]!="Scapula") { if (`objExists ($fitJoints[$i]+"Bone_template")`){ duplicate -n $bone ($fitJoints[$i]+"Bone_template");} else if ($fitJoints[$i]=="Root" || $fitJoints[$i]=="Chest" || `gmatch $fitJoints[$i] "Neck*"` || `gmatch $fitJoints[$i] "Spine*"`) duplicate -n $bone SpineBone_template; else if (`gmatch $fitJoints[$i] "*Finger*"`) duplicate -n $bone DigitBone_template; else duplicate -n $bone GenericBone_template; sets -e -forceElement asBonesSG $bone; parent $bone ($fitJoints[$i]+"Aim"); connectAttr FitSkeleton.visBones ($bone+".v"); connectAttr ($fitJoints[$i]+".fat") ($bone+".sy"); connectAttr ($fitJoints[$i]+".fat") ($bone+".sz"); } //Flare select $geoObjs; $tempString=`nonLinear -type flare -lowBound 0 -highBound 1 -startFlareX 1 -startFlareZ 1 -endFlareX 1 -endFlareZ 1 -curve 0`; string $flare=`rename $tempString[0] ($fitJoints[$i]+"Flare")`; string $flareHandle=`rename $tempString[1] ($fitJoints[$i]+"FlareHandle")`; parent $flareHandle ($fitJoints[$i]+"Aim"); setAttr -type float3 ($flareHandle+".s") 1 1 1; setAttr -type float3 ($flareHandle+".t") 0 0 0; setAttr -type float3 ($flareHandle+".r") 0 0 -90; setAttr -l 1 ($flareHandle+".v") 0; //maya2020.4 seems to have a `bug`, where flare connects from deformFlare->nonLinear, (other versions are reverse) if (`isConnected ($flareHandle+".startFlareX") ($flare+".startFlareX")`) { connectAttr ($fitJoints[$i]+".fatFrontAbs") ($flareHandle+".startFlareX"); connectAttr ($fitJoints[$i]+".fatWidthAbs") ($flareHandle+".startFlareZ"); connectAttr ($rlaChild+".fatFrontAbs") ($flareHandle+".endFlareX"); connectAttr ($rlaChild+".fatWidthAbs") ($flareHandle+".endFlareZ"); } else {//this is for the non maya2020.4 versions connectAttr ($fitJoints[$i]+".fatFrontAbs") ($flare+".startFlareX"); connectAttr ($fitJoints[$i]+".fatWidthAbs") ($flare+".startFlareZ"); connectAttr ($rlaChild+".fatFrontAbs") ($flare+".endFlareX"); connectAttr ($rlaChild+".fatWidthAbs") ($flare+".endFlareZ"); } //Distance if (`objExists ($fitJoints[$i]+"Distance")`) delete ($fitJoints[$i]+"Distance"); createNode -n ($fitJoints[$i]+"Distance") distanceBetween; connectAttr ($fitJoints[$i]+".worldMatrix[0]") ($fitJoints[$i]+"Distance.inMatrix1"); connectAttr ($rlaChild+".worldMatrix[0]") ($fitJoints[$i]+"Distance.inMatrix2"); if (`objExists ($fitJoints[$i]+"ScaleYMultiDiv1")`) delete ($fitJoints[$i]+"ScaleYMultiDiv1"); createNode -n ($fitJoints[$i]+"ScaleYMultiDiv1") multiplyDivide; setAttr ($fitJoints[$i]+"ScaleYMultiDiv1.operation") 2; // connectAttr ($fitJoints[$i]+"Distance.distance") ($fitJoints[$i]+"ScaleYMultiDiv1.input1Y"); // addAttr -ln dummyInput1Y -at double ($fitJoints[$i]+"ScaleYMultiDiv1"); // connectAttr ($fitJoints[$i]+"Distance.distance") ($fitJoints[$i]+"ScaleYMultiDiv1.dummyInput1Y"); // setAttr ($fitJoints[$i]+"ScaleYMultiDiv1.input1Y") `getAttr ($fitJoints[$i]+"Distance.distance")`; connectAttr ($fitJoints[$i]+"Distance.distance") ($fitJoints[$i]+"ScaleYMultiDiv1.input1Y"); connectAttr FitSkeleton.sy ($fitJoints[$i]+"ScaleYMultiDiv1.input2Y"); if (`objExists ($fitJoints[$i]+"ScaleYMultiDiv2")`) delete ($fitJoints[$i]+"ScaleYMultiDiv2"); createNode -n ($fitJoints[$i]+"ScaleYMultiDiv2") multiplyDivide; connectAttr ($fitJoints[$i]+"ScaleYMultiDiv1.outputY") ($fitJoints[$i]+"ScaleYMultiDiv2.input1Y"); connectAttr FitSkeleton.visGap ($fitJoints[$i]+"ScaleYMultiDiv2.input2Y"); connectAttr ($fitJoints[$i]+"ScaleYMultiDiv1.outputY") ($flareHandle+".sy"); // parentConstraint $fitJoints[$i] ($fitJoints[$i]+"Aim"); pointConstraint $fitJoints[$i] ($fitJoints[$i]+"Aim"); for ($y=0;$y<$twistJoints+$inbetweenJoints+1;$y++) { $part=""; if ($y>0) $part="Part"+$y; createNode -n ($fitJoints[$i]+"ScaleYMultiDiv4_"+$y) multiplyDivide; connectAttr ($fitJoints[$i]+"ScaleYMultiDiv1.outputY") ($fitJoints[$i]+"ScaleYMultiDiv4_"+$y+".input1Y"); setAttr ($fitJoints[$i]+"ScaleYMultiDiv4_"+$y+".input2Y") ($y*(1.0/($twistJoints+$inbetweenJoints+1))); connectAttr ($fitJoints[$i]+"ScaleYMultiDiv4_"+$y+".outputY") ($fitJoints[$i]+$part+"Geo.tx"); createNode -n ($fitJoints[$i]+"ScaleYMultiDiv5_"+$y) multiplyDivide; setAttr ($fitJoints[$i]+"ScaleYMultiDiv5_"+$y+".operation") 2; connectAttr ($fitJoints[$i]+"ScaleYMultiDiv2.outputY") ($fitJoints[$i]+"ScaleYMultiDiv5_"+$y+".input1Y"); setAttr ($fitJoints[$i]+"ScaleYMultiDiv5_"+$y+".input2Y") ($twistJoints+$inbetweenJoints+1); connectAttr ($fitJoints[$i]+"ScaleYMultiDiv5_"+$y+".outputY") ($fitJoints[$i]+$part+"Geo"+".sx"); } } if (`objExists PelvisBone`) { parent PelvisBone FitSkeletonVisualizers; setAttr PelvisBone.tx 0; setAttr -type float3 PelvisBone.r 0 0 0; pointConstraint -skip x Hip PelvisBone; } if (`objExists Mannequin_Geometry`) delete Mannequin_Geometry; if (`objExists Skeleton_Geometry`) delete Skeleton_Geometry; if (`objExists SkinCage_Geometry`) delete SkinCage_Geometry; asFitModeManualUpdate; asUpdateButtonEnables; asChangeVisGeoType; if ($displayPoleVector) asFitDisplayPoleVector 1; if ($wasInFitMode) asFitMode; catchQuiet (`select $sel`); } global proc asChangeVisGeoType () { string $geoType=`optionMenu -q -v asVisGeoType`; setAttr FitSkeleton.visCylinders 0; setAttr FitSkeleton.visBoxes 0; setAttr FitSkeleton.visSpheres 0; setAttr FitSkeleton.visBones 0; if ($geoType=="cylinders") setAttr FitSkeleton.visCylinders 1; if ($geoType=="boxes") setAttr FitSkeleton.visBoxes 1; if ($geoType=="spheres") setAttr FitSkeleton.visSpheres 1; if ($geoType=="bones") setAttr FitSkeleton.visBones 1; } global proc asEnsureAllFitJointAttrs () { string $sel[]=`ls -sl`; string $fitJoints[]=`listRelatives -ad -type joint FitSkeleton`; string $deformJoints[]; for ($i=size($fitJoints)-1;$i>-1;$i--) // Reverse order, so endJoints can copy `fat` value from parent asEnsureFitJointAttrs $fitJoints[$i]; //also update AdvJointAttrs, as we might be applying a `new` proc on a `old` character. e.g. CreateSkinCage on a rig from v<5.813 if (`objExists DeformationSystem`) { $deformJoints=`listRelatives -ad -type joint DeformationSystem`; for ($i=0;$i0) { $nextLine=`fgetline $fileId`; if ($nextLine=="//-- ASTools Procedures Starts Here --//\n") $copyLines=1; if (!$copyLines) continue; if (`gmatch $nextLine "*[*][*][*][*][*][*]*"`)// ******ext files only continue; $fDet+=$nextLine; if ($nextLine=="//-- ASTools Procedures Ends Here --//\n") break; } fclose $fileId; string $selectorsDir=`asGetScriptLocation`+"/AdvancedSkeleton5Files/Selector/"; string $selectorFiles[]=`getFileList -fs "*.mel" -fld $selectorsDir`; for ($i=0;$i0) { $fDet2+=$nextLine; $nextLine=`fgetline $fileId`; if ($nextLine=="//-- ASTools Procedures Starts Here --//\n") break; } fclose $fileId; int $fileId2=`fopen $files[$i] "w"`; fprint $fileId2 ($fDet2+$fDet); fclose $fileId2; print ("// Updated:"+$files[$i]+"\n"); } } global proc float asRoundOff (float $value, int $decimals) { float $rounded; if ($value>=0) $rounded=(trunc($value*`pow 10 $decimals`+0.5)/`pow 10 $decimals`); else $rounded=(trunc(abs($value)*`pow 10 $decimals`+0.5)/`pow 10 $decimals`)*-1; return $rounded; } global proc asSetFixedWrapOptions () { optionVar -intValue autoWeightThreshold 1; optionVar -intValue exclusiveBind 0; optionVar -intValue renderInfl 1; optionVar -stringValue falloffMode "volume"; } global proc string asGetSkinCluster (string $object) { string $historyNodes[]=`listHistory -pdo 1 -il 2 $object`; string $skinCluster; for ($i=0;$i=2014) { //Maya2015 onwards have "overrideRGBColors" $rgb=`palettePort -q -rgb asCurveColorPalettePort`; $storedRgb=`colorIndex -query $curveColor`; if ($storedRgb[0]!=$rgb[0] || $storedRgb[1]!=$rgb[1] || $storedRgb[2]!=$rgb[2]) { print "// Non default index color, using \"overrideRGBColors\".\n"; $useOverrideRGBColors=1; } } if (`objExists ControlSet`) $controlSetMembers=`sets -q ControlSet`; //if (`gmatch $curveColorType "Face:*"` && `objExists FaceControlSet`) // $controlSetMembers=`sets -q FaceControlSet`; string $sel[]=`ls -sl`; string $tempString[]; string $side; if ($curveColorSide=="Right") $side="_R"; if ($curveColorSide=="Left") $side="_L"; if ($curveColorSide=="Middle") $side="_M"; if ($curveColorType=="Selected") $controllers=$sel; else for ($i=0;$i1) error "select faces from only 1 object at the time"; int $numLetters=size($control); string $mirrorControl=`substring $control 1 ($numLetters-2)`+"_L"; if (`gmatch $control "*_L"`) $mirrorControl=`substring $control 1 ($numLetters-2)`+"_R"; select -d $control; string $faces[]=`ls -sl`; string $meshControl; asEnsureMainCtrlVisAttrs; for ($y=0;$y<99;$y++) { if ($y==0) $meshControl=$control+"MeshCtrl"; else $meshControl=$control+"MeshCtrl"+$y; if (!`objExists $meshControl`) break; } createNode -n $meshControl mesh; //$tempString=`polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 0`; $tempString=`listRelatives -p $meshControl`; string $generatedXform=$tempString[0]; parent -add -s $meshControl $control; delete $generatedXform; $tempString=`listRelatives -p $faces[0]`; string $sourceMesh=$tempString[0]; $tempString=`listRelatives -p $sourceMesh`; string $sourceXform=$tempString[0]; string $transformGeometry=`createNode -n ($control+"MCTransformGeometry") transformGeometry`; setAttr ($transformGeometry+".freezeNormals") 1;//make correct normals for right side faceCtrls connectAttr ($control+".worldInverseMatrix[0]") ($transformGeometry+".transform"); connectAttr -f ($sourceMesh+".outMesh") ($transformGeometry+".inputGeometry"); connectAttr -f ($transformGeometry+".outputGeometry") ($meshControl+".inMesh"); //Shading $tempString=`listConnections ($sourceMesh+".instObjGroups[0]")`; if (`objExists $tempString[0]`) sets -e -forceElement $tempString[0] $meshControl; //ReAssign component Shading string $shaderCmd; string $shadingEngines[]=`ls -type shadingEngine`; for ($i=0;$i$biggestJointWeight) { $biggestJointWeight=$jointWeights[$z]; $infs[$y]=$weightJoints[$z]; } } } select -cl; for ($i=0;$i5) $poseValue=1;//scale //actual poseValue might come from the run attribute// $foundRunValue=0; for ($y=0;$y($currentValue+0.001) || $poseRunValue<($currentValue-0.001)) { if ($poseValue>($currentValue+0.001) || $poseValue<($currentValue-0.001)) $newRunCmds+="setAttr "+$checkObjAttr[$z]+" "+$currentValue+";"; else ;//Arrived here, if there was a previous value set, but now replaced by 0, thereby removing entry //Also remove this from old run cmd, to avoid double up for ($y=0;$y=2011) eval ($fc+" \""+`fileDialog -dm ("*."+$ft) -m $mode`+"\" "+"fileType"); else { if (`about -win`) fileBrowserDialog -m $mode -fc $fc -ft $ft -an $action; else fileBrowser $fc $action $ft $mode; } } global proc astoShelf (string $tool) { global string $gShelfTopLevel; string $projectPath=`text -q -l ("as"+$tool+"ProjectPath")`; string $projectName=`text -q -l ("as"+$tool+"ProjectName")`; if ($projectName=="untitled") error "Can not put \"untitled\" on shelf, save your project first\n"; string $cmd="source \""+$projectPath+$projectName+".mel\";"; string $ext=".xpm"; if (`asMayaVersionAsFloat`>=2011) $ext=".png"; $icon=$projectPath+$projectName+"/"+$projectName+"_background32"+$ext; string $setParent=`setParent -q`; if (`tabLayout -exists $gShelfTopLevel`) { string $currentShelf=`tabLayout -query -selectTab $gShelfTopLevel`; setParent $currentShelf; shelfButton -c $cmd -ann ($tool+":"+$projectName) -label ($tool+":"+$projectName) -i1 $icon -st`shelfLayout -query -style $currentShelf` -width `shelfLayout -query -cellWidth $currentShelf` -height `shelfLayout -query -cellHeight $currentShelf`; } setParent $setParent; } global proc asSelectFromTextField (string $textField) { if (`textField -q -ex $textField`) evalEcho ("select "+`textField -q -tx $textField`); } global proc string asUniqueFile (string $file) { // Copies given file to a random named file, to avoid fileNode cache string $buffer[]; int $numTok=`tokenize $file "/" $buffer`; string $path=""; if (`gmatch $file "/*"`) $path="/"; for ($i=0;$i<($numTok-1);$i++) $path+=$buffer[$i]+"/"; $numTok=`tokenize $file "." $buffer`; string $ext=$buffer[$numTok-1]; string $randNumber=`rand 42`; string $uniqueFile=$path+"unique"+`substituteAllString $randNumber "." ""`+"."+$ext; sysFile -cp $uniqueFile $file; return $uniqueFile; } global proc string[] asGetControlSets () { string $controlSets[]; string $sets[]=`ls -type objectSet`; for ($i=0;$i=2011) $ext=$bgExt=".png"; if (`about -linux`) $ext=".xpm"; string $tmpDir=`asGetTempDirectory`; string $tmpIconDir=$tmpDir+"AdvancedSkeleton/"+$tool+"/untitled/"; string $uiName="as"+$tool+$projectName; string $bgc; string $buffer[]; string $fDet=""; $fDet+="//This file has been generated by AdvancedSkeleton"+$tool+"//\n"; $fDet+="//Using AdvancedSkeleton Version: "+`asGetScriptVersion`+"//\n"; $fDet+="\n"; $fDet+="global proc "+$uiName+" ()\n"; $fDet+="{\n"; $fDet+="if (`window -q -ex "+$uiName+"`)\n"; //$fDet+="\tdeleteUI "+$uiName+";\n"; $fDet+="\t{\n"; $fDet+="\tasPopulateNameSpaceMenu "+$uiName+";\n"; $fDet+="\tasShowSelJob;\n"; $fDet+="\tasSelChange;\n"; $fDet+="\tshowWindow "+$uiName+";\n"; $fDet+="\treturn;\n"; $fDet+="\t}\n"; $fDet+="\n"; $fDet+="string $asSelectorScriptLocation=`asSelectorScriptLocation`;\n"; $fDet+="string $asIconLocation=$asSelectorScriptLocation+\""+$projectName+"/\";\n"; $fDet+="window -rtf 1 -mb 1 -t "+$projectName+" "+$uiName+";\n"; $fDet+="menu -l File;\n"; $fDet+="\tmenuItem -l \"Create Reference..\" -c \"asReferenceBrowser 0\";\n"; $fDet+="\tmenuItem -l \"Reference Editor\" -c \"asReferenceEditor\";\n"; $fDet+="\tmenuItem -d 1;\n"; $fDet+="\tmenuItem -l \"Export Fbx..\" -c \"asExportFbxBrowser "+$uiName+"\";\n"; $fDet+="\tsetParent..;\n"; $fDet+="menu -l Edit;\n"; $fDet+="\tmenuItem -l Refresh -c \"asPopulateNameSpaceMenu "+$uiName+"\";\n"; $fDet+="\tmenuItem -l Filter -c \"asFilterNameSpaceMenuUI "+$uiName+"\";\n"; $fDet+="\tsetParent..;\n"; if ($tool=="Selector") { $fDet+="menu -l Display;\n"; $fDet+="\tmenuItem -l Controls -c asControlsVisibilityToggle;\n"; // $fDet+="\tmenuItem -l \"Set HotKey\" -c asSetupControlVisibilityHotKeyDialog;\n"; // $fDet+="\tmenuItem -l Joints -c \"asJointsVisibilityToggle "+$uiName+"\";\n"; $fDet+="\tmenuItem -d 1;\n"; $fDet+="\tmenuItem -l GimbalLock -c \"asVisualizeGimbalLock "+$uiName+"\";\n"; $fDet+="\tmenuItem -d 1;\n"; $fDet+="\tmenuItem -l \"FaceCtrls detach\" -c \"asFaceCtrlsDetach "+$uiName+"\";\n"; $fDet+="\tsetParent..;\n"; $fDet+="menu -l Pose -aob 1;\n"; $fDet+="\tmenuItem -l Copy -c \"asCopyToClipBoard "+$uiName+" 0\";\n"; $fDet+="\tmenuItem -l Paste -c \"asPasteFromClipBoard "+$uiName+" 0\";\n"; $fDet+="\tmenuItem -d 1;\n"; $fDet+="\tmenuItem -l Reset -c \"asGoToBuildPose "+$uiName+"\";\n"; $fDet+="\tmenuItem -l Mirror -c \"asMirror "+$uiName+"\";\n"; $fDet+="\tmenuItem -optionBox 1 -c \"asMirrorOptions "+$uiName+"\";\n"; $fDet+="\tsetParent..;\n"; $fDet+="menu -l Anim;\n"; $fDet+="\tmenuItem -l Copy -c \"asCopyToClipBoard "+$uiName+" 1\";\n"; $fDet+="\tmenuItem -l Paste -c \"asPasteFromClipBoard "+$uiName+" 1\";\n"; $fDet+="\tmenuItem -d 1;\n"; $fDet+="\tmenuItem -l Clean -c \"asDeleteStaticChannels "+$uiName+"\";\n"; $fDet+="\tmenuItem -d 1;\n"; $fDet+="\tmenuItem -l Bake -c \"asAnimBake "+$uiName+"\";\n"; $fDet+="\tmenuItem -d 1;\n"; $fDet+="\tmenuItem -l SwitchFKIK -c asAutoSwitchFKIK;\n"; $fDet+="\tmenuItem -l SwitchPivot -c asAutoSwitchPivot;\n"; $fDet+="\tmenuItem -d 1;\n"; $fDet+="\tmenuItem -l QuickIK -c asQuickIK;\n"; $fDet+="\tmenuItem -d 1;\n"; $fDet+="\tmenuItem -l TwistFlip -c \"asTwistFlipUI "+$uiName+"\";\n"; $fDet+="\tmenuItem -d 1;\n"; $fDet+="\tmenuItem -l MoCapMatcher -c \"asMoCapMatcherUI "+$uiName+"\";\n"; $fDet+="\tmenuItem -d 1;\n"; $fDet+="\tmenuItem -l \"Connect ARKit\" -c \"asConnectARKitUI "+$uiName+"\";\n"; $fDet+="\tmenuItem -l \"Connect MocapX\" -c \"asConnectMocapX "+$uiName+"\";\n"; $fDet+="\tmenuItem -d 1;\n"; $fDet+="\tmenuItem -l \"Auto lipsync\" -c \"asAutoLipSyncUI "+$uiName+"\";\n"; $fDet+="menu -l Dynamics;\n"; $fDet+="\tmenuItem -l \"Add to selected\" -c \"asDynAdd "+$uiName+"\";\n"; $fDet+="\tmenuItem -l \"Remove from selected\" -c \"asDynRemove "+$uiName+"\";\n"; $fDet+="\tmenuItem -d 1;\n"; $fDet+="\tmenuItem -l \"Set Initial State\" -c \"asDynSetInitialState "+$uiName+"\";\n"; $fDet+="\tmenuItem -l \"Interactive Playback\" -c \"asDynSetInteractivePlayback "+$uiName+"\";\n"; $fDet+="\tmenuItem -d 1;\n"; $fDet+="\tmenuItem -l Bake -c \"asDynBake "+$uiName+"\";\n"; $fDet+="menu -l Parent;\n"; $fDet+="\tmenuItem -l \"Add parent constraint\" -c \"asParentAdd "+$uiName+" 0\";\n"; $fDet+="\tmenuItem -l \"Add parent constraint (Extra)\" -c \"asParentAdd "+$uiName+" 1\";\n"; } $fDet+="\n"; //controlsets string $controlSetsText; string $menuItems[]; if (`menu -q -ex ("as"+$tool+"ControlSetsMenu")`) { $menuItems=`menu -q -ia ("as"+$tool+"ControlSetsMenu")`; for ($i=0;$i6) { $subMenuItems=`menu -q -ia $menuItems[5]`; $ctlAlignFK2IKCmd[$i]=`menuItem -q -c $subMenuItems[0]`; $ctlAlignFK2IKCmd[$i]=`substitute "\"Default\"" $ctlAlignFK2IKCmd[$i] ("\""+$projectName+"\"")`; $ctlAlignFK2IKCmd[$i]="\""+`encodeString $ctlAlignFK2IKCmd[$i]`+"\""; $ctlAlignIK2FKCmd[$i]=`menuItem -q -c $subMenuItems[1]`; $ctlAlignIK2FKCmd[$i]=`substitute "\"Default\"" $ctlAlignIK2FKCmd[$i] ("\""+$projectName+"\"")`; $ctlAlignIK2FKCmd[$i]="\""+`encodeString $ctlAlignIK2FKCmd[$i]`+"\""; $subMenuItems=`menu -q -ia $menuItems[6]`; $ctlSwitchFK2IKCmd[$i]=`menuItem -q -c $subMenuItems[0]`; $ctlSwitchFK2IKCmd[$i]=`substitute "\"Default\"" $ctlSwitchFK2IKCmd[$i] ("\""+$projectName+"\"")`; $ctlSwitchFK2IKCmd[$i]="\""+`encodeString $ctlSwitchFK2IKCmd[$i]`+"\""; $ctlSwitchIK2FKCmd[$i]=`menuItem -q -c $subMenuItems[1]`; $ctlSwitchIK2FKCmd[$i]=`substitute "\"Default\"" $ctlSwitchIK2FKCmd[$i] ("\""+$projectName+"\"")`; $ctlSwitchIK2FKCmd[$i]="\""+`encodeString $ctlSwitchIK2FKCmd[$i]`+"\""; } } } $fDet+="columnLayout -adj 1;\n"; $fDet+="text -m 0 -l \""+$controlSetsText+"\" "+$uiName+"ControlSetsText;\n"; $fDet+="rowLayout -nc 5 -adj 1 -cat 1 right 0 -cw 2 30 -cw 3 65 -cw 4 50 -cw 5 60;\n"; $fDet+="optionMenu -cc asSelChange "+$uiName+"OptionMenu;\n"; $fDet+="button -l set -c \"asSetNameSpaceFromSelection "+$uiName+"\";\n"; $fDet+="checkBox -v `optionVar -q asShowSelection` -onc \"optionVar -iv asShowSelection 1;asSelChangeToggle;\" -ofc \"optionVar -iv asShowSelection 0;asSelChangeToggle;\" -l Selection "+$uiName+"SelectionCheckBox;\n"; $fDet+="checkBox -v `optionVar -q asShowKeyed` -onc \"optionVar -iv asShowKeyed 1;asSelChangeToggle;\" -ofc \"optionVar -iv asShowKeyed 0;asSelChangeToggle;\" -l Keyed "+$uiName+"KeyedCheckBox;\n"; $fDet+="checkBox -v `optionVar -q asShowExtra` -onc \"optionVar -iv asShowExtra 1;asSelChangeToggle;\" -ofc \"optionVar -iv asShowExtra 0;asSelChangeToggle;\" -l Extra "+$uiName+"ExtraCheckBox;\n"; $fDet+="setParent..;\n"; $fDet+="formLayout "+$uiName+"FormLayout;\n"; $fDet+="\n"; $fDet+="//Controls Begin//\n"; if (`about -mac` || `about -linux`) $fDet+="iconTextButton -en 0 -w "+$pictureWidth+" -h "+$pictureHeight+" -i ($asIconLocation+\""+$projectName+"_background"+$bgExt+"\") \""+$uiName+"BGPicture\";\n"; else $fDet+="image -en 0 -w "+$pictureWidth+" -h "+$pictureHeight+" -i ($asIconLocation+\""+$projectName+"_background"+$bgExt+"\") \""+$uiName+"BGPicture\";\n"; for ($i=0;$i0) { $nextLine=`fgetline $fileId2`; if ($nextLine=="//-- ASTools Procedures Starts Here --//\n") $copyLines=1; if (!$copyLines) continue; if (`gmatch $nextLine "*[*][*][*][*][*][*]*"`)// ******ext files only continue; $fDet+=$nextLine; if ($nextLine=="//-- ASTools Procedures Ends Here --//\n") break; } fclose $fileId2; int $fileId=`fopen $projectFile "w"`; fprint $fileId $fDet; fclose $fileId; //$installFile $fDet=""; string $AdvancedSkeletonInstallFile=`asGetScriptLocation`+"/install.mel"; if (!`file -q -ex $AdvancedSkeletonInstallFile`) return; $fileId=`fopen $AdvancedSkeletonInstallFile "r"`; $nextLine = `fgetline $fileId`; int $installTemplatePause; while ( size( $nextLine ) > 0 ) { $nextLine = `fgetline $fileId`; if ($nextLine=="//--installTemplate pause--//\n") $installTemplatePause=1; if ($nextLine=="//--installTemplate resume--//\n") { $installTemplatePause=0; continue; } if ($installTemplatePause) continue; if (`gmatch $nextLine "string $scriptName=*"`) { $fDet+=("string $scriptName=\""+$projectName+"\";\n"); } else if (`gmatch $nextLine "string $sourceFile=*"`) { $fDet+=("string $sourceFile=$asInstallScriptLocation+\"../\"+$scriptName+\".mel\";\n"); } else if (`gmatch $nextLine "string $icon=*"`) { $fDet+=("string $icon=$asInstallScriptLocation+\""+$projectName+"_background32.png\";\n"); } else if (`gmatch $nextLine "string $command=*"`) { $fDet+=("string $command=\"source \\\"\"+$sourceFile+\"\\\"\";\n"); } else $fDet+=$nextLine; } fclose $fileId; $fileId=`fopen $installFile "w"`; fprint $fileId $fDet; fclose $fileId; } //-- AS IO Procedures (for tools) Ends Here --// //-- ASTools Procedures Starts Here --// global proc asSelChange () { global int $asfileLoading; global int $asSelChangeSwitching; if ($asfileLoading) return; if (!`optionVar -q asShowSelection` && !`optionVar -q asShowKeyed` && !$asSelChangeSwitching) return; int $undoState=`undoInfo -q -state`; string $sel[]=`ls -sl`; string $name,$obj,$nodeType,$projectName,$ann; string $ctls[],$buffer[],$connections[]; int $numLetters,$numTok,$keyed; string $ext=".xpm"; if (`asMayaVersionAsFloat`>=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;$i1) for ($i=0;$i$windowWidth || $y<0 || $y>$windowHeight) continue; if ($background) continue; if ($bgImageFile=="" || !`file -q -ex $bgImageFile`) error "No background image, Render a background first"; $iol=""; $labelAttr=`getAttr ($guiBox+".label")`; if ($labelAttr!="") $iol=$labelAttr; $ann=$renderBoxObjs[$i]; $fileName=$ann; $multiObjAttr=`getAttr ($guiBox+".multiObjs")`; if ($multiObjAttr!="") { $ann=$multiObjAttr; if (`gmatch $renderBoxes[$i] "*_L"`) { tokenize $ann $tempString; $ann=""; for ($z=0;$z2) setAttr SelectorRampU.colorEntryList[1].position (1-(1.00000/$width)); setAttr SelectorRampU.colorEntryList[0].color -type double3 0 0 0; setAttr SelectorRampV.type 0; setAttr SelectorRampV.interpolation 0; setAttr SelectorRampV.colorEntryList[0].color -type double3 0.75 0.75 0.75; // if ($height>2) setAttr SelectorRampV.colorEntryList[1].position (1.00000/$height); connectAttr SelectorRampU.outColor SelectorRampV.colorEntryList[1].color; setAttr SelectorRampU.colorEntryList[0].position (1.00000/$width); setAttr SelectorRampU.colorEntryList[2].color -type double3 0.75 0.75 0.75; setAttr SelectorRampV.colorEntryList[0].position (1-(1.00000/$height)); setAttr SelectorRampV.colorEntryList[2].color -type double3 0.75 0.75 0.75; createNode -n SelectorLayeredTexture layeredTexture; setAttr SelectorLayeredTexture.inputs[0].color -type double3 1 1 1 ; connectAttr SelectorRampV.outColorR SelectorLayeredTexture.inputs[0].alpha; connectAttr -f SelectorFileNode.outAlpha SelectorLayeredTexture.inputs[1].alpha; connectAttr -f SelectorFileNode.outColor SelectorLayeredTexture.inputs[1].color; string $buttonImageFileOffK0=$iconDir+$projectName+"_"+$fileName+"_OffK0.png"; string $buttonImageFileOffK1=$iconDir+$projectName+"_"+$fileName+"_OffK1.png"; string $buttonImageFileOnK0=$iconDir+$projectName+"_"+$fileName+"_OnK0.png"; string $buttonImageFileOnK1=$iconDir+$projectName+"_"+$fileName+"_OnK1.png"; //Off K0 version select SelectorLayeredTexture; eval ("convertSolidTx -aa 0 -sp 1 -al 1 -rx "+$width+" -ry "+$height+" -n asTempSolidTx -fil \"png\" -fin \""+$buttonImageFileOffK0+"\""); delete asTempSolidTx; //add tint now, so that selection/keyed buttons (with blank space background) are also visible setAttr SelectorLayeredTexture.inputs[2].alpha 0.3; //Off K1 version setAttr SelectorFileNode.colorOffset -type double3 0.27 0.27 0.27; setAttr SelectorFileNode.colorGain -type double3 $keyColor[0] $keyColor[1] $keyColor[2]; setAttr SelectorLayeredTexture.inputs[2].color -type double3 $keyColor[0] $keyColor[1] $keyColor[2]; eval ("convertSolidTx -aa 0 -sp 1 -al 1 -rx "+$width+" -ry "+$height+" -n asTempSolidTx -fil \"png\" -fin \""+$buttonImageFileOffK1+"\""); delete asTempSolidTx; //On K0 version setAttr SelectorFileNode.colorOffset -type double3 0.27 0.27 0.27; setAttr SelectorFileNode.colorGain -type double3 $selColor[0] $selColor[1] $selColor[2]; setAttr SelectorLayeredTexture.inputs[2].color -type double3 $selColor[0] $selColor[1] $selColor[2]; eval ("convertSolidTx -aa 0 -sp 1 -al 1 -rx "+$width+" -ry "+$height+" -n asTempSolidTx -fil \"png\" -fin \""+$buttonImageFileOnK0+"\""); delete asTempSolidTx; //On K1 version setAttr SelectorFileNode.colorOffset -type double3 $keyColor[0] $keyColor[1] $keyColor[2]; setAttr SelectorFileNode.colorGain -type double3 $selColor[0] $selColor[1] $selColor[2]; setAttr SelectorLayeredTexture.inputs[2].color -type double3 ($selColor[0]+$keyColor[0]) ($selColor[1]+$keyColor[1]) ($selColor[2]+$keyColor[2]); eval ("convertSolidTx -aa 0 -sp 1 -al 1 -rx "+$width+" -ry "+$height+" -n asTempSolidTx -fil \"png\" -fin \""+$buttonImageFileOnK1+"\""); delete asTempSolidTx; for ($q=0;$q=2011) $buttonImageFileExt="png"; int $nc=`optionVar -q asPoserNc`; if ($nc<1) $nc=4; int $nr=`optionVar -q asPoserNr`; if ($nr<1) $nr=2; string $poserText=`optionVar -q asPoserText`; if ($poserText=="0") $poserText="Pose"; int $onlySel=`optionVar -q asPoserOnlySel`; int $anim=`optionVar -q asPoserAnim`; int $renderView=`optionVar -q asPoserRenderView`; string $controlSets[]=`asGetControlSets`; if (`window -q -ex asPoserDefault`) deleteUI asPoserDefault; window -mb 1 -t "PoserDesigner :untitled" asPoserDefault; menu "File"; menuItem -c "evalDeferred asPoserDesigner" "New"; menuItem -c "asfileBrowse Poser Open" "Open"; menuItem -sm 1 -l "ControlSets" asPoserControlSetsMenu; menuItem -cb 1 -l ControlSet asPoserControlSetsMenuItemControlSet; for ($i=0;$i=2011) $ext="png"; string $gridOrder[]=`gridLayout -q -go ($uiName+"GridLayout")`; int $lastFilled,$childNum; //Find Last filled for ($i=1;$i($nc*$nr) && $loadData[0]=="") error "Grid is full, extend rows or columns !\n"; if ($loadData[0]=="") { if (`optionMenu -q -v asPoserDefaultOptionMenu`=="None") error "No Character In The Scene\n"; $anim=`checkBox -q -v asPoserAnim`; $cmd=`asPoserGetCmd $uiName $anim`; if ($cmd=="") error "No valid objects !\n"; $image=`asPoserSnapShoot $uiName $childNum $anim 1 1`; if ($anim && $cmd!="") $cmd+=" "+$childNum; if (`about -mac`) showWindow asPoserDefault; $label=`textField -q -tx asPoserTextField`; } else { $childNum=$loadData[4]; $numTok=`tokenize $loadData[1] "/" $buffer`; $image=$iconDir+"untitled_"+$childNum+"."+$ext; sysFile -cp $image $loadData[1]; $mayaFile=`substitute "[.][a-z][a-z][a-z]" $image ".ma"`; $loadingMayaFile=`substitute "[.][a-z][a-z][a-z]" $loadData[1] ".ma"`; if (`file -q -ex $loadingMayaFile`) sysFile -cp $mayaFile $loadingMayaFile; $jpg=`substitute "[.][a-z][a-z][a-z]" $image ".jpg"`; $loadingJpg=`substitute "[.][a-z][a-z][a-z]" $loadData[1] ".jpg"`; if (`file -q -ex $loadingJpg`) sysFile -cp $jpg $loadingJpg; $avi=`substitute "[.][a-z][a-z][a-z]" $image ".avi"`; $loadingAvi=`substitute "[.][a-z][a-z][a-z]" $loadData[1] ".avi"`; if (`file -q -ex $loadingAvi`) sysFile -cp $avi $loadingAvi; $label=$loadData[2]; $cmd=$loadData[3]; if ($asfileLoading) $cmd=`substitute $loadData[0] $cmd $uiName`; $anim=$loadData[5]; } $numTok=`tokenize $cmd ";" $buffer`; if ($numTok==2) $singleAttr=1; setParent ($uiName+"GridLayout"); columnLayout ($uiName+"ColumnLayout"+$childNum); gridLayout -e -pos ($uiName+"ColumnLayout"+$childNum) $childNum ($uiName+"GridLayout"); rowColumnLayout -ann $anim -nc 2 -cw 1 100 -cw 2 15 ($uiName+"RowColumnLayout"+$childNum); iconTextButton -w 100 -h 75 -i $image -c $cmd ($uiName+"IconTextButton"+$childNum); floatSlider -m 0 -w 10 -h 75 -hr 0 ($uiName+"FloatSlider"+$childNum); text -h 15 -al "center" -fn "smallBoldLabelFont" -l $label ($uiName+"Text"+$childNum); if ($anim) text -e -bgc 1 0 0 ($uiName+"Text"+$childNum); if ($loadData[0]=="" || $asfileLoading) { asPoserupdateGridBlock $uiName $childNum; iconTextButton -e -dgc asPoserDgc -dpc asPoserDpc ($uiName+"IconTextButton"+$childNum); } //connectControl string $connectToObj,$connectToAttr,$resolvedDestination; string $allKeyableAttrs[]; if ($singleAttr) { tokenize $cmd "\"" $buffer; tokenize $buffer[1] $buffer; tokenize $buffer[0] "." $buffer; $connectToObj=$buffer[0]; $connectToAttr=$buffer[1]; $resolvedObj=`asPoserResolveNameSpace $uiName $connectToObj`; if (`objExists $resolvedObj`) $allKeyableAttrs=`listAttr -k -m -sn $resolvedObj`; for ($allKeyableAttr in $allKeyableAttrs) if ($connectToAttr==$allKeyableAttr) if (`getAttr -se ($resolvedObj+"."+$connectToAttr)`) { if (`attributeQuery -n $resolvedObj -ex $connectToAttr`) if (!`attributeQuery -n $resolvedObj -re $connectToAttr`) break; if (`attributeQuery -n $resolvedObj -ex $connectToAttr`) $range=`attributeQuery -n $resolvedObj -r $connectToAttr`; else //probably a muli attr e.g. blenShape target..using range 0->1 $range={0,1}; floatSlider -ann ($connectToObj+"."+$connectToAttr) -e -m 1 -min $range[0] -max $range[1] ($uiName+"FloatSlider"+$childNum); connectControl ($uiName+"FloatSlider"+$childNum) ($resolvedObj+"."+$connectToAttr); text -e -l $connectToAttr ($uiName+"Text"+$childNum); } } setParent $setParent; } global proc asPoserUpdateGrid () { int $nc=`intField -q -v asPoserNc`; optionVar -iv asPoserNc $nc; int $nr=`intField -q -v asPoserNr`; optionVar -iv asPoserNr $nr; string $poserText=`textField -q -tx asPoserTextField`; optionVar -sv asPoserText $poserText; int $onlySel=`checkBox -q -v asPoserOnlySel`; optionVar -iv asPoserOnlySel $onlySel; int $anim=`checkBox -q -v asPoserAnim`; optionVar -iv asPoserAnim $anim; int $renderView=`checkBox -q -v asPoserRenderView`; optionVar -iv asPoserRenderView $renderView; if ($nc<1) { intField -e -v 1 asPoserNc; asPoserUpdateGrid; return; } if ($nr<1) { intField -e -v 1 asPoserNr; asPoserUpdateGrid; return; } gridLayout -e -nc $nc -nr $nr -w (110*$nc) -h (90*$nr) asPoserDefaultGridLayout; } global proc asPoserRename (int $childNum) { if (!`text -q -ex ("asPoserDefaultText"+$childNum)`) error "Cant find `text` uiElement\n"; string $oldname=`text -q -l ("asPoserDefaultText"+$childNum)`; string $return=`promptDialog -m "Name:" -tx $oldname -t ("AdvancedSkeleton") -b "Ok" -b "Cancel" -db "Ok" -cb "Cancel" -ds "Cancel"`; if ($return=="Cancel") return; string $newName=`promptDialog -q -tx`; text -e -l $newName ("asPoserDefaultText"+$childNum); } global proc asPoserDeletePose (string $uiName, int $num) { string $image=`iconTextButton -q -i ($uiName+"IconTextButton"+$num)`; $jpgImage=`substitute "[.]png" $image ".jpg"`; $jpgImage=`substitute "[.]xpm" $jpgImage ".jpg"`; sysFile -del $image; sysFile -del $jpgImage; evalDeferred ("deleteUI "+$uiName+"ColumnLayout"+$num); } global proc string asPoserSnapShoot (string $uiName, int $childNum, int $anim, int $updateIcon, int $updateMovie) { string $iconDir=`asGetTempDirectory`+"AdvancedSkeleton/Poser/untitled/"; int $renderView=`checkBox -q -v asPoserRenderView`; if (!`file -q -ex $iconDir`) sysFile -md $iconDir; int $curFrame=`currentTime -q`; int $startFrame=$endFrame=$curFrame; int $currFormat=`getAttr "defaultRenderGlobals.imageFormat"`; string $huds[]=`headsUpDisplay -listHeadsUpDisplays`; int $hudStates[]; for ($i=0;$i=2011) { $ext="png"; setAttr "defaultRenderGlobals.imageFormat" 32; } else { $ext="xpm"; setAttr -type "string" defaultRenderGlobals.imfPluginKey "xpm"; setAttr defaultRenderGlobals.imageFormat 50; } string $fileName=$iconDir+"untitled_"+$childNum; string $iconImage=$fileName+"."+$ext; string $blastImage=$fileName+"."+`asDoPadd $curFrame 4`; string $blastMovie=$fileName+".avi"; string $largeImage=$fileName+".jpg"; string $bgImageFile32=$iconDir+"untitled_background32."+$ext; int $iconExists; if (`file -q -ex $iconImage`) $iconExists=1; if ($renderView && $updateIcon) { if (`renderWindowEditor -q -nim renderView`<0) error ("No Image In RenderView\n"); eval ("renderWindowEditor -e -wi \""+$iconImage+"\" renderView"); asPoserResizeImage 100 75 $iconImage $iconImage; setAttr defaultRenderGlobals.imageFormat 8; evalEcho ("renderWindowEditor -e -wi \""+$largeImage+"\" renderView"); } if (!$renderView && $updateIcon) { playblast -w 100 -h 75 -compression "png" -p 100 -st $curFrame -et $curFrame -f $fileName -fmt image -fo -clearCache 0 -viewer 0 -showOrnaments 0; sysFile -ren $iconImage ($blastImage+"."+$ext); } setAttr defaultRenderGlobals.imageFormat 8; if ($anim && $updateMovie) playblast -p 100 -st `playbackOptions -q -min` -et `playbackOptions -q -max` -f $fileName -fmt movie -fo -clearCache 0 -viewer 0 -showOrnaments 0; else if ($updateIcon) { playblast -p 100 -compression "png" -st $curFrame -et $curFrame -f $fileName -fmt image -fo -clearCache 0 -viewer 0 -showOrnaments 0; sysFile -ren $largeImage ($blastImage+".jpg"); } setAttr defaultRenderGlobals.imageFormat $currFormat; for ($i=0;$i=2011) $buttonImageFileExt="png"; string $uniqueFileName=`asUniqueFile $inputImage`; string $fileNode=`createNode file`; setAttr -type "string" ($fileNode+".fileTextureName") $uniqueFileName; eval ("convertSolidTx -sp 1 -al 1 -rx "+$x+" -ry "+$y+" -n asTempSolidTx32 -fil \""+$buttonImageFileExt+"\" -fin \""+$outputImage+"\""); delete $fileNode asTempSolidTx32; sysFile -del $uniqueFileName; select $sel; } global proc string asDoPadd (int $frameNr,int $padding) { string $frameName; string $padd=""; string $neg=""; string $frameNrAsString=$frameNr; for ($i=0;$i<$padding;$i++) $padd=$padd+"0"; //move the negative symbol to start of string// if ($frameNr<0) $neg="-"; int $nr=`size ($frameNrAsString)`; if ($padding>$nr) $frameName=$neg+`substring $padd ($nr+1) 999`+abs($frameNr); else $frameName=$frameNr; return $frameName; } global proc string[] asPoserDgc (string $dragControl, int $x, int $y, int $mods) { string $return[]; $return[0]=$x; $return[1]=$y; $return[2]=$mods; return $return; } global proc asPoserDpc (string $dragControl, string $dropControl, string $msgs[], int $x, int $y, int $type) { string $iconDir=`asGetTempDirectory`+"AdvancedSkeleton/Poser/untitled/"; if (`gmatch $dropControl "*IconTextButton*"`) return; int $left=$msgs[0]; int $top=$msgs[1]; int $nc=`intField -q -v asPoserNc`; int $nr=`intField -q -v asPoserNr`; string $match=`match "[0-9]+$" $dragControl`; int $oldChildNum=$match; int $newRowNum=ceil(($x+0.00)/110); int $newColNum=ceil(($y+0.00)/90); int $newChildNum=$newRowNum+(($newColNum-1)*$nc); if ($newChildNum==$oldChildNum) return; if ($newChildNum>($nc*$nr)) error "out of grid, extend rows or columns !\n"; string $gridOrder[]=`gridLayout -q -go asPoserDefaultGridLayout`; if (`gmatch $gridOrder[$newChildNum-1] "asPoser*"`) error "grid position is occupied !\n"; gridLayout -e -pos ("asPoserDefaultColumnLayout"+$oldChildNum) $newChildNum asPoserDefaultGridLayout; //rename UI elements string $children[]=`layout -q -ca ("asPoserDefaultColumnLayout"+$oldChildNum)`; $children[size($children)]="asPoserDefaultColumnLayout"+$oldChildNum; string $grandChildren[]=`layout -q -ca $children[0]`; string $allChildren[]=`stringArrayCatenate $children $grandChildren`; string $tempString[]; string $cmd; int $numDigitsInIldChildNum=size($match); int $numDigitsInChild; int $numDigitsInImage; string $newChildName,$image,$animFile,$newAnimFile; string $ext="xpm"; if (`asMayaVersionAsFloat`>=2011) $ext="png"; for ($child in $allChildren) { $numDigitsInChild=size($child); string $newChildName=`substring $child 1 ($numDigitsInChild-$numDigitsInIldChildNum)`+$newChildNum; renameUI $child $newChildName; //rename bitmaps if (!`iconTextButton -q -ex $newChildName`) continue; $image=`iconTextButton -q -i $newChildName`; $numDigitsInImage=size($image); $newImage=`substring ("\""+$image+"\"") 2 ($numDigitsInImage-3-$numDigitsInIldChildNum)`+$newChildNum+"."+$ext; if (`file -q -ex $image` && $newImage!=$image) { eval ("sysFile -ren \""+$newImage+"\" \""+$image+"\""); iconTextButton -e -i $newImage $newChildName; reloadImage $newImage $newChildName; $jpg=`substitute "[.][a-z][a-z][a-z]" $image ".jpg"`; if (`file -q -ex $jpg`) sysFile -ren `substitute "[.][a-z][a-z][a-z]" $newImage ".jpg"` `substitute "[.][a-z][a-z][a-z]" $image ".jpg"`; $avi=`substitute "[.][a-z][a-z][a-z]" $image ".avi"`; if (`file -q -ex $avi`) sysFile -ren `substitute "[.][a-z][a-z][a-z]" $newImage ".avi"` `substitute "[.][a-z][a-z][a-z]" $image ".avi"`; } //rename anim files $animFile=$iconDir+"untitled_"+$oldChildNum+".ma"; $newAnimFile=$iconDir+"untitled_"+$newChildNum+".ma"; if (`file -q -ex $animFile` && $newAnimFile!=$animFile) eval ("sysFile -ren \""+$newAnimFile+"\" \""+$animFile+"\""); //update animation command $cmd=`iconTextButton -q -c $newChildName`; tokenize $cmd $tempString; if ($tempString[0]=="asLoadAttrs") { $cmd=$tempString[0]+" "+$tempString[1]+" "+$newChildNum; iconTextButton -e -c $cmd $newChildName; } } string $uiName="asPoserDefault"; asPoserupdateGridBlock $uiName $newChildNum; } //-- ASPoserDesigner Procedures Ends Here --// //-- ASWalkDesigner Procedures Start Here --// global proc asWalkDesigner () { string $motions[]={"run_female","run_male","walk_angry","walk_cool","walk_cute","walk_female","walk_macho","walk_male","walk_proud","walk_sad","walk_sneak"}; //create, connectControl, and delete, to disable. int $mixerExisted=1; if (!`objExists WalkDesignerMotionMixer`) { createNode -n WalkDesignerMotionMixer transform; addAttr -k 1 -dv 1 -ln "speed" -at double WalkDesignerMotionMixer; $mixerExisted=0; } if (`window -q -ex asWalkDesigner`) deleteUI asWalkDesigner; window -mb 1 -t WalkDesigner asWalkDesigner; formLayout asWDFormLayout; columnLayout; optionMenu -w 200 asWalkDesignerOptionMenu; button -l "Start" -c asWDStart; columnLayout asWDMixerColumnLayout; for($i=0;$i post infinity > cycle)" -v 1 -onc "intField -e -en 0 asWDLoopsIntField" -ofc "intField -e -en 1 asWDLoopsIntField" asWDLoopCheckBox; text -l "or"; rowLayout -nc 3; text -l "loop animation"; intField -cc asWDSpeedChange -en 0 -w 30 -min 1 -v 1 asWDLoopsIntField; text -l "times"; setParent..; button -l "Ok, Bake keys onto character" -c asWDBake; setParent..; setParent..; setParent..; button -l "Cancel and Close" -c asWDFinish asWDClose; formLayout -e -attachForm asWDClose "bottom" 0 -attachForm asWDClose "left" 0 -attachForm asWDClose "right" 0 asWDFormLayout; asPopulateNameSpaceMenu "asWalkDesigner"; if(!$mixerExisted) delete WalkDesignerMotionMixer; showWindow; } global proc asWDBake () { string $nameSpace=`optionMenu -q -v asWalkDesignerOptionMenu`; if ($nameSpace==":") $nameSpace=""; float $defaultEndTime=`getAttr WalkDesignerMotionMixer.defaultEndTime`; float $speed=`getAttr WalkDesignerMotionMixer.speed`; float $endTime=$defaultEndTime*(1.0/$speed); string $consts[]={"Root_M","Spine1_M","Spine2_M","Chest_M","Neck_M","Head_M", "Shoulder_R","Elbow_R","Wrist_R","Hip_R","Knee_R","Ankle_R","Toes_R", "Shoulder_L","Elbow_L","Wrist_L","Hip_L","Knee_L","Ankle_L","Toes_L"}; select -cl; string $allFkControls[]; for($i=0;$i-2;$b=$b-2) { if ($b==1) $side="_R"; if ($b==-1) $side="_L"; setAttr ("FKHip"+$side+"_orientConstraint1.offsetX") 180; setAttr ("FKKnee"+$side+"_orientConstraint1.offsetX") 180; setAttr ("FKAnkle"+$side+"_orientConstraint1.offsetX") 180; setAttr ("FKToes"+$side+"_orientConstraint1.offsetX") 180; setAttr ("FKShoulder"+$side+"_orientConstraint1.offsetX") -90; setAttr ("FKElbow"+$side+"_orientConstraint1.offsetX") -90; setAttr ("FKWrist"+$side+"_orientConstraint1.offsetX") -90; } connectControl asWDSpeedField WalkDesignerMotionMixer.speed; if (`attributeExists walk_male WalkDesignerMotionMixer`) setAttr WalkDesignerMotionMixer.walk_male 1; currentTime 0; if (`objExists ($nameSpace+"FKAnkle_R")` && `objExists ($nameSpace+"Ankle")`) { float $anklePos[3]=`xform -q -ws -t ($nameSpace+"FKAnkle_R")`; float $fitAnklePos[3]=`xform -q -ws -t ($nameSpace+"Ankle")`; float $offset=$anklePos[1]-$fitAnklePos[1]; setAttr asMotion:Group.ty ($offset*-1); } float $tempFloats[]=`keyframe -index 1 -q -tc asMotion:Group.timing`; float $endTime=$tempFloats[0]; playbackOptions -min 0 -ast 0 -aet $endTime -max $endTime; setAttr WalkDesignerMotionMixer.defaultEndTime $endTime; select -cl; } global proc asWDSolo (int $num) { if (!`objExists WalkDesignerMotionMixer`) error ("WalkDesignerMotionMixer not found"); float $value; string $motions[]={"run_female","run_male","walk_angry","walk_cool","walk_cute","walk_female","walk_macho","walk_male","walk_proud","walk_sad","walk_sneak"}; for($i=0;$i1) $oldVersion=5.0; else return; } else return; if ($oldVersion>5.743) return; $dialog=`confirmDialog -t "Confirm" -m "FaceFitSkeleton is from a older version.\nCreate New FaceFitSkeleton ?" -b "Yes" -db "Yes" -b "Cancel" -ds "Cancel"`; if ($dialog!="Yes") error "FaceFitSkeleton is from a older version. Delete this, and create a new FaceFitSkeleton."; if (`objExists FaceFitCheekRaiser`) delete FaceFitCheekRaiser; if (`objExists FaceFitSmileBulge`) delete FaceFitSmileBulge; if (`objExists FaceFitFrownBulge`) delete FaceFitFrownBulge; if (`objExists FaceMotionSystem`) { if (!`getAttr FaceFitSkeleton.v`) asToggleFitFace; asDeleteAdvancedFace; } $geometry=`getAttr FaceFitSkeleton.Geometry`;//changed in 5.743 $allFaceGeoString=`getAttr FaceFitSkeleton.AllFaceGeo`;//changed in 5.743 $rightEye=`getAttr FaceFitSkeleton.Eye_R`;//changed in 5.743 $leftEye=`getAttr FaceFitSkeleton.Eye_L`;//changed in 5.743 $upperTeeth=`getAttr FaceFitSkeleton.UpperTeeth`; $lowerTeeth=`getAttr FaceFitSkeleton.LowerTeeth`; $tongue=`getAttr FaceFitSkeleton.Tongue`; $headJoint=`getAttr FaceFitSkeleton.HeadJoint`; $skinCluster=`getAttr FaceFitSkeleton.SkinCluster`; $faceScale=`getAttr FaceFitSkeleton.sy`*1.5; if (`attributeExists Pupil_R FaceFitSkeleton`) $rightPupil=`getAttr FaceFitSkeleton.Pupil_R`; if (`attributeExists Pupil_R FaceFitSkeleton`) $rightIris=`getAttr FaceFitSkeleton.Iris_R`; //OldFaceFitSkeletonHolder createNode -n OldFaceFitSkeletonHolder transform; $tempString=`listRelatives -c -type transform FaceFitSkeleton`; for ($i=0;$iRig section, and turn OFF \"Z up Axis\".\n" +"Once the FaceSetup is complete you can turn back ON \"Z up Axis\".") -b "OK" -db "OK"; return; } if (!`gmatch $sel[0] "*.f*"`) error "No poly-faces selected, The polygons of the characters`s face must be selected."; progressBar -e -st "Storing Mask" -bp -ii 1 -min 0 -max 9 $gMainProgressBar; evalDeferred ("progressBar -e -ep "+$gMainProgressBar); $tempString=`listRelatives -s FaceFitSkeleton`; if (size($tempString)) delete $tempString; $tempString=`circle -c 0 0 0 -nr 0 1 0 -sw 360 -r 0.5 -d 3 -ut 0 -tol 0.000393701 -s 8 -ch 0`; rename $tempString[0] TempCircle; parent -add -s TempCircleShape FaceFitSkeleton; delete TempCircle; rename TempCircleShape FaceFitSkeletonShape; setAttr FaceFitSkeletonShape.overrideEnabled 1; setAttr FaceFitSkeletonShape.overrideColor 13; //scale -r -p 0 0 0 0.5 0.5 0.5 FaceFitSkeleton.cv[0:99]; rotate -r -p 0 0 0 -os 0 -90 0 FaceFitSkeleton.cv[0:99]; duplicate -n FaceFitSkeletonHeight FaceFitSkeleton; duplicate -n FaceFitSkeletonCircle FaceFitSkeleton; duplicate -n FaceFitSkeletonHeightCircle FaceFitSkeleton; parent -add -s FaceFitSkeletonHeightShape FaceFitSkeleton; parent -add -s FaceFitSkeletonCircleShape FaceFitSkeleton; parent -add -s FaceFitSkeletonHeightCircleShape FaceFitSkeleton; delete FaceFitSkeletonHeight FaceFitSkeletonCircle FaceFitSkeletonHeightCircle; move -r -os 0 1.0 0 FaceFitSkeletonHeightShape.cv[0:99] FaceFitSkeletonHeightCircleShape.cv[0:99]; if ($sel[0]!="") { select $sel; $bb=`xform -q -ws -bb`; $tempString=`listRelatives -s FaceFitSkeleton`; for ($i=0;$i-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; $spans=`getAttr ($upperLower+$section+$part+"Curve.spans")`; $degree=`getAttr ($upperLower+$section+$part+"Curve.degree")`; $numCVs=$spans+$degree; $middleCvNr=($numCVs-1)/2; $posA=`xform -q -ws -t ($upperLower+$section+$part+"Curve.cv["+$middleCvNr+"]")`; if ($section=="Lip") $posA=`xform -q -ws -t ($upperLower+$section+$part+"Curve.cv[0]")`; $posB=`xform -q -ws -t ($upperLower+$section+$part+"Curve.cv["+($numCVs-1)+"]")`; if ($leftSuffix=="Left") { $posA[0]=$posA[0]*-1; $posB[0]=$posB[0]*-1; } select -r $geometry; $tempString=`asDeformer softMod`; rename $tempString[0] ($upperLower+"TempSoftMod"); rename $tempString[1] ($upperLower+"TempSoftModHandle"); setAttr -type float3 ($upperLower+"TempSoftModHandleShape.origin") $posA[0] $posA[1] $posA[2]; setAttr ($upperLower+"TempSoftMod.falloffCenter") $posA[0] $posA[1] $posA[2]; xform -piv $posA[0] $posA[1] $posA[2] ($upperLower+"TempSoftModHandle"); setAttr ($upperLower+"TempSoftMod.falloffMode") 1; setAttr ($upperLower+"TempSoftMod.falloffRadius") `abs($posA[0]-$posB[0])`; move -r 0 ($scale/30.0*$upperLowerFactor) ($scale/10.0) ($upperLower+"TempSoftModHandle"); setAttr ($upperLower+"TempSoftMod.falloffCurve[3].falloffCurve_FloatValue") 1; setAttr ($upperLower+"TempSoftMod.falloffCurve[3].falloffCurve_Position") 0.5; setAttr ($upperLower+"TempSoftMod.falloffCurve[3].falloffCurve_Interp") 2; } print "// assist added.\n"; } global proc asCreateFaceFit (string $section,string $part,int $upAndLo,int $mainAndOuter,int $isSphere,string $shadingGroup) { int $nr,$sideVtxNr,$topVtxNr,$noseVtxNr,$lidInnerVtxNr,$lidOuterVtxNr,$numSel,$previousNumSel,$condition,$hitRighLowerStartVtx,$numNeighOnCurve; int $nonSymmetrical=`checkBox -q -v asFaceNonSymCheckBox`; int $selectionNeeded=1; int $selCompNrs[]; float $dist,$dist2,$maxDist,$minPosX,$maxPosX,$maxPosY,$falloffRadius,$tol,$maxPosY,$scale; float $pos[],$posA[],$posB[],$selPosX[],$selPosY[],$bb[]; string $upperLower,$growStartPos,$areaMeshShader,$closestSampler,$nearestVtx,$leftSuffix,$righLowerStartVtx; string $geometry=`textField -q -tx asFaceFaceTextField`; string $upperTeeth=`textField -q -tx asFaceUpperTeethTextField`; string $lowerTeeth=`textField -q -tx asFaceLowerTeethTextField`; string $tongue=`textField -q -tx asFaceTongueTextField`; string $tempString[],$tempString2[],$tempString3[],$tempString4[],$borderVtxs[],$edgesLidInnerNose[],$edgesNoseTop[]; string $edgesTopSide[],$edgesSideLidOuter[],$lipStartVtxs[],$selVtxs[],$leftLipSelection[],$deadEndVtxs[],$vtxs[],$previousVtxs[],$prevVtxs[],$vtxs1[],$vtxs2[]; if (`attributeExists NonSym FaceFitSkeleton`) if (`getAttr FaceFitSkeleton.NonSymSide`=="Left") $leftSuffix="Left"; if (`objExists asRunningFaceLipLeft`) $leftSuffix="Left"; if (`objExists ("FaceFit"+$section+$part+$leftSuffix)`) error ("FaceFit"+$section+$part+$leftSuffix+" Already Exists"); if (!`attributeExists faceScale FaceFitSkeleton`) error "Mask not defined. Choose \"Mask\" in the Pre section, by selecting polygons."; $scale=`getAttr FaceFitSkeleton.faceScale`; if ($section=="EyeBall") { asBuildFitEyeBall; return; } if ($section=="Tongue" || $section=="UpMidLo") { $selectionNeeded=0; select -cl; } string $sel[]=`ls -sl -fl`; int $numSelEdges[]; if (!`gmatch $sel[0] "*[.]*"` && $selectionNeeded) { error "No edge or vertex selected"; $numSelEdges=`polyEvaluate -edgeComponent`; } if (`objExists upperTempSoftModHandle`) delete upperTempSoftModHandle; if (`objExists lowerTempSoftModHandle`) delete lowerTempSoftModHandle; int $edgeSelection,$vertexSelection,$faceSelection,$startVtxSelected,$endVtxSelected; for ($i=0;$i0.001) select -d $tempString[$y]; if ($leftSuffix=="Left") if ($pos[0]<-0.001) select -d $tempString[$y]; } $tempString=`ls -sl -fl`; } $tol=0.001; if ($leftSuffix=="Left") $tol=9999; for ($y=0;$y$maxPos[0] && $pos[0]<$tol) {$maxPos[0]=$pos[0];$maxXVtx=$tempString[$y];} if ($pos[1]>$maxPos[1] && $pos[0]<$tol) {$maxPos[1]=$pos[1];$maxYVtx=$tempString[$y];} if ($pos[2]>$maxPos[2] && $pos[0]<$tol) {$maxPos[2]=$pos[2];$maxZVtx=$tempString[$y];} } for ($y=0;$y$posB[1]) {$startVtx=$deadEndVtxs[0];$endVtx=$deadEndVtxs[1];} if ($posA[1]<$posB[1]) {$startVtx=$deadEndVtxs[1];$endVtx=$deadEndVtxs[0];} } if ($section=="Pupil" || $section=="Iris") $endVtx=""; //fake a `spesified vtx`, for `Main` & `Inner`. $alignWithCurve="upper"+$section+"OuterCurve"; if (($part=="Main" || $part=="Inner") && `objExists $alignWithCurve` && !$startVtxSelected) { $closestSampler=`createNode -n closestSampler closestPointOnMesh`; connectAttr ($geometry+".outMesh") ($closestSampler+".inMesh"); $posA=`xform -q -ws -t ($alignWithCurve+".cv[0]")`; setAttr -type float3 ($closestSampler+".inPosition") $posA[0] $posA[1] $posA[2]; string $outerStartVtx=$geometry+".vtx["+`getAttr ($closestSampler+".result.closestVertexIndex")`+"]"; delete $closestSampler; float $closestDist=999;//$closestDist is numEdges to reach select $sel; ConvertSelectionToVertices; string $loopVtxs[]=`ls -sl -fl`; for ($i=0;$i1) for ($i=0;$i$maxPosY) { $maxPosY=$pos[1]; $startVtx=$lipStartVtxs[$i]; } } } select $startVtx; ConvertSelectionToEdges; $tempString=`ls -sl -fl`; for ($y=0;$y ($posB[0]+$posB[3])) $condition=1; if ($leftSuffix=="Left") $condition=!$condition; if ($condition) { $tempString[0]=$edge1; $edge1=$edge2; $edge2=$tempString[0]; } } //get $edges1[] $curveCmd="curve -n faceLoopCurve1 -d 1 "; $pos=`xform -q -ws -t $startVtx`; $curveCmd+=" -p "+$pos[0]+" "+$pos[1]+" "+$pos[2]; select $startVtx; $prevVtxs[0]=$startVtx; $vtxs1[size($vtxs1)]=$startVtx; string $coveredEdges[]; $around=0; for ($i=0;$i<199;$i++) { ConvertSelectionToEdges; $tempString=`ls -sl -fl`; for ($y=0;$y$maxPosX) { $sideVtxNr=$selCompNrs[$i]; $maxPosX=$selPosX[$i]; } } //find $topVtxNr for ($i=0;$i$maxPosY) { $topVtxNr=$selCompNrs[$i]; $maxPosY=$selPosY[$i]; } } //find $noseVtxNr for ($i=0;$i0 && size($lipStartVtxs) && `stringArrayCount $tempString2[0] $lipStartVtxs`) $hitSecondLipStartVtxs=1; if (`objExists asRunningFaceLipLeft`) if (`getAttr asRunningFaceLipLeft.righLowerStartVtx`==$tempString2[0]) $hitRighLowerStartVtx=1; if (size($lipStartVtxs) && $hitSecondLipStartVtxs==0) ; else if ($section=="Lip" && $pos[0]>0.001 && size($lipStartVtxs)==0 && !`objExists asRunningFaceLipLeft`) //only rightSide for Lip-curve ; else if ($section=="Lip" && $pos[0]<($posA[0]-0.001) && size($lipStartVtxs)==0 && `objExists asRunningFaceLipLeft`) //only rightSide for Lip-curve ; else { $curveCmd+=" -p "+$pos[0]+" "+$pos[1]+" "+$pos[2]; $vtxs2[size($vtxs2)]=$tempString2[0]; } select $tempString; if ($around) break; } ConvertSelectionToContainedEdges; eval $curveCmd; $tempString=`listRelatives -s faceLoopCurve1`; rename $tempString[0] faceLoopCurve1Shape; $tempString=`listRelatives -s faceLoopCurve2`; rename $tempString[0] faceLoopCurve2Shape; int $OneIsUpper; select $edges1; ConvertSelectionToVertices; $tempString=`ls -sl -fl`; for ($y=0;$y$posB[1]) $OneIsUpper=1; else $OneIsUpper=0; } //Special case detection of $OneIsUpper, on LipMain, as LowerVtx can be higher than UpperVtx if ($section=="Lip" && $part=="Main" && `objExists ("upperLipOuterCurve"+$leftSuffix)`) { $tempString[0]=`asGetFaceFitSelection ("upperLipOuterCurve"+$leftSuffix)`; $tempString=`stringToStringArray $tempString[0] " "`; string $upperOuterLipVtxZero=$tempString[0]; select $upperOuterLipVtxZero; for ($y=0;$y<10;$y++) { polySelectConstraint -pp 1 -t 0x0001;//GrowPolygonSelectionRegion(without print-out in Maya2018); $tempString=`ls -sl -fl`; if (`stringArrayCount $vtxs1[0] $tempString`) { $OneIsUpper=1; break; } if (`stringArrayCount $vtxs2[0] $tempString`) { $OneIsUpper=0; break; } } } //Same Special case detection for LipInner, but refering looking for LipMain if ($section=="Lip" && $part=="Inner" && `objExists ("upperLipMainCurve"+$leftSuffix)`) { $tempString[0]=`asGetFaceFitSelection ("upperLipMainCurve"+$leftSuffix)`; $tempString=`stringToStringArray $tempString[0] " "`; string $upperOuterLipVtxZero=$tempString[0]; select $upperOuterLipVtxZero; for ($y=0;$y<10;$y++) { polySelectConstraint -pp 1 -t 0x0001;//GrowPolygonSelectionRegion(without print-out in Maya2018); $tempString=`ls -sl -fl`; if (`stringArrayCount $vtxs1[0] $tempString`) { $OneIsUpper=1; break; } if (`stringArrayCount $vtxs2[0] $tempString`) { $OneIsUpper=0; break; } } } // string $upperVtxs[],$lowerVtxs[]; if ($OneIsUpper) { // $upperVtxs=$vtxs1; // $lowerVtxs=$vtxs2; rename faceLoopCurve1 ("upper"+$section+$part+"Curve"+$leftSuffix); rename faceLoopCurve2 ("lower"+$section+$part+"Curve"+$leftSuffix); } else { // $upperVtxs=$vtxs2; // $lowerVtxs=$vtxs1; rename faceLoopCurve1 ("lower"+$section+$part+"Curve"+$leftSuffix); rename faceLoopCurve2 ("upper"+$section+$part+"Curve"+$leftSuffix); } } if (!$upAndLo) { $tempString=`listRelatives -s faceLoopCurve1`; rename $tempString[0] faceLoopCurve1Shape; rename faceLoopCurve1 ($section+$part+"Curve"+$leftSuffix); } for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; if (!$upAndLo) $upperLower=""; if (!$upAndLo && $upperLowerFactor==-1) continue; parent ($upperLower+$section+$part+"Curve"+$leftSuffix) ("FaceFit"+$section+$part+"Curve"+$leftSuffix); makeIdentity -a 1 -t 1 -r 1 -s 1 ("FaceFit"+$section+$part+$leftSuffix); // setAttr ($upperLower+$section+$part+"CurveShape.dispCV") 1; setAttr ($upperLower+$section+$part+"Curve"+$leftSuffix+"Shape.overrideEnabled") 1; setAttr ($upperLower+$section+$part+"Curve"+$leftSuffix+"Shape.overrideColor") 17;//Yellow //Colors if ($part=="Main") setAttr ($upperLower+$section+$part+"Curve"+$leftSuffix+"Shape.overrideColor") 13;//Red if ($part=="Outer") setAttr ($upperLower+$section+$part+"Curve"+$leftSuffix+"Shape.overrideColor") 14;//Green if ($part=="Inner") setAttr ($upperLower+$section+$part+"Curve"+$leftSuffix+"Shape.overrideColor") 15;//Blue } if ($mainAndOuter==0) $part=""; else $parts={"Main","Outer"}; for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; if ($upAndLo==0) $upperLower=""; if ($upAndLo==0 && $upperLowerFactor==-1) continue; if ($isSphere) continue; $tempString=`circle -c 0 0 0 -nr 0 1 0 -sw 360 -r ($scale/400.0) -d 3 -ut 0 -tol 0.000393701 -s 8 -ch 0`; rename $tempString[0] ($section+"Profile"+$part+$leftSuffix); parent ($section+"Profile"+$part+$leftSuffix) ("FaceFit"+$section+$part+"Curve"+$leftSuffix); extrude -n ($upperLower+$section+"Cylinder"+$part+$leftSuffix) -ch 0 -rn false -po 0 -et 2 -ucp 1 -fpt 1 -upn 1 -rotation 0 -scale 1 -rsp 0 ($section+"Profile"+$part+$leftSuffix) ($upperLower+$section+$part+"Curve"+$leftSuffix); delete ($section+"Profile"+$part+$leftSuffix); setAttr ($upperLower+$section+"Cylinder"+$part+$leftSuffix+".overrideEnabled") 1; setAttr ($upperLower+$section+"Cylinder"+$part+$leftSuffix+".overrideDisplayType") 2; setAttr ($upperLower+$section+"Cylinder"+$part+$leftSuffix+"Shape.curvePrecisionShaded") 4; parent ($upperLower+$section+"Cylinder"+$part+$leftSuffix) ("FaceFit"+$section+$part+"Geo"+$leftSuffix); //ensure outwards normals $posA=`xform -q -ws -t ($upperLower+$section+"Cylinder"+$part+$leftSuffix+".cv[6][0]")`; $posB=`xform -q -ws -t ($upperLower+$section+"Cylinder"+$part+$leftSuffix+".cv[6][1]")`; if ($posA[1]>$posB[1]) reverseSurface -d 0 -ch 0 -rpo 1 ($upperLower+$section+"Cylinder"+$part+$leftSuffix); //Colors if ($part=="Outer" || $part=="Main" || $part=="Inner") { sets -e -forceElement "asGreenSG" ($upperLower+$section+"Cylinder"+$part+$leftSuffix); if ($upperLower=="lower") sets -e -forceElement "asGreen2SG" ($upperLower+$section+"Cylinder"+$part+$leftSuffix); } if ($section=="Tongue") sets -e -forceElement "asRedSG" ($section+"Cylinder"+$part+$leftSuffix); } if (`gmatch $section "*Line"` || $section=="Pupil" || $section=="Iris") { sets -e -forceElement $shadingGroup ($section+"Cylinder"+$leftSuffix); } if ($section=="ForeHead" || ($section=="EyeLid" && $part=="Inner") || ($section=="Lip" && $part=="Inner")) { select $sel; $tempString=`ls -sl -fl`; if ($section=="ForeHead") { $areaMeshShader="asGreenSG"; sets -e -forceElement "asGreenSG" ($section+"Cylinder"+$part+$leftSuffix); asFaceFitReSelect EyeLid Outer; $growStartPos="EyeBrowInner"+$leftSuffix; } if (($section=="EyeLid" && $part=="Inner") || ($section=="Lip" && $part=="Inner")) { $areaMeshShader="asRedSG"; loft -n tempLoft -ch 0 -u 1 -c 0 -ar 1 -d 3 -ss 2 -rn 0 -po 0 -rsn true ("upper"+$section+"OuterCurve"+$leftSuffix) ("upper"+$section+"MainCurve"+$leftSuffix) ("upper"+$section+"InnerCurve"+$leftSuffix); $growStartPos="upper"+$section+"MainCurve"+$leftSuffix+".cv["+(`getAttr ("upper"+$section+"MainCurve"+$leftSuffix+".spans")`/2)+"]"; asFaceFitReSelect $section Outer; } select -add $tempString; ConvertSelectionToVertices; $borderVtxs=`ls -sl -fl`; if (`objExists closestSampler`) delete closestSampler; createNode -n closestSampler closestPointOnMesh; connectAttr ($geometry+".outMesh") closestSampler.inMesh; $pos=`xform -q -ws -t $growStartPos`; setAttr -type float3 closestSampler.inPosition $pos[0] $pos[1] $pos[2]; if (`objExists tempLoft`) delete tempLoft; select ($geometry+".vtx["+`getAttr closestSampler.result.closestVertexIndex`+"]"); for ($i=0;$i<199;$i++) { polySelectConstraint -pp 1 -t 0x0001;//GrowPolygonSelectionRegion(without print-out in Maya2018); select -d $borderVtxs; $previousNumSel=$numSel; $tempString=`ls -sl -fl`; $numSel=size($tempString); if ($numSel==$previousNumSel) break; } delete closestSampler; ConvertSelectionToFaces; $tempString=`ls -sl -fl`; polyCube -n ($section+$part+"AreaMesh"+$leftSuffix) -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 0; sets -e -forceElement $areaMeshShader ($section+$part+"AreaMesh"+$leftSuffix); connectAttr ($geometry+".outMesh") ($section+$part+"AreaMesh"+$leftSuffix+".inMesh"); refresh; disconnectAttr ($geometry+".outMesh") ($section+$part+"AreaMesh"+$leftSuffix+".inMesh"); parent ($section+$part+"AreaMesh"+$leftSuffix) ("FaceFit"+$section+$part+"Geo"+$leftSuffix); select `asobjSetCast "" $tempString ($section+$part+"AreaMesh"+$leftSuffix)`; asInvertSelection; // setAttr ("FaceFit"+$section+$part+"Geo"+$leftSuffix+".inheritsTransform") 1;//temp switch On, to avoid Delete cmd switching this On delete; // setAttr ("FaceFit"+$section+$part+"Geo"+$leftSuffix+".inheritsTransform") 0; //Offset `outwards`with polyExtrude duplicate -n ($section+$part+"AreaMeshExtrude"+$leftSuffix) ($section+$part+"AreaMesh"+$leftSuffix); setAttr ($section+$part+"AreaMesh"+$leftSuffix+".v") 0; select ($section+$part+"AreaMeshExtrude"+$leftSuffix); $tempString=`polyExtrudeFacet -constructionHistory 1 -localTranslateZ ($scale/500.0) -keepFacesTogether 1 -divisions 1 -twist 0 -taper 1 -off 0 -thickness 0 -smoothingAngle 30`; rename $tempString[0] ($section+$part+"AreaMeshPolyExtrudeFacet"+$leftSuffix); $tempString=`listRelatives -s ($section+$part+"AreaMeshExtrude"+$leftSuffix)`; for ($i=0;$i$tysAverage) select -add $tempString[$y]; } global proc asForeHeadFromEdges () { string $sel[]=`ls -sl`; createNode -n ForeHeadFromEdges transform; select $sel; asCreateFaceFit ForeHead "" 0 0 0 asGreenSG; delete ForeHeadFromEdges; } global proc asSelectLeastEdgesPath (string $geometry, int $startVtxNr, int $endVtxNr) { string $sel[]=`ls -sl`; string $loopRingVtxs[],$ShortestPathVtxs[]; select $geometry; //First check for Loop or Ring, as this might be the "Path of Less Edges", which is prefferd over `shortest Path` select ($geometry+".vtx["+$startVtxNr+"]") ($geometry+".vtx["+$endVtxNr+"]"); $loopRingVtxs=`polySelectSp -q -loop`; //must contain start & end vtx in path if (size($loopRingVtxs)) { select $loopRingVtxs; $loopRingVtxs=`ls -sl -fl`; if (!`stringArrayCount ($geometry+".vtx["+$startVtxNr+"]") $loopRingVtxs`) { select -cl; clear $loopRingVtxs; } if (!`stringArrayCount ($geometry+".vtx["+$endVtxNr+"]") $loopRingVtxs`) { select -cl; clear $loopRingVtxs; } } if (!size($loopRingVtxs))//try edgeRing instead of edgeLoop $loopRingVtxs=`polySelectSp -q -ring`; //must contain end vtx in path if (size($loopRingVtxs)) { select $loopRingVtxs; $loopRingVtxs=`ls -sl -fl`; if (!`stringArrayCount ($geometry+".vtx["+$endVtxNr+"]") $loopRingVtxs`) { select -cl; clear $loopRingVtxs; } } //special case, loop or ring might have far more edges then shortestEdgePath, as it might loop and the expand, select $geometry; select `polySelect -q -asSelectString -shortestEdgePath $startVtxNr $endVtxNr`; $ShortestPathVtxs=`ls -sl -fl`; if (size($loopRingVtxs)>size($ShortestPathVtxs)+3)//more then 3 edges more, switching back to shortestEdgePath clear $loopRingVtxs; if (size($loopRingVtxs)) { select $loopRingVtxs; ConvertSelectionToContainedEdges; } else { select $geometry; select `polySelect -q -asSelectString -shortestEdgePath $startVtxNr $endVtxNr`; } } global proc int asFaceRemoveBodyJaw () { int $return=0; string $dialog="OK"; if (!`objExists headTopology`) $dialog=`confirmDialog -t "Confirm" -m "This will replace the Jaw from the Body-setup" -b "OK" -db "OK" -b "Cancel" -ds "Cancel"`; if ($dialog=="OK") $return=1; string $skinClusters[]=`ls -type skinCluster`; for ($i=0;$i=5.352) { if (`objExists FaceFitEyeBrowOuter` && `objExists EyeBrowOuterCurve`) delete FaceFitEyeBrowOuter; if (`objExists FaceFitEyeBrowMain`) delete FaceFitEyeBrowMain; if (`objExists FaceFitEyeLidInner`) { asFaceFitReSelect EyeLid "Inner"; delete FaceFitEyeLidInner; asCreateFaceFit EyeLid "Inner" 1 1 0 asGreenSG; } if (`objExists FaceFitLipInner`) { asFaceFitReSelect Lip "Inner"; delete FaceFitLipInner; asCreateFaceFit Lip "Inner" 1 1 0 asGreenSG; } if (`objExists FaceFitAnimateFit`) delete FaceFitAnimateFit; } //v5.354 to v5.355 if (`asGetScriptVersion`>=5.355) { string $oldNames[]={"cheek","line","cheekRaiser","noseCorner"}; string $newNames[]={"Cheek","Line","CheekRaiser","NoseCorner"}; for ($i=0;$i1 || $tempString[0]!=$headJoint) { $dialog=`confirmDialog -t "Confirm" -m "Selected vertices are not fully weighted to the headjoint." -b "Weight face to headjoint" -db "Weight face to headjoint" -b "No, keep current weighting" -b "Cancel" -ds "Cancel"`; if ($dialog=="Weight face to headjoint") skinPercent -tv $headJoint 1 $skinCluster; if ($dialog=="Cancel") error "Aborted due to Face vertices not weighted to head-joint"; } select -cl; } */ if (`asIsMayaLT`) { $dialog=`confirmDialog -t "Confirm" -m "Maya LT detected.\n\nFaceSetup will not be as accurate,\ndue to missing deformer types." -b "Ok, continue" -db "Ok, continue" -b "Cancel" -ds "Cancel"`; if ($dialog=="Cancel") error "Aborted due to Maya LT warning."; } //ensure not leaving behind assists if (`objExists upperTempSoftModHandle`) delete upperTempSoftModHandle; if (`objExists lowerTempSoftModHandle`) delete lowerTempSoftModHandle; //another non-unique name check, first check is at asChooseInput for ($i=0;$i1) $headJointNonNS=$tempString[size($tempString)-1]; //non-spherical eyes. $sca=`getAttr FitEyeBall.s`; if ($sca[0]>=($sca[1]+0.001) || $sca[0]<=($sca[1]-0.001) || $sca[0]>=($sca[2]+0.001) || $sca[0]<=($sca[2]-0.001)) { if (!`attributeExists nonSphericalEye FitEyeBall`) addAttr -ln nonSphericalEye -at bool -dv 1 FitEyeBall; $dialog=`confirmDialog -t "Confirm" -m "FitEyeBall is squashed.\nCreate Non-spherical Eye-Setup ?" -b "Yes" -db "Yes" -b "Cancel" -ds "Cancel"`; if ($dialog!="Yes") { select FitEyeBall; error "FitEyeBall is squashed."; } if ($dialog=="Yes") if (`attributeExists GameEngine FaceFitSkeleton`) if (`getAttr FaceFitSkeleton.GameEngine`) error "FitEyeBall is squashed. And options are set to \"game engine\.\nNon-spherical Eye-Setup is not compatible with GameEngines."; } //EyeAimSetup createNode -n EyeAimSetup -p EyeSetup transform; createNode -n EyeAimFollowHead -p EyeAimSetup transform; createNode -n EyeAimStatic -p EyeAimSetup transform; parentConstraint $headJoint EyeAimFollowHead; asAlign EyeAimStatic $headJoint 1 1 0 0; //scaleConstraint $headJoint EyeAimFollowHead; connectAttr MainAndHeadScaleMultiplyDivide.output EyeAimFollowHead.s; $tempString[0]=`curve -d 1 -p 0 1 0 -p 0 -1 0 -p 0 0 0 -p 1 0 0 -p -1 0 0 -k 0 -k 1 -k 2 -k 3 -k 4`; rename $tempString[0] AimEye_M; setAttr AimEye_MShape.overrideEnabled 1; connectAttr ctrlBox.AimCtrlVis AimEye_MShape.overrideVisibility; //connectAttr ctrlBox.AimCtrlColor AimEye_MShape.overrideColor; setAttr AimEye_MShape.overrideColor 17; sets -add FaceControlSet AimEye_M; //scale -r -p 0 0 0 ($scale/10.0) ($scale/10.0) ($scale/10.0) AimEye_M.cv[0:4]; createNode -n AimAimAt -p EyeAimSetup transform; xform -ws -t 0 $eyeBallPos[1] $eyeBallPos[2] AimAimAt; //aimConstraint -offset 0 0 0 -weight 1 -aimVector 0 0 -1 -upVector 0 1 0 -worldUpType "objectrotation" -worldUpVector 1 0 0 -worldUpObject AimAimAt AimAimAt AimEye_M; //setAttr -k 0 AimEye_M.rx;setAttr -k 0 AimEye_M.ry;setAttr -k 0 AimEye_M.rz; createNode -n AimEyeOffset_M transform; createNode -n AimEyeFollow_M transform; parent AimEyeFollow_M Aimcontrols; asAlign AimEyeFollow_M $headJoint 1 1 0 0; parent AimEye_M AimEyeOffset_M; setAttr -type float3 AimEyeOffset_M.s ($faceFitScale/10.0) ($faceFitScale/10.0) ($faceFitScale/10.0); asAlign AimEyeOffset_M AimEyeFollow_M 1 0 0 0; parent AimEyeOffset_M AimEyeFollow_M; xform -ws -t 0 $eyeBallPos[1] ($eyeBallPos[2]+$faceFitScale) AimEyeOffset_M; createNode -n AimEyeUpVec transform; parent AimEyeUpVec EyeAimFollowHead; addAttr -k 1 -ln follow -at double -min 0 -max 10 -dv 10 AimEye_M; createNode -n eyeAimFollowSetRange setRange; setAttr eyeAimFollowSetRange.minX 0;setAttr eyeAimFollowSetRange.minY 1; setAttr eyeAimFollowSetRange.maxX 1;setAttr eyeAimFollowSetRange.maxY 0; setAttr eyeAimFollowSetRange.oldMinX 0;setAttr eyeAimFollowSetRange.oldMinY 0; setAttr eyeAimFollowSetRange.oldMaxX 10;setAttr eyeAimFollowSetRange.oldMaxY 10; connectAttr AimEye_M.follow eyeAimFollowSetRange.value.valueX; connectAttr AimEye_M.follow eyeAimFollowSetRange.value.valueY; parentConstraint $headJoint EyeAimStatic AimEyeFollow_M; connectAttr eyeAimFollowSetRange.outValue.outValueY AimEyeFollow_M_parentConstraint1.EyeAimStaticW1; connectAttr eyeAimFollowSetRange.outValue.outValueX ("AimEyeFollow_M_parentConstraint1."+$headJointNonNS+"W0"); for ($b=1;$b>-2;$b=$b-2) { if (!`objExists FitEyeBall`) continue; if ($b==1) {$side="_R";$leftRight="Right";$leftSuffix="";} else {$side="_L";$leftRight="Left";$leftSuffix="Left";} $pos=$eyeBallPos; if ($side=="_L") { if (`objExists FitEyeBallLeft`) $pos=`xform -q -ws -t FitEyeBallLeft`; else $pos[0]=$eyeBallPos[0]*-1; } //EyeRegion asCreateFaceController "EyeRegion" $side 4; delete ("EyeRegionJoint"+$side); xform -ws -t $pos[0] $pos[1] $pos[2] ("EyeRegionOffset"+$side); scale -r -p $pos[0] $pos[1] $pos[2] 6 6 6 ("EyeRegion"+$side+".cv[0:7]"); parent ("EyeRegionOffset"+$side) ("SideReverse"+$side); xform -os -ro 0 0 0 -s 1 1 1 ("EyeRegionOffset"+$side); asFacePlaceCtrlByProjection ("EyeRegion"+$side); //Eye asCreateFaceController "Eye" $side 3; setAttr ("Eye"+$side+".rotateOrder") 2; setAttr ("EyeOffset"+$side+".s") -type float3 1 1 1; xform -ws -t $pos[0] $pos[1] $pos[2] ("EyeOffset"+$side); $pos=`xform -q -ws -t ("Eye"+$side)`; scale -r -p $pos[0] $pos[1] $pos[2] 2.16 2.16 2.16 ("Eye"+$side+".cv[0:7]"); setAttr ("Eye"+$side+"Shape.overrideColor") 18; connectAttr -f ctrlBox.EyeCtrlVis ("Eye"+$side+"Shape.overrideVisibility"); select FaceJoint_M; joint -n ("EyeJoint"+$side); setAttr ("EyeJoint"+$side+".rotateOrder") 2; xform -ws -t ($eyeBallPos[0]*$b) $eyeBallPos[1] $eyeBallPos[2] ("EyeJoint"+$side); if (!`objExists EyeControls`) { createNode -n EyeControls -p OnFacecontrols transform; parent EyeControls ControlsSetup; xform -s 1 1 1 EyeControls; } parent ("EyeOffset"+$side) EyeControls; xform -os -ro 0 0 0 -s 1 1 1 ("EyeOffset"+$side); orientConstraint FitEyeBall ("EyeOffset"+$side); delete ("EyeOffset"+$side+"_orientConstraint1"); if ($side=="_L") setAttr EyeOffset_L.ry (`getAttr EyeOffset_L.ry`*-1); delete `parentConstraint ("Eye"+$side) ("EyeJoint"+$side)`; makeIdentity -a 1 -t 0 -r 1 -s 0 ("EyeJoint"+$side); parentConstraint ("Eye"+$side) ("EyeJoint"+$side); scaleConstraint -mo ("Eye"+$side) ("EyeJoint"+$side); setAttr ("EyeJoint"+$side+".segmentScaleCompensate") 0; $eyeJoint="EyeJoint"+$side; $eye=`textField -q -tx ("asFace"+$leftRight+"EyeTextField")`; if ($eye=="") continue; tokenize $eye " " $tempString; clear $eyeGeos; for ($i=0;$i-2;$b=$b-2) { if ($b==1) {$side="_R";$rightLeft="Right";$leftSuffix="";} else {$side="_L";$rightLeft="Left";$leftSuffix="Left";} $eyeCtrl="ctrlEye"+$side; //if multiple objects defined as eyeGeo, we need to guess the correct one, by closest Vtx, and re-order it to $eyeGeos[0] $tempString[0]=`textField -q -tx ("asFace"+$rightLeft+"EyeTextField")`; $eyeGeos=`stringToStringArray $tempString[0] " "`; $minDist=999; if (size($eyeGeos)>1) { $posA=`xform -q -ws -t ("PupilCurve"+$leftSuffix+".cv[0]")`; createNode -n closestSampler closestPointOnMesh; for ($i=0;$i>`; if ($dist<$minDist) { $minDist=$dist; $nearestEyeGeo=$eyeGeos[$i]; } } delete closestSampler; if ($nearestEyeGeo!=$eyeGeos[0]) { $eyeGeos=`stringArrayRemove {$nearestEyeGeo} $eyeGeos`; stringArrayInsertAtIndex 0 $eyeGeos $nearestEyeGeo; } } $pupilText=`asGetFaceFitSelectionOtherObject ("PupilCurve"+$leftSuffix) $eyeGeos[0] $side`; $irisText=`asGetFaceFitSelectionOtherObject ("IrisCurve"+$leftSuffix) $eyeGeos[0] $side`; if ($pupilText=="") {warning ("Pupil"+$side+" EdgeLoop not defined");continue;} if ($irisText=="") {warning ("Iris"+$side+" EdgeLoop not defined");continue;} else $addIrisAttr=1; eval ("select "+$pupilText); ConvertSelectionToVertices; $pupilVtxs=`ls -sl -fl`; $bb=`xform -q -bb`; $pupilCenterPos={(($bb[3]+$bb[0])/2.0),(($bb[4]+$bb[1])/2.0),(($bb[5]+$bb[2])/2.0)}; $pupilRadius=($bb[4]-$bb[1])/2.0; eval ("select "+$irisText); ConvertSelectionToVertices; $irisVtxs=`ls -sl -fl`; $bb=`xform -q -bb`; $irisCenterPos={(($bb[3]+$bb[0])/2.0),(($bb[4]+$bb[1])/2.0),(($bb[5]+$bb[2])/2.0)}; $irisRadius=($bb[4]-$bb[1])/2.0; //find $eyeGeo & $eyeRadius // tokenize $pupilVtxs[0] "[.]" $tempString; // $eyeGeo=$tempString[0]; $bb=`xform -q -ws -bb $eyeGeos[0]`; $eyeRadius=($bb[4]-$bb[1])/2.0; //find $backHalfVtxs select $eyeGeos[0]; ConvertSelectionToVertices; $tempString=`ls -sl -fl`; createNode -n tempTransform -p ("EyeJoint"+$side) transform; for ($i=0;$i-2;$a=$a-2) { if ($a==1) {$pupilIris="Pupil";$pupilIrisLowerCase="pupil";$pos=$pupilCenterPos;$vtxs=$pupilVtxs;$radius=$pupilRadius;$type=2;} else {$pupilIris="Iris";$pupilIrisLowerCase="iris";$pos=$irisCenterPos;$vtxs=$irisVtxs;$radius=$irisRadius;$type=1;} asCreateFaceController $pupilIris $side $type; connectAttr -f ctrlBox.EyeCtrlVis ($pupilIris+$side+"Shape.overrideVisibility"); select ("EyeJoint"+$side); joint -n ($pupilIris+"Joint"+$side); setAttr ($pupilIris+"Joint"+$side+".segmentScaleCompensate") 0; parentConstraint ($pupilIris+$side) ($pupilIris+"Joint"+$side); scaleConstraint -mo ($pupilIris+$side) ($pupilIris+"Joint"+$side); scale -p 0 0 0 ($radius*4.0) ($radius*4.0) ($radius*4.0) ($pupilIris+$side+".cv[0:7]"); move -r -os -wd 0 0 ($scale/100.0) ($pupilIris+$side+".cv[0:7]"); xform -ws -t $pos[0] $pos[1] $pos[2] ($pupilIris+"Offset"+$side) ($pupilIris+"Joint"+$side); parent ($pupilIris+"Offset"+$side) ("Eye"+$side); //orient to eye setAttr ($pupilIris+"Offset"+$side+".r") 0 0 0; // if ($side=="_L") // setAttr ($pupilIris+"Offset"+$side+".r") 180 0 180; //AddAttr if ($a==1) //Add Iris attr first, so Pupil attr appear last { addAttr -k $addIrisAttr -ln iris -at double -smn -10 -hsn 1 -smx 10 -hsx 1 -dv 0 $eyeCtrl; addAttr -k 1 -ln pupil -at double -smn -10 -hsn 1 -smx 10 -hsx 1 -dv 0 $eyeCtrl; } skinCluster -e -ai ($pupilIris+"Joint"+$side) -lw false -wt 0 $skinCluster; skinPercent -tv ("EyeJoint"+$side) 1 $skinCluster $eyeGeos[0];//unusual normalize required (only fresh scene, not undone) skinPercent -tv ($pupilIris+"Joint"+$side) 1 $skinCluster $vtxs; } parent ("PupilOffset"+$side) ("Iris"+$side); parent ("PupilJoint"+$side) ("IrisJoint"+$side); select $pupilVtxs[0]; ConvertSelectionToEdges; ConvertSelectionToVertices; select -d $pupilVtxs; $tempString=`ls -sl -fl`; //Grow A select $tempString[0]; for ($i=0;$i<99;$i++) { if (`stringArrayCount $tempString[0] $irisVtxs`) // IrisLoops is next to PupilLoop {$IrisLoopNextToPupilLoop=1;select $irisVtxs;break;} polySelectConstraint -pp 1 -t 0x0001;//GrowPolygonSelectionRegion(without print-out in Maya2018); select -d $pupilVtxs $irisVtxs; if (size(`ls -sl -fl`)==size($tempString2))//same count as previously break; $tempString2=`ls -sl -fl`; } $sideAVtxs=`ls -sl -fl`; //Grow B if ($tempString[1]=="") //If pupil is a hole in the geometry { $outerVtxs=$sideAVtxs; $innerVtxs=$pupilVtxs; } else { select $tempString[1]; for ($i=0;$i<99;$i++) { if (`stringArrayCount $tempString[1] $irisVtxs`) // IrisLoops is next to PupilLoop {$IrisLoopNextToPupilLoop=1;select $irisVtxs;break;} polySelectConstraint -pp 1 -t 0x0001;//GrowPolygonSelectionRegion(without print-out in Maya2018); select -d $pupilVtxs $irisVtxs; if (size(`ls -sl -fl`)==size($tempString2))//same count as previously break; $tempString2=`ls -sl -fl`; } $sideBVtxs=`ls -sl -fl`; //Determine A/B is Inner/Outer $bbA=`xform -q -bb $sideAVtxs`; $bbB=`xform -q -bb $sideBVtxs`; $xyzA=($bbA[3]-$bbA[0]) + ($bbA[4]-$bbA[1]) + ($bbA[5]-$bbA[2]); $xyzB=($bbB[3]-$bbB[0]) + ($bbB[4]-$bbB[1]) + ($bbB[5]-$bbB[2]); if ($xyzA<$xyzB) { $innerVtxs=$sideAVtxs; $outerVtxs=$sideBVtxs; } else { $innerVtxs=$sideBVtxs; $outerVtxs=$sideAVtxs; } } //find $loopsFromPupilToIris select $pupilVtxs[0]; for ($i=0;$i<10;$i++) { polySelectConstraint -pp 1 -t 0x0001; $tempString=`ls -sl -fl`; for ($y=0;$y>`; createNode -n tempXform -p FitEyeBall transform; setAttr tempXform.tz 0.5; $posA=`xform -q -ws -t tempXform`; delete tempXform; $dist2=`mag<<$posA[0]-$posB[0],$posA[1]-$posB[1],$posA[2]-$posB[2]>>`; for ($z=0;$z-2;$a=$a-2) { if ($a==1) {$pupilIris="Pupil";$pupilIrisLowerCase="pupil";$vtxs=$pupilVtxs;} else {$pupilIris="Iris";$pupilIrisLowerCase="iris";$vtxs=$irisVtxs;} if ($a==-1 && !$addIrisAttr) continue; $buildPose="faceBuildPose"; if (!`objExists $buildPose`) $buildPose="buildPose"; $setAttrCmdExtra="setAttr "+$eyeCtrl+"."+$pupilIrisLowerCase+" 0;"; setAttr -type "string" ($buildPose+".udAttr") (`getAttr ($buildPose+".udAttr")`+$setAttrCmdExtra); } } delete TempPos; select -cl; } global proc asFaceEyeLid () { global string $gMainProgressBar; int $tempInts[]; int $numSelVtx,$prevNumSelVtx,$twoWayVtxInside,$lidMainVtxNr,$lidInnerVtxNr,$lidOuterVtxNr,$spans,$lockedWeight,$numVtx; int $nonSymmetrical=`checkBox -q -v asFaceNonSymCheckBox`; int $gameEngine=`checkBox -q -v asFaceGameEngineCheckBox`; int $upperEyeLidOuterNumCVs=`getAttr upperEyeLidOuterCurve.spans`+1; float $pos[],$posA[],$posB[],$posC[]; float $maxValue,$maxValue2,$lidFollowMultiplier,$previousMag,$mag,$tyValueForCloseLid,$upperTyValueForCloseLid,$lowerTyValueForCloseLid; string $upperLower,$upperLowerOpposite,$lidJoint,$eyeJoint,$maxTransform,$maxTransform2,$cmd,$leftSuffix,$InnerOuter,$innerouter; string $tempString[],$tempString2[],$tempString3[],$tempString4[],$infs[],$transforms[]; string $outerVtxs[],$mainVtxs[],$innerVtxs[],$drivenJoints[],$rowVtxs[],$previousVtxs[]; string $upLoOuterVtxs[],$upLoMainVtxs[],$upLoInnerVtxs[],$innerOuterVtx[],$rowWeightedVtxs[]; string $geometry=`textField -q -tx asFaceFaceTextField`; string $eyeLash=`textField -q -tx asFaceEyelashTextField`; string $headJoint=`textField -q -tx asFaceHeadJointTextField`; string $skinCluster=`textField -q -tx asFaceSkinClusterTextField`; float $scale=`getAttr FaceFitSkeleton.faceScale`; if (!`objExists upperEyeLidMainCurve`)//skip return; setAttr ctrlEye_L.tx 0;setAttr ctrlEye_L.ty 0; setAttr ctrlEye_R.tx 0;setAttr ctrlEye_R.ty 0; asFaceHideControllers 1; setAttr ctrlBoxEye_R.v 1; setAttr ctrlBoxEye_L.v 1; setAttr EyeRegionOffset_R.v 1; setAttr EyeRegionOffset_L.v 1; createNode -n LidSetup -p FaceDeformationSystem transform; createNode -n LidJoints -p LidSetup transform; createNode -n TempPos transform; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; createNode -n ("LidSetup"+$side) transform; asAlign ("LidSetup"+$side) ("Eye"+$side) 1 1 0 0; parentConstraint ("EyeRegion"+$side) ("LidSetup"+$side); scaleConstraint ("EyeRegion"+$side) ("LidSetup"+$side); parent ("LidSetup"+$side) LidSetup; } //custom FaceControlOrient object for lid rename FaceControlOrient FaceControlOrientTemp; $posA=`xform -q -ws -t upperEyeLidMainCurve.cv[99]`; $posB=`xform -q -ws -t upperEyeLidMainCurve.cv[0]`; //nurbsPlane -n FaceControlOrient -p 0 0 0 -ax 0 1 0 -w 1 -lr 1 -d 3 -u 1 -v 1 -ch 0; polyPlane -n FaceControlOrient -w 1 -h 1 -sx 3 -sy 1 -ax 0 1 0 -cuv 2 -ch 0; sets -e -forceElement asRedSG FaceControlOrient; polySoftEdge -a 0 -ch 0 FaceControlOrient; xform -ws -t 0 (($posA[1]+$posB[1])/2.0) (($posA[2]+$posB[2])/2.0) FaceControlOrient; setAttr FaceControlOrient.rx 90; //xform -ws -t $posB[0] $posB[1] $posB[2] TempPos; //delete `aimConstraint -offset 0 0 0 -weight 1 -aimVector 1 0 0 -upVector 0 0 -1 -worldUpType "scene" TempPos FaceControlOrient`; setAttr FaceControlOrient.s -type float3 $scale $scale $scale; /* createNode -n tempTransform transform; parent tempTransform FaceControlOrient; setAttr tempTransform.ty 0; setAttr tempTransform.tz 0; */ $posC=`xform -q -ws -t FaceControlOrientShape.vtx[4]`; xform -ws -t $posA[0] $posC[1] $posA[2] FaceControlOrientShape.vtx[4]; $posC=`xform -q -ws -t FaceControlOrientShape.vtx[0]`; xform -ws -t $posA[0] $posC[1] $posA[2] FaceControlOrientShape.vtx[0]; $posC=`xform -q -ws -t FaceControlOrientShape.vtx[5]`; xform -ws -t $posB[0] $posC[1] $posB[2] FaceControlOrientShape.vtx[5]; $posC=`xform -q -ws -t FaceControlOrientShape.vtx[1]`; xform -ws -t $posB[0] $posC[1] $posB[2] FaceControlOrientShape.vtx[1]; $posA=`xform -q -ws -t upperEyeLidMainCurveLeft.cv[99]`; $posB=`xform -q -ws -t upperEyeLidMainCurveLeft.cv[0]`; $posC=`xform -q -ws -t FaceControlOrientShape.vtx[7]`; xform -ws -t $posA[0] $posC[1] $posA[2] FaceControlOrientShape.vtx[7]; $posC=`xform -q -ws -t FaceControlOrientShape.vtx[3]`; xform -ws -t $posA[0] $posC[1] $posA[2] FaceControlOrientShape.vtx[3]; $posC=`xform -q -ws -t FaceControlOrientShape.vtx[6]`; xform -ws -t $posB[0] $posC[1] $posB[2] FaceControlOrientShape.vtx[6]; $posC=`xform -q -ws -t FaceControlOrientShape.vtx[2]`; xform -ws -t $posB[0] $posC[1] $posB[2] FaceControlOrientShape.vtx[2]; parent FaceControlOrient FaceBuildInProgressHidden; /* loft -n FaceControlOrient -ch 0 -u 1 -c 0 -ar 1 -d 3 -ss 1 -rn 0 -po 0 -rsn true "upperEyeLidMainCurve" "lowerEyeLidMainCurve"; select FaceControlOrient; CenterPivot; setAttr FaceControlOrient.s -type float3 1.2 1.2 1.2; duplicate -n test FaceControlOrient; */ /* $cmd="curve -n FaceControlOrientCurve -d 3"; for ($i=0;$i<8;$i++) $cmd+=" -p 0 0 0"; eval ($cmd); rename FaceControlOrient FaceControlOrientTemp; $pos=`xform -q -ws -t upperEyeLidMainCurve.cv[99]`; xform -ws -t $pos[0] $pos[1] $pos[2] FaceControlOrientCurve.ep[0]; $pos=`xform -q -ws -t upperEyeLidMainCurve.cv[($upperEyeLidOuterNumCVs/2)]`; xform -ws -t $pos[0] $pos[1] $pos[2] FaceControlOrientCurve.ep[1]; $pos=`xform -q -ws -t upperEyeLidMainCurve.cv[0]`; xform -ws -t $pos[0] $pos[1] $pos[2] FaceControlOrientCurve.ep[2]; $pos=`xform -q -ws -t upperEyeLidMainCurveLeft.cv[0]`; xform -ws -t $pos[0] $pos[1] $pos[2] FaceControlOrientCurve.ep[3]; $pos=`xform -q -ws -t upperEyeLidMainCurveLeft.cv[($upperEyeLidOuterNumCVs/2)]`; xform -ws -t $pos[0] $pos[1] $pos[2] FaceControlOrientCurve.ep[4]; $pos=`xform -q -ws -t upperEyeLidMainCurveLeft.cv[99]`; xform -ws -t $pos[0] $pos[1] $pos[2] FaceControlOrientCurve.ep[5]; extrude -n FaceControlOrient -ch 0 -rn false -po 0 -et 0 -upn 0 -d 0 1 0 -length $scale -rotation 0 -scale 1 -dl 3 FaceControlOrientCurve; delete FaceControlOrientCurve; setAttr FaceControlOrient.ty ($scale/-2.0); parent FaceControlOrient FaceBuildInProgressHidden; */ //Setup Lid int $numLid; createNode -n tempPointOnCurveInfo pointOnCurveInfo; setAttr tempPointOnCurveInfo.turnOnPercentage 1; progressBar -e -st ("Setup EyeLid") -bp -ii 0 -min 0 -max 4 $gMainProgressBar; evalDeferred ("progressBar -e -ep "+$gMainProgressBar); for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; $leftSuffix=""; if ($side=="_L" && `objExists FaceFitEyeLidMainLeft`) $leftSuffix="Left"; $eyeJoint="Eye"+$side; addAttr -dv 0.0 -k 1 -smn 0 -hsn 1 -smx 1 -hsx 1 -ln "upperLidOut" -at double ("LidSetup"+$side); addAttr -dv 0.0 -k 1 -smn 0 -hsn 1 -smx 1 -hsx 1 -ln "lowerLidOut" -at double ("LidSetup"+$side); addAttr -dv 0.0 -k 1 -smn 0 -hsn 1 -smx 1 -hsx 1 -ln "blinkCenter" -at double ("LidSetup"+$side); createNode -n ("blinkCenterReverse"+$side) reverse; connectAttr ("LidSetup"+$side+".blinkCenter") ("blinkCenterReverse"+$side+".inputX"); createNode -n ("LidLocs"+$side) transform; setAttr ("LidLocs"+$side+".inheritsTransform") 0; parent ("LidLocs"+$side) LidSetup; createNode -n ("LidCurves"+$side) transform; parent ("LidCurves"+$side) FaceDeformationSystem; for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { progressBar -e -s 1 $gMainProgressBar; if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; $numLid=`getAttr ($upperLower+"EyeLidMainCurve"+$leftSuffix+".spans")`+1; duplicate -n ($upperLower+"LidMainCurve2"+$side) ($upperLower+"EyeLidMainCurve"+$leftSuffix); rebuildCurve -ch 0 -rpo 1 -rt 0 -end 1 -kr 0 -kcp 0 -kep 1 -kt 0 -s 2 -d 3 -tol 0.004 ($upperLower+"LidMainCurve2"+$side); //rebuild another curve, for getting good placements for the cv`s rebuildCurve -n ($upperLower+"EyeLidMainRebuiltSamplerCurve"+$leftSuffix) -ch 1 -rpo 0 -rt 0 -end 1 -kr 0 -kcp 0 -kep 1 -kt 0 -s 4 -d 3 -tol 0.0001 ($upperLower+"EyeLidMainCurve"+$leftSuffix); connectAttr -f ($upperLower+"EyeLidMainRebuiltSamplerCurve"+$leftSuffix+"Shape.worldSpace[0]") tempPointOnCurveInfo.inputCurve; setAttr tempPointOnCurveInfo.parameter 0.25; $pos=`getAttr tempPointOnCurveInfo.position`; xform -ws -t $pos[0] $pos[1] $pos[2] ($upperLower+"LidMainCurve2"+$side+".cv[1]"); setAttr tempPointOnCurveInfo.parameter 0.75; $pos=`getAttr tempPointOnCurveInfo.position`; xform -ws -t $pos[0] $pos[1] $pos[2] ($upperLower+"LidMainCurve2"+$side+".cv[3]"); disconnectAttr ($upperLower+"EyeLidMainRebuiltSamplerCurve"+$leftSuffix+"Shape.worldSpace[0]") tempPointOnCurveInfo.inputCurve; delete ($upperLower+"EyeLidMainRebuiltSamplerCurve"+$leftSuffix); //Might need to flip over Left curve here if ($side=="_L" && $leftSuffix=="") scale -r -p 0 0 0 -1 1 1 ($upperLower+"LidMainCurve2"+$side+".cv[0:4]"); parent ($upperLower+"LidMainCurve2"+$side) ("LidCurves"+$side); /* //make Tweaked-Shape, so each cv is zero position at the correct place createNode -n ($upperLower+"LidMainCurve2"+$side+"TweakedShape") -p ($upperLower+"LidMainCurve2"+$side) nurbsCurve; connectAttr -f ($upperLower+"LidMainCurve2"+$side+"Shape.worldSpace[0]") ($upperLower+"LidMainCurve2"+$side+"TweakedShape.create"); setAttr ($upperLower+"LidMainCurve2"+$side+"Shape.intermediateObject") 1; */ duplicate -n ($upperLower+"LidMainCurve1"+$side) ($upperLower+"EyeLidMainCurve"+$leftSuffix); parent -w ($upperLower+"LidMainCurve1"+$side); if ($side=="_L" && $leftSuffix=="") scale -r -p 0 0 0 -1 1 1 ($upperLower+"LidMainCurve1"+$side+".cv[0:999]"); duplicate -n ($upperLower+"EyeLidMainCurve1"+$side) ($upperLower+"LidMainCurve1"+$side); parent ($upperLower+"LidMainCurve1"+$side) ("LidCurves"+$side); duplicate -n ($upperLower+"EyeLidOuterCurve1"+$side) ($upperLower+"EyeLidOuterCurve"+$leftSuffix); parent -w ($upperLower+"EyeLidOuterCurve1"+$side); if ($side=="_L" && $leftSuffix=="") scale -r -p 0 0 0 -1 1 1 ($upperLower+"EyeLidOuterCurve1"+$side+".cv[0:999]"); makeIdentity -a 1 -t 1 -r 1 -s 1 ($upperLower+"LidMainCurve2"+$side); makeIdentity -a 1 -t 1 -r 1 -s 1 ($upperLower+"LidMainCurve1"+$side); for ($i=0;$i<$numLid;$i++) { if ($upperLower=="lower" && ($i==0 || $i==($numLid-1)))//no need for lower at the same spot (start & end) continue; select -cl; joint -n ($upperLower+"LidMain"+$i+$side); setAttr ($upperLower+"LidMain"+$i+$side+".segmentScaleCompensate") 0; setAttr ($upperLower+"LidMain"+$i+$side+".radius") 0.1; $pos=`xform -q -ws -t ($upperLower+"LidMainCurve1"+$side+".cv["+$i+"]")`; xform -ws -t $pos[0] $pos[1] $pos[2] ($upperLower+"LidMain"+$i+$side); parent ($upperLower+"LidMain"+$i+$side) FaceJoint_M; spaceLocator -n ($upperLower+"LidMainLoc"+$i+$side); setAttr -type float3 ($upperLower+"LidMainLoc"+$i+$side+".localScale") ($scale/100.0) ($scale/100.0) ($scale/100.0); parent ($upperLower+"LidMainLoc"+$i+$side) ("LidLocs"+$side); createNode -n ($upperLower+"LidMainPoci"+$i+$side) pointOnCurveInfo; setAttr ($upperLower+"LidMainPoci"+$i+$side+".turnOnPercentage") 1; setAttr ($upperLower+"LidMainPoci"+$i+$side+".parameter") ($i/($numLid-1.00)); connectAttr ($upperLower+"LidMainPoci"+$i+$side+".position") ($upperLower+"LidMainLoc"+$i+$side+".translate"); connectAttr ($upperLower+"LidMainCurve1"+$side+"Shape.worldSpace[0]") ($upperLower+"LidMainPoci"+$i+$side+".inputCurve"); createNode -n ($upperLower+"LidMain"+$i+"Aim"+$side) transform; parent ($upperLower+"LidMain"+$i+"Aim"+$side) ("LidSetup"+$side); setAttr -type float3 ($upperLower+"LidMain"+$i+"Aim"+$side+".t") 0 0 0; aimConstraint -worldUpType objectrotation -worldUpObject ("LidSetup"+$side) -worldUpVector 0 1 0 ($upperLower+"LidMainLoc"+$i+$side) ($upperLower+"LidMain"+$i+"Aim"+$side); createNode -n ($upperLower+"LidMain"+$i+"AimEnd"+$side) -p ($upperLower+"LidMain"+$i+"Aim"+$side) transform; xform -ws -t $pos[0] $pos[1] $pos[2] ($upperLower+"LidMain"+$i+"AimEnd"+$side); parentConstraint -mo ($upperLower+"LidMain"+$i+"AimEnd"+$side) ($upperLower+"LidMain"+$i+$side); } for ($i=0;$i<$numLid;$i++) { if ($upperLower=="lower" && ($i==0 || $i==($numLid-1)))//no need for lower at the same spot (start & end) continue; //LidOut if ($i>0 && $i<$numLid-1) { createNode -n ($upperLower+"LidOutMult"+$i+$side) multiplyDivide; float $factor; if ($i<($numLid/2)) $factor=`smoothstep 0 $numLid $i`; else $factor=`smoothstep 0 $numLid ($numLid-1-$i)`; $factor=$factor*($scale/3.0); setAttr ($upperLower+"LidOutMult"+$i+$side+".input1X") $factor; connectAttr ("LidSetup"+$side+"."+$upperLower+"LidOut") ($upperLower+"LidOutMult"+$i+$side+".input2X"); createNode -n ($upperLower+"LidOut"+$i+$side) plusMinusAverage; setAttr ($upperLower+"LidOut"+$i+$side+".input1D[0]") `getAttr ($upperLower+"LidMain"+$i+"AimEnd"+$side+".tx")`; connectAttr ($upperLower+"LidOutMult"+$i+$side+".outputX") ($upperLower+"LidOut"+$i+$side+".input1D[1]"); connectAttr ($upperLower+"LidOut"+$i+$side+".output1D") ($upperLower+"LidMain"+$i+"AimEnd"+$side+".tx"); if (`attributeExists nonSphericalEye FitEyeBall`) { if (!`objExists ("LidSetupNonSpAim1"+$side)`) { createNode -n ("LidSetupNonSpAim1"+$side) -p FitEyeBall transform; parent ("LidSetupNonSpAim1"+$side) ("LidSetup"+$side); createNode -n ("LidSetupNonSpAim2"+$side) -p ("LidSetupNonSpAim1"+$side) transform; } parent ($upperLower+"LidMain"+$i+"Aim"+$side) ("LidSetupNonSpAim2"+$side); } } } if ($upperLower=="upper") duplicate -n ("closedLidMainCurve2"+$side) ("upperLidMainCurve2"+$side); if ($upperLower=="lower") { select -r ("upperLidMainCurve2"+$side) ("lowerLidMainCurve2"+$side) ("closedLidMainCurve2"+$side); blendShape -n ("closedLidCurveCloseBS"+$side) -frontOfChain -w 0 0.5 -w 1 0.5; connectAttr ("LidSetup"+$side+".blinkCenter") ("closedLidCurveCloseBS"+$side+".upperLidMainCurve2"+$side); connectAttr ("blinkCenterReverse"+$side+".outputX") ("closedLidCurveCloseBS"+$side+".lowerLidMainCurve2"+$side); } duplicate -n ($upperLower+"LidCurveClose"+$side) ($upperLower+"LidMainCurve2"+$side); select -r ($upperLower+"LidMainCurve2"+$side) ("closedLidMainCurve2"+$side) ($upperLower+"LidCurveClose"+$side); blendShape -n ($upperLower+"LidCurveCloseBS"+$side) -frontOfChain -w 0 0.5 -w 1 0.5; //wireDeform in WorldSpace, since wireDefomer does not work well with 180 rotation, and extreme scaling, and moving 1000+ units duplicate -n ($upperLower+"LidMainCurve1OS"+$side) ($upperLower+"LidMainCurve1"+$side); if (!`asIsMayaLT`) wire -n ($upperLower+"LidMainCurveWire"+$side) -dds 0 $scale -gw false -en 1.000000 -ce 0.000000 -li 0.000000 -w ($upperLower+"LidCurveClose"+$side) ($upperLower+"LidMainCurve1OS"+$side); connectAttr ($upperLower+"LidMainCurve1OS"+$side+"Shape.worldSpace[0]") ($upperLower+"LidMainCurve1"+$side+"Shape.create"); //MayaLT does not have Wire-deformer, but we can SkinWeigh Curve to a Curve if (`asIsMayaLT`) { select FaceJoint_M ($upperLower+"LidMainCurve1OS"+$side); $tempString=`newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"`; rename $tempString[0] ($upperLower+"LidMainCurve1OSSC"+$side); setAttr ($upperLower+"LidMainCurve1OSSC"+$side+".useComponents") 1; $lockedWeight=`getAttr FaceJoint_M.lockInfluenceWeights`; setAttr FaceJoint_M.lockInfluenceWeights 0; skinCluster -e -useGeometry -ai ($upperLower+"LidCurveClose"+$side) ($upperLower+"LidMainCurve1OSSC"+$side); skinPercent -tv ($upperLower+"LidCurveClose"+$side) 1 ($upperLower+"LidMainCurve1OSSC"+$side) ($upperLower+"LidMainCurve1OS"+$side); setAttr FaceJoint_M.lockInfluenceWeights $lockedWeight; } //inner & Outer Lid if ($upperLower=="upper") { asCreatePingPong ("upperLidMainCurve2"+$side+".ep[0]") ("innerLid") 1 $side 3 1 0; asCreatePingPong ("upperLidMainCurve2"+$side+".ep[2]") ("outerLid") 1 $side 3 1 0; parent ("innerLidOffset"+$side) ("outerLidOffset"+$side) ("EyeRegion"+$side); parent ("innerLidJoint"+$side) ("outerLidJoint"+$side) LidJoints; } //Lid $pos=`xform -q -ws -t ($upperLower+"LidMainCurve2"+$side+".ep[1]")`; xform -ws -t $pos[0] $pos[1] $pos[2] TempPos; delete `geometryConstraint ($upperLower+"EyeLidMainCurve1"+$side) TempPos`; asCreatePingPong TempPos ($upperLower+"Lid") 1 $side 2 1 0; parent ($upperLower+"LidOffset"+$side) ("EyeRegion"+$side); parent ($upperLower+"LidJoint"+$side) LidJoints; setAttr -type float3 ($upperLower+"Lid"+"Joint"+$side+".jointOrient") 0 0 0; for ($d=0;$d<2;$d++) { if ($d==0) {$InnerOuter="Inner";$innerouter="inner";$tempInts={0,1,2,3,4};} if ($d==1) {$InnerOuter="Outer";$innerouter="outer";$tempInts={4,3,2,1,0};} //inner/outer (inbetween) Lid $pos=`xform -q -ws -t ($upperLower+"LidMainCurve2"+$side+".cv["+$tempInts[1]+"]")`; xform -ws -t $pos[0] $pos[1] $pos[2] TempPos; delete `geometryConstraint ($upperLower+"EyeLidMainCurve1"+$side) TempPos`; asCreatePingPong TempPos ($upperLower+$InnerOuter+"Lid") 1 $side 1 1 0; // parent ($upperLower+$InnerOuter+"LidOffset"+$side) ("EyeRegion"+$side); parent ($upperLower+$InnerOuter+"LidJoint"+$side) LidJoints; asFaceAddConstrained ($upperLower+$InnerOuter+"Lid"+$side) ($upperLower+"Lid"+$side) ($innerouter+"Lid"+$side) 5; } //lidBase - upper only, lower mismatch with cheekRaiser if ($upperLower=="upper") { $spans=`getAttr ($upperLower+"EyeLidOuterCurve"+$leftSuffix+".spans")`; $pos=`xform -q -ws -t ($upperLower+"EyeLidOuterCurve"+$leftSuffix+".cv["+($spans/2)+"]")`; xform -ws -t $pos[0] $pos[1] $pos[2] TempPos; asCreatePingPong TempPos ($upperLower+"LidBase") 1 $side 3 1 0; // parent ($upperLower+"LidBaseOffset"+$side) ("EyeRegion"+$side);//not nice for Squint setAttr ($upperLower+"LidBaseOffset"+$side+".v") 0; } select ($upperLower+"LidMainCurve2"+$side); select -add ("outerLidJoint"+$side) ("innerLidJoint"+$side); select -add ($upperLower+"OuterLidJoint"+$side) ($upperLower+"LidJoint"+$side) ($upperLower+"InnerLidJoint"+$side); $tempString=`newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"`; rename $tempString[0] ($upperLower+"LidMainCurve2SC"+$side); skinPercent -tv ("outerLidJoint"+$side) 1 ($upperLower+"LidMainCurve2SC"+$side) ($upperLower+"LidMainCurve2"+$side+".cv[4]"); skinPercent -tv ($upperLower+"OuterLidJoint"+$side) 1 ($upperLower+"LidMainCurve2SC"+$side) ($upperLower+"LidMainCurve2"+$side+".cv[3]"); skinPercent -tv ($upperLower+"LidJoint"+$side) 1 ($upperLower+"LidMainCurve2SC"+$side) ($upperLower+"LidMainCurve2"+$side+".cv[2]"); skinPercent -tv ($upperLower+"InnerLidJoint"+$side) 1 ($upperLower+"LidMainCurve2SC"+$side) ($upperLower+"LidMainCurve2"+$side+".cv[1]"); skinPercent -tv ("innerLidJoint"+$side) 1 ($upperLower+"LidMainCurve2SC"+$side) ($upperLower+"LidMainCurve2"+$side+".cv[0]"); /* connectAttr ("outerLidJoint"+$side+".t") ($upperLower+"LidMainCurve2"+$side+".cv[4]"); connectAttr ($upperLower+"OuterLidJoint"+$side+".t") ($upperLower+"LidMainCurve2"+$side+".cv[3]"); connectAttr ($upperLower+"LidJoint"+$side+".t") ($upperLower+"LidMainCurve2"+$side+".cv[2]"); connectAttr ($upperLower+"InnerLidJoint"+$side+".t") ($upperLower+"LidMainCurve2"+$side+".cv[1]"); connectAttr ("innerLidJoint"+$side+".t") ($upperLower+"LidMainCurve2"+$side+".cv[0]"); */ } //HalfMoon asFaceHalfMoonCurve ("upperLid"+$side) 90; asFaceHalfMoonCurve ("lowerLid"+$side) -90; asFaceHalfMoonCurve ("innerLid"+$side) 180; asFaceHalfMoonCurve ("outerLid"+$side) 0; asFaceHalfMoonCurve ("upperOuterLid"+$side) 60; asFaceHalfMoonCurve ("upperInnerLid"+$side) 120; asFaceHalfMoonCurve ("lowerOuterLid"+$side) -60; asFaceHalfMoonCurve ("lowerInnerLid"+$side) -120; asFaceHalfMoonCurve ("upperLidBase"+$side) 90; // asFaceHalfMoonCurve ("lowerLidBase"+$side) -90; } createNode -n LidWireWS -p LidSetup transform; parentConstraint -mo $headJoint LidWireWS; scaleConstraint -mo $headJoint LidWireWS; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; if (`asIsMayaLT`) break; //transformGeometry to wire deform in ws createNode -n ($upperLower+"OS2WSTG"+$side) transformGeometry; connectAttr ($upperLower+"LidMainCurve2SC"+$side+".outputGeometry[0]") ($upperLower+"OS2WSTG"+$side+".inputGeometry"); connectAttr LidWireWS.worldInverseMatrix ($upperLower+"OS2WSTG"+$side+".transform"); connectAttr -f ($upperLower+"OS2WSTG"+$side+".outputGeometry") ($upperLower+"LidMainCurve2"+$side+"Shape.create"); createNode -n ($upperLower+"WS2OSTG"+$side) transformGeometry; connectAttr ($upperLower+"LidMainCurveWire"+$side+".outputGeometry[0]") ($upperLower+"WS2OSTG"+$side+".inputGeometry"); connectAttr LidWireWS.worldMatrix ($upperLower+"WS2OSTG"+$side+".transform"); connectAttr -f ($upperLower+"WS2OSTG"+$side+".outputGeometry") ($upperLower+"LidMainCurve1OS"+$side+"Shape.create"); } } //ctrlLid attributes for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { progressBar -e -s 1 $gMainProgressBar; if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; //blink if (!`attributeExists blink ($upperLower+"Lid"+$side)`) { addAttr -ln "blink" -k 1 -at double -smx 10 -hsx 1 -smn 0 -hnv 1 ($upperLower+"Lid"+$side); asEnsureOutputBlendWeighted ($upperLower+"Lid"+$side+".blink"); asUnitConvertAndReverse ($upperLower+"blinkBlend"+$side) ("bw"+$upperLower+"Lid"+$side+"_blink.output"); } connectAttr ($upperLower+"blinkBlend"+$side+"UnitConversion.output") ($upperLower+"LidCurveCloseBS"+$side+".closedLidMainCurve2"+$side); connectAttr ($upperLower+"blinkBlend"+$side+"Reverse.outputX") ($upperLower+"LidCurveCloseBS"+$side+"."+$upperLower+"LidMainCurve2"+$side); if (!`asIsMayaLT`) connectAttr ($upperLower+"blinkBlend"+$side+"Reverse.outputX") ($upperLower+"LidMainCurveWire"+$side+".scale[0]"); //blinkCenter if ($upperLower=="upper") if (!`attributeExists blinkCenter ($upperLower+"Lid"+$side)`) { addAttr -ln "blinkCenter" -k 1 -at double -smx 10 -hsx 1 -smn 0 -hnv 1 -dv 2 ($upperLower+"Lid"+$side); asEnsureOutputBlendWeighted ($upperLower+"Lid"+$side+".blinkCenter"); asUnitConvertAndReverse ($upperLower+"blinkCenterBlend"+$side) ("bw"+$upperLower+"Lid"+$side+"_blinkCenter.output"); connectAttr ($upperLower+"blinkCenterBlend"+$side+"UnitConversion.output") ("LidSetup"+$side+".blinkCenter"); delete ($upperLower+"blinkCenterBlend"+$side+"Reverse");//not using the reverse } //lidOut if (!`attributeExists lidOut ($upperLower+"Lid"+$side)`) { addAttr -ln "lidOut" -k 1 -at double -smx 10 -hsx 1 -smn 0 -hnv 1 ($upperLower+"Lid"+$side); asEnsureOutputBlendWeighted ($upperLower+"Lid"+$side+".lidOut"); asUnitConvertAndReverse ($upperLower+"lidOutBlend"+$side) ("bw"+$upperLower+"Lid"+$side+"_lidOut.output"); } connectAttr ($upperLower+"lidOutBlend"+$side+"UnitConversion.output") ("LidSetup"+$side+"."+$upperLower+"LidOut"); delete ($upperLower+"lidOutBlend"+$side+"Reverse");//not using the reverse //CtrlBox drivingSystems //fleshyEye // asDsSdk ("ctrlEye"+$side+".tx") ("SDK"+$upperLower+"Lid"+$side+".tx") 1 (-0.25*$b); // asDsSdk ("ctrlEye"+$side+".ty") ("SDK"+$upperLower+"Lid"+$side+".ty") 1 0.5; createNode -n ($upperLower+"LidFleshy"+$side) -p ($upperLower+"LidOffset"+$side) transform; parent ("SDK"+$upperLower+"Lid"+$side) ($upperLower+"LidFleshy"+$side); addAttr -ln "fleshy" -k 1 -at double -smx 10 -hsx 1 -smn 0 -hnv 1 -dv 5 ($upperLower+"Lid"+$side); createNode -n ($upperLower+"Lid"+$side+"FleshyMPD") multiplyDivide; createNode -n ($upperLower+"Lid"+$side+"FleshyTXConversion") unitConversion; createNode -n ($upperLower+"Lid"+$side+"FleshyTYConversion") unitConversion; setAttr ($upperLower+"Lid"+$side+"FleshyTXConversion.conversionFactor") (-0.125*$b); setAttr ($upperLower+"Lid"+$side+"FleshyTYConversion.conversionFactor") -0.25; connectAttr ("EyeJoint"+$side+".ry") ($upperLower+"Lid"+$side+"FleshyTXConversion.input"); connectAttr ("EyeJoint"+$side+".rx") ($upperLower+"Lid"+$side+"FleshyTYConversion.input"); connectAttr ($upperLower+"Lid"+$side+"FleshyTXConversion.output") ($upperLower+"Lid"+$side+"FleshyMPD.input1X"); connectAttr ($upperLower+"Lid"+$side+"FleshyTYConversion.output") ($upperLower+"Lid"+$side+"FleshyMPD.input1Y"); connectAttr ($upperLower+"Lid"+$side+".fleshy") ($upperLower+"Lid"+$side+"FleshyMPD.input2X"); connectAttr ($upperLower+"Lid"+$side+".fleshy") ($upperLower+"Lid"+$side+"FleshyMPD.input2Y"); connectAttr ($upperLower+"Lid"+$side+"FleshyMPD.outputX") ($upperLower+"LidFleshy"+$side+".tx"); connectAttr ($upperLower+"Lid"+$side+"FleshyMPD.outputY") ($upperLower+"LidFleshy"+$side+".ty"); } //asEnsureOutputBlendWeighted $tempString=`listAttr -k ("ctrlEye"+$side)`; for ($i=0;$i-2;$b=$b-2) { $leftSuffix=""; if ($b==-1 && !`objExists FaceFitEyeLidMainLeft`) break; if ($b==-1 && `objExists FaceFitEyeLidMainLeft`) $leftSuffix="Left"; eval ("select "+`asGetFaceFitSelection ("FaceFitEyeLidOuterCurve"+$leftSuffix)`); $outerVtxs=`ls -sl -fl`; eval ("select "+`asGetFaceFitSelection ("FaceFitEyeLidMainCurve"+$leftSuffix)`); $mainVtxs=`ls -sl -fl`; eval ("select "+`asGetFaceFitSelection ("FaceFitEyeLidInnerCurve"+$leftSuffix)`); $innerVtxs=`ls -sl -fl`; select $mainVtxs; for ($i=0;$i<20;$i++) { polySelectConstraint -pp 1 -t 0x0001; select -d $outerVtxs $innerVtxs; } select -add $mainVtxs; sets -n ("eyeLidArea"+$leftSuffix); sets -add FaceAreas ("eyeLidArea"+$leftSuffix); } //Add joint as influences string $addInfCmd="skinCluster -e "; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) {$upperLower="upper";} else {$upperLower="lower";} $numLid=`getAttr ($upperLower+"EyeLidMainCurve1"+$side+".spans")`+1; for ($i=0;$i<$numLid;$i++) { if ($upperLower=="lower" && ($i==0 || $i==($numLid-1)))//no need for lower at the same spot (start & end) continue; progressBar -e -s 1 $gMainProgressBar; $addInfCmd+=" -ai "+$upperLower+"LidMain"+$i+$side; } } } $addInfCmd+=" -lw false -wt 0 "+$skinCluster; eval ($addInfCmd); if (`objExists closestSampler`) delete closestSampler; createNode -n closestSampler closestPointOnMesh; connectAttr -f ($geometry+".outMesh") closestSampler.inMesh; //Full weight for $mainVtxs & $innerVtxs for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; $leftSuffix=""; if ($side=="_L" && `objExists FaceFitEyeLidMainLeft`) $leftSuffix="Left"; for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) {$upperLower="upper";} else {$upperLower="lower";} $numLid=`getAttr ($upperLower+"EyeLidMainCurve"+$leftSuffix+".spans")`+1; $tempString[0]=`asGetFaceFitSelection ($upperLower+"EyeLidMainCurve"+$leftSuffix)`; $upLoMainVtxs=`stringToStringArray $tempString[0] " "`; // $upLoMainVtxs=`asobjSetCast "" $tempString EyeLidLayer`; $tempString[0]=`asGetFaceFitSelection ($upperLower+"EyeLidInnerCurve"+$leftSuffix)`; $upLoInnerVtxs=`stringToStringArray $tempString[0] " "`; // $upLoInnerVtxs=`asobjSetCast "" $tempString EyeLidLayer`; for ($i=0;$i-2;$b=$b-2) { $leftSuffix=""; if ($b==-1 && !`objExists FaceFitEyeLidMainLeft`) break; if ($b==-1 && `objExists FaceFitEyeLidMainLeft`) $leftSuffix="Left"; for ($z=0;$z<2;$z++) { eval ("select "+`asGetFaceFitSelection ("FaceFitEyeLidOuterCurve"+$leftSuffix)`); $outerVtxs=`ls -sl -fl`; // $outerVtxs=`asobjSetCast "" $outerVtxs EyeLidLayer`; eval ("select "+`asGetFaceFitSelection ("FaceFitEyeLidMainCurve"+$leftSuffix)`); $mainVtxs=`ls -sl -fl`; // $mainVtxs=`asobjSetCast "" $mainVtxs EyeLidLayer`; eval ("select "+`asGetFaceFitSelection ("FaceFitEyeLidInnerCurve"+$leftSuffix)`); $innerVtxs=`ls -sl -fl`; // $innerVtxs=`asobjSetCast "" $innerVtxs EyeLidLayer`; if ($z==0) $innerOuterVtx=$outerVtxs; if ($z==1) $innerOuterVtx=$innerVtxs; if ($z==1)//if the same edgeLoop has been used for Main & Inner, then skip { if (`stringArrayCount $innerVtxs[0] $mainVtxs`) break; } //traversing edgeRow is slow for dense models, so we skip this for 500+ verts, with clear $rowWeightedVtxs they will get hammered select ("eyeLidArea"+$leftSuffix); if (size(`ls -sl -fl`)>500) { print "// eyeLidArea exceed 500 verticies, using simplified skinning for this area.\n"; break; } for ($i=0;$i-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; $leftSuffix=""; if ($b==-1 && `objExists FaceFitEyeLidMainLeft`) $leftSuffix="Left"; for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; if ($upperLower=="upper") $tempString[0]="lowerLidMain"+(`getAttr lowerEyeLidMainCurve.spans`/2)+$side; if ($upperLower=="lower") $tempString[0]="upperLidMain"+(`getAttr upperEyeLidMainCurve.spans`/2)+$side; $posA=`xform -q -ws -t $tempString[0]`; $previousMag=999; for ($i=0;$i<999;$i++) { move -r -ls -wd 0 (($scale/-40.0)*$upperLowerFactor) 0 ($upperLower+"Lid"+$side); refresh; $tempString[0]=$upperLower+"LidMain"+(`getAttr ($upperLower+"EyeLidMainCurve.spans")`/2)+$side; $posB=`xform -q -ws -t $tempString[0]`; if ($i>0) $previousMag=$mag; $mag=`mag <<($posA[0]-$posB[0]),($posA[1]-$posB[1]),($posA[2]-$posB[2])>>`; if ($mag>$previousMag) { $tyValueForCloseLid=`getAttr ($upperLower+"Lid"+$side+".ty")`; break; } } setAttr ($upperLower+"Lid"+$side+".ty") 0; if ($upperLower=="upper") $upperTyValueForCloseLid=$tyValueForCloseLid; if ($upperLower=="lower") $lowerTyValueForCloseLid=$tyValueForCloseLid; } if ($upperTyValueForCloseLid==0 || $lowerTyValueForCloseLid==0) error "Unable to find translateY value to close the eyeLid"; //CloseAutoShape for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) {$upperLower="upper";$upperLowerOpposite="lower";$tyValueForCloseLid=$upperTyValueForCloseLid;} else {$upperLower="lower";$upperLowerOpposite="upper";$tyValueForCloseLid=$lowerTyValueForCloseLid;} addAttr -k 1 -ln closeAutoShape -at double -min 0 -max 10 -dv 10 ($upperLower+"Lid"+$side); addAttr -k 0 -ln tyValueForCloseLid -at double -dv $tyValueForCloseLid ($upperLower+"Lid"+$side); if (`asIsMayaLT`) continue; // no wrap deformer in LT, skipping closeAutoShape, but keeping the attribute createNode -n ($upperLower+"Lid"+$side+"CloseAutoShapeUnitConversion") unitConversion; setAttr ($upperLower+"Lid"+$side+"CloseAutoShapeUnitConversion.conversionFactor") 0.1; connectAttr ($upperLower+"Lid"+$side+".closeAutoShape") ($upperLower+"Lid"+$side+"CloseAutoShapeUnitConversion.input"); $spans=`getAttr ($upperLower+"LidMainCurve1"+$side+".spans")`; rebuildCurve -n ($upperLower+"LidMainCurve1CloseAutoShape"+$side) -ch 0 -rpo 0 -rt 0 -end 1 -kr 0 -kcp 0 -kep 1 -kt 0 -s $spans -d 1 -tol 0.01 ($upperLowerOpposite+"LidMainCurve1"+$side); parent ($upperLower+"LidMainCurve1CloseAutoShape"+$side) ("LidCurves"+$side); setAttr ($upperLower+"Lid"+$side+".ty") $tyValueForCloseLid; select -r ($upperLower+"LidMainCurve1CloseAutoShape"+$side) ($upperLower+"LidMainCurve2"+$side); // doWrapArgList "7" { "1","0","0", "2", "0", "0", "1", "0" }; //doWrapArgList (7) {$operation=createWrap, $threshold, $maxDist , $inflType(1=vtx2=f), $exclusiveBind, $autoWeightThreshold, $renderInfl, $falloffMode} //Maya2020 (Wrap): Exclusive bind only works on polys, ignoring option // asCreateWrap (($upperLower+"LidMainCurve1CloseAutoShapeWrap"+$side),0,0,1,0,0);//$threshold $maxDistance $exclusiveBind $autoWeightThreshold $falloffMode asCreateWrap (($upperLower+"LidMainCurve1CloseAutoShapeWrap"+$side),0,0,0,0,0);//$threshold $maxDistance $exclusiveBind $autoWeightThreshold $falloffMode setAttr ("lowerLid"+$side+".ty") 0; setAttr ("upperLid"+$side+".ty") 0; select -r ($upperLower+"LidMainCurve1CloseAutoShape"+$side) ($upperLower+"LidMainCurve1"+$side); blendShape -n ($upperLower+"LidCloseAutoShapeBS"+$side) -frontOfChain; //then drive the BS with distance ty createNode -n ($upperLower+"Lid"+$side+"Dist") distanceBetween; connectAttr -f ($upperLower+"LidMainCurve2"+$side+".editPoints[1].yValueEp") ($upperLower+"Lid"+$side+"Dist.point1Y"); connectAttr -f ($upperLower+"LidMainCurve2"+$side+".editPoints[1].yValueEp") ($upperLower+"Lid"+$side+"Dist.point2Y"); setAttr ($upperLower+"Lid"+$side+".ty") $tyValueForCloseLid; disconnectAttr ($upperLower+"LidMainCurve2"+$side+".editPoints[1].yValueEp") ($upperLower+"Lid"+$side+"Dist.point2Y"); setAttr ($upperLower+"Lid"+$side+".ty") 0; createNode -n ($upperLower+"Lid"+$side+"CloseAutoShapeMultiplyDivide1") multiplyDivide; connectAttr ($upperLower+"Lid"+$side+"Dist.distance") ($upperLower+"Lid"+$side+"CloseAutoShapeMultiplyDivide1.input1X"); setAttr ($upperLower+"Lid"+$side+"CloseAutoShapeMultiplyDivide1.input2X") `getAttr ($upperLower+"Lid"+$side+"Dist.distance")`; setAttr ($upperLower+"Lid"+$side+"CloseAutoShapeMultiplyDivide1.operation") 2; createNode -n ($upperLower+"Lid"+$side+"CloseAutoShapeReverse") reverse; connectAttr ($upperLower+"Lid"+$side+"CloseAutoShapeMultiplyDivide1.outputX") ($upperLower+"Lid"+$side+"CloseAutoShapeReverse.inputX"); createNode -n ($upperLower+"Lid"+$side+"CloseAutoShapeMultiplyDivide2") multiplyDivide; connectAttr ($upperLower+"Lid"+$side+"CloseAutoShapeReverse.outputX") ($upperLower+"Lid"+$side+"CloseAutoShapeMultiplyDivide2.input1X"); connectAttr ($upperLower+"Lid"+$side+"CloseAutoShapeUnitConversion.output") ($upperLower+"Lid"+$side+"CloseAutoShapeMultiplyDivide2.input2X"); connectAttr ($upperLower+"Lid"+$side+"CloseAutoShapeMultiplyDivide2.outputX") ($upperLower+"LidCloseAutoShapeBS"+$side+"."+$upperLower+"LidMainCurve1CloseAutoShape"+$side); } } if (!$nonSymmetrical) copySkinWeights -ss $skinCluster -ds $skinCluster -mirrorMode YZ -mirrorInverse -surfaceAssociation closestPoint -influenceAssociation closestJoint; //show CloseAutoShape for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; $leftSuffix=""; if ($b==-1 && `objExists FaceFitEyeLidMainLeft`) $leftSuffix="Left"; for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) {$upperLower="upper";$upperLowerOpposite="lower";$tyValueForCloseLid=$upperTyValueForCloseLid;} else {$upperLower="lower";$upperLowerOpposite="upper";$tyValueForCloseLid=$lowerTyValueForCloseLid;} setAttr ($upperLower+"Lid"+$side+".ty") $tyValueForCloseLid; setAttr ($upperLower+"Lid"+$side+".closeAutoShape") 0; for ($i=1;$i<50;$i++) { setAttr ($upperLower+"Lid"+$side+".closeAutoShape") (($i*2)/10.0); refresh; } setAttr ($upperLower+"Lid"+$side+".closeAutoShape") 10; refresh; setAttr ($upperLower+"Lid"+$side+".ty") 0; } } //default closeAutoShape value to 0 setAttr upperLid_R.closeAutoShape 0; setAttr upperLid_L.closeAutoShape 0; setAttr lowerLid_R.closeAutoShape 0; setAttr lowerLid_L.closeAutoShape 0; //delete EyeLidSkinCage_R; delete upperEyeLidMainCurve1_R upperEyeLidOuterCurve1_R lowerEyeLidMainCurve1_R lowerEyeLidOuterCurve1_R; delete upperEyeLidMainCurve1_L upperEyeLidOuterCurve1_L lowerEyeLidMainCurve1_L lowerEyeLidOuterCurve1_L; //dualQ weight eyeLids if (!$gameEngine) { setAttr ($skinCluster+".skinningMethod") 2; //flood first $tempInts=`polyEvaluate -v $geometry`; $numVtx=$tempInts[0]; for ($i=0;$i<$numVtx;$i++) setAttr ($skinCluster+".bw["+$i+"]") 0; //then weight eyeLidArea select eyeLidArea eyeLidAreaLeft; $tempString=`ls -sl -fl`; for ($i=0;$i-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; addAttr -ln "blink" -k 1 -at double -smx 10 -hsx 1 -smn 0 -hnv 1 ("ctrlEye"+$side); asEnsureOutputBlendWeighted ("ctrlEye"+$side+".blink"); } asFaceHideControllers 1; setAttr ctrlBoxEye_R.v 1; setAttr ctrlBoxEye_L.v 1; setAttr ctrlBox.RegionsCtrlVis 0; setAttr EyeRegionOffset_R.v 1; setAttr EyeRegionOffset_L.v 1; setAttr upperLidOffset_R.v 1; setAttr upperLidOffset_L.v 1; setAttr lowerLidOffset_R.v 1; setAttr lowerLidOffset_L.v 1; setAttr upperLidBaseOffset_R.v 1; setAttr upperLidBaseOffset_L.v 1; asFaceMirrorConnectCtrls 1; //fit-anim asFaceFitAnim ctrlEye_R.blink 10; asFaceFitAnim ctrlEye_L.blink 10; asFaceFitAnim upperLid_R.blink 10; asFaceFitAnim lowerLid_R.blink 10; asFaceFitAnim upperLidBase_R 0; if (`asIsMayaLT`) warning "Maya LT detected, this version of Maya does not have \"Wrap\" deformer, so Eyelid deformation will not be optimal."; playbackOptions -min 0 -max 30 -ast 0 -aet 30; currentTime 30; select -cl; } global proc asFaceEyeBlinkFinish () { if (!`objExists upperEyeLidMainCurve`)//skip return; if (`attributeExists EyeBlinkFinish FaceBuildInProgress`) return; addAttr -k 0 -ln EyeBlinkFinish -at bool -dv true FaceBuildInProgress; asFaceMirrorConnectCtrls 0; //remove fitAnim from driver $tempString=`listConnections -s 1 -d 0 -type animCurve ctrlEye_R.blink ctrlEye_L.blink`; if (size($tempString)) delete $tempString; setAttr ctrlEye_R.blink 0; setAttr ctrlEye_L.blink 0; asFaceStoreAsDsSdk {"upperLid"} "_RL" "ctrlEye" "_RL" "blink" 10; asFaceStoreAsDsSdk {"lowerLid"} "_RL" "ctrlEye" "_RL" "blink" 10; asFaceStoreAsDsSdk {"upperLidBase"} "_RL" "ctrlEye" "_RL" "blink" 10; asFaceRemoveFitAnimationsFromOnFaceCtrls; asFaceHideControllers 1; setAttr ctrlBoxEye_R.v 1; setAttr ctrlBoxEye_L.v 1; } global proc asFaceEyeBrow () { int $modifier=`getModifiers`; int $vtxNr,$edgeNr,$noseVtxNr,$topVtxNr,$sideVtxNr,$numVtxStep,$c,$divisionsX,$numEyeBrowMid,$start,$end,$tempInt1,$tempInt2,$tempInt3,$tempInt4; int $upperEyeLidOuterNumCVs; int $nonSymmetrical=`checkBox -q -v asFaceNonSymCheckBox`; float $pos[],$rot[],$posA[],$posB[],$outerUpDownTowardsPos[]; float $percentage,$dist,$weight; float $scale=`getAttr FaceFitSkeleton.faceScale`; float $ctrlScale=`getAttr OnFacecontrols.sx`; string $geometry=`textField -q -tx asFaceFaceTextField`; string $headJoint=`textField -q -tx asFaceHeadJointTextField`; //string $skinCluster="EyeBrowSC"; string $skinCluster=`textField -q -tx asFaceSkinClusterTextField`; string $eyeBrow=`textField -q -tx asFaceEyebrowTextField`; string $side,$curveCmd,$cmd,$parent,$leftSuffix; string $tempString[],$tempString2[],$inbetweenEyeBrowVtxs[],$prevVtxs[],$doneVtxs[],$eyeLidInnerAreaVtxs[],$eyeBrowGeos[]; string $EyeBrowCenterVtx,$eyeBrowInnerVtx,$eyeBrowOuterVtx,$eyeBrowForeHeadNoseVtx,$eyeBrowForeHeadTopVtx,$eyeBrowForeHeadSideVtx,$eyeBrowForeHeadTopSide1Vtx; string $eyeBrowForeHeadTopSide2Vtx,$eyeBrowForeHeadTopSide3Vtx,$eyeBrowEyeInnerCnrVtx,$eyeBrowEyeMid1CnrVtx,$eyeBrowEyeOuterCnrVtx; string $eyeBrowMid1Vtx,$eyeBrowMid2Vtx,$eyeBrowMid3Vtx,$sc; string $eyeBrowEyeMid2CnrVtx,$eyeBrowEyeMid3CnrVtx,$eyeBrowEyeMid4CnrVtx; string $eyeBrowForeHeadTopSide4Vtx,$eyeBrowForeHeadTopSide5Vtx,$eyeBrowForeHeadTopSide6Vtx; asFaceEyeBlinkFinish; if (!`objExists EyeBrowInner`)//skip return; $upperEyeLidOuterNumCVs=`getAttr upperEyeLidOuterCurve.spans`+1; string $eyeBrows[]={"EyeBrowInner"}; for ($a=1;$a<4;$a++) if (`objExists ("EyeBrowMid"+$a)`) $eyeBrows[size($eyeBrows)]=("EyeBrowMid"+$a); $eyeBrows[size($eyeBrows)]="EyeBrowOuter"; if (`objExists EyeBrowCenter`) $eyeBrows[size($eyeBrows)]="EyeBrowCenter"; asFaceHideControllers 1; setAttr ctrlBox.RegionsCtrlVis 1; setAttr ctrlBoxBrow_R.v 1; setAttr ctrlBoxBrow_L.v 1; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) {$side="_R";$rightLeft="Right";$leftSuffix="";} else {$side="_L";$rightLeft="Left";$leftSuffix="Left";} //EyeBrowRegion asCreateFaceController "EyeBrowRegion" $side 4; // setAttr ("EyeBrowRegion"+$side+"Shape.overrideColor") 14; asFaceHalfMoonCurve ("EyeBrowRegion"+$side) 90; delete ("EyeBrowRegionJoint"+$side); parent ("EyeBrowRegionOffset"+$side) ("SideReverse"+$side); xform -os -ro 0 0 0 -s 1 1 1 ("EyeBrowRegionOffset"+$side); setAttr ("EyeBrowRegionOffset"+$side+".s") -type float3 1 1 1; $posA=`xform -q -ws -t EyeBrowInner`; $posB=`xform -q -ws -t EyeBrowOuter`; $pos[0]=($posA[0]+$posB[0])/(2.0*$b);$pos[1]=($posA[1]+$posB[1])/2.0;$pos[2]=($posA[2]+$posB[2])/2.0; xform -ws -t $pos[0] $pos[1] $pos[2] ("EyeBrowRegionOffset"+$side); $dist=$posA[0]-$posB[0]; scale -r -p $pos[0] $pos[1] $pos[2] ($scale/$dist) ($scale/($dist*2)) ($scale/$dist) ("EyeBrowRegion"+$side+".cv[0:7]"); asFacePlaceCtrlByProjection ("EyeBrowRegion"+$side); createNode -n ("EyeBrowRegionConstrainTo"+$side) transform; parent ("EyeBrowRegionConstrainTo"+$side) ("EyeBrowRegion"+$side); xform -os -t 0 0 0 -s 1 1 1 ("EyeBrowRegionConstrainTo"+$side); $pos=`xform -q -ws -t ("EyeBrowInner"+$leftSuffix)`; xform -ws -t $pos[0] $pos[1] $pos[2] ("EyeBrowRegionConstrainTo"+$side); } createNode -n EyeBrowRegionOffset_M -p SideReverse_M transform; createNode -n SDKEyeBrowRegion_M -p EyeBrowRegionOffset_M transform; createNode -n EyeBrowRegion_M -p SDKEyeBrowRegion_M transform; delete `pointConstraint EyeBrowRegionConstrainTo_R EyeBrowRegionConstrainTo_L EyeBrowRegionOffset_M`; pointConstraint EyeBrowRegionConstrainTo_R EyeBrowRegionConstrainTo_L EyeBrowRegion_M; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; for ($c=0;$c$sideVtxNr) { $start=$sideVtxNr; $end=$topVtxNr; } for ($i=$start;$i<$end+1;$i++) { $pos=`xform -q -ws -t ("ForeHeadCurve.cv["+$i+"]")`; $curveCmd+=" -p "+$pos[0]+" "+$pos[1]+" "+$pos[2]; } eval ($curveCmd); if ($topVtxNr>$sideVtxNr) { reverseCurve -ch 0 -rpo 1 TempForeHeadCurve; } connectAttr -f TempForeHeadCurve.worldSpace[0] tempPointOnCurveInfo.inputCurve; //find $outerUpDownTowardsPos for later usage setAttr tempPointOnCurveInfo.parameter 0.65; $outerUpDownTowardsPos=`getAttr tempPointOnCurveInfo.position`; createNode -n TempPos transform; createNode -n TempPos2 transform; xform -ws -t $outerUpDownTowardsPos[0] $outerUpDownTowardsPos[1] $outerUpDownTowardsPos[2] TempPos; delete `pointConstraint EyeBrowOuter TempPos TempPos2`; //delete `geometryConstraint EyeBrowLayer TempPos2`; $outerUpDownTowardsPos=`xform -q -ws -t TempPos2`; delete TempPos TempPos2; for ($i=0;$i<$numEyeBrowMid+3;$i++) { setAttr tempPointOnCurveInfo.parameter ((1.0/($numEyeBrowMid+4))*($i+1)); $pos=`getAttr tempPointOnCurveInfo.position`; if ($i==0) xform -ws -t $pos[0] $pos[1] $pos[2] $eyeBrowForeHeadTopSide1Vtx; if ($i==1) xform -ws -t $pos[0] $pos[1] $pos[2] $eyeBrowForeHeadTopSide2Vtx; if ($i==2) xform -ws -t $pos[0] $pos[1] $pos[2] $eyeBrowForeHeadTopSide3Vtx; if ($i==3) xform -ws -t $pos[0] $pos[1] $pos[2] $eyeBrowForeHeadTopSide4Vtx; if ($i==4) xform -ws -t $pos[0] $pos[1] $pos[2] $eyeBrowForeHeadTopSide5Vtx; if ($i==5) xform -ws -t $pos[0] $pos[1] $pos[2] $eyeBrowForeHeadTopSide6Vtx; } delete TempForeHeadCurve; //skinning select FaceJoint_M eyeBrowCage; $tempString=`newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"`; rename $tempString[0] eyeBrowCageSC; skinCluster -e -dr 4 -lw false -wt 0 -ai EyeBrowCenterJoint_M -ai EyeBrowInnerJoint_R -ai EyeBrowInnerJoint_L -ai EyeBrowOuterJoint_R -ai EyeBrowOuterJoint_L -ai EyeBrowCenterJoint_M -ai upperLidBaseJoint_R -ai upperLidBaseJoint_L eyeBrowCageSC; skinPercent -tv EyeBrowCenterJoint_M 1 eyeBrowCageSC $EyeBrowCenterVtx; skinPercent -tv EyeBrowInnerJoint_R 1 eyeBrowCageSC $eyeBrowInnerVtx; skinPercent -tv EyeBrowOuterJoint_R 1 eyeBrowCageSC $eyeBrowOuterVtx; skinPercent -tv upperLidBaseJoint_R 1 eyeBrowCageSC $eyeBrowEyeMid1CnrVtx; if ($eyeBrowMid1Vtx!="") { skinCluster -e -dr 4 -lw false -wt 0 -ai EyeBrowMid1Joint_R eyeBrowCageSC; skinPercent -tv EyeBrowMid1Joint_R 1 eyeBrowCageSC $eyeBrowMid1Vtx; } if ($eyeBrowMid2Vtx!="") { skinCluster -e -dr 4 -lw false -wt 0 -ai EyeBrowMid2Joint_R eyeBrowCageSC; skinPercent -tv EyeBrowMid2Joint_R 1 eyeBrowCageSC $eyeBrowMid2Vtx; } if ($eyeBrowMid3Vtx!="") { skinCluster -e -dr 4 -lw false -wt 0 -ai EyeBrowMid3Joint_R eyeBrowCageSC; skinPercent -tv EyeBrowMid3Joint_R 1 eyeBrowCageSC $eyeBrowMid3Vtx; } duplicate -n eyeBrowCage_M eyeBrowCage; duplicate -n eyeBrowCage_M2 eyeBrowCage; scale -r -p 0 0 0 -1 1 1 eyeBrowCage_M2.vtx[0:99]; polyNormal -normalMode 0 -userNormalMode 0 -ch 0 eyeBrowCage_M2; polyUnite -n eyeBrowCage_M3 -ch 0 -mergeUVSets 1 eyeBrowCage_M eyeBrowCage_M2; delete eyeBrowCage_M eyeBrowCage_M2; rename eyeBrowCage_M3 eyeBrowCage_M; polyMergeVertex -d 0.001 -am 1 -ch 0 eyeBrowCage_M; select "EyeBrow*Joint_*"; select -add upperLidBaseJoint_R upperLidBaseJoint_L; select -add FaceJoint_M eyeBrowCage_M; $tempString=`newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"`; rename $tempString[0] eyeBrowCage_MSC; select eyeBrowCage eyeBrowCage_M; copySkinWeights -noMirror -surfaceAssociation closestPoint -influenceAssociation closestJoint; copySkinWeights -ss eyeBrowCage_MSC -ds eyeBrowCage_MSC -mirrorMode YZ -mirrorInverse -surfaceAssociation closestPoint -influenceAssociation closestJoint; delete eyeBrowCage; //extrude extention, to avoid bleeding to e.g snout duplicate -n eyeBrowCage2_M eyeBrowCage_M; select -r eyeBrowCage2_M.e[0] ; //polyConvertToShellBorder;//non-print-out alternative //changed back to SelectEdgeLoopSp, as polyConvertToShellBorder seem to not work on tuna in maya2016 //after delteAdv, then re-build, the eyeBrowCage mesh does not work with the polyConvertToShellBorder command //todo, find a non-print-out alternative SelectEdgeLoopSp; polyExtrudeEdge -n tempPolyExtrudeEdge -constructionHistory 1 -keepFacesTogether 1 -divisions 1 -twist 0 -taper 1 -offset 0 -thickness 0 -smoothingAngle 30; setAttr polyExtrudeEdge1.localTranslateZ 1; ConvertSelectionToVertices; $tempString2=`ls -sl`; select "EyeBrow*Joint_*"; select -add upperLidBaseJoint_R upperLidBaseJoint_L; select -add FaceJoint_M eyeBrowCage2_M; $tempString=`newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"`; rename $tempString[0] eyeBrowCage2_MSC; select eyeBrowCage_M eyeBrowCage2_M; copySkinWeights -noMirror -surfaceAssociation closestPoint -influenceAssociation closestJoint; skinPercent -tv FaceJoint_M 1 eyeBrowCage2_MSC $tempString2; delete eyeBrowCage_M; //non-symmetry if ($nonSymmetrical) { if (`objExists EyeBrowInnerLeft`) { $eyeBrowInnerVtx="eyeBrowCage2_M.vtx[17]"; $eyeBrowOuterVtx="eyeBrowCage2_M.vtx[16]"; $eyeBrowEyeInnerCnrVtx="eyeBrowCage2_M.vtx[14]"; $eyeBrowEyeMid1CnrVtx="eyeBrowCage2_M.vtx[13]"; $eyeBrowEyeOuterCnrVtx="eyeBrowCage2_M.vtx[12]"; if (`objExists EyeBrowMid1`) { $eyeBrowInnerVtx="eyeBrowCage2_M.vtx[20]"; $eyeBrowMid1Vtx="eyeBrowCage2_M.vtx[19]"; $eyeBrowOuterVtx="eyeBrowCage2_M.vtx[18]"; $eyeBrowEyeInnerCnrVtx="eyeBrowCage2_M.vtx[16]"; $eyeBrowEyeMid1CnrVtx="eyeBrowCage2_M.vtx[15]"; $eyeBrowEyeOuterCnrVtx="eyeBrowCage2_M.vtx[14]"; } if (`objExists EyeBrowMid2`) { $eyeBrowInnerVtx="eyeBrowCage2_M.vtx[25]"; $eyeBrowMid1Vtx="eyeBrowCage2_M.vtx[24]"; $eyeBrowMid2Vtx="eyeBrowCage2_M.vtx[23]"; $eyeBrowOuterVtx="eyeBrowCage2_M.vtx[22]"; $eyeBrowEyeInnerCnrVtx="eyeBrowCage2_M.vtx[20]"; $eyeBrowEyeMid1CnrVtx="eyeBrowCage2_M.vtx[19]"; $eyeBrowEyeMid2CnrVtx="eyeBrowCage2_M.vtx[18]"; $eyeBrowEyeOuterCnrVtx="eyeBrowCage2_M.vtx[17]"; } if (`objExists EyeBrowMid3`) { $eyeBrowInnerVtx="eyeBrowCage2_M.vtx[30]"; $eyeBrowMid1Vtx="eyeBrowCage2_M.vtx[29]"; $eyeBrowMid2Vtx="eyeBrowCage2_M.vtx[28]"; $eyeBrowMid3Vtx="eyeBrowCage2_M.vtx[27]"; $eyeBrowOuterVtx="eyeBrowCage2_M.vtx[26]"; $eyeBrowEyeInnerCnrVtx="eyeBrowCage2_M.vtx[24]"; $eyeBrowEyeMid1CnrVtx="eyeBrowCage2_M.vtx[23]"; $eyeBrowEyeMid2CnrVtx="eyeBrowCage2_M.vtx[22]"; $eyeBrowEyeMid3CnrVtx="eyeBrowCage2_M.vtx[21]"; $eyeBrowEyeOuterCnrVtx="eyeBrowCage2_M.vtx[20]"; } $pos=`xform -q -ws -t EyeBrowInnerLeft`; xform -ws -t $pos[0] $pos[1] $pos[2] $eyeBrowInnerVtx; $pos=`xform -q -ws -t EyeBrowOuterLeft`; xform -ws -t $pos[0] $pos[1] $pos[2] $eyeBrowOuterVtx; if (`objExists EyeBrowMid1`) { $pos=`xform -q -ws -t EyeBrowMid1Left`; xform -ws -t $pos[0] $pos[1] $pos[2] $eyeBrowMid1Vtx; } if (`objExists EyeBrowMid2`) { $pos=`xform -q -ws -t EyeBrowMid2Left`; xform -ws -t $pos[0] $pos[1] $pos[2] $eyeBrowMid2Vtx; } if (`objExists EyeBrowMid3`) { $pos=`xform -q -ws -t EyeBrowMid3Left`; xform -ws -t $pos[0] $pos[1] $pos[2] $eyeBrowMid3Vtx; } //$eyeBrowEyeVtxs as well $pos=`xform -q -ws -t upperEyeLidOuterCurveLeft.cv[0]`; xform -ws -t $pos[0] $pos[1] $pos[2] $eyeBrowEyeInnerCnrVtx; $pos=`xform -q -ws -t upperEyeLidOuterCurveLeft.cv[$upperEyeLidOuterNumCVs-1]`; xform -ws -t $pos[0] $pos[1] $pos[2] $eyeBrowEyeOuterCnrVtx; //Calculated `averaged` vtxs for left as well if (`objExists tempPointOnCurveInfo`) delete tempPointOnCurveInfo; createNode -n tempPointOnCurveInfo pointOnCurveInfo; setAttr tempPointOnCurveInfo.turnOnPercentage 1; connectAttr -f upperEyeLidOuterCurveLeft.worldSpace[0] tempPointOnCurveInfo.inputCurve; for ($i=1;$i<$numEyeBrowMid+1;$i++) { setAttr tempPointOnCurveInfo.parameter ((1.0/($numEyeBrowMid+1))*$i); if ($numEyeBrowMid==0) setAttr tempPointOnCurveInfo.parameter 0.5; $pos=`getAttr tempPointOnCurveInfo.position`; if ($i==1) xform -ws -t $pos[0] $pos[1] $pos[2] $eyeBrowEyeMid1CnrVtx; if ($i==2) xform -ws -t $pos[0] $pos[1] $pos[2] $eyeBrowEyeMid2CnrVtx; if ($i==3) xform -ws -t $pos[0] $pos[1] $pos[2] $eyeBrowEyeMid3CnrVtx; } } } select eyeBrowCage2_M; eval ("select -add "+`asGetFaceFitSelection ForeHeadAreaMesh`); eval ("select -add "+`asGetFaceFitSelection ForeHeadAreaMeshLeft`); copySkinWeights -noMirror -surfaceAssociation closestPoint -influenceAssociation closestJoint; eval ("select "+`asGetFaceFitSelection EyeLidInnerAreaMesh`); $eyeLidInnerAreaVtx=`ls -sl`; //Hammer weights for vtx 1 step out from upperEyeLidMainCurve duplicate -n upperEyeLidOuterCurve2 upperEyeLidOuterCurve; parent -w upperEyeLidOuterCurve2; delete upperEyeLidOuterCurve2.cv[0] upperEyeLidOuterCurve2.cv[(`getAttr upperEyeLidOuterCurve2.spans`+1)]; eval ("select "+`asGetFaceFitSelection upperEyeLidOuterCurve2`); delete upperEyeLidOuterCurve2; $tempString=`ls -sl`; //select `asobjSetCast "" $tempString EyeBrowLayer`; polySelectConstraint -pp 1 -t 0x0001;//GrowPolygonSelectionRegion; select -d $eyeLidInnerAreaVtx; $tempString=`ls -sl -fl`; select -cl; for ($i=0;$i-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; if (`objExists ("EyeBrowMid1"+$side)`) asFaceAddConstrained ("EyeBrowMid1"+$side) ("EyeBrowInner"+$side) ("EyeBrowRegion"+$side) 3; if (`objExists ("EyeBrowMid3"+$side)`) { asFaceAddConstrained ("EyeBrowMid3"+$side) ("EyeBrowOuter"+$side) ("EyeBrowRegion"+$side) 3; //in case there is a Mid3, also constrain Mid2 to get same behaviour from all Mids asFaceAddConstrained ("EyeBrowMid2"+$side) ("EyeBrowOuter"+$side) ("EyeBrowRegion"+$side) 1; } else if (`objExists ("EyeBrowMid2"+$side)`) asFaceAddConstrained ("EyeBrowMid2"+$side) ("EyeBrowOuter"+$side) ("EyeBrowRegion"+$side) 3; } //EyeBrowCenter_M stay in middle of Left/Right EyeBrowInner addAttr -k 1 -ln follow -at double -min 0 -max 10 -dv 10 EyeBrowCenter_M; createNode -n EyeBrowCenterFollow_M -p EyeBrowCenterOffset_M transform; createNode -n EyeBrowCenterFollowUnitConversion unitConversion; setAttr EyeBrowCenterFollowUnitConversion.conversionFactor 0.1; connectAttr EyeBrowCenter_M.follow EyeBrowCenterFollowUnitConversion.input; parent SDKEyeBrowCenter_M EyeBrowCenterFollow_M; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; createNode -n ("EyeBrowCenterBlenderPMA"+$side) plusMinusAverage; connectAttr ("EyeBrowInner"+$side+".t") ("EyeBrowCenterBlenderPMA"+$side+".input3D[0]"); connectAttr ("SDKEyeBrowInner"+$side+".t") ("EyeBrowCenterBlenderPMA"+$side+".input3D[1]"); } createNode -n ("EyeBrowCenterBlenderPMA_M") plusMinusAverage; setAttr ("EyeBrowCenterBlenderPMA_M.operation") 3; connectAttr ("EyeBrowCenterBlenderPMA_R.output3D") ("EyeBrowCenterBlenderPMA_M.input3D[0]"); connectAttr ("EyeBrowCenterBlenderPMA_L.output3D") ("EyeBrowCenterBlenderPMA_M.input3D[1]"); createNode -n ("EyeBrowCenterBlenderMPD_M") multiplyDivide; connectAttr ("EyeBrowCenterBlenderPMA_M.output3Dy") ("EyeBrowCenterBlenderMPD_M.input1Y"); connectAttr ("EyeBrowCenterBlenderPMA_M.output3Dz") ("EyeBrowCenterBlenderMPD_M.input1Z"); connectAttr EyeBrowCenterFollowUnitConversion.output ("EyeBrowCenterBlenderMPD_M.input2Y"); connectAttr EyeBrowCenterFollowUnitConversion.output ("EyeBrowCenterBlenderMPD_M.input2Z"); connectAttr ("EyeBrowCenterBlenderMPD_M.outputY") ("EyeBrowCenterFollow_M.ty"); connectAttr ("EyeBrowCenterBlenderMPD_M.outputZ") ("EyeBrowCenterFollow_M.tz"); //DrivingSystem $posA=`xform -q -ws -t EyeBrowInner`; $posB=`xform -q -ws -t FitEyeBall`; $dist=(($posA[1]-$posB[1])/$ctrlScale)/2.0; if ($dist<0.25) $dist=0.25; if ($dist>1.0) $dist=1.0; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; if (`objExists EyeBrowInner_R`) { asDsSdk ("ctrlBrow"+$side+".ty") ("SDKEyeBrowInner"+$side+".ty") 1 $dist; asDsSdk ("ctrlBrow"+$side+".ty") ("SDKEyeBrowInner"+$side+".ty") -1 ($dist*-1); asDsSdk ("ctrlBrow"+$side+".tx") ("SDKEyeBrowInner"+$side+".ty") 1 $dist; asDsSdk ("ctrlBrow"+$side+".tx") ("SDKEyeBrowInner"+$side+".ty") -1 ($dist*-1); } if (`objExists EyeBrowMid1_R`) { asDsSdk ("ctrlBrow"+$side+".ty") ("SDKEyeBrowMid1"+$side+".ty") 1 ($dist*0.7); asDsSdk ("ctrlBrow"+$side+".ty") ("SDKEyeBrowMid1"+$side+".ty") -1 ($dist*-0.7); asDsSdk ("ctrlBrow"+$side+".tx") ("SDKEyeBrowMid1"+$side+".ty") 1 ($dist*0.1); asDsSdk ("ctrlBrow"+$side+".tx") ("SDKEyeBrowMid1"+$side+".ty") -1 ($dist*-0.1); } if (`objExists EyeBrowMid2_R`) { if (`objExists EyeBrowMid3_R`) { asDsSdk ("ctrlBrow"+$side+".ty") ("SDKEyeBrowMid2"+$side+".ty") 1 $dist; asDsSdk ("ctrlBrow"+$side+".ty") ("SDKEyeBrowMid2"+$side+".ty") -1 ($dist*-1); } else { asDsSdk ("ctrlBrow"+$side+".ty") ("SDKEyeBrowMid2"+$side+".ty") 1 ($dist*0.7); asDsSdk ("ctrlBrow"+$side+".ty") ("SDKEyeBrowMid2"+$side+".ty") -1 ($dist*-0.7); } asDsSdk ("ctrlBrow"+$side+".tx") ("SDKEyeBrowMid2"+$side+".ty") 1 ($dist*0.1); asDsSdk ("ctrlBrow"+$side+".tx") ("SDKEyeBrowMid2"+$side+".ty") -1 ($dist*-0.1); } if (`objExists EyeBrowMid3_R`) { asDsSdk ("ctrlBrow"+$side+".ty") ("SDKEyeBrowMid3"+$side+".ty") 1 ($dist*0.7); asDsSdk ("ctrlBrow"+$side+".ty") ("SDKEyeBrowMid3"+$side+".ty") -1 ($dist*-0.7); } if (`objExists EyeBrowOuter_R`) { asDsSdk ("ctrlBrow"+$side+".ty") ("SDKEyeBrowOuter"+$side+".ty") 1 $dist; asDsSdk ("ctrlBrow"+$side+".ty") ("SDKEyeBrowOuter"+$side+".ty") -1 ($dist*-1); } /* asDsSdk ("ctrlBrow"+$side+".ty") ("SDKEyeBrowCenter_M.ty") 1 $dist; asDsSdk ("ctrlBrow"+$side+".ty") ("SDKEyeBrowCenter_M.ty") -1 ($dist*-1); asDsSdk ("ctrlBrow"+$side+".tx") ("SDKEyeBrowCenter_M.ty") 1 $dist; asDsSdk ("ctrlBrow"+$side+".tx") ("SDKEyeBrowCenter_M.ty") -1 ($dist*-1); */ } //squeeze $curveCmd="curve -d 1 -n EyeBrowCurve "; $pos=`xform -q -ws -t EyeBrowCenter`;$curveCmd+=" -p "+$pos[0]+" "+$pos[1]+" "+$pos[2]; $pos=`xform -q -ws -t EyeBrowInner`;$curveCmd+=" -p "+$pos[0]+" "+$pos[1]+" "+$pos[2]; if (`objExists EyeBrowMid1_R`) {$pos=`xform -q -ws -t EyeBrowMid1_R`;$curveCmd+=" -p "+$pos[0]+" "+$pos[1]+" "+$pos[2];} if (`objExists EyeBrowMid2_R`) {$pos=`xform -q -ws -t EyeBrowMid2_R`;$curveCmd+=" -p "+$pos[0]+" "+$pos[1]+" "+$pos[2];} if (`objExists EyeBrowMid3_R`) {$pos=`xform -q -ws -t EyeBrowMid3_R`;$curveCmd+=" -p "+$pos[0]+" "+$pos[1]+" "+$pos[2];} $pos=`xform -q -ws -t EyeBrowOuter`;$curveCmd+=" -p "+$pos[0]+" "+$pos[1]+" "+$pos[2]; eval ($curveCmd); rebuildCurve -ch 0 -rpo 1 -rt 0 -end 1 -kr 0 -kcp 0 -kep 0 -kt 0 -s 0 -d 3 -tol 0.01 EyeBrowCurve; createNode -n TempPos transform; createNode -n tempMotionPath motionPath; setAttr tempMotionPath.fractionMode 1; connectAttr EyeBrowCurve.worldSpace tempMotionPath.geometryPath; connectAttr tempMotionPath.allCoordinates TempPos.t; connectAttr tempMotionPath.rotate TempPos.rotate; setAttr tempMotionPath.worldUpType 0; setAttr tempMotionPath.upAxis 1; setAttr tempMotionPath.frontAxis 0; setAttr tempMotionPath.inverseFront 1; createNode -n tempNearestPointOnCurve nearestPointOnCurve; connectAttr -f EyeBrowCurve.worldSpace[0] tempNearestPointOnCurve.inputCurve; createNode -n TempPos2 transform; connectAttr TempPos2.t tempNearestPointOnCurve.inPosition; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; addAttr -k 1 -ln squeeze -at double -smx 10 -hsx 1 -smn 0 -hnv 1 ("ctrlBrow"+$side); asEnsureOutputBlendWeighted ("ctrlBrow"+$side+".squeeze"); $pos=`xform -q -ws -t EyeBrowInner_R`; // asDsSdk ("ctrlBrow"+$side+".squeeze") ("SDKEyeBrowCenter_M.ty") 10 (($pos[0]/$ctrlScale)*-0.05); asDsSdk ("ctrlBrow"+$side+".squeeze") ("SDKEyeBrowInner"+$side+".tx") 10 (($pos[0]/$ctrlScale)*0.50); asDsSdk ("ctrlBrow"+$side+".squeeze") ("SDKEyeBrowInner"+$side+".ty") 10 (($pos[0]/$ctrlScale)*0.25); // asDsSdk ("ctrlBrow"+$side+".squeeze") ("SDKEyeBrowInner"+$side+".sx") 10 0.25; clear $tempString; $tempString={"EyeBrowMid1","EyeBrowMid2","EyeBrowMid3","EyeBrowOuter"}; for ($i=0;$i-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; addAttr -k 1 -ln outerUpDown -at double -smx 10 -hsx 1 -smn 0 -hnv 1 ("ctrlBrow"+$side); asEnsureOutputBlendWeighted ("ctrlBrow"+$side+".outerUpDown"); xform -ws -t $outerUpDownTowardsPos[0] $outerUpDownTowardsPos[1] $outerUpDownTowardsPos[2] EyeBrowOuter_R; $pos=`getAttr EyeBrowOuter_R.t`; setAttr EyeBrowOuter_R.t 0 0 0; clear $tempString; $tempString={"EyeBrowInner","EyeBrowMid1","EyeBrowMid2","EyeBrowMid3","EyeBrowOuter"}; for ($i=0;$i0.99) skinPercent -tv $headJoint 1 $skinCluster $tempString[$i]; } //attach eyeBrow objects $eyeBrowGeos=`stringToStringArray $eyeBrow " "`; for ($i=0;$i-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; for ($y=0;$y-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; $leftSuffix=""; if ($b==-1 && `objExists FaceFitEyeLidMainLeft`) $leftSuffix="Left"; skinCluster -e -dr 4 -lw false -wt 0 -ai ("upperLidBaseJoint"+$side) $skinCluster; //weight on-curve vtxs first $tempString[0]=`asGetFaceFitSelection ("upperEyeLidOuterCurve"+$leftSuffix)`; $tempString=`stringToStringArray $tempString[0] " "`; select -cl; $stepValue=1.0/(size($tempString)-1); for ($i=0;$i1) $value=2-$value; $value=`smoothstep 0 1 $value`; if ($value<0.001) continue; catchQuiet (`skinPercent -tv ("upperLidBaseJoint"+$side) $value $skinCluster $tempString[$i]`); } //weight inbetw vtxs next select ("eyeLidArea"+$leftSuffix); $tempString=`ls -sl -fl`; select -cl; for ($i=0;$i0.01) select -add $tempString[$i]; } $tempString=`ls -sl`; if (size(`ls -sl`)) weightHammerVerts; } select -cl; } global proc asFaceSquint () { string $tempString[]; if (!`objExists upperEyeLidMainCurve`)//skip return; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; addAttr -ln squint -k 1 -at double -smx 10 -hsx 1 -smn 0 -hnv 1 -dv 0 ("ctrlEye"+$side); asEnsureOutputBlendWeighted ("ctrlEye"+$side+".squint"); } asFaceHideControllers 1; setAttr ctrlBoxEye_R.v 1; setAttr ctrlBoxEye_L.v 1; setAttr ctrlBox.RegionsCtrlVis 1; setAttr EyeRegionOffset_R.v 1; setAttr EyeRegionOffset_L.v 1; setAttr upperLidBaseOffset_R.v 1; setAttr upperLidBaseOffset_L.v 1; catchQuiet (`setAttr CheekRaiserOffset_R.v 1`); catchQuiet (`setAttr CheekRaiserOffset_L.v 1`); asFaceMirrorConnectCtrls 1; //fit-anim asFaceFitAnim ctrlEye_R.squint 10; asFaceFitAnim ctrlEye_L.squint 10; asFaceFitAnim EyeRegion_R 0; asFaceFitAnim EyeRegion_R.tz 0.1; asFaceFitAnim EyeRegion_R.sy 0.5; asFaceFitAnim CheekRaiser_R 0; asFaceFitAnim CheekRaiser_R.ty 0.4; asFaceFitAnim upperLidBase_R 0; playbackOptions -min 0 -max 30 -ast 0 -aet 30; currentTime 30; select -cl; } global proc asFaceSquintFinish () { if (!`objExists upperEyeLidMainCurve`)//skip return; if (`attributeExists SquintFinish FaceBuildInProgress`) return; addAttr -k 0 -ln SquintFinish -at bool -dv true FaceBuildInProgress; setAttr ctrlBox.RegionsCtrlVis 0; asFaceMirrorConnectCtrls 0; //remove fitAnim from driver $tempString=`listConnections -s 1 -d 0 -type animCurve ctrlEye_R.squint ctrlEye_L.squint`; if (size($tempString)) delete $tempString; setAttr ctrlEye_R.squint 0; setAttr ctrlEye_L.squint 0; //asFaceStoreAsDsSdk {"EyeRegion","CheekRaiser","upperLidBase"} "_RL" "ctrlEye" "_RL" "squint" 10; //CheekRaiser used to be part of squint, but shuffled buildOrder, so just removing this asFaceStoreAsDsSdk {"EyeRegion","upperLidBase"} "_RL" "ctrlEye" "_RL" "squint" 10; asFaceRemoveFitAnimationsFromOnFaceCtrls; asFaceHideControllers 1; setAttr ctrlBoxEye_R.v 1; setAttr ctrlBoxEye_L.v 1; } global proc asFaceLip () { global string $gMainProgressBar; global string $gSelect; global string $artSelectObject; string $geometry=`textField -q -tx asFaceFaceTextField`; string $headJoint=`textField -q -tx asFaceHeadJointTextField`; string $skinCluster=`textField -q -tx asFaceSkinClusterTextField`; int $outerNumCv,$ctrlNr,$type,$numCvs,$nrAsInt,$nearestVtx; int $nonSymmetrical=`checkBox -q -v asFaceNonSymCheckBox`; int $innerVtxNr[],$outerVtxNr[],$mainVtxNr[]; float $scale=`getAttr FaceFitSkeleton.faceScale`; float $ctrlScale=`getAttr OnFacecontrols.sx`; //float $faceFitScale=`getAttr FaceFitSkeleton.sy`; float $faceFitScale=`getAttr FaceFitSkeleton.faceScale`; float $dist,$currentValue,$factor,$lipDistOffsetScale,$minDist,$value,$driveStartValue; float $pos[],$posA[],$posB[],$posC[],$posD[],$posAB[],$posUpperA[],$posLowerA[],$libBShapePos[]; string $startVtx,$endVtx,$inOutMain,$side,$inf,$ctrl,$cd,$setRange,$plusMinusAverage,$joint,$grpA,$grpB,$jointOffset,$nr,$cmd,$upperLower,$leftSuffix; string $tempString[],$tempString2[],$tempString3[],$completedVtxs[],$endingVtxs[],$allLoopVtxs[],$lipArea[],$lipPress[]; string $rightCnrVtxs[],$leftCnrVtxs[],$loopVtxs[]; string $AB[]={"A","B"}; string $tr[]={"t","r"}; string $xyz[]={"x","y","z"}; asFaceSquintFinish; if (!`objExists upperLipMainCurve`)//skip return; asFaceHideControllers 1; progressBar -e -st "Lip Falloff" -bp -ii 0 -min 0 -max 14 $gMainProgressBar; evalDeferred ("progressBar -e -ep "+$gMainProgressBar); eval ("select "+`asGetFaceFitSelection LipInnerAreaMesh`); $tempString=`ls -sl`; //select `asobjSetCast "" $tempString LipLayer`; $lipArea=`ls -sl -fl`; createNode -n lipArea objectSet; sets -add FaceAreas lipArea; sets -add lipArea $lipArea; createNode -n LipSetup transform; parent LipSetup FaceDeformationSystem; //createNode -n LipPuckerSetup transform; //parent LipPuckerSetup FaceDeformationFollowHead; if (`objExists closestSampler`) delete closestSampler; createNode -n closestSampler closestPointOnMesh; connectAttr ($geometry+".outMesh") closestSampler.inMesh; createNode -n closestNurbsSampler closestPointOnSurface; createNode -n LipConstruction transform; //LipJoint select FaceJoint_M; joint -n LipJoints_M; setAttr LipJoints_M.segmentScaleCompensate 0; setAttr LipJoints_M.drawStyle 2;//Draw-style=none, otherwise looks too busy /* transformLimits -sx 0.1 1 -esx 1 0 LipJoint_M; transformLimits -sy 0.1 1 -esy 1 0 LipJoint_M; transformLimits -sz 0.1 1 -esz 1 0 LipJoint_M; */ $pos=`xform -q -ws -t ("upperLipOuterCurve.cv[0]")`; $posA=`xform -q -ws -t ("lowerLipOuterCurve.cv[0]")`; xform -ws -t 0 (($pos[1]+$posA[1])/2.0) `max $pos[2] $posA[2]` LipJoints_M; /* duplicate -n LipNarrowJoint_R LipNarrowJoint_M; duplicate -n LipNarrowJoint_L LipNarrowJoint_M; */ //Press & Roll & Pucker addAttrs for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper";else $upperLower="lower"; addAttr -k 1 -ln ($upperLower+"Press") -at double -smx 10 -hsx 1 -smn -10 -hnv 1 ctrlMouth_M; asEnsureOutputBlendWeighted ("ctrlMouth_M."+$upperLower+"Press"); } for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper";else $upperLower="lower"; addAttr -k 1 -ln ($upperLower+"Squeeze") -at double -smx 10 -hsx 1 -smn -10 -hnv 1 ctrlMouth_M; asEnsureOutputBlendWeighted ("ctrlMouth_M."+$upperLower+"Squeeze"); } for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper";else $upperLower="lower"; addAttr -k 1 -ln ($upperLower+"Roll") -at double -smx 10 -hsx 1 -smn -10 -hnv 1 ctrlMouth_M; asEnsureOutputBlendWeighted ("ctrlMouth_M."+$upperLower+"Roll"); } for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper";else $upperLower="lower"; addAttr -k 1 -ln ($upperLower+"Pucker") -at double -smx 10 -hsx 1 -smn -10 -hnv 1 ctrlMouth_M; asEnsureOutputBlendWeighted ("ctrlMouth_M."+$upperLower+"Pucker"); } //LipRegion $posA=`xform -q -ws -t upperLipMainCurve.cv[0]`; $posB=`xform -q -ws -t lowerLipMainCurve.cv[0]`; $pos[0]=0;$pos[1]=($posA[1]+$posB[1])/2.0;$pos[2]=($posA[2]+$posB[2])/2.0; asCreateFaceController "LipRegion" "_M" 4; delete LipRegionJoint_M; parent LipRegionOffset_M SideReverse_M; setAttr LipRegionOffset_M.s -type float3 1 1 1; scale -r -p 0 0 0 6 6 6 LipRegion_M.cv[0:7]; xform -ws -t 0 $pos[1] $pos[2] LipRegionOffset_M; move -r 0 0 ($scale/10.0) LipRegion_M.cv[0:99]; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $leftSuffix=""; else $leftSuffix="Left"; for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; //Create BuildCurves (based on ordered selection) for ($a=0;$a<3;$a++) { progressBar -e -s 1 $gMainProgressBar; if ($a==0) $inOutMain="Inner";if ($a==1) $inOutMain="Outer";if ($a==2) $inOutMain="Main"; $curveCmd="curve -d 1 "; // eval ("select "+`getAttr ("FaceFitLip"+$inOutMain+"."+$upperLower+"Selection")`); eval ("select "+`asGetFaceFitSelection ($upperLower+"Lip"+$inOutMain+"Curve"+$leftSuffix)`); $loopVtxs=`ls -sl -fl`; clear $completedVtxs; // $tempString[0]=`getAttr ("FaceFitLip"+$inOutMain+"."+$upperLower+"Selection")`; $tempString[0]=`asGetFaceFitSelection ($upperLower+"Lip"+$inOutMain+"Curve"+$leftSuffix)`; $tempString=`stringToStringArray $tempString[0] " "`; select $tempString[0]; for ($i=0;$i-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; $outerNumCv=`getAttr ($upperLower+"LipOuterBuildCurve.spans")`+1; //Mirror joints for ($i=0;$i<$outerNumCv;$i++) { if ($i==0) $side="_M"; else $side="_R"; if ($upperLower=="lower" && $i==($outerNumCv-1))//no need for lower at the same spot (start & end) continue; if (!`objExists ($upperLower+"LipJoint"+$i)`) error ("LipJoint:\""+$upperLower+"LipJoint"+$i+" not found. Probably the model is not symmetrical.\n" +"Try to redo the FitLips, and include 3 vertex selection on the edgeloops, to spesify center and sides"); rename ($upperLower+"LipJoint"+$i) ($upperLower+"LipJoint"+$i+$side); parent ($upperLower+"LipJoint"+$i+$side) LipJoints_M; if ($side=="_R") { duplicate -n ($upperLower+"LipJoint"+$i+"_L") ($upperLower+"LipJoint"+$i+"_R"); // parent ($upperLower+"LipJoint"+$i+"_L") LipJoints_M; $pos=`xform -q -ws -t ($upperLower+"LipJoint"+$i+"_L")`; if (`objExists ($upperLower+"LipJoint"+$i+"Left")`) { $pos=`xform -q -ws -t ($upperLower+"LipJoint"+$i+"Left")`; $pos[0]=$pos[0]*-1; delete ($upperLower+"LipJoint"+$i+"Left"); } xform -ws -t ($pos[0]*-1) $pos[1] $pos[2] ($upperLower+"LipJoint"+$i+"_L"); } } // if ($side=="_M") // parent ($upperLower+"LipJoint"+$i+"_M") LipJointsPart_M; if (`objExists ($upperLower+"LipJoint0Left")`) delete ($upperLower+"LipJoint0Left"); } //JointOffsetGrps & ziplip createNode -n LipRibbon -p LipSetup transform; createNode -n LipFollicles -p LipSetup transform; $pos=`xform -q -ws -t ("upperLipOuterCurve.cv[0]")`; $posA=`xform -q -ws -t ("lowerLipOuterCurve.cv[0]")`; xform -ws -t 0 (($pos[1]+$posA[1])/2.0) `max $pos[2] $posA[2]` LipFollicles; parentConstraint -mo FaceJoint_M LipFollicles; scaleConstraint FaceJoint_M LipFollicles; createNode -n LipRibbonJoints -p LipSetup transform; scaleConstraint FaceJoint_M LipRibbonJoints; for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { progressBar -e -s 1 $gMainProgressBar; if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; $outerNumCv=`getAttr ($upperLower+"LipOuterBuildCurve.spans")`+1; //Ribbon duplicate -n ($upperLower+"LipCenterBuildCurve_L") ($upperLower+"LipCenterBuildCurve"); setAttr ($upperLower+"LipCenterBuildCurve_L.sx") -1; if (`objExists ($upperLower+"LipCenterBuildCurveLeft")`) { delete ($upperLower+"LipCenterBuildCurve_L"); duplicate -n ($upperLower+"LipCenterBuildCurve_L") ($upperLower+"LipCenterBuildCurveLeft"); } attachCurve -ch 0 -n ($upperLower+"LipCenterBuildCurve_M") -rpo 0 -kmk 1 -m 1 -bb 0.5 -bki 0 -p 0.1 ($upperLower+"LipCenterBuildCurve_L") ($upperLower+"LipCenterBuildCurve"); curve -n tempLoftProfile -d 1 -p 0 0 ($faceFitScale/-50.0) -p 0 0 ($faceFitScale/50.0) -k 0 -k 1 ; // rebuildCurve -ch 0 -rpo 1 -rt 0 -end 1 -kr 0 -kcp 0 -kep 1 -kt 0 -s 0 -d 3 -tol 0.01 tempLoftProfile; if (`objExists tempPointOnCurveInfo`) delete tempPointOnCurveInfo; createNode -n tempPointOnCurveInfo pointOnCurveInfo; setAttr tempPointOnCurveInfo.turnOnPercentage 1; duplicate -n ($upperLower+"LipCenterBuildCurve2_M") ($upperLower+"LipCenterBuildCurve_M"); rebuildCurve -ch 0 -rpo 1 -rt 0 -end 1 -kr 0 -kcp 0 -kep 1 -kt 0 -s 4 -d 3 -tol 0.01 ($upperLower+"LipCenterBuildCurve2_M"); connectAttr -f ($upperLower+"LipCenterBuildCurve2_MShape.worldSpace[0]") tempPointOnCurveInfo.inputCurve; for ($i=0;$i<5;$i++) { duplicate -n ("tempLoftProfile"+$i) tempLoftProfile; setAttr tempPointOnCurveInfo.parameter ($i/4.0); if ($i==1) setAttr tempPointOnCurveInfo.parameter 0.20; if ($i==3) setAttr tempPointOnCurveInfo.parameter 0.80; $pos=`getAttr tempPointOnCurveInfo.position`; xform -ws -t $pos[0] $pos[1] $pos[2] ("tempLoftProfile"+$i); } delete ($upperLower+"LipCenterBuildCurve2_M"); if (`objExists TempPos`) delete TempPos; //orient curves, for `folding back` mouths e.g. cody delete `aimConstraint -offset 0 0 0 -weight 1 -aimVector -1 0 0 -upVector 0 1 0 -worldUpType "scene" tempLoftProfile1 tempLoftProfile0`; delete `aimConstraint -offset 0 0 0 -weight 1 -aimVector -1 0 0 -upVector 0 1 0 -worldUpType "scene" tempLoftProfile2 tempLoftProfile1`; delete `aimConstraint -offset 0 0 0 -weight 1 -aimVector 1 0 0 -upVector 0 1 0 -worldUpType "scene" tempLoftProfile3 tempLoftProfile4`; delete `aimConstraint -offset 0 0 0 -weight 1 -aimVector 1 0 0 -upVector 0 1 0 -worldUpType "scene" tempLoftProfile2 tempLoftProfile3`; select -cl; for ($i=0;$i<5;$i++) select -add ("tempLoftProfile"+$i); loft -ch 1 -n ($upperLower+"LipCenterPlane") -u 1 -c 0 -ar 0 -d 3 -ss 1 -rn 0 -po 0 -rsn true; delete tempLoftProfile; for ($i=0;$i<5;$i++) delete ("tempLoftProfile"+$i); reverseSurface -d 3 -ch 0 -rpo 1 ($upperLower+"LipCenterPlane"); rebuildSurface -ch 0 -rpo 1 -rt 0 -end 1 -kr 0 -kcp 0 -kc 0 -su 0 -du 3 -sv 0 -dv 3 -tol 0.01 -fr 0 -dir 2 ($upperLower+"LipCenterPlane"); parent ($upperLower+"LipCenterPlane") LipRibbon; connectAttr -f ($upperLower+"LipCenterPlaneShape.worldSpace[0]") closestNurbsSampler.inputSurface; // parent ($upperLower+"LipCenterBuildCurve_M") LipRibbon; delete ($upperLower+"LipCenterBuildCurve_M"); for ($b=1;$b>-2;$b=$b-2) { for ($i=0;$i<$outerNumCv;$i++) { if ($b==1) $side="_R"; else $side="_L"; if ($i==0) $side="_M"; if ($i==0 && $b==-1) continue; if ($upperLower=="lower" && $i==($outerNumCv-1))//no need for lower at the same spot (start & end) continue; if (`asIsMayaLT`) continue; $tempString[0]=`createNode follicle`; $tempString=`listRelatives -p $tempString[0]`; rename $tempString[0] ($upperLower+"follicle"+$i+$side); parent ($upperLower+"follicle"+$i+$side) LipFollicles; setAttr ($upperLower+"follicle"+$i+$side+".collide") 0; connectAttr ($upperLower+"LipCenterPlane.local") ($upperLower+"follicle"+$i+$side+".inputSurface"); // connectAttr ($upperLower+"LipCenterPlane.worldMatrix[0]") ($upperLower+"follicle"+$i+$side+".inputWorldMatrix"); connectAttr -f ("LipFollicles.worldInverseMatrix[0]") ($upperLower+"follicle"+$i+$side+".inputWorldMatrix"); connectAttr -f ($upperLower+"follicle"+$i+$side+".outTranslate") ($upperLower+"follicle"+$i+$side+".t"); connectAttr -f ($upperLower+"follicle"+$i+$side+".outRotate") ($upperLower+"follicle"+$i+$side+".r"); $pos=`xform -q -ws -t ($upperLower+"LipJoint"+$i+$side)`; setAttr -type float3 closestNurbsSampler.inPosition $pos[0] $pos[1] $pos[2]; setAttr ($upperLower+"follicle"+$i+$side+".parameterU") `getAttr closestNurbsSampler.parameterU`; setAttr ($upperLower+"follicle"+$i+$side+".parameterV") `getAttr closestNurbsSampler.parameterV`; connectAttr ($upperLower+"follicle"+$i+$side+".t") ($upperLower+"LipJoint"+$i+$side+".t"); // connectAttr ($upperLower+"follicle"+$i+$side+".r") ($upperLower+"LipJoint"+$i+$side+".r"); orientConstraint ($upperLower+"follicle"+$i+$side) ($upperLower+"LipJoint"+$i+$side); setAttr ($upperLower+"LipJoint"+$i+$side+"_orientConstraint1.offset") -type float3 90 0 180; } } } if (`objExists tempPointOnCurveInfo`) delete tempPointOnCurveInfo; //Bind $tempString=`listRelatives -ad -type joint FaceJoint_M`; select -cl; for ($i=0;$i-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; $outerNumCv=`getAttr ($upperLower+"LipOuterBuildCurve.spans")`+1; for ($b=1;$b>-2;$b=$b-2) { progressBar -e -s 1 $gMainProgressBar; //Hard weights for ($a=0;$a<3;$a++) { if ($a==0) $inOutMain="Inner";if ($a==1) $inOutMain="Outer";if ($a==2) $inOutMain="Main"; for ($i=0;$i<$outerNumCv;$i++) { if ($b==1) $side="_R"; else $side="_L"; if ($i==0) $side="_M"; if ($i==0 && $b==-1) continue; if ($upperLower=="lower" && $i==($outerNumCv-1))//no need for lower at the same spot (start & end) continue; $pos=`xform -q -ws -t ($upperLower+"Lip"+$inOutMain+"BuildCurve.cv["+$i+"]")`; if ($side=="_L" && `objExists ($upperLower+"Lip"+$inOutMain+"BuildCurveLeft.cv["+$i+"]")`) { $pos=`xform -q -ws -t ($upperLower+"Lip"+$inOutMain+"BuildCurveLeft.cv["+$i+"]")`; $pos[0]=$pos[0]*-1; } setAttr -type float3 closestSampler.inPosition ($pos[0]*$b) $pos[1] $pos[2]; select ($geometry+".vtx["+`getAttr closestSampler.result.closestVertexIndex`+"]"); catchQuiet (`skinPercent -tv ($upperLower+"LipJoint"+$i+$side) 1 $skinCluster`); if ($inOutMain=="Inner") $innerVtxNr[$i]=`getAttr closestSampler.result.closestVertexIndex`; if ($inOutMain=="Outer") $outerVtxNr[$i]=`getAttr closestSampler.result.closestVertexIndex`; if ($inOutMain=="Main") $mainVtxNr[$i]=`getAttr closestSampler.result.closestVertexIndex`; } } //shortestEdgePath vtxs for ($i=0;$i<$outerNumCv;$i++) { if ($b==1) $side="_R"; else $side="_L"; if ($i==0) $side="_M"; if ($i==0 && $b==-1) continue; if ($upperLower=="lower" && $i==($outerNumCv-1))//no need for lower at the same spot (start & end) continue; select $geometry; // select `polySelect -q -asSelectString -shortestEdgePath $outerVtxNr[$i] $mainVtxNr[$i]`;//outer -> main asSelectLeastEdgesPath $geometry $outerVtxNr[$i] $mainVtxNr[$i]; ConvertSelectionToVertices; if ($i==$outerNumCv-1 && $b==1) $rightCnrVtxs=`ls -sl`; if ($i==$outerNumCv-1 && $b==-1) $leftCnrVtxs=`ls -sl`; catchQuiet (`skinPercent -tv ($upperLower+"LipJoint"+$i+$side) 1 $skinCluster`); select $geometry; // select `polySelect -q -asSelectString -shortestEdgePath $innerVtxNr[$i] $mainVtxNr[$i]`;//inner -> main asSelectLeastEdgesPath $geometry $innerVtxNr[$i] $mainVtxNr[$i]; ConvertSelectionToVertices; $tempString=`ls -sl`; if ($i==$outerNumCv-1 && $b==1) $rightCnrVtxs=`stringArrayCatenate $rightCnrVtxs $tempString`; if ($i==$outerNumCv-1 && $b==-1) $leftCnrVtxs=`stringArrayCatenate $leftCnrVtxs $tempString`; catchQuiet (`skinPercent -tv ($upperLower+"LipJoint"+$i+$side) 1 $skinCluster`); } } } //hammer any leftovers select -cl; for ($i=0;$i-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; for ($i=0;$i<7;$i++) { if ($i==0) {$ctrl="Lip";$side="_R";$type=1;} if ($i==1) {$ctrl=$upperLower+"LipB";$side="_R";$type=3;} if ($i==2) {$ctrl=$upperLower+"LipA";$side="_R";$type=1;} if ($i==3) {$ctrl=$upperLower+"Lip";$side="_M";$type=2;} if ($i==4) {$ctrl=$upperLower+"LipA";$side="_L";$type=1;} if ($i==5) {$ctrl=$upperLower+"LipB";$side="_L";$type=3;} if ($i==6) {$ctrl="Lip";$side="_L";$type=1;} if (`objExists TempPos`) delete TempPos; createNode -n TempPos transform; createNode -n tempMotionPath motionPath; setAttr tempMotionPath.fractionMode 1; connectAttr ($upperLower+"LipOuterCurve.worldSpace") tempMotionPath.geometryPath; if ($i>3 && `objExists upperLipOuterCurveLeft`) connectAttr -f ($upperLower+"LipOuterCurveLeft.worldSpace") tempMotionPath.geometryPath; connectAttr -f tempMotionPath.allCoordinates TempPos.t; if ($i==1)//$libBShapePos { setAttr tempMotionPath.uValue 0.8; $libBShapePos=`xform -q -ws -t TempPos`; } if ($i==0) setAttr tempMotionPath.uValue 1; if ($i==1) setAttr tempMotionPath.uValue 1; if ($i==2) setAttr tempMotionPath.uValue 0.6; if ($i==3) setAttr tempMotionPath.uValue 0; if ($i==4) setAttr tempMotionPath.uValue 0.6;//nonSymm face if ($i==5) setAttr tempMotionPath.uValue 1;//nonSymm face if ($i==6) setAttr tempMotionPath.uValue 1;//nonSymm face //LipB to attach to the vtx before the corner if ($i==1 || $i==5) { setAttr tempMotionPath.fractionMode 0; setAttr tempMotionPath.uValue (`getAttr ($upperLower+"LipOuterCurve.spans")`-1); } $pos=`xform -q -ws -t TempPos`; delete tempMotionPath; if (($i==0 || $i==6) && $upperLower=="lower") ;//No need of controller else { asCreatePingPong TempPos $ctrl 1 $side $type 1 0; rename ($ctrl+"Joint"+$side) ($ctrl+"RibbonJoint"+$side); rename ($ctrl+"Joint"+$side+"_parentConstraint1") ($ctrl+"RibbonJoint"+$side+"_parentConstraint1"); delete ($ctrl+"Joint"+$side+"_scaleConstraint1"); parent ($ctrl+"RibbonJoint"+$side) LipRibbonJoints;//joint not a direct-bind } delete TempPos; if ($ctrl==$upperLower+"LipB")//$libBShapePos { $pos=`xform -q -ws -t ($ctrl+$side)`; if ($side=="_L") move -r (($libBShapePos[0]*-1)-$pos[0]) ($libBShapePos[1]-$pos[1]) ($libBShapePos[2]-$pos[2]) ($ctrl+$side+".cv[0:99]"); if ($side=="_R") move -r (($libBShapePos[0]* 1)-$pos[0]) ($libBShapePos[1]-$pos[1]) ($libBShapePos[2]-$pos[2]) ($ctrl+$side+".cv[0:99]"); asFacePlaceCtrlByProjection ($ctrl+$side); } //bind CVs if ($i==0) { select ($upperLower+"LipCenterPlane") ($ctrl+"RibbonJoint"+$side); $tempString=`newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"`; rename $tempString[0] ($upperLower+"LipCenterPlaneSC"); } else skinCluster -e -dr 4 -lw false -wt 0 -ai ($ctrl+"RibbonJoint"+$side) ($upperLower+"LipCenterPlaneSC"); select -r ($upperLower+"LipCenterPlane.cv["+(6-$i)+"][0:4]"); skinPercent -tv ($ctrl+"RibbonJoint"+$side) 1 ($upperLower+"LipCenterPlaneSC"); } } //connect lip-cnr follicle (upper) for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; if (`asIsMayaLT`) continue; $outerNumCv=`getAttr ("upperLipOuterBuildCurve.spans")`+1; disconnectAttr ("upperfollicle"+($outerNumCv-1)+$side+".outTranslate") ("upperfollicle"+($outerNumCv-1)+$side+".t"); disconnectAttr ("upperfollicle"+($outerNumCv-1)+$side+".outRotate") ("upperfollicle"+($outerNumCv-1)+$side+".r"); parentConstraint -mo ("LipRibbonJoint"+$side) ("upperfollicle"+($outerNumCv-1)+$side); } select -cl; if (!$nonSymmetrical) copySkinWeights -ss $skinCluster -ds $skinCluster -mirrorMode YZ -mirrorInverse -surfaceAssociation closestPoint -influenceAssociation closestJoint; asFaceHalfMoonCurve upperLip_M 90; asFaceHalfMoonCurve lowerLip_M -90; //createNode -n WideNarrowMouthScale -p LipSetup transform; //scaleConstraint FaceJoint_M WideNarrowMouthScale; /* //WideNarrowBlender for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; $posA=`xform -q -ws -t ("Lip"+$side)`; xform -ws -t 0 $posA[1] $posA[2] ("Lip"+$side); // $posA=`getAttr ("Lip"+$side+".t")`; xform -os -t 0 0 0 ("Lip"+$side); createNode -n ("LipNonNarrowParent"+$side) transform; parent ("LipNonNarrowParent"+$side) LipNarrowJoint_M; setAttr ("LipNonNarrowParent"+$side+".t") -type float3 0 0 0; parent ("LipNonNarrowParent"+$side) WideNarrowMouthScale; createNode -n ("LipNonNarrowAim"+$side) -p ("LipNonNarrowParent"+$side) transform; setAttr ("LipNonNarrowParent"+$side+".s") -type float3 1 1 1; delete `aimConstraint -offset 0 0 0 -weight 1 -aimVector 1 0 0 -upVector 0 1 0 -worldUpType "objectrotation" -worldUpVector 0 1 0 -worldUpObject $headJoint ("Lip"+$side) ("LipNonNarrowAim"+$side)`; createNode -n ("LipNonNarrow"+$side) -p ("LipNonNarrowAim"+$side) transform; $posA=`xform -q -ws -t ("Lip"+$side)`; xform -ws -t $posA[0] $posA[1] $posA[2] ("LipNonNarrow"+$side); duplicate -n ("LipNonNarrow2"+$side) ("LipNonNarrow"+$side); $posA=`getAttr ("LipNonNarrow"+$side+".t")`; // createNode -n ("LipNonNarrow"+$side) -p ("LipOffset"+$side) transform; pointConstraint -skip x ("Lip"+$side) ("LipNonNarrow"+$side); orientConstraint ("Lip"+$side) ("LipNonNarrow"+$side); pointConstraint ("Lip"+$side) ("LipNonNarrow2"+$side); delete ("LipRibbonJoint"+$side+"_parentConstraint1"); parentConstraint -mo ("Lip"+$side) ("LipNonNarrow"+$side) ("LipRibbonJoint"+$side); createNode -n ("LipNonNarrowCondition"+$side) condition; setAttr ("LipNonNarrowCondition"+$side+".operation") 2; connectAttr ("LipNonNarrow2"+$side+".tx") ("LipNonNarrowCondition"+$side+".firstTerm"); setAttr ("LipNonNarrowCondition"+$side+".secondTerm") $posA[0]; setAttr ("LipNonNarrowCondition"+$side+".colorIfTrue") -type float3 1 0 0; setAttr ("LipNonNarrowCondition"+$side+".colorIfFalse") -type float3 0 1 1; connectAttr ("LipNonNarrowCondition"+$side+".outColorR") ("LipRibbonJoint"+$side+"_parentConstraint1.Lip"+$side+"W0"); connectAttr ("LipNonNarrowCondition"+$side+".outColorG") ("LipRibbonJoint"+$side+"_parentConstraint1.LipNonNarrow"+$side+"W1"); //Narrow for ($z=0;$z-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; createNode -n ("LipNonRot"+$side) -p ("LipOffset"+$side) transform; pointConstraint -mo ("LipRibbonJoint"+$side) ("LipNonRot"+$side); orientConstraint ("Lip"+$side) ("LipNonRot"+$side); for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; if ($side=="_R") {//LipPos means we can use asFaceAddConstrained without undesired scale-effects createNode -n ($upperLower+"LipPos_M") transform; parentConstraint ($upperLower+"Lip_M") ($upperLower+"LipPos_M"); parent ($upperLower+"LipPos_M") FaceDeformationFollowHead; } // asFaceAddConstrained ($upperLower+"LipA"+$side) ($upperLower+"LipPos_M") ("LipNonRot"+$side) 7.5; // asFaceAddConstrained ($upperLower+"LipB"+$side) ($upperLower+"LipPos_M") ("LipNonRot"+$side) 1.0; //below option is following LipCnr Rot, better four pull-out motion, but worse for pull-in motion, os not using this asFaceAddConstrained ($upperLower+"LipA"+$side) ($upperLower+"Lip_M") ("Lip"+$side) 7.5; asFaceAddConstrained ($upperLower+"LipB"+$side) ($upperLower+"Lip_M") ("Lip"+$side) 1.0; } } for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; createNode -n ("LipScaleSizer"+$side) transform; createNode -n ("LipScaleAutoVolume"+$side) -p ("LipScaleSizer"+$side) transform; createNode -n ("LipScale"+$side) -p ("LipScaleAutoVolume"+$side) transform; parent ("LipScaleSizer"+$side) ("Lip"+$side); xform -os -t 0 0 0 -ro 0 0 0 ("LipScaleSizer"+$side); // for ($z=0;$z-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; spaceLocator -n ("LipDistLoc"+$side); parent -r ("LipDistLoc"+$side) ("Lip"+$side); setAttr -l 1 ("LipDistLoc"+$side+".v") 0; } connectAttr -f ("LipDistLoc_R.worldPosition[0]") LipDist.point1; connectAttr -f ("LipDistLoc_L.worldPosition[0]") LipDist.point2; //LipDist.distance; for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper";else $upperLower="lower"; createNode -n ($upperLower+"LipScaleSizer_M") transform; createNode -n ($upperLower+"LipScaleAutoVolume_M") -p ($upperLower+"LipScaleSizer_M") transform; createNode -n ($upperLower+"LipScale_M") -p ($upperLower+"LipScaleAutoVolume_M") transform; transformLimits -sz -1 2 -esz 0 1 ($upperLower+"LipScaleAutoVolume_M");//max scale 2 parent ($upperLower+"LipScaleSizer_M") ($upperLower+"Lip_M"); xform -os -t 0 0 0 -ro 0 0 0 ($upperLower+"LipScaleSizer_M") ; //AutoVolume addAttr -k 1 -ln lipAutoVolume -at double -smx 10 -hsx 1 -smn 0 -hnv 1 -dv 5 ($upperLower+"Lip_M"); asEnsureOutputBlendWeighted ($upperLower+"Lip_M.lipAutoVolume"); createNode -n ($upperLower+"LipAutoVolumeBW_M") blendWeighted; // createNode -n ($upperLower+"LipAutoVolumePMA_M") plusMinusAverage; // connectAttr LipNonNarrow2_R.tx ($upperLower+"LipAutoVolumePMA_M.input1D[0]"); // connectAttr LipNonNarrow2_L.tx ($upperLower+"LipAutoVolumePMA_M.input1D[1]"); createNode -n ($upperLower+"LipAutoVolumeMPD_M") multiplyDivide; setAttr ($upperLower+"LipAutoVolumeMPD_M.operation") 2; connectAttr LipDist.distance ($upperLower+"LipAutoVolumeMPD_M.input2X"); setAttr ($upperLower+"LipAutoVolumeMPD_M.input1X") `getAttr LipDist.distance`; // connectAttr ($upperLower+"LipAutoVolumeMPD_M.outputX") ($upperLower+"LipAutoVolumeBW_M.input[0]"); createNode -n ($upperLower+"LipAutoVolumeMPD2_M") multiplyDivide; connectAttr ($upperLower+"LipAutoVolumeMPD_M.outputX") ($upperLower+"LipAutoVolumeMPD2_M.input1X"); connectAttr MainAndHeadScaleMultiplyDivide.outputX ($upperLower+"LipAutoVolumeMPD2_M.input2X"); connectAttr ($upperLower+"LipAutoVolumeMPD2_M.outputX") ($upperLower+"LipAutoVolumeBW_M.input[0]"); setAttr ($upperLower+"LipAutoVolumeBW_M.input[1]") 1; asUnitConvertAndReverse ($upperLower+"LipAutoVolumeBlend") ("bw"+$upperLower+"Lip_M_lipAutoVolume.output"); connectAttr ($upperLower+"LipAutoVolumeBlendUnitConversion.output") ($upperLower+"LipAutoVolumeBW_M.weight[0]"); connectAttr ($upperLower+"LipAutoVolumeBlendReverse.outputX") ($upperLower+"LipAutoVolumeBW_M.weight[1]"); connectAttr ($upperLower+"LipAutoVolumeBW_M.output") ($upperLower+"LipScaleAutoVolume_M.sz"); } createNode -n LipScale_M transform; parent LipScale_M FaceDeformationFollowHead; //ScaleContraint for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; $outerNumCv=`getAttr ($upperLower+"LipOuterBuildCurve.spans")`+1; //Roll attrs addAttr -k 1 -ln roll -at double -smx 10 -hsx 1 -smn -10 -hnv 1 ($upperLower+"Lip_M"); asEnsureOutputBlendWeighted ($upperLower+"Lip_M.roll"); for ($b=1;$b>-2;$b=$b-2) { for ($i=0;$i<$outerNumCv;$i++) { if ($b==1) $side="_R"; else $side="_L"; if ($i==0) $side="_M"; if ($i==0 && $b==-1) continue; if ($upperLower=="lower" && $i==($outerNumCv-1))//no need for lower at the same spot (start & end) continue; //ScaleContraint scaleConstraint ($upperLower+"LipScale_M") ("LipScale"+$side) ($upperLower+"LipJoint"+$i+$side); $value=`smoothstep 0 1 (1-((1/($outerNumCv-1.0)*$i)))`; setAttr ($upperLower+"LipJoint"+$i+$side+"_scaleConstraint1."+$upperLower+"LipScale_MW0") $value; setAttr ($upperLower+"LipJoint"+$i+$side+"_scaleConstraint1.LipScale"+$side+"W1") (1-$value); //Roll createNode -n ($upperLower+"LipJoint"+$i+$side+"RollUnitConversion") unitConversion; setAttr ($upperLower+"LipJoint"+$i+$side+"RollUnitConversion.conversionFactor") (57.296*($upperLowerFactor*-0.15*`smoothstep 0 1 (1-((1/($outerNumCv-1.0)*$i)))`)); connectAttr ("bw"+$upperLower+"Lip_M_roll.output") ($upperLower+"LipJoint"+$i+$side+"RollUnitConversion.input"); //add 90degrees to offset createNode -n ($upperLower+"LipJoint"+$i+$side+"RollPMA") plusMinusAverage; connectAttr ($upperLower+"LipJoint"+$i+$side+"RollUnitConversion.output") ($upperLower+"LipJoint"+$i+$side+"RollPMA.input1D[0]"); setAttr ($upperLower+"LipJoint"+$i+$side+"RollPMA.input1D[1]") 90; if (!`asIsMayaLT`) connectAttr ($upperLower+"LipJoint"+$i+$side+"RollPMA.output1D") ($upperLower+"LipJoint"+$i+$side+"_orientConstraint1.offsetX"); } } } //press squeeze roll pucker sdk for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; //Press setKeyframe -t 0 ($upperLower+"Lip_M"); setKeyframe -t 30 -v 0.2 ($upperLower+"Lip_M.sz"); asFaceStoreAsDsSdk {$upperLower+"Lip"} "_M" "ctrlMouth" "_M" ($upperLower+"Press") 10; asFaceRemoveFitAnimationsFromOnFaceCtrls; delete ($upperLower+"LipValues_M"); //Squeeze $posA=`xform -q -ws -t ($upperLower+"Lip_M")`; $posB=`xform -q -ws -t ($upperLower+"LipMainCurve.cv[0]")`; setKeyframe -t 0 ($upperLower+"Lip_M"); setKeyframe -t 30 -v 0.3 ($upperLower+"Lip_M.sy"); setKeyframe -t 30 -v ((($posB[1]-$posA[1])/$ctrlScale)*0.5) ($upperLower+"Lip_M.ty"); asFaceStoreAsDsSdk {$upperLower+"Lip"} "_M" "ctrlMouth" "_M" ($upperLower+"Squeeze") 10; asFaceRemoveFitAnimationsFromOnFaceCtrls; delete ($upperLower+"LipValues_M"); //Roll setKeyframe -t 0 ($upperLower+"Lip_M"); setKeyframe -t 30 -v 10 ($upperLower+"Lip_M.roll"); asFaceStoreAsDsSdk {$upperLower+"Lip"} "_M" "ctrlMouth" "_M" ($upperLower+"Roll") 10; asFaceRemoveFitAnimationsFromOnFaceCtrls; delete ($upperLower+"LipValues_M"); //Pucker $posA=`xform -q -ws -t upperLipOuterCurve.cv[0]`; $posB=`xform -q -ws -t upperLipMainCurve.cv[0]`; $value=$posA[1]-$posB[1];//relative to lip thickness // setKeyframe -t 30 -v ((($value/$ctrlScale)/2.0)*$upperLowerFactor) ($upperLower+"Lip_M.ty"); // setKeyframe -t 30 -v (($value/$ctrlScale)/2.0) ($upperLower+"Lip_M.tz"); setKeyframe -t 0 ($upperLower+"Lip_M"); setKeyframe -t 30 -v 5 ($upperLower+"Lip_M.roll"); asFaceStoreAsDsSdk {$upperLower+"Lip"} "_M" "ctrlMouth" "_M" ($upperLower+"Pucker") 10; asFaceRemoveFitAnimationsFromOnFaceCtrls; delete ($upperLower+"LipValues_M"); setKeyframe -t 0 Lip_R Lip_L; setKeyframe -t 30 -v (($value/$ctrlScale)*-0.3) Lip_R.tx; setKeyframe -t 30 -v (($value/$ctrlScale)*-0.3) Lip_L.tx; asFaceStoreAsDsSdk {"Lip"} "_RL" "ctrlMouth" "_M" ($upperLower+"Pucker") 10; asFaceRemoveFitAnimationsFromOnFaceCtrls; delete LipValues_R; } //last nr lipJoint -> LipJoint_R $outerNumCv=`getAttr upperLipOuterCurve.spans`; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; rename ("upperLipJoint"+$outerNumCv+$side) ("LipJoint"+$side); } parent upperLipOffset_M lowerLipOffset_M LipOffset_R LipOffset_L LipRegion_M; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; parent ($upperLower+"LipAOffset"+$side) ($upperLower+"LipBOffset"+$side) LipRegion_M; // parent ($upperLower+"LipAConstrainedOffset"+$upperLower+"LipPos_M"+$side) ($upperLower+"LipBConstrainedOffset"+$upperLower+"LipPos_M"+$side) LipRegion_M; parent ($upperLower+"LipAConstrainedOffset"+$upperLower+"Lip_M"+$side) ($upperLower+"LipBConstrainedOffset"+$upperLower+"Lip_M"+$side) LipRegion_M; } } delete LipConstruction; if (`objExists closestNurbsSampler`) delete closestNurbsSampler; select -cl; setToolTo $gSelect; } global proc asFaceLipFalloff () { global string $gMove; int $test,$lipFalloff,$numCVs,$vtxsFromLipToNose; int $nonSymmetrical=`checkBox -q -v asFaceNonSymCheckBox`; int $vtxNrs[]; float $value,$factor,$faceWeightAddValue,$minDist,$dist,$weight,$portion,$weightValue,$fadeDist,$falloffRadius,$weight; float $scale=`asGetScale`; float $sideTreshold=0.0001*$scale; float $fadeFloat=1.3; if (`floatField -q -ex asFaceLipFalloffSideFadeFloatField`) $fadeFloat=`floatField -q -v asFaceLipFalloffSideFadeFloatField`; float $pos[],$posA[],$posB[],$values[],$weights[],$heightweight[],$widthweight[]; string $geometry=`textField -q -tx asFaceFaceTextField`; string $headJoint=`textField -q -tx asFaceHeadJointTextField`; string $skinCluster=`textField -q -tx asFaceSkinClusterTextField`; string $innerOuter,$inf,$closestLipOuterCurveVtx,$side,$leftSuffix,$vtxNrA,$vtxNrB; string $tempString[],$tempString2[],$tempString3[],$infs[],$lipFalloffInsideMouthArea[],$upperVtxs[],$lowerVtxs[],$upperVtxsL[],$lowerVtxsL[]; string $innerLipFalloffVtxs[],$outerLipFalloffVtxs[],$lipOuterCurveVtx[],$previousSel[],$nonLipFalloffAreaVtxs[],$doneVtxs[]; if (!`objExists upperLipMainCurve` || !`objExists NoseUnder`)//skip return; setAttr upperLipA_R.ty 1; refresh; if (`objExists asFaceLipFalloffTest`) { $test=1; delete asFaceLipFalloffTest; } asFaceLockWeights 1; setAttr ($headJoint+".lockInfluenceWeights") 0; $tempString=`listRelatives -c -type joint LipJoints_M`; for ($i=0;$i0) $vtxsFromLipToNose++; } $vtxsFromLipToNose++; setAttr FaceFitSkeleton.vtxsFromLipToNose $vtxsFromLipToNose; asFaceUpdateInfo 1; } select -cl; setFocus MayaWindow;//ensure execution of intField -cc cmd, if focus is still at intField xform -os -t 0 0 0 -ro 0 0 0 -s 1 1 1 upperLipA_R upperLipB_R lowerLipA_R lowerLipB_R Lip_R; if (`objExists lipFalloffArea`) delete lipFalloffArea; if (`objExists lipFalloffInsideMouthArea`) delete lipFalloffInsideMouthArea; createNode -n lipFalloffArea objectSet; sets -add FaceAreas lipFalloffArea; if (!`objExists lipFalloffAreaMax`) { createNode -n lipFalloffAreaMax objectSet; sets -add FaceBuildingSets lipFalloffAreaMax; } for ($a=0;$a<2;$a++) { if ($a==0) $innerOuter="Inner"; if ($a==1) $innerOuter="Outer"; $lipFalloff=`intField -q -v ("lipFalloff"+$innerOuter+"IntField")`; duplicate -n ("upperLip"+$innerOuter+"Curve_L") ("upperLip"+$innerOuter+"Curve"); duplicate -n ("lowerLip"+$innerOuter+"Curve_L") ("lowerLip"+$innerOuter+"Curve"); setAttr ("upperLip"+$innerOuter+"Curve_L.sx") -1; setAttr ("lowerLip"+$innerOuter+"Curve_L.sx") -1; eval ("select "+`asGetFaceFitSelection ("upperLip"+$innerOuter+"Curve")`); $tempString=`ls -sl`; // select `asobjSetCast "" $tempString LipLayer`; $upperVtxs=`ls -sl -fl`; eval ("select "+`asGetFaceFitSelection ("lowerLip"+$innerOuter+"Curve")`); $tempString=`ls -sl`; // select `asobjSetCast "" $tempString LipLayer`; $lowerVtxs=`ls -sl -fl`; //+left side if (`objExists ("upperLip"+$innerOuter+"CurveLeft")`) eval ("select "+`asGetFaceFitSelection ("upperLip"+$innerOuter+"CurveLeft")`); else eval ("select "+`asGetFaceFitSelection ("upperLip"+$innerOuter+"Curve_L")`); $tempString=`ls -sl`; // select `asobjSetCast "" $tempString LipLayer`; $upperVtxsL=`ls -sl -fl`; if (`objExists ("lowerLip"+$innerOuter+"CurveLeft")`) eval ("select "+`asGetFaceFitSelection ("lowerLip"+$innerOuter+"CurveLeft")`); else eval ("select "+`asGetFaceFitSelection ("lowerLip"+$innerOuter+"Curve_L")`); $tempString=`ls -sl`; // select `asobjSetCast "" $tempString LipLayer`; $lowerVtxsL=`ls -sl -fl`; select $upperVtxs $lowerVtxs $upperVtxsL $lowerVtxsL; for ($i=0;$i<$lipFalloff;$i++) { polySelectConstraint -pp 1 -t 0x0001; select -d lipArea; } select -d lipArea; if (size(`ls -sl`)) { sets -add lipFalloffArea `ls -sl`; sets -add lipFalloffAreaMax `ls -sl`; } if ($innerOuter=="Inner") $innerLipFalloffVtxs=`ls -sl -fl`; if ($innerOuter=="Outer") $outerLipFalloffVtxs=`ls -sl -fl`; delete ("upperLip"+$innerOuter+"Curve_L") ("lowerLip"+$innerOuter+"Curve_L"); } select lipFalloffArea; refresh; if ($test) return; eval ("select "+`asGetFaceFitSelection FaceFitLipOuterCurve`); $lipOuterCurveVtx=`ls -sl -fl`; //flood to head first, as rhis function might have ran previously with a larger falloff select lipFalloffAreaMax; catchQuiet (`skinPercent -tv $headJoint 1 $skinCluster`); //just hammer select lipFalloffArea; if (size(`ls -sl`)) weightHammerVerts; if (!$nonSymmetrical) copySkinWeights -ss $skinCluster -ds $skinCluster -mirrorMode YZ -mirrorInverse -surfaceAssociation closestPoint -influenceAssociation closestJoint; //just hammer inside select $lipFalloffInsideMouthArea; if (size(`ls -sl`)) weightHammerVerts; setKeyframe -t 0 -v 0 upperLipA_R.ty; setKeyframe -t 30 -v 1 upperLipA_R.ty; currentTime 30 ; select -cl; } global proc asFaceLipCorner () { int $numBlends; float $outerNumCv; if (!`objExists upperLipMainCurve`)//skip return; asFaceRemoveFitAnimationsFromOnFaceCtrls; refresh; setKeyframe -t 0 -v 0 upperLipB_R.ty; setKeyframe -t 30 -v 0.5 upperLipB_R.ty; setKeyframe -t 0 -v 0 lowerLipB_R.ty; setKeyframe -t 30 -v -0.5 lowerLipB_R.ty; currentTime 30; $outerNumCv=`getAttr upperLipOuterCurve.spans`; if ($outerNumCv<10) $numBlends=0; if ($outerNumCv>9) $numBlends=1; if ($outerNumCv>14) $numBlends=2; if ($outerNumCv>17) $numBlends=3; intField -e -v $numBlends lipCornerIntField; asFaceLipCornerUpdate; } global proc asFaceLipCornerUpdate () { int $numBlends=`intField -q -v lipCornerIntField`; float $currentTime=`currentTime -q`; string $geometry=`textField -q -tx asFaceFaceTextField`; string $skinCluster=`textField -q -tx asFaceSkinClusterTextField`; string $side,$upperLower; string $vtxs[]; if (!`objExists upperLipMainCurve`)//skip return; //keep preLipCorner weights, so we can revert if ($currentTime!=30) currentTime 0; if (`objExists PreLipCornerLayer`) { select PreLipCornerLayer $geometry; copySkinWeights -noMirror -surfaceAssociation closestPoint -influenceAssociation name; } else { duplicate -n PreLipCornerLayer templateLayer; select `listConnections -s 1 -d 0 -type joint ($skinCluster+".matrix")`; select -add PreLipCornerLayer; $tempString=`newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"`; rename $tempString[0] PreLipCornerLayerSC; select $geometry PreLipCornerLayer; copySkinWeights -noMirror -surfaceAssociation closestPoint -influenceAssociation name; } if ($currentTime!=30) currentTime $currentTime; //towards lipCnr blend weights for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; $blendNum=0; for ($i=99;$i>0;$i--) { if (!`objExists ($upperLower+"LipJoint"+$i+$side)`) continue; /* select $geometry; skinCluster -e -selectInfluenceVerts ($upperLower+"LipJoint"+$i+$side); select -d $geometry; $tempString=`ls -sl -fl`; */ $vtxs=`asInfluenceVerts ($upperLower+"LipJoint"+$i+$side) $skinCluster 1.0`; $weight=(1-((1.0/($numBlends+1))*($blendNum+1))); if (size($vtxs)) { catchQuiet (`skinPercent -tv ("LipJoint"+$side) 0 $skinCluster $vtxs`); if ($blendNum<$numBlends) catchQuiet (`skinPercent -tv ("LipJoint"+$side) $weight $skinCluster $vtxs`); } $blendNum++; } } } select lipFalloffArea; if (size(`ls -sl`)) weightHammerVerts; select -cl; } global proc asFaceSmileLine () { float $posA[],$posB[]; float $dist; int $nonSymmetrical=`checkBox -q -v asFaceNonSymCheckBox`; string $geometry=`textField -q -tx asFaceFaceTextField`; string $skinCluster=`textField -q -tx asFaceSkinClusterTextField`; string $headJoint=`textField -q -tx asFaceHeadJointTextField`; string $side,$leftSuffix,$noseCnrVtx; string $tempString[],$tempString2[],$SmileLineCurveVtxs[]; if (!`objExists upperLipMainCurve`)//skip return; //create LayerMesh if (!`getAttr -l ($geometry+".v")`) setAttr ($geometry+".v") 0; $tempString=`listRelatives -c DeformationLayers`; for ($i=0;$i-2;$b=$b-2) { if ($b==1) {$side="_R";$leftSuffix="";} else {$side="_L";$leftSuffix="Left";} eval ("select "+`asGetFaceFitSelection ("SmileLineCurve"+$leftSuffix)`); $SmileLineCurveVtxs=`ls -sl -fl`; eval ("select "+`asGetFaceFitSelection ("NoseCorner"+$leftSuffix)`); $tempString=`ls -sl -fl`; $noseCnrVtx=$tempString[0]; createNode -n ("SmileLine"+$leftSuffix) transform; pointConstraint ("SmileBulge"+$side) ("FrownBulge"+$side) ("Lip"+$side) ("SmileLine"+$leftSuffix); setAttr ("SmileLine"+$leftSuffix+"_pointConstraint1.Lip"+$side+"W2") 3;//icon pos $posA=`xform -q -ws -t ("SmileLine"+$leftSuffix)`; setAttr ("SmileLine"+$leftSuffix+"_pointConstraint1.Lip"+$side+"W2") 30;//joint pos $posB=`xform -q -ws -t ("SmileLine"+$leftSuffix)`; delete ("SmileLine"+$leftSuffix+"_pointConstraint1"); delete `geometryConstraint $geometry ("SmileLine"+$leftSuffix)`; SoftModLayerWeight ("SmileLine"+$leftSuffix) SmileLine $b $side 0 3; skinCluster -e -dr 4 -lw false -wt 0 -ai ("SmileLineJoint"+$side) SmileLineSC; move -r ($posA[0]-$posB[0]) ($posA[1]-$posB[1]) ($posA[2]-$posB[2]) ("SmileLine"+$side+".cv[0:99]"); asFacePlaceCtrlByProjection ("SmileLine"+$side); $posA=`xform -q -ws -t ("SmileLine"+$leftSuffix)`; $posB=`xform -q -ws -t ("SmileLineCurve"+$leftSuffix+".cv[0]")`; $falloffRadius=`mag<<$posA[0]-$posB[0],$posA[1]-$posB[1],$posA[2]-$posB[2]>>`; asSkinWeightBySoftMod ("SmileLineJoint"+$side) SmileLineLayer SmileLineSC $falloffRadius 1; if (!$nonSymmetrical && $side=="_L") { copySkinWeights -ss $skinCluster -ds $skinCluster -mirrorMode YZ -mirrorInverse -surfaceAssociation closestPoint -influenceAssociation closestJoint; break; } //copy weights inside smileLine skinCluster -e -selectInfluenceVerts ("SmileBulgeJoint"+$side) $skinCluster; $tempString=`ls -sl`; skinCluster -e -selectInfluenceVerts ("FrownBulgeJoint"+$side) $skinCluster; $tempString2=`ls -sl`; $tempString=`stringArrayCatenate $tempString $tempString2`; skinCluster -e -selectInfluenceVerts ("SmileLineJoint"+$side) SmileLineSC; $tempString2=`ls -sl`; select `asobjSetCast "" $tempString2 $geometry`; select -d $tempString lipArea; $tempString=`ls -sl`; select `asobjSetCast "" $tempString SmileLineLayer`; select -add $tempString; // copySkinWeights -noMirror -surfaceAssociation closestPoint -influenceAssociation closestJoint; $tempString=`ls -sl -fl`; refresh; dgdirty -a; for ($i=0;$i-2;$b=$b-2) { if ($b==1) {$side="_R";$leftSuffix="";} else {$side="_L";$leftSuffix="Left";} eval ("select "+`asGetFaceFitSelection ("FaceFitLipOuterCurve"+$leftSuffix)`); polySelectConstraint -pp 1 -t 0x0001; select -d lipArea; if (size(`ls -sl`)) weightHammerVerts; } */ delete SmileLine SmileLineLeft; select -cl; } global proc asFaceSmileBulge () { global string $gMove; setToolTo $gMove; int $modifier=`getModifiers`; int $preGrowNum,$postGrowNum,$numGrowToBorder; int $autoKeyState=`autoKeyframe -q -state`; int $upperEyeLidOuterNumCVs=`getAttr upperEyeLidOuterCurve.spans`+1; float $falloffRadius,$smileBulgeVtxValue,$value; float $faceFitScale=`getAttr FaceFitSkeleton.sy`; float $pos[],$posA[],$posB[],$values[]; string $side,$leftSuffix,$smileBulgeVtx,$smileFrown,$smileBulgeLayerSmileBulgeVtx; string $geometry=`textField -q -tx asFaceFaceTextField`; string $headJoint=`textField -q -tx asFaceHeadJointTextField`; string $skinCluster=`textField -q -tx asFaceSkinClusterTextField`; string $tempString[],$tempString2[],$infs[],$copyToVtx[],$smileBulgeBorderCurveVtxs[],$smileBulgeBorderCurveEdges[]; string $xyz[]={"x","y","z"}; if (!`objExists upperLipMainCurve`)//skip return; //create LayerMesh if (!`getAttr -l ($geometry+".v")`) setAttr ($geometry+".v") 0; $tempString=`listRelatives -c DeformationLayers`; for ($i=0;$i-2;$b=$b-2) { if ($b==1) {$side="_R";$leftSuffix="";} else {$side="_L";$leftSuffix="Left";} SoftModLayerWeight ("SmileBulge"+$leftSuffix) SmileBulge $b $side 0 1; skinCluster -e -dr 4 -lw false -wt 0 -ai ("SmileBulgeJoint"+$side) SmileBulgeSC; sets -em -n leastEdgesPathSet; eval ("select "+`asGetFaceFitSelection ("lowerEyeLidMainCurve"+$leftSuffix)`); ConvertSelectionToContainedEdges; sets -add leastEdgesPathSet `ls -sl`; asAddLeastEdgesPathToSet $geometry ("NoseCorner"+$leftSuffix) ("lowerEyeLidMainCurve"+$leftSuffix+".cv[0]"); asAddLeastEdgesPathToSet $geometry ("lowerEyeLidMainCurve"+$leftSuffix+".cv[99]") ("JawPivot"+$leftSuffix); asAddLeastEdgesPathToSet $geometry ("JawPivot"+$leftSuffix) ("JawCorner"+$leftSuffix); asAddLeastEdgesPathToSet $geometry ("JawCorner"+$leftSuffix) ("FrownBulge"+$leftSuffix); asAddLeastEdgesPathToSet $geometry ("FrownBulge"+$leftSuffix) ("upperLipOuterCurve"+$leftSuffix+".cv[99]"); asAddLeastEdgesPathToSet $geometry ("upperLipOuterCurve"+$leftSuffix+".cv[99]") ("NoseCorner"+$leftSuffix); select leastEdgesPathSet; $tempString=`ls -sl -fl`; for ($i=0;$i>`*2; asSkinWeightBySoftMod ("FrownBulgeJoint"+$side) SmileBulgeLayer SmileBulgeSC $falloffRadius 1; } //lip not affected select `asobjSetCast lipArea {} SmileBulgeLayer`; skinPercent -tv FaceJoint_M 1 SmileBulgeSC; //SmileLineCurve - Remove weiging inside if (`objExists SmileLineCurve`) { for ($b=1;$b>-2;$b=$b-2) { if ($b==1) {$side="_R";$leftSuffix="";} else {$side="_L";$leftSuffix="Left";} skinCluster -e -selectInfluenceVerts ("FrownBulgeJoint"+$side); select -add ("cheekArea"+$leftSuffix); asFaceDeselInsideSmileLineCurve SmileBulgeLayer $leftSuffix; $tempString2=`ls -sl`; eval ("select "+`asGetFaceFitSelection ("SmileLineCurve"+$leftSuffix)`); $tempString=`ls -sl`; select `asobjSetCast "" $tempString SmileBulgeLayer`; select -add $tempString2; $tempString=`ls -sl`; $copyToVtx=`stringArrayCatenate $copyToVtx $tempString`; } select $copyToVtx; asInvertSelection; skinPercent -tv FaceJoint_M 1 SmileBulgeSC; } //lock`n`copy $tempString=`listRelatives -type joint -ad FaceJoint_M`; $tempString[size($tempString)]="Face_M"; for ($i=0;$i-2;$a=$a-2) { if ($a==1) $smileFrown="Smile"; else $smileFrown="Frown"; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) {$side="_R";$leftSuffix="";} else {$side="_L";$leftSuffix="Left";} select SmileBulgeLayer; skinCluster -e -selectInfluenceVerts ($smileFrown+"BulgeJoint"+$side); $tempString=`ls -sl -fl`; for ($i=0;$i-2;$b=$b-2) { if ($b==1) {$side="_R";$leftSuffix="";} else {$side="_L";$leftSuffix="Left";} $posA=`xform -q -ws -t ("CheekRaiser"+$leftSuffix)`; $posB=`xform -q -ws -t ("upperEyeLidOuterCurve"+$leftSuffix+".cv[0]")`; $falloffRadius=`mag<<$posA[0]-$posB[0],$posA[1]-$posB[1],$posA[2]-$posB[2]>>`; SoftModLayerWeight ("CheekRaiser"+$leftSuffix) CheekRaiser $b $side $falloffRadius 1; } rename FaceControlOrient FaceControlOrientEye; rename FaceControlOrientTemp FaceControlOrient; } //ZygomaticusMajor if (!`objExists FaceMuscles`) createNode -n FaceMuscles -p FaceBuildInProgress transform; if (!`objExists FaceMusclesLayer`) createDisplayLayer -name FaceMusclesLayer; createNode -n ZygomaticusMajor -p FaceMuscles transform; $tempString=`circle -c 0 0 0 -nr 0 0 1 -sw 360 -r ($scale/25.0) -d 3 -ut 0 -tol 0.000393701 -s 8 -ch 0`; rename $tempString[0] ZygomaticusMajor_curve1; setAttr ZygomaticusMajor_curve1.v 0; $posA=`xform -q -ws -t JawPivot`; $posB=`xform -q -ws -t upperEyeLidOuterCurve.cv[99]`; spaceLocator -n ZygomaticusMajorPosition1; parent ZygomaticusMajorPosition1 ZygomaticusMajor; setAttr ZygomaticusMajorPosition1.v 0; setAttr ZygomaticusMajorPosition1.overrideEnabled 1; setAttr ZygomaticusMajorPosition1.overrideColor 17; setAttr ZygomaticusMajorPosition1Shape.localScale -type float3 ($scale/15.0) ($scale/15.0) ($scale/15.0); //instead of half-way btw JawPivot and eyeCurve, slide towards JawPivot, until 45 degrees createNode -n tempXform -p Lip_R transform; createNode -n tempXform2 transform; xform -ws -t $posB[0] $posB[1] $posB[2] tempXform2; pointConstraint tempXform2 JawPivot tempXform; geometryConstraint $geometry tempXform; setAttr "tempXform.displayLocalAxis" 1; for ($i=0;$i<101;$i++) { setAttr tempXform_pointConstraint1.tempXform2W0 (1-($i/100.0)); setAttr tempXform_pointConstraint1.JawPivotW1 ($i/100.0); refresh; if (`getAttr tempXform.tx`>`getAttr tempXform.ty`) break; } $posB=`xform -q -ws -t tempXform`; delete tempXform tempXform2; xform -ws -t $posB[0] $posB[1] $posB[2] ZygomaticusMajorPosition1; //delete `geometryConstraint $geometry ZygomaticusMajorPosition1`; parent -r ZygomaticusMajor_curve1 ZygomaticusMajorPosition1; delete `aimConstraint -offset 0 0 0 -weight 1 -aimVector 0 0 1 -upVector 0 0 1 -worldUpType "objectrotation" -worldUpObject Lip_R Lip_R ZygomaticusMajorPosition1`; duplicate -n ZygomaticusMajorPosition2 ZygomaticusMajorPosition1; rename ZygomaticusMajorPosition2|ZygomaticusMajor_curve1 ZygomaticusMajor_curve2; duplicate -n ZygomaticusMajorPosition3 ZygomaticusMajorPosition1; rename ZygomaticusMajorPosition3|ZygomaticusMajor_curve1 ZygomaticusMajor_curve3; setAttr ZygomaticusMajor_curve1.scaleX 0; setAttr ZygomaticusMajor_curve2.scaleX 0.5; setAttr ZygomaticusMajor_curve3.scaleX 0; $posA=`xform -q -ws -t ZygomaticusMajorPosition2`; $posB=`xform -q -ws -t Lip_R`; xform -ws -t (($posA[0]+$posB[0])/2.0) (($posA[1]+$posB[1])/2.0) (($posA[2]+$posB[2])/2.0) ZygomaticusMajorPosition2; xform -ws -t $posB[0] $posB[1] $posB[2] ZygomaticusMajorPosition3; loft -n ZygomaticusMajor_loft -ch 1 -u 1 -c 0 -ar 0 -d 3 -ss 1 -rn 0 -po 0 -rsn true "ZygomaticusMajor_curve1" "ZygomaticusMajor_curve2" "ZygomaticusMajor_curve3"; sets -e -forceElement asFaceRedSG ZygomaticusMajor_loft; parent ZygomaticusMajor_loft ZygomaticusMajor; createNode -n ZygomaticusMajorScale -p ZygomaticusMajorPosition1 transform; setKeyframe -t 0 -v 1 ZygomaticusMajorScale.s; setKeyframe -t 30 -v 0.75 ZygomaticusMajorScale.s; setKeyframe -t 0 -v 1 ZygomaticusMajorPosition2.s; setKeyframe -t 30 -v 1.3 ZygomaticusMajorPosition2.s; currentTime 0; parentConstraint -mo ZygomaticusMajorScale ZygomaticusMajorPosition3; parentConstraint ZygomaticusMajorPosition1 ZygomaticusMajorPosition3 ZygomaticusMajorPosition2; parentConstraint -mo ZygomaticusMajorScale Lip_R; //for showing ZygomaticusMajor catchQuiet (`setAttr ($geometry+".overrideEnabled") 1`); catchQuiet (`setAttr ($geometry+".overrideShading") 0`); for ($i=0;$i<30;$i=$i+1) { currentTime $i; refresh; } catchQuiet (`setAttr ($geometry+".overrideEnabled") 0`); catchQuiet (`setAttr ($geometry+".overrideShading") 1`); setAttr FaceMusclesLayer.v 0; currentTime 0; if (`objExists SmileLineCurve`) asFaceSmileLine; //FitLoc placeholder for Lip (stores falloff attrs) if (!`objExists Lip`) { $posA=`xform -q -ws -t Lip_R`; $posB=`xform -q -ws -t SmileBulge`; $falloffRadius=`mag<<$posA[0]-$posB[0],$posA[1]-$posB[1],$posA[2]-$posB[2]>>`; //note this falloffRadius will be larger then the default, causing it to `pop` bigger. //it can be odd, but likly more correct createNode -n Lip -p LipSetup transform; asAlign Lip Lip_R 1 0 0 0; addAttr -k 1 -ln falloffRadius -at double -dv $falloffRadius Lip; if ($nonSymmetrical) { duplicate -n LipLeft Lip; asAlign LipLeft Lip_L 1 0 0 0; } } asFaceHideControllers 1; setAttr LipRegionOffset_M.v 1; setAttr LipOffset_R.v 1; setAttr LipOffset_L.v 1; setAttr SmileBulgeOffset_R.v 1; setAttr SmileBulgeOffset_L.v 1; setAttr CheekRaiserOffset_R.v 1; setAttr CheekRaiserOffset_L.v 1; if (`objExists SmileLineOffset_R`) setAttr SmileLineOffset_R.v 1; if (`objExists SmileLineOffset_L`) setAttr SmileLineOffset_L.v 1; setAttr ctrlBoxMouthCorner_R.v 1; setAttr ctrlBoxMouthCorner_L.v 1; asFaceMirrorConnectCtrls 1; currentTime 30; $posC=`getAttr Lip_R.t`; delete Lip_R_parentConstraint1; currentTime 0; //fit-anim asFaceFitAnim ctrlMouthCorner_R.tx 1; asFaceFitAnim ctrlMouthCorner_R.ty 1; asFaceFitAnim ctrlMouthCorner_L.tx 1; asFaceFitAnim ctrlMouthCorner_L.ty 1; asFaceFitAnim Lip_R 0; asFaceFitAnim Lip_R.tx $posC[0]; asFaceFitAnim Lip_R.ty $posC[1]; asFaceFitAnim Lip_R.tz $posC[2]; //asFaceFitAnim Lip_R.rz 25; asFaceFitAnim CheekRaiser_R 0; asFaceFitAnim CheekRaiser_R.ty 0.1; if (`objExists SmileLineCurve`) { asFaceFitAnim SmileLine_R 0; asFaceFitAnim SmileLine_R.tx $posC[0]; asFaceFitAnim SmileLine_R.ty $posC[1]; asFaceFitAnim SmileLine_R.tz $posC[2]; // asFaceFitAnim SmileLine_R.rz 25; } asFaceFitAnim SmileBulge_R 0; asFaceFitAnim SmileBulge_R.tx ($posC[0]*0.8); asFaceFitAnim SmileBulge_R.ty ($posC[1]*0.8); asFaceFitAnim SmileBulge_R.tz ($posC[0]*0.1); if (`objExists SmileLineCurve`) { //guess other SmileBulge values, if we have SmileLine (less far, and more bulge) asFaceFitAnim SmileBulge_R.tx ($posC[0]*0.5); asFaceFitAnim SmileBulge_R.ty ($posC[1]*0.5); asFaceFitAnim SmileBulge_R.tz ($posC[0]*0.5); } //asFaceFitAnim SmileBulge_R.sx 1.2; //asFaceFitAnim SmileBulge_R.sy 1.2; //asFaceFitAnim SmileBulge_R.sz 1.2; playbackOptions -min 0 -max 30 -ast 0 -aet 30; currentTime 30; select -cl; } global proc asFaceSmilePullFinish () { string $tempString[]; if (!`objExists upperLipMainCurve` || !`objExists upperEyeLidOuterCurve`)//skip return; if (`attributeExists SmilePullFinish FaceBuildInProgress`) return; addAttr -k 0 -ln SmilePullFinish -at bool -dv true FaceBuildInProgress; if (`objExists Lip`) delete Lip;//Remove FitLoc placeholder if (`objExists FaceMuscles`) delete FaceMuscles; if (`objExists FaceMusclesLayer`) delete FaceMusclesLayer; if (`objExists SmileMuscles`) delete SmileMuscles; asFaceMirrorConnectCtrls 0; //remove fitAnim from driver $tempString=`listConnections -s 1 -d 0 -type animCurve ctrlMouthCorner_R ctrlMouthCorner_L`; if (size($tempString)) delete $tempString; setAttr ctrlMouthCorner_R.tx 0; setAttr ctrlMouthCorner_R.ty 0; setAttr ctrlMouthCorner_L.tx 0; setAttr ctrlMouthCorner_L.ty 0; $tempString=`listConnections -s 1 -d 0 -type animCurve ctrlCheek_R.ty ctrlCheek_L.ty`; if (size($tempString)) delete $tempString; setAttr ctrlCheek_R.ty 0; setAttr ctrlCheek_L.ty 0; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; //create blendedAttr for mouthCorner X&Y (smile) setAttr ("ctrlMouthCorner"+$side+".tx") 1; setAttr ("ctrlMouthCorner"+$side+".ty") 1; asCreateBlendedAttribute {("ctrlMouthCorner"+$side+".tx"),("ctrlMouthCorner"+$side+".ty")}; if (`objExists BlendedCorrectiveDriver`) delete BlendedCorrectiveDriver; asEnsureOutputBlendWeighted ("ctrlMouthCorner"+$side+".txPos_tyPos"); //re-wire blendedAttr to use the bw, so it`s also affected by external drivers connectAttr -f ("bwctrlMouthCorner"+$side+"_translateX.output") ("ctrlMouthCorner"+$side+"txPos_tyPosMPD.input1X"); connectAttr -f ("bwctrlMouthCorner"+$side+"_translateY.output") ("ctrlMouthCorner"+$side+"txPos_tyPosMPD.input1Y"); setAttr ("ctrlMouthCorner"+$side+".tx") 0; setAttr ("ctrlMouthCorner"+$side+".ty") 0; //create blendedAttr for mouthCorner X&Y (frown) setAttr ("ctrlMouthCorner"+$side+".tx") 1; setAttr ("ctrlMouthCorner"+$side+".ty") -1; asCreateBlendedAttribute {("ctrlMouthCorner"+$side+".tx"),("ctrlMouthCorner"+$side+".ty")}; if (`objExists BlendedCorrectiveDriver`) delete BlendedCorrectiveDriver; asEnsureOutputBlendWeighted ("ctrlMouthCorner"+$side+".txPos_tyNeg"); //re-wire blendedAttr to use the bw, so it`s also affected by external drivers connectAttr -f ("bwctrlMouthCorner"+$side+"_translateX.output") ("ctrlMouthCorner"+$side+"txPos_tyNegMPD.input1X"); connectAttr -f ("bwctrlMouthCorner"+$side+"_translateY.output") ("ctrlMouthCorner"+$side+"txPos_tyNegMPD.input1Y"); setAttr ("ctrlMouthCorner"+$side+".tx") 0; setAttr ("ctrlMouthCorner"+$side+".ty") 0; } //only translate channels of Lip, driven by tx / ty, rotation driven by txPos_tyPos currentTime 0; asFaceStoreAsDsSdk {"Lip","SmileLine"} "_RL" "ctrlMouthCorner" "_RL" "tx" 1; asFaceStoreAsDsSdk {"Lip","SmileLine"} "_RL" "ctrlMouthCorner" "_RL" "ty" 1; asFaceStoreAsDsSdk {"SmileBulge","CheekRaiser"} "_RL" "ctrlMouthCorner" "_RL" "txPos_tyPos" 1; asFaceStoreAsDsSdk {"Lip","SmileLine"} "_RL" "ctrlMouth" "_M" "tx" 1; asFaceStoreAsDsSdk {"CheekRaiser"} "_RL" "ctrlCheek" "_RL" "ty" 1; asFaceRemoveFitAnimationsFromOnFaceCtrls; //asFaceFrownPull; //asFaceFrownPullFinish; //asFaceNarrowPull; //asFaceNarrowPullFinish; //asFaceSmilePullController; asFaceHideControllers 1; setAttr ctrlBoxMouthCorner_R.v 1; setAttr ctrlBoxMouthCorner_L.v 1; } global proc asFaceFrownPull () { global string $gMove; setToolTo $gMove; float $falloffRadius,$xDist,$yDist,$xyDist,$minXyDist; float $pos[],$rot[],$sca[],$posA[],$posB[]; string $side,$leftSuffix,$chosenVert; string $geometry=`textField -q -tx asFaceFaceTextField`; string $headJoint=`textField -q -tx asFaceHeadJointTextField`; string $tempString[]; string $smileCtrls[]={"Lip","Smile","SmileBulge","CheekRaiser"}; if (!`objExists upperLipMainCurve` || !`objExists upperEyeLidOuterCurve`)//skip return; asFaceSmilePullFinish; if (!`objExists upperLipMainCurve`)//skip return; if (!`objExists SmileBulge`)//skip return; setAttr FrownBulgeOffset_R.v 1; setAttr FrownBulgeOffset_L.v 1; setAttr ctrlBoxMouthCorner_R.v 1; setAttr ctrlBoxMouthCorner_L.v 1; asFaceMirrorConnectCtrls 1; //fit-anim asFaceFitAnim ctrlMouthCorner_R.tx 1; asFaceFitAnim ctrlMouthCorner_R.ty -1; asFaceFitAnim ctrlMouthCorner_L.tx 1; asFaceFitAnim ctrlMouthCorner_L.ty -1; asFaceFitAnim FrownBulge_R 0; asFaceFitAnim FrownBulge_R.tx 0.5; asFaceFitAnim FrownBulge_R.ty -0.5; asFaceFitAnim FrownBulge_R.sx 1.2; asFaceFitAnim FrownBulge_R.sy 1.2; asFaceFitAnim FrownBulge_R.sz 1.2; /* if (`objExists SmileLineCurve`) { $pos=`getAttr SmileLineValues_R.t`; $rot=`getAttr SmileLineValues_R.r`; $sca=`getAttr SmileLineValues_R.s`; delete SmileLineValues_R; asFaceFitAnim SmileLine_R 0; asFaceFitAnim SmileLine_R.tx $pos[0]; asFaceFitAnim SmileLine_R.ty ($pos[1]*-1); asFaceFitAnim SmileLine_R.tz $pos[2]; asFaceFitAnim SmileLine_R.rx $rot[0]; asFaceFitAnim SmileLine_R.ry $rot[1]; asFaceFitAnim SmileLine_R.rz ($rot[2]*-1); asFaceFitAnim SmileLine_R.sx $sca[0]; asFaceFitAnim SmileLine_R.sy $sca[1]; asFaceFitAnim SmileLine_R.sz $sca[2]; } */ playbackOptions -min 0 -max 30 -ast 0 -aet 30; currentTime 30; select -cl; } global proc asFaceFrownPullFinish () { if (!`objExists upperLipMainCurve` || !`objExists upperEyeLidOuterCurve`)//skip return; if (`attributeExists FrownPullFinish FaceBuildInProgress`) return; addAttr -k 0 -ln FrownPullFinish -at bool -dv true FaceBuildInProgress; asFaceMirrorConnectCtrls 0; //remove fitAnim from driver $tempString=`listConnections -s 1 -d 0 -type animCurve ctrlMouthCorner_R ctrlMouthCorner_L`; if (size($tempString)) delete $tempString; setAttr ctrlMouthCorner_R.tx 0; setAttr ctrlMouthCorner_R.ty 0; setAttr ctrlMouthCorner_L.tx 0; setAttr ctrlMouthCorner_L.ty 0; asFaceStoreAsDsSdk {"FrownBulge"} "_RL" "ctrlMouthCorner" "_RL" "txPos_tyNeg" 1; asFaceRemoveFitAnimationsFromOnFaceCtrls; asFaceHideControllers 1; setAttr ctrlBoxMouthCorner_R.v 1; setAttr ctrlBoxMouthCorner_L.v 1; } global proc asFaceNarrowPull () { float $reCalcFactor,$dist,$factor; float $ctrlScale=`getAttr OnFacecontrols.sx`; float $posA[],$posB[],$posA2[],$posB2[]; string $upperLower,$side; string $tempString[],$tempString2[],$tempString3[]; string $trs[]={"t","r","s"}; string $xyz[]={"x","y","z"}; string $AB[]={"A","B"}; if (!`objExists upperLipMainCurve` || !`objExists upperEyeLidOuterCurve`)//skip return; asFaceFrownPullFinish; if (!`objExists upperLipMainCurve`)//skip return; //temporary prevent Negative-post-infinity from wide $tempString={"SDKLip_R","SDKSmileLine_R"}; for ($i=0;$i-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; for ($a=0;$a-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; asCreateFaceController "SmilePull" $side 2; setAttr ("SmilePull"+$side+"Shape.overrideColor") 17; $pos=`xform -q -ws -t ("Lip"+$side)`; scale -r -p 0 0 0 1.8 1.8 1.8 ("SmilePull"+$side+".cv[0:99]"); xform -ws -t $pos[0] $pos[1] $pos[2] ("SmilePullOffset"+$side); parent ("SmilePullOffset"+$side) ("SideReverse"+$side); setAttr ("SmilePullOffset"+$side+".s") -type float3 1 1 1; asFaceHalfMoonCurve ("SmilePull"+$side) 0; setAttr ("SmilePullOffset"+$side+".ry") $rotY; // rotate -r -os 0 (($rotY*-1)/2.0) 0 ("SmilePullOffset"+$side); asLockAttr ("SmilePull"+$side) 1 1 1 1; setAttr -k 1 -l 0 ("SmilePull"+$side+".tx"); setAttr -k 1 -l 0 ("SmilePull"+$side+".ty"); asFacePlaceCtrlByProjection ("SmilePull"+$side); //find driverValue, how far SmilePull needs travel, to equivalent ctrlMouthCorner=1 if ($side=="_R") { createNode -n tempTransform1 -p SmilePull_R transform; pointConstraint Lip_R tempTransform1; setAttr ctrlMouthCorner_R.tx 1; $tx=`getAttr tempTransform1.tx`; setAttr ctrlMouthCorner_R.tx 0; setAttr ctrlMouthCorner_R.ty 1; $ty=`getAttr tempTransform1.ty`; setAttr ctrlMouthCorner_R.ty 0; delete tempTransform1; } asEnsureOutputBlendWeighted ("SmilePull"+$side+".tx"); asEnsureOutputBlendWeighted ("SmilePull"+$side+".ty"); asDsSdk ("SmilePull"+$side+".tx") ("bwctrlMouthCorner"+$side+"_translateX.input") $tx 1; asDsSdk ("SmilePull"+$side+".ty") ("bwctrlMouthCorner"+$side+"_translateY.input") $ty 1; } if ($autoKeyState) autoKeyframe -state 1; } global proc asFaceCheek () { string $geometry=`textField -q -tx asFaceFaceTextField`; string $headJoint=`textField -q -tx asFaceHeadJointTextField`; string $skinCluster=`textField -q -tx asFaceSkinClusterTextField`; int $vtxNrs[]; float $falloffRadius,$distToEyeCurve,$weight,$value,$distToSmileBulge,$distToFrownBulge; float $scale=`getAttr FaceFitSkeleton.faceScale`; float $posA[],$posB[],$posC[],$posD[],$weights[]; string $side,$leftSuffix; string $xyz[]={"x","y","z"}; string $infJoints[],$tempString[],$copyToVtx[]; asFaceNarrowPullFinish; if (!`objExists Cheek`)//skip return; if (`objExists LipValues_R`) delete LipValues_R; //SoftModLayerWeight Controller asFaceHideControllers 1; setAttr ctrlBoxCheek_R.v 1; setAttr ctrlBoxCheek_L.v 1; setAttr LipRegionOffset_M.v 1; setAttr LipOffset_R.v 1; setAttr LipOffset_L.v 1; if (`objExists SmileLineCurve`) { setAttr SmileLineOffset_R.v 1; setAttr SmileLineOffset_L.v 1; if (`objExists SmileLineValues_R`) delete SmileLineValues_R; } asFaceLockWeights 1; setAttr ($headJoint+".lockInfluenceWeights") 0; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) {$side="_R";$leftSuffix="";} else {$side="_L";$leftSuffix="Left";} $posA=`xform -q -ws -t ("Cheek"+$leftSuffix)`; $posB=`xform -q -ws -t ("upperLipOuterCurve"+$leftSuffix+".cv[999]")`; $falloffRadius=`mag<<$posA[0]-$posB[0],$posA[1]-$posB[1],$posA[2]-$posB[2]>>`; SoftModLayerWeight ("Cheek"+$leftSuffix) Cheek $b $side $falloffRadius 2; } //Cheek pulls Smile/Frown Bulge for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; asFaceAddConstrained ("SmileBulge"+$side) ("Cheek"+$side) ("lowerFaceStatic"+$side) 5.0; // asFaceAddConstrained ("FrownBulge"+$side) ("Cheek"+$side) ("FaceStatic"+$side) 5.0; asFaceAddConstrained ("FrownBulge"+$side) ("Cheek"+$side) ("JawFollow"+$side) 5.0; // if (`objExists ("SmileLine"+$side)`) SmileLine already follows Lip_R, so not needed to follow cheek // asFaceAddConstrained ("SmileLine"+$side) ("Cheek"+$side) ("JawFollow"+$side) 2.5; } asFaceMirrorConnectCtrls 1; //fit-anim asFaceFitAnim ctrlCheek_R.tx 1; asFaceFitAnim ctrlCheek_L.tx 1; //asFaceFitAnim Cheek_R.tx 0.75; asFaceFitAnim Cheek_R 0; asFaceFitAnim Cheek_R.tz 1.0; asFaceFitAnim Cheek_R.sx 1.2; asFaceFitAnim Cheek_R.sy 1.2; asFaceFitAnim Cheek_R.sz 1.2; asFaceFitAnim Lip_R 0; asFaceFitAnim Lip_R.tz 0.4; if (`objExists SmileLineCurve`) { asFaceFitAnim SmileLine_R 0; asFaceFitAnim SmileLine_R.tz 0.45; } playbackOptions -min 0 -max 30 -ast 0 -aet 30; currentTime 30; select -cl; } global proc asFaceCheekFinish () { float $pos[]; if (!`objExists Cheek`)//skip return; if (`attributeExists CheekFinish FaceBuildInProgress`) return; addAttr -k 0 -ln CheekFinish -at bool -dv true FaceBuildInProgress; asFaceMirrorConnectCtrls 0; //remove fitAnim from driver $tempString=`listConnections -s 1 -d 0 -type animCurve ctrlCheek_R ctrlCheek_L`; if (size($tempString)) delete $tempString; setAttr ctrlCheek_R.tx 0; setAttr ctrlCheek_L.tx 0; //asFaceStoreAsDsSdk {"Cheek"} "_RL" "ctrlCheek" "_RL" "tx" 1; asFaceStoreAsDsSdk {"Cheek","Lip","SmileLine"} "_RL" "ctrlCheek" "_RL" "tx" 1; asFaceRemoveFitAnimationsFromOnFaceCtrls; /* //also add a sdk for ctrlMouthCorner to push cheek //removed, as this complicated editing the SD delete CheekValues_R; setAttr ctrlMouthCorner_R.tx 1; //setAttr ctrlMouthCorner_R.ty 1; $pos=`getAttr SmileBulgeValues_R.t`; setKeyframe -t 0 -v 0 Cheek_R.tx; setKeyframe -t 30 -v 0.3 Cheek_R.tx; asFaceStoreAsDsSdk {"Cheek"} "_RL" "ctrlMouthCorner" "_RL" "tx" 1; setAttr ctrlMouthCorner_R.tx 0; setAttr ctrlMouthCorner_R.ty 0; asFaceRemoveFitAnimationsFromOnFaceCtrls; */ asFaceHideControllers 1; setAttr ctrlBoxCheek_R.v 1; setAttr ctrlBoxCheek_L.v 1; } global proc asFaceCheekRaiser () { float $falloffRadius,$cheekRaiserTy,$lowerLidTy; float $posA[],$posB[]; string $headJoint=`textField -q -tx asFaceHeadJointTextField`; string $skinCluster=`textField -q -tx asFaceSkinClusterTextField`; string $cheekRaiservtx,$side,$leftSuffix; string $tempString[],$lineVtxs[]; asFaceCheekFinish; if (!`objExists CheekRaiser`)//skip return; //calculate $cheekRaiserTy to make scale appear to origin from lowerEyeLidMainCurve createNode -n tempXform -p CheekRaiser_R transform; delete `geometryConstraint lowerEyeLidMainCurve tempXform`; $cheekRaiserTy=`getAttr tempXform.ty`/2.0; delete tempXform; //calculate $lowerLidTy to `half-close` delete lowerLidValues_R; createNode -n tempXform -p lowerLid_R transform; pointConstraint innerLid_R outerLid_R tempXform; $lowerLidTy=`getAttr tempXform.ty`/2.0; delete tempXform; asFaceHideControllers 1; setAttr ctrlBoxCheek_R.v 1; setAttr ctrlBoxCheek_L.v 1; setAttr CheekRaiserOffset_R.v 1; setAttr CheekRaiserOffset_L.v 1; setAttr lowerLidOffset_R.v 1; setAttr lowerLidOffset_L.v 1; setAttr EyeRegionOffset_L.v 1; setAttr EyeRegionOffset_R.v 1; asFaceMirrorConnectCtrls 1; //fit-anim asFaceFitAnim ctrlCheek_R.ty 1; asFaceFitAnim ctrlCheek_L.ty 1; delete CheekRaiserValues_R; asFaceFitAnim CheekRaiser_R 0; asFaceFitAnim CheekRaiser_R.ty $cheekRaiserTy; asFaceFitAnim CheekRaiser_R.tz 0.1; asFaceFitAnim CheekRaiser_R.sy 0.75; asFaceFitAnim lowerLid_R.ty $lowerLidTy; playbackOptions -min 0 -max 30 -ast 0 -aet 30; currentTime 30; select -cl; } global proc asFaceCheekRaiserFinish () { if (!`objExists CheekRaiser`)//skip return; if (`attributeExists CheekRaiserFinish FaceBuildInProgress`) return; addAttr -k 0 -ln CheekRaiserFinish -at bool -dv true FaceBuildInProgress; asFaceMirrorConnectCtrls 0; //remove fitAnim from driver $tempString=`listConnections -s 1 -d 0 -type animCurve ctrlCheek_R.ty ctrlCheek_L.ty`; if (size($tempString)) delete $tempString; setAttr ctrlCheek_R.ty 0; setAttr ctrlCheek_L.ty 0; asFaceStoreAsDsSdk {"CheekRaiser"} "_RL" "ctrlCheek" "_RL" "ty" 1; asFaceStoreAsDsSdk {"lowerLid"} "_RL" "ctrlCheek" "_RL" "ty" 1; asFaceRemoveFitAnimationsFromOnFaceCtrls; asFaceHideControllers 1; setAttr ctrlBoxCheek_R.v 1; setAttr ctrlBoxCheek_L.v 1; } global proc asFaceJawWeighing () { string $geometry=`textField -q -tx asFaceFaceTextField`; string $upperTeeth=`textField -q -tx asFaceUpperTeethTextField`; string $lowerTeeth=`textField -q -tx asFaceLowerTeethTextField`; string $headJoint=`textField -q -tx asFaceHeadJointTextField`; string $skinCluster="JawSC"; float $scale=`getAttr FaceFitSkeleton.faceScale`; float $pos[],$pos2[],$posA[],$posB[],$bb[]; string $tempString[],$lipCtrl[],$lipSide[],$lipUpLo[]; string $xyz[]={"x","y","z"}; string $XYZ[]={"X","Y","Z"}; string $tr[]={"t","r"}; string $upLoCtrl,$side; asFaceCheekRaiserFinish; if (!`objExists JawPivot`)//skip return; //JawCurves, used to be in Pre section, but moved to here //It still creates FaceFitJawCurves as a Fit-Element, and will be keept as a Fit if (!`objExists FaceFitJawCurves`) asFaceFitJawCurves; //create LayerMesh (weightBysoftmod ignores locked weights) if (!`getAttr -l ($geometry+".v")`) setAttr ($geometry+".v") 0; $tempString=`listRelatives -c DeformationLayers`; for ($i=0;$i-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) {$upperLower="upper";$upperLowerTeeth=$upperTeeth;} else {$upperLower="lower";$upperLowerTeeth=$lowerTeeth;} if ($upperLowerTeeth!="") { eval ("select "+$upperLowerTeeth); showHidden -a; refresh; $tempString=`ls -sl -o`; if (size($tempString)>1) { //for multiple teeth objects, dup&group to get bb duplicate -rr; parent -w; group -n BoundingBoxGroup; $bb=`xform -q -ws -bb`; delete BoundingBoxGroup; } else $bb=`xform -q -ws -bb`; eval ("select "+$upperLowerTeeth); asShowLayer Jaw; asCreateFaceController ($upperLower+"Teeth") "_M" 4; parent ($upperLower+"TeethJoint_M") FaceJoint_M; parent ($upperLower+"TeethOffset_M") SideReverse_M; setAttr ($upperLower+"TeethOffset_M.s") -type float3 1 1 1; rotate -r -p 0 0 0 -os -90 0 0 ($upperLower+"Teeth_M.cv[0:7]");; scale (($bb[3]-$bb[0])/($scale*0.03)) 1 (($bb[5]-$bb[2])/($scale*0.03)) ($upperLower+"Teeth_M.cv[0:7]"); xform -ws -t 0 (($bb[1]+$bb[4])/2.0) (($bb[2]+$bb[5])/2.0) ($upperLower+"TeethOffset_M"); move -r 0 0 ($scale/-10.0) ($upperLower+"Teeth_M.cv[0:99]"); connectAttr -f ctrlBox.TeethCtrlVis ($upperLower+"Teeth_MShape.overrideVisibility"); if ($upperLower=="lower") asFaceAddConstrained lowerTeeth_M JawFollow_M JawStatic_M 10; parentConstraint ($upperLower+"Teeth_M") ($upperLower+"TeethJoint_M"); scaleConstraint -mo ($upperLower+"Teeth_M") ($upperLower+"TeethJoint_M"); } } setAttr JawJoint_M.segmentScaleCompensate 0; if (`objExists upperTeethJoint_M`) setAttr upperTeethJoint_M.segmentScaleCompensate 0; if (`objExists lowerTeethJoint_M`) setAttr lowerTeethJoint_M.segmentScaleCompensate 0; if (`objExists upperTeethOffset_M`) setAttr upperTeethOffset_M.v 0; if (`objExists lowerTeethOffset_M`) setAttr lowerTeethOffset_M.v 0; skinCluster -e -lw false -wt 0 -ai JawJoint_M $skinCluster; //Skin jaw-curves select FaceJoint_M JawJoint_M JawCurve; $tempString=`newSkinCluster "-toSelectedBones -mi 1 -dr 4 -rui false"`; rename $tempString[0] JawCurveSC; //Create the JawOpenLayer mesh duplicate -n JawOpenLayer templateLayer; parent JawOpenLayer FaceBuildInProgress; setAttr JawLayer.v 0; setAttr JawOpenLayer.v 1; sets -e -forceElement initialShadingGroup JawOpenLayer; select JawOpenLayer FaceJoint_M JawJoint_M; $tempString=`newSkinCluster "-toSelectedBones -mi 1 -dr 4 -rui false"`; rename $tempString[0] JawOpenLayerSC; skinPercent -tv FaceJoint_M 1 JawOpenLayerSC JawOpenLayer.vtx[0:99999]; select `asobjSetCast lipArea {} JawOpenLayer`; sets -n lipAreaJawOpenLayer; sets -add FaceBuildingSets lipAreaJawOpenLayer; asFaceLockWeights 0; asSkinTeeth; asFaceDesignMouthOpen; asFaceWeightLips; asFaceUpdateJawCurvesWeights; setAttr JawLayer.v 0; parent FaceFitJawCurves FaceBuildInProgress; parent mouthOpenSoftModHandle FaceBuildInProgressHidden; currentTime 30; //select Jaw_M; //autoKeyframe -st 1; select -cl; } global proc asFaceJawWeighingFinish () { float $values[]; string $geometry=`textField -q -tx asFaceFaceTextField`; string $headJoint=`textField -q -tx asFaceHeadJointTextField`; string $skinCluster=`textField -q -tx asFaceSkinClusterTextField`; string $tempString[],$tempString2[],$infs[],$mainSmileLineVtxs[]; if (`attributeExists JawWeighingFinish FaceBuildInProgress`) return; addAttr -k 0 -ln JawWeighingFinish -at bool -dv true FaceBuildInProgress; currentTime 0; delete JawCurveSC; parent JawOpenLayer DeformationLayers; //finish Jaw parent FaceFitJawCurves FaceFitSkeleton; asShowLayer Normal; setAttr lowerLipOffset_M.v 1; asFaceAddConstrained upperLip_M JawFollow_M lowerFaceStatic_M 0; asFaceAddConstrained lowerLip_M JawFollow_M lowerFaceStatic_M 10; //aliasAttr followJaw_M upperLip_M.followJawFollow_M; //aliasAttr followJaw_M lowerLip_M.followJawFollow_M; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; //sideLocalJawFollow jaws(needed on the right side to avoid constraint flip) // createNode -n ("JawFollow"+$side) -p JawSetup transform; parentConstraint -mo Jaw_M ("JawFollow"+$side); scaleConstraint -mo Jaw_M ("JawFollow"+$side); setAttr ("LipOffset"+$side+".v") 1; asFaceAddConstrained ("Lip"+$side) ("JawFollow"+$side) ("lowerFaceStatic"+$side) 5; asFaceAddConstrained ("Cheek"+$side) ("JawFollow"+$side) ("middleFaceStatic"+$side) 5; if (`objExists ("SmileLine"+$side)`) asFaceAddConstrained ("SmileLine"+$side) ("JawFollow"+$side) ("lowerFaceStatic"+$side) 5; /* if (`objExists SmileBulge` && `objExists FrownBulge`) { // asFaceAddConstrained ("SmileBulge"+$side) ("JawFollow"+$side) ("FaceStatic"+$side) 2;//not needed as it follows Cheeck which follows jaw asFaceAddConstrained ("FrownBulge"+$side) ("JawFollow"+$side) ("FaceStatic"+$side) 5; } */ // parent ("LipNonNarrowParent"+$side) ("LipFollow"+$side); } dgdirty -a; skinCluster -e -lw false -wt 0 -ai JawJoint_M $skinCluster; //lock`n`copy $tempString=`listRelatives -type joint -ad FaceJoint_M`; $tempString[size($tempString)]="FaceJoint_M"; for ($i=0;$i0.5) $mainSmileLineVtxs[size($mainSmileLineVtxs)]=$tempString[$i]; } select lipFalloffArea; select -d $mainSmileLineVtxs; } if (size(`ls -sl`)) weightHammerVerts; //change the jaw animation to DrivingSystem currentTime 30; asDsSdk ctrlMouth_M.ty SDKJaw_M.ty -1 `getAttr Jaw_M.ty`; asDsSdk ctrlMouth_M.ty SDKJaw_M.tz -1 `getAttr Jaw_M.tz`; asDsSdk ctrlMouth_M.ty SDKJaw_M.rx -1 `getAttr Jaw_M.rx`; delete `listConnections -s 1 -d 0 -type animCurve Jaw_M`; delete `listConnections -s 1 -d 0 -type animCurve ctrlMouth_M`; setAttr ctrlMouth_M.ty 0; setAttr -l 0 Jaw_M.tx; setAttr -l 0 Jaw_M.ry; setAttr -l 0 Jaw_M.rz; xform -os -t 0 0 0 -ro 0 0 0 -s 1 1 1 Jaw_M; asFaceHideControllers 1; setAttr ctrlBoxMouth_M.v 1; } global proc asFaceJawOpen () { float $pos[]; float $scale=`asGetScale`; if (!`objExists JawPivot`)//skip return; asFaceJawWeighingFinish; asFaceHideControllers 1; setAttr ctrlBoxMouth_M.v 1; setAttr LipRegionOffset_M.v 1; //setAttr LipOffset_R.v 1; //setAttr LipOffset_L.v 1; setAttr CheekOffset_R.v 1; setAttr CheekOffset_L.v 1; //setAttr SmileBulgeOffset_R.v 1; //setAttr SmileBulgeOffset_L.v 1; //setAttr FrownBulgeOffset_R.v 1; //setAttr FrownBulgeOffset_L.v 1; setAttr upperLipBOffset_R.v 1; setAttr upperLipBOffset_L.v 1; setAttr lowerLipBOffset_R.v 1; setAttr lowerLipBOffset_L.v 1; if (`objExists SmileLine_R`) setAttr SmileLineOffset_R.v 1; asShowLayer Normal; asFaceMirrorConnectCtrls 1; //fit-anim asFaceFitAnim ctrlMouth_M.ty -1; asFaceFitAnim Cheek_R 0; asFaceFitAnim Cheek_R.tz -0.3; //asFaceFitAnim Lip_R 0; //asFaceFitAnim Lip_R.tx -0.3; asFaceFitAnim upperLipB_R 0; asFaceFitAnim lowerLipB_R 0; if (`objExists SmileLine_R`) { asFaceFitAnim SmileLine_R 0; asFaceFitAnim SmileLine_R.sy 1.35; } playbackOptions -min 0 -max 30 -ast 0 -aet 30; currentTime 30; select -cl; } global proc asFaceJawOpenFinish () { if (!`objExists JawPivot`)//skip return; if (`attributeExists JawOpenFinish FaceBuildInProgress`) return; addAttr -k 0 -ln JawOpenFinish -at bool -dv true FaceBuildInProgress; asFaceMirrorConnectCtrls 0; //remove fitAnim from driver $tempString=`listConnections -s 1 -d 0 -type animCurve ctrlMouth_M.ty`; if (size($tempString)) delete $tempString; setAttr ctrlMouth_M.ty 0; delete CheekValues_R; if (`objExists upperLipBValues_R`) delete upperLipBValues_R; if (`objExists lowerLipBValues_R`) delete lowerLipBValues_R; if (`objExists SmileLine_R`) delete SmileLineValues_R; asFaceStoreAsDsSdk {"Cheek","SmileLine","upperLipB","lowerLipB"} "_RL" "ctrlMouth" "_M" "ty" -1; asFaceRemoveFitAnimationsFromOnFaceCtrls; asFaceHideControllers 1; setAttr ctrlBoxMouth_M.v 1; select -cl; } global proc asFaceZipLips () { int $upperLowerFactor; string $upperLower,$side; if (!`objExists upperLipMainCurve`)//skip return; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; // addAttr -k 1 -ln zip -at double -min 0 -max 10 -dv 0 ("Lip"+$side); addAttr -k 1 -ln zip -at double -smx 10 -hsx 1 -smn -10 -hnv 1 ("Lip"+$side); asEnsureOutputBlendWeighted ("Lip"+$side+".zip"); for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper";else $upperLower="lower"; asDsSdk ("bwLip"+$side+"_zip.output") ("bw"+$upperLower+"LipB"+$side+"_follow"+$upperLower+"Lip_M.input") 4 -1; keyframe -option over -index 0 -absolute -floatChange -10 -valueChange 5 ("bw"+$upperLower+"LipB"+$side+"_follow"+$upperLower+"Lip_M_input_1_"); // setAttr ("bw"+$upperLower+"LipB"+$side+"_follow"+$upperLower+"Lip_M_input_1_.preInfinity") 1; setAttr ("bw"+$upperLower+"LipB"+$side+"_follow"+$upperLower+"Lip_M_input_1_.postInfinity") 1; asDsSdk ("bwLip"+$side+"_zip.output") ("bw"+$upperLower+"LipA"+$side+"_follow"+$upperLower+"Lip_M.input") 7 -7.5; setAttr ("bw"+$upperLower+"LipA"+$side+"_follow"+$upperLower+"Lip_M_input_1_.preInfinity") 1; setAttr ("bw"+$upperLower+"LipA"+$side+"_follow"+$upperLower+"Lip_M_input_1_.postInfinity") 1; keyframe -option over -index 0 -absolute -floatChange 2 ("bw"+$upperLower+"LipA"+$side+"_follow"+$upperLower+"Lip_M_input_1_"); asDsSdk ("bwLip"+$side+"_zip.output") ("bw"+$upperLower+"Lip_M_followJawFollow_M.input") 10 (2.5*$upperLowerFactor); setAttr ("bw"+$upperLower+"Lip_M_followJawFollow_M_input_1_.preInfinity") 1; setAttr ("bw"+$upperLower+"Lip_M_followJawFollow_M_input_1_.postInfinity") 1; keyframe -option over -index 0 -absolute -floatChange 3 ("bw"+$upperLower+"Lip_M_followJawFollow_M_input_1_"); } } } global proc asFaceNose () { int $type; float $pos[],$posA[],$posB[]; float $radius,$falloffRadius,$noseUnderFalloffRadius; string $geometry=`textField -q -tx asFaceFaceTextField`; string $skinCluster=`textField -q -tx asFaceSkinClusterTextField`; string $headJoint=`textField -q -tx asFaceHeadJointTextField`; string $side,$leftSuffix; string $noseLocs[]={"NoseSide","NoseUnder","NoseCenter","Nostril","NoseCorner","Nose"}; string $tempString[],$tempString2[]; asFaceJawOpenFinish; asFaceZipLips; if (!`objExists Nose`)//skip return; //SoftModLayerWeight Controller asFaceHideControllers 1; setAttr ctrlBox.RegionsCtrlVis 0; asFaceLockWeights 1; setAttr ($headJoint+".lockInfluenceWeights") 0; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) {$side="_R";$leftSuffix="";} else {$side="_L";$leftSuffix="Left";} if (`objExists Nose` && $side=="_R") { $posA=`xform -q -ws -t Nose`; $posB=`xform -q -ws -t NoseCorner`; $falloffRadius=`mag<<$posA[0]-$posB[0],$posA[1]-$posB[1],$posA[2]-$posB[2]>>`; SoftModLayerWeight Nose Nose 1 "_M" $falloffRadius 2; } if (`objExists NoseCorner`) { $posA=`xform -q -ws -t Nose`; $posB=`xform -q -ws -t ("NoseCorner"+$leftSuffix)`; $falloffRadius=`mag<<$posA[0]-$posB[0],$posA[1]-$posB[1],$posA[2]-$posB[2]>>`; SoftModLayerWeight ("NoseCorner"+$leftSuffix) NoseCorner $b $side $falloffRadius 1; } if (`objExists NoseSide`) { $posA=`xform -q -ws -t ("NoseSide"+$leftSuffix)`; $posB=`xform -q -ws -t ("NoseCorner"+$leftSuffix)`; $falloffRadius=`mag<<$posA[0]-$posB[0],$posA[1]-$posB[1],$posA[2]-$posB[2]>>`; SoftModLayerWeight ("NoseSide"+$leftSuffix) NoseSide $b $side $falloffRadius 3; } if (`objExists Nostril`) { $posA=`xform -q -ws -t ("Nostril"+$leftSuffix)`; $posB=`xform -q -ws -t ("NoseCorner"+$leftSuffix)`; $falloffRadius=`mag<<$posA[0]-$posB[0],$posA[1]-$posB[1],$posA[2]-$posB[2]>>`; SoftModLayerWeight ("Nostril"+$leftSuffix) Nostril $b $side $falloffRadius 3; } if (`objExists NoseCenter` && $side=="_R") { $posA=`xform -q -ws -t ("NoseCenter"+$leftSuffix)`; $posB=`xform -q -ws -t ("NoseSide"+$leftSuffix)`; $falloffRadius=`mag<<$posA[0]-$posB[0],$posA[1]-$posB[1],$posA[2]-$posB[2]>>`; SoftModLayerWeight ("NoseCenter"+$leftSuffix) NoseCenter 1 "_M" $falloffRadius 3; } if (`objExists Nostril`) asFaceAddConstrained ("Nostril"+$side) Nose_M ("NoseCorner"+$side) 5; if (`objExists NoseSide`) asFaceAddConstrained ("NoseSide"+$side) ("NoseCorner"+$side) ("middleFaceStatic"+$side) 3; } $posA=`xform -q -ws -t Nose`; $posB=`xform -q -ws -t NoseCorner`; asCreateFaceController "NoseRegion" "_M" 4; delete NoseRegionJoint_M; parent NoseRegionOffset_M SideReverse_M; setAttr NoseRegionOffset_M.s -type float3 1 1 1; scale -r -p 0 0 0 6 6 6 NoseRegion_M.cv[0:7]; xform -ws -t 0 $posA[1] (($posA[2]+$posB[2])/2.0) NoseRegionOffset_M; select -cl; } global proc asFaceSnarl () { float $noseSidePos[],$noseCornerPos[],$upperLipAPos[]; string $geometry=`textField -q -tx asFaceFaceTextField`; if (!`objExists NoseCorner` || !`objExists upperLipA_R`)//skip return; asFaceHideControllers 1; setAttr ctrlBoxNose_R.v 1; setAttr ctrlBoxNose_L.v 1; setAttr NoseCornerOffset_R.v 1; setAttr NoseCornerOffset_L.v 1; setAttr LipRegionOffset_M.v 1; setAttr upperLipAOffset_R.v 1; setAttr upperLipAOffset_L.v 1; if (`objExists NoseSideOffset_R`) setAttr NoseSideOffset_R.v 1; if (`objExists NoseSideOffset_L`) setAttr NoseSideOffset_L.v 1; asFaceMirrorConnectCtrls 1; delete upperLipAValues_R; if (`objExists NoseSide_R`) { createNode -n TempPos -p upperLidMain0_R transform; delete `geometryConstraint $geometry TempPos`; parent TempPos NoseSide_R; setAttr TempPos.tx 0; setAttr TempPos.tz 0; delete `geometryConstraint $geometry TempPos`; createNode -n TempPos2 transform; pointConstraint -w 0.25 TempPos NoseSide_R TempPos2; pointConstraint -w 0.75 NoseSide_R TempPos2; delete TempPos2_pointConstraint1; delete `geometryConstraint $geometry TempPos2`; parent TempPos2 NoseSideOffset_R; $noseSidePos=`getAttr TempPos2.t`; delete `pointConstraint NoseCorner_R NoseSide_R TempPos2`; parent TempPos2 NoseCornerOffset_R; $noseCornerPos=`getAttr TempPos2.t`; delete `pointConstraint NoseCorner_R upperLipA_R TempPos2`; parent TempPos2 upperLipAOffset_R; $upperLipAPos=`getAttr TempPos2.t`; delete TempPos TempPos2; } else { $noseSidePos={0.0, 0.25, 0.0}; $noseCornerPos={0.0, 0.5, 0.0}; $upperLipAPos={0.0, 0.75, 0.0}; } //fit-anim asFaceFitAnim ctrlNose_R.ty 1; asFaceFitAnim ctrlNose_L.ty 1; asFaceFitAnim upperLipA_R 0; asFaceFitAnim upperLipA_R.tx $upperLipAPos[0]; asFaceFitAnim upperLipA_R.ty $upperLipAPos[1]; asFaceFitAnim upperLipA_R.tz $upperLipAPos[2]; asFaceFitAnim NoseCorner_R 0; asFaceFitAnim NoseCorner_R.tx $noseCornerPos[0]; asFaceFitAnim NoseCorner_R.ty $noseCornerPos[1]; asFaceFitAnim NoseCorner_R.tz $noseCornerPos[2]; asFaceFitAnim NoseSide_R 0; asFaceFitAnim NoseSide_R.tx $noseSidePos[0]; asFaceFitAnim NoseSide_R.ty $noseSidePos[1]; asFaceFitAnim NoseSide_R.tz $noseSidePos[2]; playbackOptions -min 0 -max 30 -ast 0 -aet 30; currentTime 30; select -cl; } global proc asFaceSnarlFinish () { if (!`objExists NoseCorner`)//skip return; if (`attributeExists SnarlFinish FaceBuildInProgress`) return; addAttr -k 0 -ln SnarlFinish -at bool -dv true FaceBuildInProgress; asFaceMirrorConnectCtrls 0; //remove fitAnim from driver $tempString=`listConnections -s 1 -d 0 -type animCurve ctrlNose_R.ty ctrlNose_L.ty`; if (size($tempString)) delete $tempString; setAttr ctrlNose_R.ty 0; setAttr ctrlNose_L.ty 0; asFaceStoreAsDsSdk {"upperLipA","NoseCorner","NoseSide"} "_RL" "ctrlNose" "_RL" "ty" 1; asFaceRemoveFitAnimationsFromOnFaceCtrls; //ctrlNose_R.tx as well delete NoseCornerValues_R; setKeyframe -t 0 -v 0 NoseCorner_R.tx; setKeyframe -t 30 -v 0.5 NoseCorner_R.tx; asFaceStoreAsDsSdk {"NoseCorner"} "_RL" "ctrlNose" "_RL" "tx" -1; asFaceRemoveFitAnimationsFromOnFaceCtrls; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; asFaceAddConstrained ("NoseCorner"+$side) ("Lip"+$side) middleFaceStatic_M 1; } asFaceHideControllers 1; setAttr ctrlBoxNose_R.v 1; setAttr ctrlBoxNose_L.v 1; select -cl; } global proc asFaceTongue () { global string $gSelect; setToolTo $gSelect; int $modifier=`getModifiers`; string $geometry=`textField -q -tx asFaceFaceTextField`; string $tongue=`textField -q -tx asFaceTongueTextField`; asFaceSnarlFinish; if (!`objExists FaceFitTongue`)//skip return; float $pos[],$bb[]; float $scale=`getAttr FaceFitSkeleton.faceScale`; string $side; string $tongueSkinCluster=""; string $tempString[]; string $allFaceGeoString=`textField -q -tx asFaceAllHeadTextField`; tokenize $allFaceGeoString $tempString; for ($i=0;$i-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; parent ("EyeRegionOffset"+$side) ("EyeOffset"+$side) ("EyeBrowRegionOffset"+$side) ("upperLidBaseOffset"+$side) ("upperSideReverse"+$side); parent ("middleFaceStatic"+$side) ("CheekRaiserOffset"+$side) ("middleSideReverse"+$side); parent ("lowerFaceStatic"+$side) ("SmilePullOffset"+$side) ("lowerSideReverse"+$side); } parent EyeBrowRegionOffset_M upperSideReverse_M; parent NoseRegionOffset_M middleFaceStatic_M middleSideReverse_M; if (`objExists NoseCenterOffset_M`) parent NoseCenterOffset_M middleSideReverse_M; parent JawOffset_M lowerFaceStatic_M lowerSideReverse_M; if (`objExists upperTeethOffset_M`) parent upperTeethOffset_M lowerSideReverse_M;; //UpMidLoLayer select FaceJoint_M upperFaceJoint_M middleFaceJoint_M lowerFaceJoint_M UpMidLoLayer; $tempString=`newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"`; rename $tempString[0] UpMidLoSC; skinPercent -tv middleFaceJoint_M 1 UpMidLoSC UpMidLoLayer; $posA=`xform -q -ws -t upperFace`; select UpMidLoLayer; polySelectConstraint -m 3 -t 1 -d 3 -db $posA[1] 9999 -da 0 1 0 -dp 0 0 0; skinPercent -tv upperFaceJoint_M 1 UpMidLoSC; $posA=`xform -q -ws -t lowerFace`; polySelectConstraint -m 3 -t 1 -d 3 -db 0 $posA[1] -da 0 1 0 -dp 0 0 0; skinPercent -tv lowerFaceJoint_M 1 UpMidLoSC; polySelectConstraint -m 0; select UpMidLoLayer; asSmoothFlood upperFaceJoint_M middleFaceJoint_M 10; asSmoothFlood lowerFaceJoint_M middleFaceJoint_M 10; asSmoothFlood lowerFaceJoint_M FaceJoint_M 10; //transfer to $geometry skinCluster -e -lw false -wt 0 -ai upperFaceJoint_M -ai middleFaceJoint_M -ai lowerFaceJoint_M $skinCluster; $tempInts=`polyEvaluate -v $geometry`; $numVtx=$tempInts[0]; for ($i=0;$i<$numVtx;$i++) { $pos=`xform -q -ws -t ("UpMidLoLayer.vtx["+$i+"]")`; if (!$nonSymmetrical && $pos[0]>($centerTolerance)) continue; $infs=`skinPercent -ignoreBelow 0.01 -q -t $skinCluster ($geometry+".vtx["+$i+"]")`; $values=`skinPercent -ignoreBelow 0.01 -q -v $skinCluster ($geometry+".vtx["+$i+"]")`; if (!`stringArrayCount $headJoint $infs`) continue; $vtxNrs[size($vtxNrs)]=$i; $headJointWeight=`skinPercent -t $headJoint -q -v $skinCluster ($geometry+".vtx["+$i+"]")`; $headJointWeights[size($headJointWeights)]=0; $upperFaceWeight =`skinPercent -t upperFaceJoint_M -q -v UpMidLoSC ("UpMidLoLayer.vtx["+$i+"]")`; $middleFaceWeight =`skinPercent -t middleFaceJoint_M -q -v UpMidLoSC ("UpMidLoLayer.vtx["+$i+"]")`; $lowerFaceWeight =`skinPercent -t lowerFaceJoint_M -q -v UpMidLoSC ("UpMidLoLayer.vtx["+$i+"]")`; $upperFaceWeights[size($upperFaceWeights)] = $headJointWeight * $upperFaceWeight; $middleFaceWeights[size($middleFaceWeights)] = $headJointWeight * $middleFaceWeight; $lowerFaceWeights[size($lowerFaceWeights)] = $headJointWeight * $lowerFaceWeight; } asSkinWeightSet $headJoint $geometry $skinCluster $vtxNrs $headJointWeights; asSkinWeightSet upperFaceJoint_M $geometry $skinCluster $vtxNrs $upperFaceWeights; asSkinWeightSet middleFaceJoint_M $geometry $skinCluster $vtxNrs $middleFaceWeights; asSkinWeightSet lowerFaceJoint_M $geometry $skinCluster $vtxNrs $lowerFaceWeights; if (!$nonSymmetrical) copySkinWeights -ss $skinCluster -ds $skinCluster -mirrorMode YZ -mirrorInverse -surfaceAssociation closestPoint -influenceAssociation closestJoint; //transfer to objects other then $geometry $definedGeos[0]=$geometry; $tempString=`stringToStringArray $rightEye " "`; $definedGeos=`stringArrayCatenate $definedGeos $tempString`; $tempString=`stringToStringArray $leftEye " "`; $definedGeos=`stringArrayCatenate $definedGeos $tempString`; $tempString=`stringToStringArray $upperTeeth " "`; $definedGeos=`stringArrayCatenate $definedGeos $tempString`; $tempString=`stringToStringArray $lowerTeeth " "`; $definedGeos=`stringArrayCatenate $definedGeos $tempString`; $tempString=`stringToStringArray $tongue " "`; $definedGeos=`stringArrayCatenate $definedGeos $tempString`; $tempString=`stringToStringArray $eyeBrow " "`; $definedGeos=`stringArrayCatenate $definedGeos $tempString`; $tempString=`stringToStringArray $eyeLash " "`; $definedGeos=`stringArrayCatenate $definedGeos $tempString`; for ($i=0;$i-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; //LipA towards Smile(upper) or Frown(lower) $value=0; if ($phonemes[$i]=="aaa" && $upperLower=="upper") $value=0.15; if ($phonemes[$i]=="aaa" && $upperLower=="lower") $value=0.25; if ($phonemes[$i]=="eh" && $upperLower=="upper") $value=0.25; if ($phonemes[$i]=="eh" && $upperLower=="lower") $value=0.35; if ($phonemes[$i]=="ahh" && $upperLower=="upper") $value=0.15; if ($phonemes[$i]=="ahh" && $upperLower=="lower") $value=0.25; // if ($phonemes[$i]=="uuu" && $upperLower=="upper") $value=0.1; // if ($phonemes[$i]=="uuu" && $upperLower=="lower") $value=0.2; if ($phonemes[$i]=="iee" && $upperLower=="upper") $value=0.1; if ($phonemes[$i]=="iee" && $upperLower=="lower") $value=0.25; if ($phonemes[$i]=="mbp" && $upperLower=="upper") $value=-0.1; if ($phonemes[$i]=="sss" && $upperLower=="lower") $value=-0.1; if ($phonemes[$i]=="tth" && $upperLower=="upper") $value=0.1; if ($phonemes[$i]=="ssh" && $upperLower=="upper") $value=0.1; if ($phonemes[$i]=="ssh" && $upperLower=="lower") $value=-0.1; if ($value!=0) { pointConstraint -w (1.0-$value) ($upperLower+"LipA"+$side) tempXform; if ($upperLower=="upper") pointConstraint -w $value ("SmileBulge"+$side) tempXform; if ($upperLower=="lower") pointConstraint -w $value ("FrownBulge"+$side) tempXform; $pos=`xform -q -ws -t tempXform`; parent tempXform ($upperLower+"LipAFollow"+$side); asDsSdk ("ctrlPhonemes_M."+$phonemes[$i]) ("SDK"+$upperLower+"LipA"+$side+".tx") 10 `getAttr tempXform.tx`; asDsSdk ("ctrlPhonemes_M."+$phonemes[$i]) ("SDK"+$upperLower+"LipA"+$side+".ty") 10 `getAttr tempXform.ty`; asDsSdk ("ctrlPhonemes_M."+$phonemes[$i]) ("SDK"+$upperLower+"LipA"+$side+".tz") 10 `getAttr tempXform.tz`; delete tempXform_pointConstraint1; parent -w tempXform; } } //MouthCorner upDown $value=0; if ($phonemes[$i]=="iee") $value=0.2; if ($phonemes[$i]=="fff") $value=0.2; if ($value!=0) asDsSdk ("ctrlPhonemes_M."+$phonemes[$i]) ("SDKLip"+$side+".ty") 10 (`getAttr LipSmileValues.ty`*$value); //SmileBulge towards CheekRaiser $value=0; if ($phonemes[$i]=="aaa") $value=0.15; if ($phonemes[$i]=="eh") $value=0.25; if ($phonemes[$i]=="iee") $value=0.25; if ($phonemes[$i]=="tth") $value=0.05; if ($value!=0) { pointConstraint -w (1.0-$value) ("SmileBulge"+$side) tempXform; pointConstraint -w $value ("CheekRaiser"+$side) tempXform; parent tempXform ("SmileBulgeFollow"+$side); $pos=`getAttr tempXform.t`; delete tempXform_pointConstraint1; for ($z=0;$z-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; asDsSdk $driver ("SDKEyeBrowOuter"+$side+".ty") 10 -0.1; asDsSdk $driver ("bwctrlMouthCorner"+$side+"_translateX.input") 10 1; asDsSdk $driver ("bwctrlMouthCorner"+$side+"_translateY.input") 10 1; asDsSdk $driver ("bwctrlEye"+$side+"_blink.input") 10 3; } //angry $driver="ctrlEmotions_M.angry"; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; asDsSdk $driver ("bwctrlBrow"+$side+"_translateX.input") 10 -0.5; asDsSdk $driver ("bwctrlBrow"+$side+"_translateY.input") 10 -0.5; asDsSdk $driver ("bwctrlBrow"+$side+"_squeeze.input") 10 8; asDsSdk $driver ("bwctrlMouthCorner"+$side+"_translateX.input") 10 -0.5; // asDsSdk $driver ("SDKNoseCorner"+$side+".tx") 10 -0.5; asDsSdk $driver ("bwctrlEye"+$side+"_blink.input") 10 3; asDsSdk $driver ("bwctrlEye"+$side+"_squint.input") 10 3; if (`objExists Nostril_R`) asDsSdk $driver ("SDKNostril"+$side+".tx") 10 0.2; } asDsSdk $driver ("bwctrlMouth_M_upperSqueeze.input") 10 5; asDsSdk $driver ("bwctrlMouth_M_lowerSqueeze.input") 10 5; //sad $driver="ctrlEmotions_M.sad"; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; asDsSdk $driver ("bwctrlBrow"+$side+"_translateX.input") 10 0.5; asDsSdk $driver ("bwctrlBrow"+$side+"_translateY.input") 10 -0.5; asDsSdk $driver ("bwctrlBrow"+$side+"_squeeze.input") 10 5; asDsSdk $driver ("bwctrlMouthCorner"+$side+"_translateX.input") 10 0.5; asDsSdk $driver ("bwctrlMouthCorner"+$side+"_translateY.input") 10 -0.5; asDsSdk $driver ("bwctrlEye"+$side+"_blink.input") 10 3; asDsSdk $driver ("bwctrlEye"+$side+"_squint.input") 10 3; // if (`objExists Nostril_R`) // asDsSdk $driver ("SDKNostril"+$side+".tx") 10 0.4; } asDsSdk $driver ("bwctrlMouth_M_upperSqueeze.input") 10 3; asDsSdk $driver ("bwctrlMouth_M_lowerSqueeze.input") 10 3; //surprise $driver="ctrlEmotions_M.surprise"; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; asDsSdk $driver ("bwctrlBrow"+$side+"_translateY.input") 10 0.75; asDsSdk $driver ("bwctrlEye"+$side+"_blink.input") 10 -1; asDsSdk $driver ("bwctrlEye"+$side+"_squint.input") 10 -1; } asDsSdk $driver bwctrlMouth_M_translateY.input 10 -1; //fear $driver="ctrlEmotions_M.fear"; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; asDsSdk $driver ("bwctrlBrow"+$side+"_translateX.input") 10 1.0; asDsSdk $driver ("bwctrlBrow"+$side+"_squeeze.input") 10 7; asDsSdk $driver ("bwctrlMouthCorner"+$side+"_translateX.input") 10 0.4; asDsSdk $driver ("bwctrlMouthCorner"+$side+"_translateY.input") 10 -0.25; asDsSdk $driver ("SDKNoseCorner"+$side+".ty") 10 -0.1; // asDsSdk $driver ("SDKCheekRaiser"+$side+".ty") 10 0.1; asDsSdk $driver ("SDKupperLid"+$side+".ty") 10 0.1; asDsSdk $driver ("SDKlowerLid"+$side+".ty") 10 -0.1; } asDsSdk $driver bwctrlMouth_M_translateY.input 10 -0.75; asDsSdk $driver ("bwctrlMouth_M_upperSqueeze.input") 10 3; asDsSdk $driver ("bwctrlMouth_M_lowerSqueeze.input") 10 3; //disgust $driver="ctrlEmotions_M.disgust"; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; // asDsSdk $driver ("bwctrlBrow"+$side+"_translateX.input") 10 -0.5; // asDsSdk $driver ("bwctrlBrow"+$side+"_translateY.input") 10 -0.5; asDsSdk $driver ("bwctrlBrow"+$side+"_squeeze.input") 10 5; asDsSdk $driver ("bwctrlEye"+$side+"_squint.input") 10 3; asDsSdk $driver ("bwctrlNose"+$side+"_translateY.input") 10 0.75; asDsSdk $driver ("bwctrlCheek"+$side+"_translateY.input") 10 1; asDsSdk $driver ("bwctrlMouthCorner"+$side+"_translateX.input") 10 0.25; asDsSdk $driver ("bwctrlMouthCorner"+$side+"_translateY.input") 10 -0.25; // asDsSdk $driver ("SDKNoseCorner"+$side+".ty") 10 0.3; } asDsSdk $driver SDKlowerLip_M.ty 10 -0.5; //contempt $driver="ctrlEmotions_M.contempt"; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; asDsSdk $driver ("bwctrlMouthCorner"+$side+"_translateX.input") 10 0.6; asDsSdk $driver ("bwctrlMouthCorner"+$side+"_translateY.input") 10 0.3; } //select ctrlEmotions_M; select -cl; } global proc asFaceDsSdk () { if (!`objExists upperLipMainCurve`)//skip return; //add jawForward addAttr -k 1 -ln jawForward -at double -smx 10 -hsx 1 -smn -10 -hnv 1 ctrlMouth_M; asEnsureOutputBlendWeighted ctrlMouth_M.jawForward; asDsSdk ctrlMouth_M.jawForward SDKJaw_M.tz 10 2; //add jawSide addAttr -k 1 -ln jawSide -at double -smx 10 -hsx 1 -smn -10 -hnv 1 ctrlMouth_M; asEnsureOutputBlendWeighted ctrlMouth_M.jawSide; asDsSdk ctrlMouth_M.jawSide SDKJaw_M.ry 10 15; //add lipSide addAttr -k 1 -ln lipSide -at double -min -10 -max 10 -dv 0 ctrlMouth_M; asEnsureOutputBlendWeighted ctrlMouth_M.lipSide; setAttr ctrlMouth_M.lipSide 10; setKeyframe -t 0 LipRegion_M; setKeyframe -t 30 -v 1.2 LipRegion_M.tx; setKeyframe -t 30 -v 25 LipRegion_M.ry; setKeyframe -t 30 -v 0.8 LipRegion_M.sx; setKeyframe -t 30 -v 0.8 LipRegion_M.sz; catchQuiet (`setKeyframe -t 0 NoseRegion_M`); catchQuiet (`setKeyframe -t 30 -v 0.3 NoseRegion_M.tx`); catchQuiet (`setKeyframe -t 30 -v -0.05 NoseRegion_M.ty`); catchQuiet (`setKeyframe -t 30 -v 5 NoseRegion_M.ry`); catchQuiet (`setKeyframe -t 30 -v 5 NoseRegion_M.rz`); catchQuiet (`setKeyframe -t 30 -v 0.9 NoseRegion_M.sx`); catchQuiet (`setKeyframe -t 30 -v 1.1 NoseRegion_M.sy`); asFaceStoreAsDsSdk {"LipRegion","NoseRegion"} "_M" "ctrlMouth" "_M" "lipSide" 10; asFaceRemoveFitAnimationsFromOnFaceCtrls; setAttr ctrlMouth_M.lipSide -10; setKeyframe -t 00 LipRegion_M; setKeyframe -t 30 -v 0.8 LipRegion_M.sx; setKeyframe -t 30 -v 0.8 LipRegion_M.sz; catchQuiet (`setKeyframe -t 0 NoseRegion_M`); catchQuiet (`setKeyframe -t 30 -v 0.9 NoseRegion_M.sx`); catchQuiet (`setKeyframe -t 30 -v 1.1 NoseRegion_M.sy`); asFaceStoreAsDsSdk {"LipRegion","NoseRegion"} "_M" "ctrlMouth" "_M" "lipSide" -10; setAttr ctrlMouth_M.lipSide 0; asFaceRemoveFitAnimationsFromOnFaceCtrls; } global proc asFaceExtras () { string $geometry=`textField -q -tx asFaceFaceTextField`; string $extras=`textField -q -tx asFaceExtrasTextField`; string $headJoint=`textField -q -tx asFaceHeadJointTextField`; string $skinCluster=`textField -q -tx asFaceSkinClusterTextField`; string $cmd,$sc; string $extraGeos[],$tempString[],$faceJoints[],$alreadyInfluencingJoints[]; $extraGeos=`stringToStringArray $extras " "`; $faceJoints=`listRelatives -ad -type joint FaceJoint_M`; $faceJoints[size($faceJoints)]="FaceJoint_M"; for ($i=0;$i0)//blendshapes if (!`objExists asFaceBS`)//if rebuilding, asBSConvertDStoBS happens in asFaceRebuildRestore { checkBox -e -v (`getAttr FaceFitSkeleton.RigType`-1) asKeepJointsCheckBox; asBSConvertDStoBS; } cycleCheck -e on; evalDeferred ("sets -clear allBeforeFaceBuild;delete allBeforeFaceBuild;"); asUpdateButtonEnables; select -cl; print ("// Advanced Face created\n"); } global proc asFaceRebuildRestore () { int $numKeys,$customizedDrivingSystemCurve,$haveSkinCluster,$spans,$degree,$numCVs; int $keepAll=`checkBox -q -v asFaceKeepAllCheckBox`; int $keepSkinWeights=`checkBox -q -v asFaceKeepSkinWeightsCheckBox`; int $keepHeadSquash=`checkBox -q -v asFaceKeepHeadSquashCheckBox`; int $keepBlendShapes=`checkBox -q -v asFaceKeepBlendShapesCheckBox`; int $keepCorrectiveShapes=`checkBox -q -v asFaceKeepCorrectiveShapesCheckBox`; int $keepDrivingSystems=`checkBox -q -v asFaceKeepDrivingSystemsCheckBox`; int $keepCurveShapes=`checkBox -q -v asFaceKeepCurveShapesCheckBox`; float $fc[],$vc[],$pFc[],$pVc[]; string $geometry=`textField -q -tx asFaceFaceTextField`; string $allFaceGeoString=`textField -q -tx asFaceAllHeadTextField`; string $newAnimCurve,$blendWeighted,$deltaMush,$curveShape,$prefixCurveShape,$nonPrefixDriverPlug; string $tempString[],$tempString2[],$tempString3[],$tempString4[],$historyNodes[],$allFaceGeo[],$animCurves[],$cmds[],$asFaceBSs[]; string $drivers[],$sdks[],$driverPlugs[],$targets[],$prefixTargets[]; string $controls[]=`sets -q FaceControlSet`; string $correctiveShapeNodes[]=`ls -r 1 -type blendShape "*Corrective*"`; tokenize $allFaceGeoString $tempString; for ($i=0;$i-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; if ($ctrlsSide=="_M") $side="_M"; if ($ctrlsSide=="_M" && $driveSide=="_M" && $b==-1) continue; if ($side=="_M") $valuObj=$ctrls[$i]+"Values"+$side; else $valuObj=$ctrls[$i]+"Values_R"; $ctrl=$ctrls[$i]+$side; if (!`objExists $ctrl`) { if (!`gmatch $ctrl "SmileLine_*"`) print ("// control:\""+$ctrl+"\" not found. skipping.\n"); $skipCtrl[$i]=1; } if (!`objExists $valuObj` && !$skipCtrl[$i]) { createNode -n $valuObj -p $ctrl transform; parent $valuObj `listRelatives -p $ctrl`; } } currentTime 0; if ($skipCtrl[$i]) continue; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; // if ($ctrlsSide=="_M") $side="_M"; if ($ctrlsSide=="_M" && $driveSide=="_M" && $b==-1) continue; if ($ctrlsSide=="_M") { $ctrl=$ctrls[$i]+"_M"; $valuObj=$ctrls[$i]+"Values"+"_M"; } else { $ctrl=$ctrls[$i]+$side; $valuObj=$ctrls[$i]+"Values_R"; } delete -staticChannels $ctrl; if ($driveSide=="_RL") $driveObjSide=$driveObj+$side; if ($driveSide=="_M") $driveObjSide=$driveObj+"_M"; $attrs=`listAttr -k $ctrl`; for ($y=0;$ylipNarrow) if ($driveAttr=="tx" && ($attrs[$y]=="translateY" || $attrs[$y]=="rotateZ")) continue; if ($driveAttr=="ty" && ! ($attrs[$y]=="translateY" || $attrs[$y]=="rotateZ")) continue; } if (!`attributeExists $attrs[$y] $valuObj`)//custom attr, do not use SDK node { if (`objExists ("bw"+$ctrl+"_"+$attrs[$y])`) asDsSdk ($driveObjSide+"."+$driveAttr) ("bw"+$ctrl+"_"+$attrs[$y]+".input") $driveValue $drivenValues[$y]; } else asDsSdk ($driveObjSide+"."+$driveAttr) ("SDK"+$ctrl+"."+$attrs[$y]) $driveValue $drivenValues[$y]; } } } if ($autoKeyState) autoKeyframe -state 1; } global proc asFacePaintSkinWeights () { string $geometry=`textField -q -tx asFaceFaceTextField`; string $headJoint=`textField -q -tx asFaceHeadJointTextField`; string $name,$side; string $joint=$headJoint; string $sel[]=`ls -sl`; string $tempString[]; select $geometry; if (`objExists FaceJointsLayer`) { if (!`getAttr FaceJointsLayer.v`) { print ("// SkinLayers detected, now switching to FaceJoints layer. (Use the Layers section to switch back to Normal layer))\n"); asShowLayer FaceJoints; } select FaceJointsLayer; } ArtPaintSkinWeightsTool; toolPropertyWindow; if ($sel[0]!="") { tokenize $sel[0] "_" $tempString; $name=$tempString[0]; $side="_"+$tempString[1]; if (`objExists ($name+"Joint"+$side)`) $joint=$name+"Joint"+$side; } artAttrSkinPaintCtx -e -influence $joint artAttrSkinContext; artSkinInflListChanging $joint 1; artSkinInflListChanged artAttrSkinPaintCtx; toolPropertyWindow; } global proc asFaceLockWeights (int $lock) { string $headJoint=`textField -q -tx asFaceHeadJointTextField`; string $topJoint=$headJoint; string $tempString[]; //if AdvSkel body rig, include body joints if (`objExists Root_M`) $topJoint="Root_M"; $tempString=`listRelatives -type joint -ad $topJoint`; $tempString[size($tempString)]=$topJoint; for ($i=0;$i0) geometryConstraint SmileLineCurveLeft tempXform2; else geometryConstraint SmileLineCurve tempXform2; $posC=`xform -q -ws -t tempXform`; $posD=`xform -q -ws -t tempXform2`; if (`stringArrayCount $tempString[$i] $SmileLineCurveVtxs`) continue;//vtx is On the curve if (`mag<<$posC[0]-$pos[0],$posC[1]-$pos[1],$posC[2]-$pos[2]>>`<`mag<<$posD[0]-$pos[0],$posD[1]-$pos[1],$posD[2]-$pos[2]>>`) $tempString2[size($tempString2)]=$tempString[$i]; if ($posC[0]>$posA[0]) $tempString2[size($tempString2)]=$tempString[$i]; delete tempXform2; } delete tempXform tempXformCenter; select $tempString; select -d $tempString2; */ } global proc asAddLeastEdgesPathToSet (string $geometry, string $startPosObj, string $endPosObj) { int $startVtxNr,$endVtxNr; float $pos[]; string $tempString[],$edgesToRemove[]; string $sel[]=`ls -sl`; if (`objExists closestSampler`) delete closestSampler; createNode -n closestSampler closestPointOnMesh; connectAttr -f ($geometry+".outMesh") closestSampler.inMesh; $pos=`xform -q -ws -t $startPosObj`; setAttr -type float3 closestSampler.inPosition $pos[0] $pos[1] $pos[2]; $startVtxNr=`getAttr closestSampler.result.closestVertexIndex`; $pos=`xform -q -ws -t $endPosObj`; setAttr -type float3 closestSampler.inPosition $pos[0] $pos[1] $pos[2]; $endVtxNr=`getAttr closestSampler.result.closestVertexIndex`; asSelectLeastEdgesPath $geometry $startVtxNr $endVtxNr; $tempString=`ls -sl -fl`; //remove edges that are `double up`, to avoid `outsticking lines` if (!`objExists leastEdgesPathSet`) sets -em -n leastEdgesPathSet; for ($i=0;$i0) $factor=4; $posA=`xform -q -ws -t ($ctrl+".cv["+$cv1Nr+"]")`; $posB=`xform -q -ws -t ($ctrl+".cv["+$cv2Nr+"]")`; xform -ws -t ((($posA[0]*$factor)+($posB[0]*1))/($factor+1)) ((($posA[1]*3)+($posB[1]*1))/4.0) ((($posA[2]*3)+($posB[2]*1))/4.0) ($ctrl+".cv["+$cv2Nr+"]"); } $posA=`xform -q -ws -t ($ctrl+".cv[1]")`; $posB=`xform -q -ws -t ($ctrl+".cv[3]")`; xform -ws -t ((($posA[0]*$factor)+($posB[0]*1))/($factor+1)) $posA[1] $posA[2] ($ctrl+".cv[1]"); $posA=`xform -q -ws -t ($ctrl+".cv[5]")`; $posB=`xform -q -ws -t ($ctrl+".cv[3]")`; xform -ws -t ((($posA[0]*$factor)+($posB[0]*1))/($factor+1)) $posA[1] $posA[2] ($ctrl+".cv[5]"); $posA=`xform -q -ws -t $ctrl`; rotate -r -p $posA[0] $posA[1] $posA[2] -os 0 0 $rotation ($ctrl+".cv[0:99]"); scale -r -p $posA[0] $posA[1] $posA[2] 1.35 1.35 1.35 ($ctrl+".cv[0:99]"); } global proc asFaceAddConstrained (string $target, string $sourceA, string $sourceB, float $value) { int $plugNr; string $targetName,$targetSide,$sourceAName,$sourceASide,$sourceBName,$sourceBSide,$psA,$psB; string $xyz[]={"x","y","z"}; string $tempString[]; tokenize $target "_" $tempString;$targetName=$tempString[0];$targetSide="_"+$tempString[1]; tokenize $sourceA "_" $tempString;$sourceAName=$tempString[0];$sourceASide="_"+$tempString[1]; tokenize $sourceB "_" $tempString;$sourceBName=$tempString[0];$sourceBSide="_"+$tempString[1]; if (!`objExists ($targetName+"Follow"+$targetSide)`) { createNode -n ($targetName+"Follow"+$targetSide) -p ($targetName+"Offset"+$targetSide) transform; parent ("SDK"+$targetName+$targetSide) ($targetName+"Follow"+$targetSide); createNode -n ($targetName+"ConstrainedPMAT"+$targetSide) plusMinusAverage; createNode -n ($targetName+"ConstrainedPMAR"+$targetSide) plusMinusAverage; createNode -n ($targetName+"ConstrainedPMAS"+$targetSide) plusMinusAverage; for ($z=0;$z-0.001) select -d $tempString[$i]; } if (size(`ls -sl`)) weightHammerVerts; select JawOpenLayer; if (!$nonSymmetrical) copySkinWeights -ss JawOpenLayerSC -ds JawOpenLayerSC -mirrorMode YZ -mirrorInverse -surfaceAssociation closestPoint -influenceAssociation closestJoint; if (`objExists JawOpenLayerDeleteComponent`) setAttr JawOpenLayerDeleteComponent.nodeState 0; currentTime $currentTime; select $sel; } global proc asFaceUpdateJawCurvesWeights () { global string $gMainPane; global string $gMainProgressBar; string $sel[]=`ls -sl`; string $geometry=`textField -q -tx asFaceFaceTextField`; string $skinCluster=`textField -q -tx asFaceSkinClusterTextField`; string $lowerTeeth=`textField -q -tx asFaceLowerTeethTextField`; string $tongue=`textField -q -tx asFaceTongueTextField`; float $posA[],$posB[],$posC[]; float $bbCurveTop[],$bbCurveBottom[]; float $faceFitScale=`getAttr FaceFitSkeleton.faceScale`; float $maxDist; string $tempString[],$ySel[],$zSelInv[],$infJoints[],$lipFalloffAreaVtxs[]; int $nonSymmetrical=`checkBox -q -v asFaceNonSymCheckBox`; int $numJawSmooths=`intField -q -v asFaceNumJawSmooths`; int $upperLipOuterNumCVs=`getAttr upperLipOuterCurve.spans`+1; int $vtxsFromLipToNose=3; if (`attributeExists vtxsFromLipToNose FaceFitSkeleton`) $vtxsFromLipToNose=`getAttr FaceFitSkeleton.vtxsFromLipToNose`; float $currentTime=`currentTime -q`; currentTime 0; progressBar -e -st ("Update Jaw Weights") -bp -ii 0 -min 0 -max 1 $gMainProgressBar; evalDeferred ("progressBar -e -ep "+$gMainProgressBar); if (`objExists JawOpenLayerDeleteComponent`) setAttr JawOpenLayerDeleteComponent.nodeState 1; if (`objExists jawArea`) delete jawArea; if (`objExists jawCurveVtxs`) delete jawCurveVtxs; asSelectCurveVtx JawCurve; $tempString=`ls -sl -fl`;select -cl; for ($i=0;$i>`; for ($i=0;$i>`; if ($dist<($maxDist/2.0)) skinPercent -tv JawJoint_M (($dist/$maxDist)*2) JawOpenLayerSC $jawCurveVtxs[$i]; } //taper off skinWeights towards the jawPivot, based on distance (50vtx) $posA=`xform -q -ws -t JawPivot`; $posB=`xform -q -ws -t upperLipOuterCurve.cv[$upperLipOuterNumCVs]`; $maxDist=`mag<<$posA[0]-$posB[0],$posA[1]-$posB[1],$posA[2]-$posB[2]>>`; for ($i=0;$i>`; if ($dist<($maxDist/2.0)) skinPercent -tv JawJoint_M ($dist/$maxDist) JawOpenLayerSC $jawCurveMidVtxs[$i]; } //Select vtxs with curve boundaries, first from BB polySeConstr for speed duplicate -n JawCurveTopSampler JawCurveTop; duplicate -n JawCurveBottomSampler JawCurveBottom; select JawCurveTopSampler.cv[0:6] JawCurveBottomSampler.cv[0:5]; move -x 0; //include Jaw vtx move -r 0 -0.001 0 JawCurveBottomSampler.cv[5]; //Jaw can be lower than throat on some characters $posA=`xform -q -ws -t Jaw`; $posB=`xform -q -ws -t Throat`; if ($posA[1]<$posB[1]) { xform -ws -t 0 $posA[1] $posA[2] JawCurveBottomSampler.cv[5]; //And there might be vtx`s lower then Jaw loc $posC=`xform -q -ws -t JawCurveBottomSampler.cv[4]`; xform -ws -t 0 ($posA[1]-($faceFitScale/10.0)) (($posA[2]+$posC[2])/2.0) JawCurveBottomSampler.cv[4]; } spaceLocator -n samplerLocator; spaceLocator -n samplerLocatorTop; spaceLocator -n samplerLocatorBottom; parent samplerLocatorTop samplerLocatorBottom samplerLocator; select JawCurveTopSampler samplerLocatorTop;geometryConstraint -weight 1; select samplerLocator samplerLocatorTop;pointConstraint; select JawCurveBottomSampler samplerLocatorBottom;geometryConstraint -weight 1; select samplerLocator samplerLocatorBottom;pointConstraint; $bbCurveTop=`xform -q -ws -bb JawCurveTopSampler`; $bbCurveBottom=`xform -q -ws -bb JawCurveBottomSampler`; select JawOpenLayer; //polySelectConstraint -m 3 -t 1 -d 3 -db $bbCurveBottom[1] $bbCurveTop[4] -da 0 1 0 -dp 0 0 0; //updated to all for jaw to be under world Y axis(fish) polySelectConstraint -m 3 -t 1 -d 3 -db 0 (($bbCurveTop[4]-$bbCurveBottom[1])/1.99) -dp 0 (($bbCurveTop[4]+$bbCurveBottom[1])/2.0) 0 -da 0 1 0; $ySel=`ls -sl`; polySelectConstraint -m 3 -t 1 -d 3 -db 0 100 -da 0 0 1 -dp 0 0 ($bbCurveBottom[2]-100); $zSelInv=`ls -sl`; polySelectConstraint -m 0; select $ySel; select -d $zSelInv; asInvertSelection; string $outsideOuterBoundsVtxs[]=`ls -sl`; $bbCurveTop=`xform -q -ws -bb JawCurveTopSampler`; $bbCurveBottom=`xform -q -ws -bb JawCurveBottomSampler`; select JawOpenLayer; //polySelectConstraint -m 3 -t 1 -d 3 -db $bbCurveBottom[1] $bbCurveTop[1] -da 0 1 0 -dp 0 0 0; //updated to all for jaw to be under world Y axis(fish) polySelectConstraint -m 3 -t 1 -d 3 -db 0 (($bbCurveTop[1]-$bbCurveBottom[1])/2.0) -dp 0 (($bbCurveTop[1]+$bbCurveBottom[1])/2.0) 0 -da 0 1 0; $ySel=`ls -sl`; polySelectConstraint -m 3 -t 1 -d 3 -db 0 100 -da 0 0 1 -dp 0 0 ($bbCurveBottom[5]-100); $zSelInv=`ls -sl`; polySelectConstraint -m 0; select $ySel; select -d $zSelInv; string $insideInnerBoundsVtxs[]=`ls -sl`; $bbCurveTop=`xform -q -ws -bb JawCurveTopSampler`; $bbCurveBottom=`xform -q -ws -bb JawCurveBottomSampler`; select JawOpenLayer; //polySelectConstraint -m 3 -t 1 -d 3 -db $bbCurveTop[4] $bbCurveTop[1] -da 0 1 0 -dp 0 0 0; //updated to all for jaw to be under world Y axis(fish) polySelectConstraint -m 3 -t 1 -d 3 -db 0 (($bbCurveTop[4]-$bbCurveTop[1])/2.0) -dp 0 (($bbCurveTop[4]+$bbCurveTop[1])/2.0) 0 -da 0 1 0; string $yOnBoundSel[]=`ls -sl`; polySelectConstraint -m 3 -t 1 -d 3 -db 0 ((($bbCurveBottom[5]-$bbCurveBottom[2])/2.0)*1.001) -da 0 0 1 -dp 0 0 (($bbCurveBottom[5]+$bbCurveBottom[2])/2.0); string $zOnBoundSelInv[]=`ls -sl`; polySelectConstraint -m 0; select $yOnBoundSel $zOnBoundSelInv; select -d $outsideOuterBoundsVtxs; string $onBoundsVtxs[]=`ls -sl -fl`; select -cl; for ($i=0;$i0) select -add $onBoundsVtxs[$i]; } select -add $insideInnerBoundsVtxs; select -d lipAreaJawOpenLayer; sets -n jawArea; sets -add FaceBuildingSets jawArea; select -d $jawCurveVtxs $jawCurveMidVtxs; if (size(`ls -sl`)) { weightHammerVerts; copySkinWeights -ss -ds -mirrorMode YZ -mirrorInverse -surfaceAssociation closestPoint -influenceAssociation closestJoint; } select jawArea; //asSmoothFlood FaceJoint_M JawJoint_M $numJawSmooths; select JawOpenLayer JawCurve; copySkinWeights -noMirror -surfaceAssociation closestPoint -influenceAssociation closestJoint; //fix the weighting just above upperLip select lipAreaJawOpenLayer; string $completedVtxs[]=`ls -sl -fl`; //eval ("select "+`getAttr FaceFitLipOuter.upperSelection`); eval ("select "+`asGetFaceFitSelection upperLipOuterCurve`); $tempString=`ls -sl -fl`; float $bb[]=`xform -q -bb`; select -cl; for ($i=0;$i0) // continue; select $lipOutherVtxs[$i]; float $prevWeights[]; float $onLipWeights[]=`skinPercent -ignoreBelow 0.001 -q -v JawOpenLayerSC`; select $lipOutherVtxs[$i]; for ($y=0;$y<$vtxsFromLipToNose;$y++) { asWsPickWalk 0 1 0; // refresh; $tempString=`ls -sl -fl`; if (`sets -im lipAreaJawOpenLayer $tempString[0]`) continue; float $newWeight=$onLipWeights[1]-(($onLipWeights[1]/$vtxsFromLipToNose)*$y); skinPercent -tv JawJoint_M $newWeight JawOpenLayerSC; } } if (!$nonSymmetrical) copySkinWeights -ss JawOpenLayerSC -ds JawOpenLayerSC -mirrorMode YZ -mirrorInverse -surfaceAssociation closestPoint -influenceAssociation closestJoint; select jawArea; select -d jawCurveVtxs; currentTime 30; asSmoothFlood FaceJoint_M JawJoint_M $numJawSmooths; if (!$nonSymmetrical) copySkinWeights -ss JawOpenLayerSC -ds JawOpenLayerSC -mirrorMode YZ -mirrorInverse -surfaceAssociation closestPoint -influenceAssociation closestJoint; if (`objExists JawOpenLayerDeleteComponent`) setAttr JawOpenLayerDeleteComponent.nodeState 0; delete samplerLocator JawCurveTopSampler JawCurveBottomSampler; //remove all jaw weights, as the jawAre might have been reduced by adjustment of JawCurves skinPercent -tv JawJoint_M 0 JawSC JawLayer; //transfer to JawLayer mesh - from:LipDeform select `asobjSetCast lipArea {} LipDeform`; select -add `asobjSetCast lipArea {} JawLayer`; copySkinWeights -noMirror -surfaceAssociation closestPoint -influenceAssociation closestJoint; //Hammer $lipFalloffAreaVtxs select `asobjSetCast lipFalloffArea {} JawOpenLayer`; $lipFalloffAreaVtxs=`ls -sl -fl`; select $lipFalloffAreaVtxs; if (size(`ls -sl`)) weightHammerVerts; //if teeth part of Main mesh if (`gmatch $lowerTeeth ($geometry+"*")` && `gmatch $lowerTeeth "*[.]*"`) { eval ("select "+$lowerTeeth); ConvertSelectionToVertices; $tempString=`ls -sl`; select `asobjSetCast "" $tempString JawOpenLayer`; skinPercent -tv JawJoint_M 1 JawOpenLayerSC `ls -sl`; } //if tongue part of Main mesh //if (`gmatch $tongue ($geometry+"*")` && `gmatch $tongue "*[.]*"`)//a case had tongue part of a InnerMouth object if (`gmatch $tongue "*[.]*"`) { eval ("select "+$tongue); ConvertSelectionToVertices; $tempString=`ls -sl`; select `asobjSetCast "" $tempString JawOpenLayer`; skinPercent -tv JawJoint_M 1 JawOpenLayerSC `ls -sl`; } currentTime 0 ; if (`objExists FaceFitLipMainLeft`) { select -r `asobjSetCast lipArea {} JawOpenLayer`; asInvertSelection; copySkinWeights -ss -ds -mirrorMode YZ -mirrorInverse -surfaceAssociation closestPoint -influenceAssociation closestJoint; } else copySkinWeights -ss JawOpenLayerSC -ds JawOpenLayerSC -mirrorMode YZ -mirrorInverse -surfaceAssociation closestPoint -influenceAssociation closestJoint; currentTime $currentTime; select $sel; } global proc asWsPickWalk (int $x, int $y, int $z) { string $sel[]=`ls -sl`; if (size($sel)==0) error "No selection provided to asWsPickWalk"; float $posA[]=`xform -q -ws -t $sel[0]`; ConvertSelectionToEdges; ConvertSelectionToVertices; string $expandSel[]=`ls -sl -fl`; float $dist,$maxWeight; //float $minDist=9999; for ($i=0;$i$posA[0]) continue; if ($y==-1 && $posB[1]>$posA[1]) continue; if ($z==-1 && $posB[2]>$posA[2]) continue; $xDist=abs($posB[0]-$posA[0]); $yDist=abs($posB[1]-$posA[1]); $zDist=abs($posB[2]-$posA[2]); $xyzDist=$xDist+$yDist+$zDist; if (abs($x)) $weight=$xDist/$xyzDist; if (abs($y)) $weight=$yDist/$xyzDist; if (abs($z)) $weight=$zDist/$xyzDist; if ($weight>$maxWeight) { $maxWeight=$weight; select $expandSel[$i]; } } string $tempString[]=`ls -sl -fl`; if (size($tempString)>1) select $tempString[0]; } global proc string[] asDeformer (string $deformer) { int $deformationUseComponentTags; string $return[]; //Maya2022 needs deformationUseComponentTags optionVar set to 0, to create legacy deformer-sets if (`asMayaVersionAsFloat`>=2022) { $deformationUseComponentTags=`optionVar -q deformationUseComponentTags`; if ($deformationUseComponentTags) optionVar -iv deformationUseComponentTags 0; } if ($deformer=="softMod") $return=`softMod -falloffMode 1 -falloffAroundSelection 0`; if ($deformer=="cluster") $return=`cluster -envelope 1`; if ($deformationUseComponentTags) optionVar -iv deformationUseComponentTags 1; return $return; } global proc asCurveOffsetMesh (string $curve, string $geometry ,float $offset) { float $spans=`getAttr ($curve+".spans")`; float $startPos[]=`xform -q -ws -t ($curve+".cv[0]")`; float $endPos[]=`xform -q -ws -t ($curve+".cv[99]")`; rebuildCurve -ch 0 -rpo 1 -rt 0 -end 1 -kr 0 -kcp 0 -kep 1 -kt 0 -s 20 -d 3 -tol 0.01 $curve; spaceLocator -n constraintLoc; spaceLocator -n constraintLoc2; parent constraintLoc2 constraintLoc; setAttr constraintLoc2.tx $offset; select $geometry constraintLoc; geometryConstraint -weight 1; select $geometry constraintLoc; normalConstraint -weight 1 -aimVector 1 0 0 -upVector 0 1 0 -worldUpType "vector" -worldUpVector 0 1 0; for ($i=0;$i<23;$i++) { $posA=`xform -q -ws -t ($curve+".cv["+$i+"]")`; xform -ws -t $posA[0] $posA[1] $posA[2] constraintLoc; $posB=`xform -q -ws -t constraintLoc2`; xform -ws -t $posB[0] $posB[1] $posB[2] ($curve+".cv["+$i+"]"); } rebuildCurve -ch 0 -rpo 1 -rt 0 -end 1 -kr 0 -kcp 0 -kep 1 -kt 0 -s $spans -d 3 -tol 0.01 $curve; delete constraintLoc; xform -ws -t $startPos[0] $startPos[1] $startPos[2] ($curve+".cv[0]"); xform -ws -t $endPos[0] $endPos[1] $endPos[2] ($curve+".cv[99]"); } global proc asFaceWrapDeformToFace () { float $pos[]; string $sel[]=`ls -sl`; string $geometry=`textField -q -tx asFaceFaceTextField`; string $shape; string $tempString[]; //remove possible existing defomers first for ($i=0;$i0) $side="_L"; // select $EyeBrowLayerGeos[$i]; // DeleteHistory; if (`objExists ("EyeBrowWireCurve"+$side)`) delete ("EyeBrowWireCurve"+$side); duplicate -n ("EyeBrowWireCurve"+$side) EyeBrowMainCurve; if ($side=="_L") { setAttr EyeBrowWireCurve_L.sx -1; makeIdentity -a 1 -t 0 -r 0 -s 1 EyeBrowWireCurve_L; } rebuildCurve -ch 0 -rpo 1 -rt 0 -end 1 -kr 0 -kcp 0 -kep 1 -kt 0 -s $spans -d 3 -tol 0.000393701 ("EyeBrowWireCurve"+$side); $tempString=`wire -gw false -en 1.000000 -ce 0.000000 -li 0.000000 -w ("EyeBrowWireCurve"+$side) $EyeBrowLayerGeos[$i]`; $tempString[0]=`rename $tempString[0] ("EyeBrowWire"+$side)`; string $wireDeformer=$tempString[0]; // connectAttr ("EyeBrowWireScale"+$side+".sx") ($wireDeformer+".scale[0]"); //set dropoffDistance to the width of the geometry (5x to allow for scaling) $bb=`xform -q -ws -bb $EyeBrowLayerGeos[$i]`; setAttr ("EyeBrowWire"+$side+".dropoffDistance[0]") (($bb[3]-$bb[0])*5); for ($y=0;$y0) $cv=$y+1; if ($y==size($eyeBrows)-1) $cv=$y+2; select -r ("EyeBrowWireCurve"+$side+".cv["+$cv+"]"); $tempString=`newCluster " -envelope 1"`; rename $tempString[0] ($eyeBrows[$y]+"WireCluster"+$side); rename $tempString[1] ($eyeBrows[$y]+"WireClusterHandle"+$side); $tempString=`listConnections ($eyeBrows[$y]+"WireCluster"+$side+".message")`; rename $tempString[0] ($eyeBrows[$y]+"WireClusterSet"+$side); parent ($eyeBrows[$y]+"WireClusterHandle"+$side) EyeBrowWire; } sets -add ($eyeBrows[0]+"WireClusterSet"+$side) ("EyeBrowWireCurve"+$side+".cv[1]"); sets -add ($eyeBrows[size($eyeBrows)-1]+"WireClusterSet"+$side) ("EyeBrowWireCurve"+$side+".cv["+`size($eyeBrows)`+"]"); for ($y=0;$y>); $tempString=`sphere -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r (($mag*5)/$faceFitScale) -d 3 -ut 0 -tol 0.01 -s 8 -nsp 4 -ch 0`; rename $tempString[0] ($onFaceCtrls[$i]+"Sphere"); parent -add -s ($onFaceCtrls[$i]+"SphereShape") $onFaceCtrls[$i]; delete ($onFaceCtrls[$i]+"Shape"); rename ($onFaceCtrls[$i]+"SphereShape") ($onFaceCtrls[$i]+"Shape"); delete ($onFaceCtrls[$i]+"Sphere"); if (`stringArrayCount $onFaceCtrls[$i] $aCtrls`) sets -e -forceElement asFaceGreenSG ($onFaceCtrls[$i]+"Shape"); if (`stringArrayCount $onFaceCtrls[$i] $bCtrls`) sets -e -forceElement asFaceRedSG ($onFaceCtrls[$i]+"Shape"); if (`stringArrayCount $onFaceCtrls[$i] $cCtrls`) sets -e -forceElement asFaceBlueSG ($onFaceCtrls[$i]+"Shape"); if (!$keepOffset) continue; $posB=`xform -q -ws -t ($onFaceCtrls[$i]+".cv[0][0]")`; $mag=mag(<<$posA[0]-$posB[0],$posA[1]-$posB[1],$posA[2]-$posB[2]>>); move -r 0 0 $mag ($onFaceCtrls[$i]+".cv[0:99][0:99]"); } select $sel; } global proc asFaceDetachControllers () { string $allFaceGeoString=`textField -q -tx asFaceAllHeadTextField`; string $tempString[]; tokenize $allFaceGeoString $tempString; for ($i=0;$i-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; for ($y=1;$y<99;$y++) { if (`objExists ($upperLower+"LidMain"+$y+$side)`) $numLid=$y; else break; } polyPlane -n ($upperLower+"EyeLidCage"+$side) -w 1 -h 1 -sx ($numLid-1) -sy 1 -ax 0 1 0 -cuv 2 -ch 1; for ($y=1;$y<$numLid+1;$y++) { $pos=`xform -q -ws -t ($upperLower+"LidMain"+$y+$side)`; xform -ws -t $pos[0] $pos[1] $pos[2] ($upperLower+"EyeLidCage"+$side+".vtx["+($y-1)+"]"); xform -ws -t $pos[0] $pos[1] $pos[2] ($upperLower+"EyeLidCage"+$side+".vtx["+($y-1+$numLid)+"]"); $pos=`xform -q -ws -t FitEyeBall`; scale -r -p ($pos[0]*$b) $pos[1] $pos[2] 4 4 4 ($upperLower+"EyeLidCage"+$side+".vtx["+($y-1+$numLid)+"]"); } select ($upperLower+"EyeLidCage"+$side); for ($y=1;$y<$numLid+1;$y++) select -add ($upperLower+"LidMain"+$y+$side); $tempString=`newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"`; rename $tempString[0] ($upperLower+"EyeLidCageSC"+$side); select $geometry ($upperLower+"EyeLidCage"+$side); copySkinWeights -noMirror -surfaceAssociation closestPoint -influenceAssociation closestJoint; for ($y=1;$y<$numLid+1;$y++) { $infs=`skinPercent -ignoreBelow 0.001 -q -t ($upperLower+"EyeLidCageSC"+$side) ($upperLower+"EyeLidCage"+$side+".vtx["+($y-1)+"]")`; $values=`skinPercent -ignoreBelow 0.001 -q -v ($upperLower+"EyeLidCageSC"+$side) ($upperLower+"EyeLidCage"+$side+".vtx["+($y-1)+"]")`; for ($z=0;$z-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; for ($y=1;$y<99;$y++) { if (`objExists ($upperLower+"LidMain"+$y+$side)`) $numLid=$y; else break; } for ($y=1;$y<$numLid+1;$y++) $addInfCmd+=" -ai "+$upperLower+"LidMain"+$y+$side; } } $addInfCmd+=" "+$sc; eval ($addInfCmd); //dualQ weight eyeLashes to match the eyeLids if (!$gameEngine) setAttr ($sc+".skinningMethod") 1; } //cageWeights to eyeLash geo for ($i=0;$i-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) {$upperLower="upper";$teeth=$upperTeethInVtxString;$teethJoint=$upperTeethJoint;} else {$upperLower="lower";$teeth=$lowerTeethInVtxString;$teethJoint=$lowerTeethJoint;} if ($teeth=="") continue; eval ("select "+$teeth); $teethObjects=`ls -sl -o`; for ($i=0;$i0) { $targetName=$name+"_"+`substituteAllString $geos[$a] ":" "_"`; rename $name $targetName; } if (`objExists tempRenamingBlendShapeTarget`) rename tempRenamingBlendShapeTarget $name; asLockAttr $targetName 0 0 0 0; move -r ($cheekPos[0]*2.5*$sideFactor*$sideStepNr) 0 0 $targetName; } if (`stringArrayCount $attrs[$y] $blendedAttrs`) asSetBlendedAttribute $objs[$i] $attrs[$y] 0 0; else setAttr ($objs[$i]+"."+$attrs[$y]) 0; setDrivenKeyframe -itt linear -ott linear -dv 0 -v 0 -currentDriver ($objs[$i]+"."+$attrs[$y]) ($asFaceBS+"."+$name); setDrivenKeyframe -itt linear -ott linear -dv $drivingValue -v 1 -currentDriver ($objs[$i]+"."+$attrs[$y]) ($asFaceBS+"."+$name); setAttr ($asFaceBS+"_"+$name+".preInfinity") 4; setAttr ($asFaceBS+"_"+$name+".postInfinity") 4; if ($values[$z]>0) setAttr ($asFaceBS+"_"+$name+".preInfinity") 1; // no neg weight when drive<0 else setAttr ($asFaceBS+"_"+$name+".postInfinity") 0; // no neg weight when drive>0 // if ($attrs[$y]=="translateX" && `attributeExists txMixed $objs[$i]`) connectAttr -f ($objs[$i]+".txMixed") ($asFaceBS+"_"+$name+".input"); // if ($attrs[$y]=="translateY" && `attributeExists tyMixed $objs[$i]`) connectAttr -f ($objs[$i]+".tyMixed") ($asFaceBS+"_"+$name+".input"); if (`gmatch $objs[$i] "ctrlMouthCorner_*"`) connectAttr -f ("bwctrlMouthCorner"+$side+"_"+$attrs[$y]+".output") ($asFaceBS+"_"+$name+".input"); if (!$keepBSTarget) delete $name; } } } } if ($limitsStatus) setAttr ctrlBox.limits 1; //reorderDeformers "asFaceBS" $skinCluster $geometry; $keepSDKs={"SDKEye_*","SDKIris_*","SDKPupil_*"}; if ($keepJoints) { //new JawOpenSDK to drive tongue & lowerTeeth setAttr ctrlMouth_M.ty -1; if (`objExists lowerTeethFollow_M`) { $pos=`getAttr lowerTeethFollow_M.t`; $rot=`getAttr lowerTeethFollow_M.r`; } if (`objExists Tongue0Follow_M`) { $pos2=`getAttr Tongue0Follow_M.t`; $rot2=`getAttr Tongue0Follow_M.r`; } setAttr ctrlMouth_M.ty 0; dgdirty -a; refresh; $tempString=`ls -type blendWeighted "bwSDK*_*_*"`; for ($i=0;$i-2;$b=$b-2) { if ($b==1) {$side="_R";$eyeGeoText=$rightEye;} else {$side="_L";$eyeGeoText=$leftEye;} if (!`objExists "squashEyeFfd1Set_R"`) continue; clear $eyeGeos; tokenize $eyeGeoText $tempString; for ($i=0;$i-2;$b=$b-2) { if ($b==1) {$side="_R";$eyeGeoText=$rightEye;} else {$side="_L";$eyeGeoText=$leftEye;} if (!`objExists "squashEyeFfd1Set_R"`) continue; clear $eyeGeos; tokenize $eyeGeoText $tempString; for ($i=0;$ieyeRot if (`gmatch $rightEye ($geometry+"[.]*")` && `objExists ctrlARKit_M`) { delete `listConnections -s 0 -d 1 -type animCurve bwctrlARKit_M_eyeLookUpLeft bwctrlARKit_M_eyeLookDownLeft bwctrlARKit_M_eyeLookOutLeft bwctrlARKit_M_eyeLookInLeft`; delete `listConnections -s 0 -d 1 -type animCurve bwctrlARKit_M_eyeLookUpRight bwctrlARKit_M_eyeLookDownRight bwctrlARKit_M_eyeLookOutRight bwctrlARKit_M_eyeLookInRight`; } //if tongue is part of main-mesh, then remove SDK from Jaw if (`gmatch $tongue ($geometry+"[.]*")` && `objExists ctrlARKit_M`) delete `listConnections -scn 1 -s 1 -d 0 -type blendWeighted SDKJaw_M`; //update FaceAllSet //was Removed, as this makes ReBuild with "Keep BlendShapes" to complex //was Resored as ReBuild would not work with otherBS e.g. asFaceBS_model_brow_L select `ls`; for ($i=0;$i0 || $bbMax[0]<0) { $geoIsHalfSideOnly[$i]=1; $halfSideGeos[size($halfSideGeos)]=$geos[$i]; } } //asBSGetTargets skips _L targets, so check these as well for ($i=0;$i0.99 && $targetWeights[$i]<1.01) $targetNum=$i; } if ($targetWeightsSum>1.01 || $targetWeightsSum<0.99) { for ($i=0;$i0.001 || $targetWeights[$i]<-0.001) print ("// asFaceBS."+$targets[$i]+" = "+$targetWeights[$i]+"\n"); } select asFaceBS; AttributeEditor; error "Must have one target set to \"1\", and the rest set to \"0\"\n"; } if (`objExists deleteThis`) delete deleteThis; createNode -n deleteThis transform; float $cheekPos[]=`xform -q -ws -t JawPivot`; string $targetName=$targets[$targetNum]; if (`objExists $targetName`) error ("Object "+$targetName+" exists"); if (!`attributeExists ($targetName+"_tweaked") FaceFitSkeleton`) addAttr -k 1 -dv 1 -ln ($targetName+"_tweaked") -at bool FaceFitSkeleton; setAttr ("FaceFitSkeleton."+$targetName+"_tweaked") 1; //make a combinedMesh for the $geoIsHalfSideOnly objects, to wrap to a combined mesh if (`intArrayCount 1 $geoIsHalfSideOnly`) { if (`objExists faceCombined`) delete faceCombined; for ($i=0;$i1) { polyUnite -ch 0 -mergeUVSets 1 -name faceCombinedDefault; delete $tempString; } else rename $tempString[0] faceCombinedDefault; for ($i=0;$i1) { polyUnite -ch 0 -mergeUVSets 1 -name faceCombined; delete $tempString; } else rename $tempString[0] faceCombined; sets -e -forceElement initialShadingGroup faceCombined faceCombinedDefault; parent faceCombined faceCombinedDefault deleteThis; setAttr faceCombined.v 0; setAttr faceCombinedDefault.v 0; duplicate -n faceCombinedMirrorDriver faceCombined; move -r (`getAttr ctrlBoxOffset.tx`*2) 0 0 faceCombinedMirrorDriver; setAttr faceCombinedMirrorDriver.sx -1; move -r ($cheekPos[0]*2.5) 0 0 faceCombined; connectAttr faceCombined.outMesh faceCombinedMirrorDriver.inMesh; select faceCombinedDefault faceCombinedMirrorDriver; blendShape -n faceCombinedMirrorDriverBS -frontOfChain; } for ($a=0;$a0.99 && $targetWeights[$i]<1.01) $targetNum=$i; } if ($targetWeightsSum<1) continue; if ($targets[$targetNum]!="") $target=$targets[$targetNum]; //ARKit targets have no suffix if (!(`gmatch $target "*_R*"` || `gmatch $target "*_L*"` || `gmatch $target "*_M*"`)) { aliasAttr ($target+"_M") ($asFaceBS+"."+$target); $aliasAttrCmd="aliasAttr "+$target+" "+$asFaceBS+"."+$target+"_M"; $target=$target+"_M"; } if ($a==0) $targetName=$target; else $targetName=$target+"_"+`substituteAllString $geos[$a] ":" "_"`; if (`gmatch $targetName "*_R*"`) { $targetLeft=`substitute "_R" $targetName "_L"`; print ("$targetName="+$targetName+" $targetLeft="+$targetLeft+"\n"); if (!`attributeExists ($targetLeft+"_tweaked") FaceFitSkeleton`) addAttr -k 1 -dv 1 -ln ($targetLeft+"_tweaked") -at bool FaceFitSkeleton; setAttr ("FaceFitSkeleton."+$targetLeft+"_tweaked") 1; } if ($multiply!=1) setAttr ($asFaceBS+".w["+$targetNum+"]") $multiply; setAttr ($skinCluster+".envelope") 0; // duplicate -n $targetName $geos[$a]; //duplicate geo causes onFace ctrls to move (due to wrapDeformer confused when duplicating driver, and moving copy), so instead create mesh $tempString[0]=`createNode mesh`; $tempString=`listRelatives -p $tempString[0]`; rename $tempString[0] $targetName; connectAttr ($geos[$a]+".outMesh") ($targetName+".inMesh"); refresh; disconnectAttr ($geos[$a]+".outMesh") ($targetName+".inMesh"); sets -e -forceElement initialShadingGroup $targetName; addAttr -ln sourceObject -dt "string" $targetName; setAttr -type "string" ($targetName+".sourceObject") $geos[$a]; asLockAttr $targetName 0 0 0 0; setAttr ($skinCluster+".envelope") 1; parent $targetName deleteThis; select $targetName; $tempString=`listRelatives -f -s $targetName`; for ($i=0;$i1) select deleteThis; } global proc string[] asBSGetTargets () { string $targets[]; string $tempString[],$tempString2[]; $tempString=`listAttr -m asFaceBS.weight`; for ($i=0;$i-2;$b=$b-2) { if ($b==1) $ctrlSide="_R"; else $ctrlSide="_L"; if ($side=="_M") $ctrlSide="_M"; if ($side=="_M" && $b==-1) continue; $asDSObjNameSideLess=$asDSObjName; if (`gmatch $asDSObjName "*_R"` || `gmatch $asDSObjName "*_M"`) { $numChar=size($asDSObjName); $asDSObjNameSideLess=`substring $asDSObjNameSideLess 1 ($numChar-2)`; } $driverName=$asDSObjNameSideLess+$ctrlSide; if ($a==0)//addAttr and create ctrl if needed { if (!`objExists $driverName`) { $tempString=`circle -c 0 0 0 -nr 0 0 1 -sw 360 -r 0.1 -d 3 -ut 0 -tol 0.000393701 -s 8 -ch 0`; rename $tempString[0] $driverName; parent $driverName ctrlBox; $tempString=`listRelatives -s $driverName`; setAttr ($tempString[0]+".overrideEnabled") 1; setAttr ($tempString[0]+".overrideColor") 13; xform -os -t 0 0 0 -ro 0 0 0 -s 1 1 1 $driverName; if ($ctrlSide!="_M") setAttr ($driverName+".tx") ($cheekPos[0]*0.2*$b); } if (!`attributeExists $asDSAttrName $driverName`) addAttr -k 1 -ln $asDSAttrName -at double -smn 0 -hsn 1 -smx 10 -hsx 1 -dv 10 $driverName; } if ($a>0) { rename ($asDSAttrName+$ctrlSide) ("TEMP_"+$asDSAttrName+$ctrlSide); rename ($targetName+$ctrlSide) ($asDSAttrName+$ctrlSide); } blendShape -e -tc 0 -t $geos[$a] `getAttr -s ($asFaceBS+".w")` ($asDSAttrName+$ctrlSide) 1 $asFaceBS; if ($a>0) { rename ($asDSAttrName+$ctrlSide) ($targetName+$ctrlSide); rename ("TEMP_"+$asDSAttrName+$ctrlSide) ($asDSAttrName+$ctrlSide); } setDrivenKeyframe -itt "linear" -ott "spline" -v 0 -dv 0 -cd ($driverName+"."+$asDSAttrName) ($asFaceBS+"."+$asDSAttrName+$ctrlSide); setDrivenKeyframe -itt "linear" -ott "spline" -v 1 -dv 10 -cd ($driverName+"."+$asDSAttrName) ($asFaceBS+"."+$asDSAttrName+$ctrlSide); selectKey -add -k -f 0 -f 10 ($asFaceBS+"_"+$asDSAttrName+$ctrlSide); setInfinity -pri cycleRelative -poi cycleRelative; string $setAttrCmdExtra="setAttr "+$driverName+"."+$asDSAttrName+" 0;"; setAttr -type "string" faceBuildPose.udAttr (`getAttr faceBuildPose.udAttr`+$setAttrCmdExtra); } } //delete targets, and re-extract, to get same values and behaviour as standardextracted target delete deleteThis; asGoToBuildPose faceSetup; if ($ctrlSide=="_M") setAttr ($asDSObjNameSideLess+"_M."+$asDSAttrName) 10; else setAttr ($asDSObjNameSideLess+"_R."+$asDSAttrName) 10; dgdirty -a; asBSAdjustTarget; } global proc asFaceConvertControlToSoftMod () { int $b=1; int $falloffMode=1; int $nonSymmetrical=`checkBox -q -v asFaceNonSymCheckBox`; float $t[],$r[],$s[]; float $falloffRadius=1; float $currentTime=`currentTime -q`; float $ctrlScale=`getAttr OnFacecontrols.sx`; string $geometry=`textField -q -tx asFaceFaceTextField`; string $skinCluster=`textField -q -tx asFaceSkinClusterTextField`; string $sel[]=`ls -sl`; string $rootLevelObjects[]=`ls -as`; string $tempString[]; tokenize $sel[0] "_" $tempString; string $fitJoint=$tempString[0]; string $side="_"+$tempString[1]; //string $deformJoint=$fitJoint+"Joint"+$side; string $falloffCurveString; if ($side=="_L" && !$nonSymmetrical) error "must be Right side"; if ($side=="_R") $b=-1; for ($i=0;$iFit section must be completed first"; float $pos[]; string $tempString[]; string $headJoint=`getAttr FaceFitSkeleton.HeadJoint`; string $geometry=`textField -q -tx asFaceFaceTextField`; if (`objExists faceCage`) delete faceCage; string $asGeometryFile=`asGetScriptLocation`+"/AdvancedSkeleton5Files/div/asGeometry.ma"; file -i $asGeometryFile; parent -w faceCage; setAttr faceCage.v 1; if (`objExists Mannequin_Geometry`) delete Mannequin_Geometry; if (`objExists Skeleton_Geometry`) delete Skeleton_Geometry; if (`objExists SkinCage_Geometry`) delete SkinCage_Geometry; int $vtxs[]={0,1,2,3,4,5,6,7,8,9, 10,11,12,13, 14,16,17,18,20,21, 22,23, 24,25}; string $dests[]={"JawCurve.cv[3] ","Jaw","JawCorner","Throat","upperLipOuterCurve.cv[99]","lowerLipOuterCurve.cv[0]","JawPivot","Cheek","NoseCorner","NoseUnder", "CheekRaiser","upperLipOuterCurve.cv[0]","Nose",("lowerEyeLidOuterCurve.cv["+(`getAttr lowerEyeLidOuterCurve.spans`/2)+"]"), "lowerEyeLidOuterCurve.cv[0]","lowerEyeLidOuterCurve.cv[99]","EyeBrowMain3","EyeBrowMain0","EyeBrowMain6","EyeBrowOuterCurve.cv[99]", ("upperEyeLidOuterCurve.cv["+(`getAttr upperEyeLidOuterCurve.spans`/2)+"]"),("EyeBrowOuterCurve.cv["+(`getAttr EyeBrowOuterCurve.spans`/2)+"]"), "EyeBrowOuterCurve.cv[0]","JawCurveTop.cv[3]"}; for ($i=0;$i-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; for ($b=0;$b<3;$b++) { if ($b==0) $outerMain="Outer"; if ($b==1) $outerMain="Main"; if ($b==2) $outerMain="Inner"; rebuildCurve -n ($upperLower+$lidLip+$outerMain+"Curve2") -ch 0 -rpo 0 -rt 0 -end 1 -kr 0 -kcp 0 -kep 1 -kt 0 -s 4 -d 3 -tol 0.000393701 ($upperLower+$lidLip+$outerMain+"Curve"); setAttr ($upperLower+$lidLip+$outerMain+"Curve2.v") 0; parent ($upperLower+$lidLip+$outerMain+"Curve2") topologyConstruction; } select ($upperLower+$lidLip+"OuterCurve2") ($upperLower+$lidLip+"MainCurve2") ($upperLower+$lidLip+"InnerCurve2"); $tempString=`loft -n ($upperLower+$lidLip+"Surface") -ch 1 -u 1 -c 0 -ar 1 -d 1 -ss 1 -rn 0 -po 0 -rsn true`; setAttr ($upperLower+$lidLip+"Surface.v") 0; rename $tempString[1] ($upperLower+$lidLip+"Loft"); connectAttr ("topologyConstruction."+$lidLip+"Degree") ($upperLower+$lidLip+"Loft.degree"); $tempString=`nurbsToPoly -n ($upperLower+$lidLip) -mnd 1 -ch 1 -f 2 -pt 1 -pc 200 -chr 0.1 -ft 0.01 -mel 0.001 -d 0.1 -ut 2 -un 8 -vt 3 -vn 1 -uch 0 -ucr 0 -cht 0.2 -es 0 -ntr 0 -mrt 0 -uss 1 ($upperLower+$lidLip+"Surface")`; rename $tempString[1] ($upperLower+$lidLip+"NurbsTessellate"); parent ($upperLower+$lidLip+"Surface") ($upperLower+$lidLip) topologyConstruction; connectAttr ("topologyConstruction."+$lidLip+"UNumber") ($upperLower+$lidLip+"NurbsTessellate.uNumber"); connectAttr ("topologyConstruction."+$lidLip+"VNumber") ($upperLower+$lidLip+"NurbsTessellate.vNumber"); sets -e -forceElement asRedSG ($upperLower+$lidLip); rename ($upperLower+$lidLip) ($upperLower+$lidLip+"_R"); instance -n ($upperLower+$lidLip+"_L") ($upperLower+$lidLip+"_R"); setAttr ($upperLower+$lidLip+"_L.scaleX") -1; } } polyPlane -n NosePatch -w 1 -h 1 -sx 1 -sy 2 -ax 0 1 0 -cuv 2 -ch 0; parent NosePatch topologyConstruction; sets -e -forceElement asGreen2SG NosePatch; $pos=`xform -q -ws -t NoseCorner`; xform -ws -t $pos[0] $pos[1] $pos[2] NosePatch.vtx[0:5]; $pos=`xform -q -ws -t NoseUnder`; xform -ws -t $pos[0] $pos[1] $pos[2] NosePatch.vtx[1]; $pos=`xform -q -ws -t Nose`; xform -ws -t $pos[0] $pos[1] $pos[2] NosePatch.vtx[3]; spaceLocator -n tempGeoSnapLoc; geometryConstraint $geometry tempGeoSnapLoc; $pos=`xform -q -ws -t Nose`; xform -ws -t $pos[0] $pos[1] $pos[2] tempGeoSnapLoc; $posA=`xform -q -ws -t Nose`; $posB=`xform -q -ws -t upperEyeLidOuterCurve.cv[0]`; for ($i=0;$i<10;$i++) setAttr tempGeoSnapLoc.ty (($posA[1]+$posB[1])/2.0); $pos=`xform -q -ws -t tempGeoSnapLoc`; xform -ws -t $pos[0] $pos[1] $pos[2] NosePatch.vtx[5]; $posA=`xform -q -ws -t Nose`; $posB=`xform -q -ws -t NoseCorner`; for ($i=0;$i<10;$i++) setAttr tempGeoSnapLoc.tx ($posB[0]/3.0); $pos=`xform -q -ws -t tempGeoSnapLoc`; xform -ws -t $pos[0] $pos[1] $pos[2] NosePatch.vtx[4]; for ($i=0;$i<10;$i++) { setAttr tempGeoSnapLoc.ty (($pos[1]+$posB[1])/2.0); setAttr tempGeoSnapLoc.tx $posB[0]; } $pos=`xform -q -ws -t tempGeoSnapLoc`; xform -ws -t $pos[0] $pos[1] $pos[2] NosePatch.vtx[2]; rename NosePatch NosePatch_R; instance -n NosePatch_L NosePatch_R; setAttr NosePatch_R.scaleX -1; delete tempGeoSnapLoc; select topologyConstruction; } global proc asFaceDeleteSkinCage () { delete faceCage; } global proc asEyeBallsChooseInput (string $textField) { string $sel[]=`ls -sl`; string $txt=$sel[0]; if (size($sel)>1) for ($i=1;$i1) for ($i=1;$i$centerErrorMargin || $pos[0]<(-1*$centerErrorMargin)) error ($region+" needs to be in the center, currently:"+$pos[0]+"\n"); int $jointNumber; string $jointName; for ($i=1;$i<99;$i++) { $jointNumber=$i; $jointName=$region+$jointNumber; if (!`objExists $jointName`) break; } for ($i=0;$i1) $jointName=$region+$jointNumber; $jointNumber++; $jointName=`asFaceCreateFitJoint $jointName $size $color`; $pos=`xform -q -ws -t $sel[$i]`; xform -ws -t $pos[0] $pos[1] $pos[2] $jointName; } if (`checkBox -q -ex ("asFaceFit"+$region)`) checkBox -e -v 1 -ed 1 ("asFaceFit"+$region); hilite -r `ls -o $sel`; select $sel; repeatLast -addCommand ("asCreateFaceFitJoint "+$region+" "+$size+" "+$color); if (`gmatch $region "eyeBrow[0-9]"`) asAutoEyeBrowFalloff $region; } global proc asAutoEyeBrowFalloff (string $region) { float $posA[3],$posB[3]; float $mag; int $nr=`substring $region 8 8`; string $previousRegion="eyeBrow"+($nr-1); if (!`objExists $previousRegion`) return; $posA=`xform -q -ws -t $region`; $posB=`xform -q -ws -t $previousRegion`; $mag=mag(<<$posA[0]-$posB[0],$posA[1]-$posB[1],$posA[2]-$posB[2]>>); setAttr ($region+".falloffRadius") $mag; float $previousRad=`getAttr ($previousRegion+".falloffRadius")`; if ($mag>$previousRad || $previousRegion=="eyeBrow0") setAttr ($previousRegion+".falloffRadius") $mag; } global proc string asFaceCreateFitJoint (string $name, float $radius, int $color) { if (`objExists $name`) error ($name+" Already Exists"); if (!`objExists FaceFitFromSoftMods`) createNode -n FaceFitFromSoftMods -p FaceFitSkeleton transform; select FaceFitFromSoftMods; joint -n $name; setAttr ($name+".overrideEnabled") 1; setAttr ($name+".overrideColor") $color; addAttr -k 1 -min 0 -dv $radius -ln "falloffRadius" -at double $name; addAttr -k 1 -ln "falloffMode" -at "enum" -en "volume:surface:" $name; addAttr -k 1 -ln "interpolation" -at "enum" -en "none:linear:smooth:spline:" $name; if (`gmatch $name "lowerEye*"` || `gmatch $name "upperEye*"` || `gmatch $name "lowerLip*"` || `gmatch $name "upperLip*"`) ; else { setAttr ($name+".falloffMode") 1; setAttr ($name+".interpolation") 2; } if (`gmatch $name "*Sculpt*"`) setAttr ($name+".falloffMode") 0; return $name; } global proc asFaceUpdateInfo (int $read)//info between UI and FitSkeleton { if (!`columnLayout -q -ex asColumnLayout`) return; int $vtxsFromLipToNose=3; //int $vtxsFromLipCornerToNoseCorner=6; int $stepBuild,$nextStep,$headerEn,$bodyEn,$m,$nonSymFace,$leftFaceFitting,$inputNr,$value,$optionNr; int $disableSteps[]; string $text,$obj,$fitType,$savedFitType,$leftSuffix,$parent,$stepBuildText,$type,$ctrl,$optionEnums,$valueAsString; string $avaiableBuiltTypes[],$tempString[],$tempString2[],$tempString3[],$inputs[],$inputTypes[],$ctrls[]; //3-level recursive searching layots for textFields,etc ($ctrls) $tempString=`layout -q -ca asFacePreColumnLayout`; for ($a=0;$a($nextStep-2)) $m=1; //if build is complete, show no steps (to ensure showing correct even if we changed AS version, and new version has more steps) if (`objExists FaceAllSet` && !`objExists allBeforeFaceBuild` && $stepBuild!=0 && !`objExists prefix_FaceGroup`) $m=0; if (`text -q -ex ("stepBuild"+$i+"Text")`) { $stepBuildText=`text -q -l ("stepBuild"+$i+"Text")`; if (`gmatch $stepBuildText "*RebuildRestore"`) if (!`objExists prefix_FaceGroup`) $m=0; } if ($i==($nextStep-1)) $bodyEn=1; if ($i==$nextStep) $headerEn=1; rowLayout -e -en $headerEn -m $m ("asStepBuildRowLayout"+$i); columnLayout -e -en $bodyEn -m $m ("asStepBuildColumnLayout"+$i); } //vtxsFromLipToNose if (`attributeExists vtxsFromLipToNose FaceFitSkeleton`) $vtxsFromLipToNose=`getAttr FaceFitSkeleton.vtxsFromLipToNose`; if (`intField -q -ex lipFalloffOuterIntField`) intField -e -v $vtxsFromLipToNose lipFalloffOuterIntField; } global proc string asFaceOptionMenuItemsAsEnums (string $input) { string $return; string $menuItems[]=`optionMenu -q -ill ("asFace"+$input+"OptionMenu")`; for ($i=0;$i0) asSkinWeightBySoftMod ($name+"Joint"+$side) SoftModLayer SoftModSC $falloffRadius 1; select $geometry; polySelectConstraint -m 3 -t 1 -d 1 -db 0 $falloffRadius -dp $pos[0] $pos[1] $pos[2]; polySelectConstraint -m 0; $tempString=`ls -sl -fl`; select -cl; for ($i=0;$i$maxZ) $maxZ=$posZ; } /* $bb=`xform -q -ws -bb $curves[$i]`; if ($bb[5]>$maxZ) $maxZ=$bb[5]; */ } delete cvPos; delete $tempString[0]; //$pos=`xform -q -ws -t ($ctrl+".cv[0]")`; $wScale=`xform -q -ws -s $ctrl`; move -r -os -wd 0 0 ($maxZ*$wScale[0]) ($ctrl+".cv[0:99]"); /* //extra forward offset, to avoid sinking into geo $tempString=`listConnections -p 1 ($ctrl+"Shape.overrideVisibility")`; tokenize $tempString[0] "[.]" $tempString; $offset=0; if ($tempString[1]=="ACtrlVis") $offset=$faceFitScale/100.0; if ($tempString[1]=="BCtrlVis") $offset=$faceFitScale/90.0; if ($tempString[1]=="CCtrlVis") $offset=$faceFitScale/80.0; move -r 0 0 $offset ($ctrl+".cv[0:99]"); */ } global proc asFaceControlOrient (string $ctrl) { string $name,$side; string $tempString[]; if (!`objExists FaceControlOrient`) return; tokenize $ctrl "_" $tempString; $name=$tempString[0]; $side="_"+$tempString[1]; delete `normalConstraint -weight 1 -aimVector 0 0 1 -upVector 0 1 0 -worldUpType "vector" -worldUpVector 0 1 0 FaceControlOrient ($name+"Offset"+$side)`; } global proc asFaceSoftModToSkinWeights (string $softMod, string $joint, string $ctrl, string $skinCluster, string $geometry) { int $autoKeyState=`autoKeyframe -q -state`; if ($autoKeyState) autoKeyframe -state 0; float $falloffRadius; float $onFaceCtrlScale=`getAttr OnFacecontrols.sx`; float $pos[],$posA[],$posB[]; string $sel[]=`ls -sl`; string $tempString[]; $pos=`xform -q -ws -t $joint`; $falloffRadius=`getAttr ($softMod+".falloffRadius")`; select $geometry; polySelectConstraint -m 3 -t 1 -d 1 -db 0 $falloffRadius -dp $pos[0] $pos[1] $pos[2]; $tempString=`ls -sl -fl`; polySelectConstraint -m 0; setAttr ($ctrl+".t") -type float3 0 0 0; for ($i=0;$i>`; if ($mag>$maxDist) $maxDist=$mag; } $maxDist=$maxDist+($maxDist/20.0); select ClustersRegion; sets -add ($oppositeCluster+"Set") ClustersRegion; polySelectConstraint -m 3 -t 1 -d 1 -db 0 $maxDist -dp ($posA[0]*-1) $posA[1] $posA[2]; string $vtxs[]=`ls -sl -fl`; polySelectConstraint -m 0; //sets -add ($oppositeCluster+"Set") $vtxs; string $closestSampler=`createNode -n closestSampler closestPointOnMesh`; $tempString=`listRelatives -ni -s ClustersRegion`; connectAttr -f ($tempString[0]+".outMesh") ($closestSampler+".inMesh"); connectAttr -f ("ClustersRegion.worldMatrix[0]") ($closestSampler+".inputMatrix"); int $closestOppositeVtxNr; global string $gMainProgressBar; progressBar -e -st ("Mirroring Cluster for: "+$control) -bp -ii 1 -min 0 -max `size($vtxs)` $gMainProgressBar; for ($i=0;$i0) { parent -w ("FitEyeBall"+$leftSuffix); if (!$hadBodyEye) xform -ws -t $pos[0] $pos[1] $pos[2] ("FitEyeBall"+$leftSuffix); xform -os -s ($bb[4]-$bb[1]) ($bb[4]-$bb[1]) ($bb[4]-$bb[1]) ("FitEyeBall"+$leftSuffix); parent ("FitEyeBall"+$leftSuffix) ("FaceFitEyeBall"+$leftSuffix); } if (`objExists asDuplicatedEye`) delete asDuplicatedEye; // if ($leftSuffix=="Left") // setAttr ("FitEyeBall"+$leftSuffix+".tx") (`getAttr ("FitEyeBall"+$leftSuffix+".tx")`*-1); } //Now lock FaceFitSkeleton, it is not to be changed once fitting started asLockAttr FaceFitSkeleton 1 1 1 0; asFaceUpdateInfo 1; select ("FitEyeBall"+$leftSuffix); print ("// FitEyeBall"+$leftSuffix+" created, place this to match the eye-ball of your character\n"); //checkBox -e -ed 1 -v 1 asFaceFitEyeBall; } global proc asFaceEnsureShaders () { string $colors[]={"asFaceBlue","asFaceBrown","asFaceGreen","asFaceCyan","asFaceRed"}; float $rs[]={0.0,0.541,0.000,0.0,0.4}; float $gs[]={0.0,0.282,0.275,0.5,0}; float $bs[]={1.0,0.200,0.098,0.5,0}; for ($i=0;$i1) { polyUnite -ch 0 -mergeUVSets 1 -name allHeadCombinedLayer; delete $tempString; } else rename $tempString[0] allHeadCombinedLayer; parent allHeadCombinedLayer DeformationLayers; sets -e -forceElement initialShadingGroup allHeadCombinedLayer; $tempString=`listRelatives -s -f allHeadCombinedLayer`; for ($i=0;$i0 || `gmatch $scriptLocation "/*"`) $latestLocalScriptLocation+="/"; $latestLocalScriptLocation+=$tempString[$i]; } } } return $latestLocalScriptLocation; } global proc string asGetLatestLocalVersionAsString () { string $latestLocalVersion=`asGetScriptVersionAsString`; string $scriptLocation=`asGetScriptLocation`; string $tempString[]; string $latestLocalASFile; if (`gmatch $scriptLocation "*oldVersions*"`) { $latestLocalASFile=`asGetLatestLocalScriptLocation`+"/AdvancedSkeleton5.mel"; $latestLocalVersion=`asGetScriptVersionFromFile $latestLocalASFile`; } return $latestLocalVersion; } global proc asDownloadDemoUpdates () { int $fileId,$replacedLine; string $scriptLocation=`asGetScriptLocation`; string $curl=$scriptLocation+"/AdvancedSkeleton5Files/bin/curl.e"; string $zip=$scriptLocation+"/AdvancedSkeleton5Files/bin/7za.e"; if (`about -mac` || `about -linux`) $curl="curl"; else if (!`file -q -ex $curl`) error ("File not found:"+$curl); string $tempString[],$oldFilesList[],$exampleFolders[]; string $cmd,$name,$unzipFolder,$downloadedFile,$zipFileUrl,$file,$exampleFile,$nextLine,$demoVersionsText,$onlineVersion; string $exampleFilesFolder=$scriptLocation+"/AdvancedSkeleton5Files/exampleFiles"; string $downloadsFolder=$exampleFilesFolder+"/downloads"; string $demoVersionsTextFile=$downloadsFolder+"/DemoVersions.txt"; if (!`file -q -ex $downloadsFolder`) sysFile -md $downloadsFolder; for ($i=0;$i<99;$i++) { if (!`checkBox -q -ex ("asDemoUpdateCheckBox"+$i)`) break; if (!`checkBox -q -v ("asDemoUpdateCheckBox"+$i)`) continue; $name=`text -q -l ("asDemoUpdateFileText"+$i)`; $onlineVersion=`text -q -l ("asDemoUpdateFileOnlineVersion"+$i)`; $downloadedFile=$downloadsFolder+"/"+$name+".7z"; $unzipFolder=$downloadsFolder+"/"+$name; $zipFileUrl="https://www.advancedskeleton.com/download/AdvancedSkeletonExamples/"+$name+".7z"; if (!`file -q -ex $unzipFolder`) sysFile -md $unzipFolder; //download if (`about -mac` || `about -linux`) { $cmd="\"curl -o "+$downloadedFile+" "+$zipFileUrl+"\""; evalEcho ("system("+$cmd+")"); } else { $cmd="start\/wait/I \"Downloading\" \""+$curl+"\" -k -o \""+$downloadedFile+"\" "+$zipFileUrl; system ($cmd); } //confirm download if (`file -q -ex $downloadedFile`) print ("// Downloaded sucessfully:"+$downloadedFile+";\n"); else error ("// Download failed, could not find:"+$downloadedFile+";\n"); //unzip (with -y for overwrite) if (`about -mac` || `about -linux`) $cmd="unzip "+$downloadedFile+" -d "+$unzipFolder; else $cmd="start\/wait/I \"Unzipping\" \""+$zip+"\" x -y \""+$downloadedFile+"\" -o\""+$unzipFolder+"\""; print ("// Starting Unzip:"+$cmd+";\n"); system($cmd); //confirm unzip if (`file -q -ex ($unzipFolder+"/"+$name+".mb")`) print ("// Unzipped sucessfully:"+$unzipFolder+"/"+$name+".mb;\n"); else error ("// Unzipp failed, could not find:"+$unzipFolder+"/"+$name+".mb;\n"); //remove old file if (`file -q -ex ($exampleFilesFolder+"/"+$name)`) { $oldFilesList=`getFileList -fld ($exampleFilesFolder+"/"+$name+"/")`; for ($file in $oldFilesList) sysFile -del ($exampleFilesFolder+"/"+$name+"/"+$file); sysFile -red ($exampleFilesFolder+"/"+$name); } // //Move (by rename) downloadedFolder to exampleFolder // sysFile -ren ($exampleFilesFolder+"/"+$name) $unzipFolder; //Delete $downloadedFile sysFile -del $downloadedFile; //Update DemoVersions.txt $demoVersionsText=""; $replacedLine=0; $fileId=`fopen $demoVersionsTextFile "r"`; $nextLine=`fgetline $fileId`; while ( size( $nextLine ) > 0 ) { $nextLine=`strip $nextLine`; tokenize $nextLine $tempString; if ($tempString[0]==$name) { $demoVersionsText=$demoVersionsText+`substitute $tempString[1] $nextLine $onlineVersion`+"\r\n"; $replacedLine=1; } else if ($nextLine!="") $demoVersionsText=$demoVersionsText+$nextLine+"\r\n"; $nextLine=`fgetline $fileId`; } fclose $fileId; if (!$replacedLine) $demoVersionsText=$demoVersionsText+$name+" "+$onlineVersion+"\r\n"; $fileId=`fopen $demoVersionsTextFile "w"`; fprint $fileId $demoVersionsText; fclose $fileId; //populate Demo optionMenu $tempString=`optionMenu -q -ill asDemoOptionMenu`; for ($y=0;$y 0 ) { $localVersionsText=$localVersionsText+$nextLine; $nextLine=`fgetline $fileId`; } fclose $fileId; $x=0; tokenize $localVersionsText $tempString; for ($i=0;$i$latestInstalledVersion) { text -e -en 1 -l $latestVersionAsString asUpdateFoundVersion; button -e -en 1 asUpdateVersionButton; print ("// New version found, click Update, to update to the new version\n"); } else print ("// Latest version("+$latestVersionAsString+"), is not greater than your latest installed version("+$latestInstalledVersionAsString+")\n"); waitCursor -st 0; } global proc string asGetLatestInstalledVersionScriptLocation () { string $sLoc=`asGetScriptLocation`; string $ts[]; int $numTok=`tokenize $sLoc "/" $ts`; if ($ts[size($ts)-2]=="oldVersions") $sLoc=`substitute ("/"+$ts[$numTok-3]+"/"+$ts[$numTok-2]+"/"+$ts[$numTok-1]) $sLoc ""`; return $sLoc; } global proc asUpdateVersion () { //First check if download is from Autodesk store, //since the C:\ProgramData\Autodesk\ApplicationPlugins folder probably does not have overwrite priveleges //Testing by attempting to rename eula.txt file int $fileId; int $isReadOnly=0; string $dialog; string $fDet,$cmd,$changePriviligeFolder; string $asScriptLocation=`asGetScriptLocation`; string $eulaFile=$asScriptLocation+"/eula.txt"; string $eula2File=$asScriptLocation+"/eula2.txt"; string $tmpDir=`asGetTempDirectory`; string $batFile=$tmpDir+"AdvancedSkeleton_changeFolderPriviliges.bat"; if (`file -q -ex $eulaFile` && `about -win`) { sysFile -rename $eula2File $eulaFile; if (!`file -q -ex $eulaFile`) sysFile -rename $eulaFile $eula2File; else { $isReadOnly=1; sysFile -del $eula2File; } } if ($isReadOnly) { $changePriviligeFolder=$asScriptLocation; if (`gmatch $asScriptLocation "C:/ProgramData/Autodesk/ApplicationPlugins/AdvancedSkeleton5*"`) $changePriviligeFolder="C:/ProgramData/Autodesk/ApplicationPlugins/AdvancedSkeleton5"; $dialog=`confirmDialog -t "Confirm" -m ("Detected Read-Only AdvancedSkeleton files,\nClick OK to attemp to modify the priviliges for this folder:\n"+$changePriviligeFolder) -b "OK" -db "OK" -b "Cancel" -ds "Cancel"`; if ($dialog!="OK") error ("Unable to Update, as the files are Read-Only.\nThis is common if you downloaded AdvancedSkeleton from the Autodesk store.\n" +"You can try to manually add Write-priviliges to this folder:\n"+$changePriviligeFolder); $fDet="icacls "+$changePriviligeFolder+" /grant Everyone:(OI)(CI)F"; $fileId=`fopen $batFile "w"`; fprint $fileId ($fDet); fclose $fileId; $cmd="powershell -Command \"Start-Process '"+$batFile+"' -Verb runAs\""; system ($cmd); } waitCursor -st 1; string $sLoc=`asGetLatestInstalledVersionScriptLocation`; string $latestInstalledVersionAsString=`asGetScriptVersionFromFileAsString ($sLoc+"/AdvancedSkeleton5.mel")`; string $curl=$sLoc+"/AdvancedSkeleton5Files/bin/curl.e"; string $zip=$sLoc+"/AdvancedSkeleton5Files/bin/7za.e"; string $newVersionAsString=`text -q -l asUpdateFoundVersion`; string $newVersionFolder=$sLoc+"/AdvancedSkeleton5Files/newVersions/AdvancedSkeleton_v"+$newVersionAsString; if (!`file -q -ex $newVersionFolder`) sysFile -md $newVersionFolder; //download string $newVersionZipFile=$newVersionFolder+"/AdvancedSkeleton5.zip"; string $zipFileUrl="https://www.advancedskeleton.com/download/AdvancedSkeleton5/AdvancedSkeleton_v"+$newVersionAsString+"/AdvancedSkeleton5.zip"; if (`checkBox -q -v asBetaCheckBox`) $zipFileUrl="https://www.advancedskeleton.com/download/AdvancedSkeleton5Beta/AdvancedSkeleton_v"+$newVersionAsString+"/AdvancedSkeleton5.zip"; if (`about -mac` || `about -linux`) { $cmd="\"curl -o "+$newVersionZipFile+" "+$zipFileUrl+"\""; evalEcho ("system("+$cmd+")"); } else { $cmd="start\/wait/I \"Downloading\" \""+$curl+"\" -k -o \""+$newVersionZipFile+"\" "+$zipFileUrl; print ("// Starting Download:"+$cmd+";\n"); system ($cmd); } //confirm download if (`file -q -ex $newVersionZipFile`) print ("// Downloaded sucessfully:"+$newVersionZipFile+";\n"); else error ("// Download failed, could not find:"+$newVersionZipFile+";\n"); //unzip if (`about -mac` || `about -linux`) $cmd="unzip "+$newVersionZipFile+" -d "+$newVersionFolder; else $cmd="start\/wait/I \"Unzipping\" \""+$zip+"\" x \""+$newVersionZipFile+"\" -o\""+$newVersionFolder+"\""; print ("// Starting Unzip:"+$cmd+";\n"); system($cmd); //confirm unzip if (`file -q -ex ($newVersionFolder+"/AdvancedSkeleton5.mel")`) print ("// Unzipped sucessfully:"+$newVersionFolder+"/AdvancedSkeleton5.mel;\n"); else error ("// Unzipp failed, could not find:"+$newVersionFolder+"/AdvancedSkeleton5.mel;\n"); //remove zip file if (`file -q -ex ($newVersionFolder+"/AdvancedSkeleton5.zip")`) sysFile -del ($newVersionFolder+"/AdvancedSkeleton5.zip"); //backup $latestInstalledVersion version string $oldVersionsFolder=$sLoc+"/AdvancedSkeleton5Files/oldVersions/AdvancedSkeleton_v"+$latestInstalledVersionAsString; print ("// Backing up old version: asCopyFilesInFolder \""+$oldVersionsFolder+"\" \""+$sLoc+"\";\n"); sysFile -md ($oldVersionsFolder+"/AdvancedSkeleton5Files"); asCopyFilesInFolder ($oldVersionsFolder+"/AdvancedSkeleton5Files") ($sLoc+"/AdvancedSkeleton5Files"); sysFile -cp ($oldVersionsFolder+"/AdvancedSkeleton5.mel") ($sLoc+"/AdvancedSkeleton5.mel"); //replace with new version print ("// Replacing current version with the downloaded version: asCopyFilesInFolder \""+$sLoc+"\" \""+$newVersionFolder+";\n"); asCopyFilesInFolder $sLoc $newVersionFolder; waitCursor -st 0; print ("// Updated from "+$latestInstalledVersionAsString+" to "+$newVersionAsString+"\n"); //Re-start if (`window -q -ex AdvancedSkeletonWindow`) deleteUI AdvancedSkeletonWindow; optionVar -iv asHaveRanThisVersion 0; evalDeferred -lp ("source \""+$sLoc+"/AdvancedSkeleton5.mel\";AdvancedSkeleton5;"); } global proc asVersionHistory () { global string $gMainProgressBar; string $versionHistoryFileUrl="https://www.advancedskeleton.com/download/AdvancedSkeleton5/versionHistory.txt"; if (`getModifiers`==13) $versionHistoryFileUrl="https://www.advancedskeleton.com/download/AdvancedSkeleton5Beta/betaVersionHistory.txt"; string $curl=`asGetScriptLocation`+"/AdvancedSkeleton5Files/bin/curl.e"; if (`about -mac` || `about -linux`) $curl="curl"; else if (!`file -q -ex $curl`) error ("File not found:"+$curl); evalDeferred ("progressBar -e -ep "+$gMainProgressBar); print ("// Downloading version information from:"+$versionHistoryFileUrl+"\n"); progressBar -e -st "Downloading version information" -bp -ii 1 -min 0 -max 1 $gMainProgressBar; string $versionHistoryText=`system ("\""+$curl+"\" -k -s "+$versionHistoryFileUrl)`; if (`window -q -ex asVersionHistory`) deleteUI asVersionHistory; window asVersionHistory; formLayout asVersionHistoryFormLayout; scrollField -text $versionHistoryText asVersionHistoryScrollField; formLayout -e -af asVersionHistoryScrollField "left" 0 -af asVersionHistoryScrollField "right" 0 -af asVersionHistoryScrollField "top" 0 -af asVersionHistoryScrollField "bottom" 0 asVersionHistoryFormLayout; showWindow; } global proc asCopyFilesInFolder (string $destFolder, string $sourceFolder) { global string $gMainProgressBar; if (`gmatch $destFolder"*/exampleFiles/*"`) return;//dont include downloaded exampleFiles if (`gmatch $destFolder"*forced-aligner*"`) return;//dont include forced-aligners if (`gmatch $destFolder"*download*"`) return;//dont include download folders (eg. AdvancedSkeleton5Files\bin\download used for forced-aligner) if (!`file -q -ex $destFolder`) sysFile -md $destFolder; string $fileList[]=`getFileList -fld ($sourceFolder+"/")`; if (`size($fileList)`==0) return; progressBar -e -st "Copy files" -bp -ii 1 -min 0 -max (size($fileList)) $gMainProgressBar; for ($i=0;$i1) $dialog=`confirmDialog -t "Confirm" -m ($shortName+" already exist") -b "Replace" -db "Replace" -b "Merge" -ds "Merge"`; if ($dialog=="Replace") { for ($y=0;$y2) $limbOnly=1; } if ($limbOnly) $fitSkeletonsDir=$asScriptLocation+"/AdvancedSkeleton5Files/fitSkeletonsLimbs/"; string $return[] = `fileDialog2 -fileFilter "*.ma" -dialogStyle 2 -dir $fitSkeletonsDir`; string $file=$return[0]; if ($file=="") return; $tempString=`listRelatives -p FitSkeleton`; string $currentParent=$tempString[0]; if ($fitSkeletonVisLocked) setAttr -l 0 FitSkeleton.v; setAttr FitSkeleton.v 1; if (`objExists $currentParent`) parent -w FitSkeleton; $tempString=`listConnections -s 0 -d 1 -type animCurve`; for ($i=0;$i2) { if (!`objExists previousFitSkeletonChildren`) { createNode -n previousFitSkeletonChildren transform; $previousFitSkeletonChildren=`listRelatives -c -type joint FitSkeleton`; parent $previousFitSkeletonChildren previousFitSkeletonChildren; } $tempString=`listRelatives -p $selJoints[$i]`; $previousSelJointParents[$i]=$tempString[0]; parent $selJoints[$i] FitSkeleton; } } select FitSkeleton; if (size($drivingSystems)) delete $drivingSystems; file -force -options "v=0;" -typ "mayaAscii" -es $file; if (size($drivingSystems)) undo; if (`objExists $currentParent`) parent FitSkeleton $currentParent; if ($fitSkeletonVisLocked) setAttr -l 1 FitSkeleton.v; //Limb only ? (restore) for ($i=0;$iPre\" section."; for ($i=0;$i1) { polySeparate -ch 0 ("CombinedSkin"+$i); $tempString=`listRelatives -c -type transform ("CombinedSkin"+$i)`; for ($y=0;$y$maxNumFaces) { $maxNumFaces=$tempInts[0]; $maxNumFacesShell=$tempString[$y]; } } parent $maxNumFacesShell AutoPlacing; delete ("CombinedSkin"+$i); rename $maxNumFacesShell ("CombinedSkin"+$i); } */ } //Merge all SkinObjects select CombinedSkin0; if (size($skinObjects)>1) { for ($i=1;$i$maxY) $maxY=$pos[1]; } if (size($tempString)==0) $maxY=17.176; if ($maxY<0.1) $maxY=0.1; $newScale=($bbMaxY/$maxY)*$scale; for ($i=size($tempString)-1;$i>-1;$i--) { $pos=`xform -q -ws -t $tempString[$i]`; $posXs[$i]=$pos[0]; $posYs[$i]=$pos[1]; $posZs[$i]=$pos[2]; } for ($i=size($tempString)-1;$i>-1;$i--) { xform -ws -t ($posXs[$i]*$newScale) ($posYs[$i]*$newScale) ($posZs[$i]*$newScale) $tempString[$i]; if (`attributeExists fat $tempString[$i]`) setAttr ($tempString[$i]+".fat") (`getAttr ($tempString[$i]+".fat")`*$newScale); } setAttr FitSkeleton.s -type float3 1 1 1; //$pos=`xform -q -ws -t FitSkeletonShape.cv[3]`; $bb=`getAttr FitSkeletonShape.boundingBoxMax`; $scale=($bbMaxY/5.5)/$bb[0]; scale -r -p 0 0 0 $scale $scale $scale FitSkeletonShape.cv[0:99]; jointDisplayScale ($bbMaxY/100.0); if (`objExists asFitAutoScale`) { delete asFitAutoScale; asFitDeleteGuides; catchQuiet (`select $sel`); return; } $tempString[0]=`curve -d 1 -p $bbMinX 0 0 -p $bbMaxX 0 0`; rename $tempString[0] asFitScanCurve; setAttr asFitScanCurveShape.overrideEnabled 1; setAttr asFitScanCurveShape.overrideColor 14; //setAttr asFitScanCurveShape.dispGeometry 0; parent asFitScanCurve asFitScanCurves; for ($z=0;$z$maxWidth) $maxWidth=$width; $zWidth=$bbMax[2]-$bbMin[2]; if ($zWidth>$zWidthMax) { $tyAtMaxZ=`getAttr asFitScanCurve.ty`; $zWidthMax=$zWidth; } $bbCenterX=($bbMin[0]+$bbMax[0])/2.0; //checks if ($zxy[$z]=="zLoft" && !$fourFingerHit) { asFitDeleteGuides; print ("// Unable to detect \""+$fitSkeletonTemplate+"\" form.\n"); return; } //Loft if (`gmatch $zxy[$z] "*Loft"`) { if ($zxy[$z]=="zLoft" && $i<$hitCrotchNr) {$find="right";$combinedSkin="CombinedSkinLower_R";} else if ($zxy[$z]=="yLoft") {$find="widest";$combinedSkin="CombinedSkinUpper_M";} else {$find="widest";$combinedSkin="CombinedSkin";} if ($i==0) createNode -n ("asFitLoftCurves"+$zxy[$z]) -p AutoPlacing transform; asSaveProjection ("Loft"+$zxy[$z]+$i) $zxy[$z] $combinedSkin $find 0; $tempString=`listRelatives -c ("asFitProjectionLoft"+$zxy[$z]+$i)`; $projectedCurve=`asGetProjectedCurve ("asFitProjectionLoft"+$zxy[$z]+$i) $find`; //print ("$projectedCurve="+$projectedCurve+"\n"); //if ($zxy[$z]=="yLoft" && $i==4) a; for ($x=0;$x($hitCrotchNr+5) && $hasHitArmPit==0) if ($width>($previousWidth*1.5) || ($numHits==1 && $numPreviousHits>1))//got >1.5x wider, or multiHit > singleHit (armsDown) { move -r -os -wd 0 ($bbMaxY/-100.0) 0 asFitScanCurve; asSaveProjection ArmPit $zxy[$z] CombinedSkin "center" 0; $tempString[0]=`asGetProjectedCurve asFitProjectionArmPit "center"`; $tempFloatA=`getAttr ($tempString[0]+".boundingBoxMin")`; $tempFloatB=`getAttr ($tempString[0]+".boundingBoxMax")`; $armPitWidth=$tempFloatB[0]-$tempFloatA[0]; $a=`getAttr asFitScanCurveRoot.ty`; $b=`getAttr asFitScanCurveArmPit.ty`; setAttr asFitScanCurve.ty ($b-(($b-$a)/4.0)); asSaveProjection Chest $zxy[$z] CombinedSkinLower_M "center" 1; $b=`getAttr asFitScanCurveChest.ty`; setAttr asFitScanCurve.ty ($b-(($b-$a)/2.0)); asSaveProjection Spine1 $zxy[$z] CombinedSkinLower_M "center" 1; setAttr asFitScanCurve.ty `getAttr asFitScanCurveArmPit.ty`; $hasHitArmPit=1; } //Neck if ($zxy[$z]=="z" && $hasHitNeck==0 && $hasHitArmPit==1 && $width<$armPitWidth) { asSaveProjection Neck $zxy[$z] CombinedSkin "center" 1; $hasHitNeck=1; } //Head if ($zxy[$z]=="z" && $hasHitNeck==1 && $hasHitHead==0) { $a=`getAttr asFitScanCurveNeck.ty`; $b=$a+($bbMaxY-$a)/5.0; if (`getAttr asFitScanCurve.ty`>$b) { asSaveProjection Head $zxy[$z] CombinedSkin "center" 1; $hasHitHead=1; } } //Ankle if ($zxy[$z]=="x" && $hasHitAnkle==0 && $i>2 && $width<($maxWidth/2.0) && $width>($previousWidth*0.9) && $numHits==2) { move -r -os -wd 0 ($bbMaxY/-100.0) 0 asFitScanCurve; asSaveProjection Ankle $zxy[$z] CombinedSkinLower_M "right" 1; setAttr asFitScanCurve.ty ((`getAttr asFitScanCurveCrotch.ty`+`getAttr asFitScanCurveAnkle.ty`)/2.0); //Knee asSaveProjection Knee $zxy[$z] CombinedSkinLower_M "right" 1; setAttr asFitScanCurve.ty `getAttr asFitScanCurveAnkle.ty` 1; move -r -os -wd 0 ($bbMaxY/-100.0) 0 asFitScanCurve; //Toes (maxZ before Ankle) setAttr asFitScanCurve.ty $tyAtMaxZ; asSaveProjection Toes $zxy[$z] CombinedSkinLower_M "right" 1; setAttr asFitScanCurve.ty `getAttr asFitScanCurveAnkle.ty`; //Ankle orientation $projectedCurve=`asGetProjectedCurve asFitProjectionToes "right"`; duplicate -n AnkleRotSampler $projectedCurve; parent AnkleRotSampler AutoPlacing; // $tempString=`listRelatives -s AnkleRotSampler`; // $projectedCurveShape=$tempString[0]; asLockAttr AnkleRotSampler 1 0 1 1; select AnkleRotSampler; CenterPivot; for ($i=0;$i<90;$i++) { $pos=`xform -q -ws -piv AnkleRotSampler`; rotate -r -p $pos[0] $pos[1] $pos[2] -os -fo 0 1 0 AnkleRotSampler.cv[0:999]; // refresh; $bb=`xform -q -ws -bb AnkleRotSampler`; $previousWidth=$width; $width=$bb[3]-$bb[0]; if ($i>0 && $width>$previousWidth) { setAttr AnkleRotSampler.ry (($i+1)*-1); break; } } // setAttr Ankle.rx (`getAttr AnkleRotSampler.ry`*-1); // xform -ws -ro (90-`getAttr AnkleRotSampler.ry`) 0 -90 Ankle; $ankleCurveRy=`getAttr AnkleRotSampler.ry`; //FootSideOuter FootSideInner ToesEnd Heel setAttr AnkleRotSampler.ry 0; createNode -n tempXform1 -p AnkleRotSampler transform; duplicate -n tempXform2 tempXform1; duplicate -n tempXform3 tempXform1; duplicate -n tempXform4 tempXform1; duplicate -n tempXform5 tempXform1; duplicate -n tempXform6 tempXform1; $bbMin=`getAttr AnkleRotSamplerShape.boundingBoxMin`; $bbMax=`getAttr AnkleRotSamplerShape.boundingBoxMax`; xform -ws -t (($bbMin[0]+$bbMax[0])/2.0) (($bbMin[1]+$bbMax[1])/2.0) $bbMin[2] tempXform1; xform -ws -t (($bbMin[0]+$bbMax[0])/2.0) (($bbMin[1]+$bbMax[1])/2.0) $bbMax[2] tempXform2; xform -ws -t $bbMin[0] (($bbMin[1]+$bbMax[1])/2.0) (($bbMin[2]+$bbMax[2])/2.0) tempXform4; xform -ws -t $bbMax[0] (($bbMin[1]+$bbMax[1])/2.0) (($bbMin[2]+$bbMax[2])/2.0) tempXform5; xform -ws -t (($bbMin[0]+$bbMax[0])/2.0) (($bbMin[1]+$bbMax[1])/2.0) $bbMax[2] tempXform6; pointConstraint -w 0.25 tempXform1 tempXform3; pointConstraint -w 0.75 tempXform2 tempXform3; parent tempXform4 tempXform5 tempXform6 tempXform3; setAttr tempXform4.tz 0; setAttr tempXform5.tz 0; setAttr AnkleRotSampler.ry $ankleCurveRy; parent tempXform3 asFitPivotToes; // pointConstraint -w 1.0 asFitPivotOffsetToes Toes;//find the offset setAttr asFitHandleToes.offsetZ `getAttr tempXform3.tz`; if (`objExists FootSideOuter`) { asFitAnchor FootSideOuter; $pos=`xform -q -ws -t tempXform4`; xform -ws -t $pos[0] 0 $pos[2] asFitAnchorFootSideOuter; } if (`objExists FootSideInner`) { asFitAnchor FootSideInner; $pos=`xform -q -ws -t tempXform5`; xform -ws -t $pos[0] 0 $pos[2] asFitAnchorFootSideInner; } if (`objExists ToesEnd`) { asFitAnchor ToesEnd; $pos=`xform -q -ws -t tempXform6`; xform -ws -t $pos[0] 0 $pos[2] asFitAnchorToesEnd; } if (`objExists Heel`) { asFitAnchor Heel; $pos=`xform -q -ws -t tempXform1`; xform -ws -t $pos[0] 0 $pos[2] asFitAnchorHeel; } // setAttr ToesEnd.tz 0; delete tempXform1 tempXform2 tempXform3 tempXform4 tempXform5 tempXform6; //re-orient asFitPivotToes setAttr asFitPivotOrientToes.ry $ankleCurveRy; $hasHitAnkle=1; } //ArmTip if ($zxy[$z]=="yArmStraight" && $hasHitArmTip==0) { asSaveProjection ArmTip $zxy[$z] CombinedSkin "0" 0; $hasHitArmTip=1; } //Shoulder if ($zxy[$z]=="yArmStraight" && $hasHitShoulder==0 && `getAttr asFitScanCurve.tx`>($armPitWidth*-0.5) && `objExists asFitPivotArmPit`) { asSaveProjection Shoulder $zxy[$z] CombinedSkin "closestToasFitPivotArmPit" 1; //BodyCut if (!$hasStraightenArm && `objExists asFitPivotArmPit` && `objExists asFitPivotNeck` && `objExists asFitPivotShoulder`) { $camOrbitStep*=-1; catchQuiet (`setAttr CombinedSkin.v 0`); catchQuiet (`setAttr CombinedSkinLower_M.v 0`); catchQuiet (`setAttr CombinedSkinUpper_M.v 1`); select CombinedSkinUpper_M; polySelectConstraint -m 3 -t 1 -d 3 -db 0 ($bbMaxY/10.0) -da 0 1 0 -dp 0 0 0; polySelectConstraint -m 0; for ($a=0;$a<999;$a++) { $numVtxsA=size(`ls -sl -fl`); polySelectConstraint -pp 1 -t 0x0001; $numVtxsB=size(`ls -sl -fl`); if ($numVtxsB==$numVtxsA) break; $tempBBox=`xform -q -bb`; if ($tempBBox[4]>`getAttr asFitPivotArmPit.ty`) break; } ConvertSelectionToFaces; $tempString=`ls -sl`; delete; select `asobjSetCast "" $tempString CombinedSkinLower_M`; asInvertSelection; delete; //separate head duplicate -n CombinedSkinHead_M CombinedSkinUpper_M; connectAttr -f CombinedSkinUpper_M.outMesh closestSampler.inMesh; $pos=`xform -q -ws -t asFitHandleNeck`; select CombinedSkinHead_M; polySelectConstraint -m 3 -t 1 -d 3 -db 0 $pos[1] -da 0 1 0 -dp 0 0 0; polySelectConstraint -m 0; ConvertSelectionToFaces; $tempString=`ls -sl`; delete; select `asobjSetCast "" $tempString CombinedSkinUpper_M`; asInvertSelection; delete; //find $armVtxs $pos=`xform -q -ws -t asFitPivotOffsetArmTip`; setAttr closestSampler.inPosition $pos[0] $pos[1] $pos[2]; $closestVtxIndex=`getAttr closestSampler.closestVertexIndex`; select ("CombinedSkinUpper_M.vtx["+$closestVtxIndex+"]"); for ($a=0;$a<999;$a++) { $numVtxsA=size(`ls -sl -fl`); polySelectConstraint -pp 1 -t 0x0001; $numVtxsB=size(`ls -sl -fl`); if ($numVtxsB==$numVtxsA) { //`out of grow` before reach, attempt Shell-leap. e.g wrist geo ended, leap to sleeve //separate shell to obj, wrap-def (exl-bind), grow maxDist until `bite` asPolyGrowPastShell; $numVtxsB=size(`ls -sl -fl`); if ($numVtxsB==$numVtxsA) break; } $tempBBox=`xform -q -bb`; if (($tempBBox[4]>((`getAttr asFitPivotArmPit.ty`+`getAttr asFitPivotNeck.ty`)/2.0)) && $tempBBox[3]>`getAttr asFitPivotShoulder.tx`) break; } $armVtxs=`ls -sl -fl`; select asFitAutoPlaceJoints; joint -n asFitArmStraightBase; joint -n asFitArmStraight; setAttr asFitArmStraightBase.v 0; $posA=`xform -q -ws -t asFitPivotArmPit`; $posB=`xform -q -ws -t asFitPivotNeck`; $posC=`xform -q -ws -t asFitPivotShoulder`; xform -ws -t $posC[0] (($posA[1]+$posB[1])/2.0) (($posA[2]+$posB[2])/2.0) asFitArmStraight; select asFitArmStraight asFitArmStraightBase CombinedSkinUpper_M; $tempString=`newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"`; rename $tempString[0] CombinedSkinUpperSC_M; skinPercent -tv asFitArmStraightBase 1 CombinedSkinUpperSC_M CombinedSkinUpper_M; skinPercent -tv asFitArmStraight 1 CombinedSkinUpperSC_M $armVtxs; select CombinedSkinUpper_M; deltaMush -n asFitDeltaMush -smoothingIterations 30 -smoothingStep 0.5 -pinBorderVertices 1 -envelope 1; refresh;//ensure to store bindPose in deltaMush createNode -n tempXform1 -p AutoPlacing transform; pointConstraint asFitArmStraight tempXform1; aimConstraint -offset 0 0 0 -weight 1 -aimVector -1 0 0 -upVector 0 1 0 -worldUpType "scene" asFitPivotArmTip tempXform1; if (`getAttr tempXform1.rz`>10) setAttr asFitArmStraight.rz (`getAttr tempXform1.rz`*-1); $rz=`getAttr asFitArmStraight.rz`; delete tempXform1; $posA=`xform -q -ws -t asFitPivotArmTip`; delete asFitProjectionArmTip asFitScanCurveArmTip; xform -ws -t $posA[0] $posA[1] $posA[2] asFitPivotArmTip; // delete asFitProjectionShoulder asFitScanCurveShoulder; $hasHitArmTip=0; $bbMin=`getAttr "CombinedSkinUpper_M.boundingBoxMin"`; $bbMinX=$bbMin[0]; //update AutoPlacing.bbMinX setAttr AutoPlacing.bbMinX $bbMinX; //split Left/Right for ($b=1;$b>-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="Upper"; else $upperLower="Lower"; duplicate -n ("CombinedSkin"+$upperLower+$side) ("CombinedSkin"+$upperLower+"_M"); select ("CombinedSkin"+$upperLower+"_M") ("CombinedSkin"+$upperLower+$side); blendShape -n ("CombinedSkin"+$upperLower+"BS"+$side) -frontOfChain -w 0 1; select ("CombinedSkin"+$upperLower+$side); refresh; polySelectConstraint -m 3 -t 0x0008 -d 3 -db 0 ($bbMinX*-1) -da 1 0 0 -dp $bbMinX 0 0; if ($side=="_R") asInvertSelection; delete; polySelectConstraint -m 0; catchQuiet (`setAttr ("CombinedSkin"+$upperLower+$side+".v") 0`); } } //Re-Do Shoulder to project on CombinedSkinUpper_R asUpdateProjection Shoulder $zxy[$z] CombinedSkinUpper_R "closestToasFitPivotArmPit" 1; $hasStraightenArm=1; } $hasHitShoulder=1; break;//change $zxy[$z]="yArmStraight" to $zxy[$z]="y" } if ($hasStraightenArm) { //Wrist if ($zxy[$z]=="y" && $hasHitWrist==0 && `objExists asFitPivotMiddleFinger1`) { $a=`getAttr asFitPivotMiddleFinger1.tx`; $b=`getAttr asFitPivotMiddleFinger4.tx`; $fingerLenght=$b-$a; if (`getAttr asFitScanCurve.tx`<($a-($fingerLenght*1.0))) continue;//minimum 1 `$fingerLenght` if ($numHits>1) continue;//no fingerbranches for ($a=1;$a<199;$a++) { move -r -os -wd 0 0 ($zStep/4.0) asFitScanCurve;//Move forward to check $previousWidth=$width; $bbMin=`getAttr ($projectedCenterCurve+".boundingBoxMin")`; $bbMax=`getAttr ($projectedCenterCurve+".boundingBoxMax")`; $width=$bbMax[2]-$bbMin[2]; if ($width<$previousWidth*1.01)//allow slightly bigger to also count as shrink $numShrink++; else $numShrink=0; if ($numShrink>3) $hitNumShrinkMany=1; if ($width>($previousWidth*0.99) && $hitNumShrinkMany) { move -r -os -wd 0 0 ($zStep/-4.0) asFitScanCurve;//Move back $i+=$a/4;//Skipping ahead in Main $i loop, no need to rescan slices before wrist break;//hit $hitNumShrinkMany & Shrinking stopped } } if (($hitNumShrinkMany && $width>$previousWidth)) $wristDetectByShrink=1; if (`getAttr asFitScanCurve.tx`>$b/1.8) $wristDetectByGuess=1; if ($wristDetectByShrink || $wristDetectByGuess) { $scanCurveTx=`getAttr asFitScanCurve.tx`; move -r -os -wd 0 0 ($zStep*-1) asFitScanCurve; asSaveProjection Wrist $zxy[$z] CombinedSkinUpper_R "0" 1; setAttr asFitScanCurve.tx $scanCurveTx; if ($wristDetectByGuess) setAttr ($projectedCenterCurve+".overrideColor") 13; if ($hasRefinedArmStraight) $hasHitWrist=1; else { //refine ArmStraight by aiming at asFitPivotWrist createNode -n tempXform2 -p asFitPivotWrist transform;; parent -w tempXform2; setAttr tempXform2.ty `getAttr asFitArmStraight.ty`; parent tempXform2 asFitPivotWrist; setAttr "CombinedSkinUpperBS_R.nodeState" 2;//avoid cycle parent asFitPivotsFingers asFitArmStraight; aimConstraint -mo -weight 1 -aimVector 0 -1 0 -upVector -1 0 0 -worldUpType "scene" tempXform2 asFitArmStraight; setAttr tempXform2.ty (`getAttr tempXform2.ty`*2); parent asFitPivotsFingers asFitPivots; delete asFitArmStraight_aimConstraint1; delete asFitScanCurveWrist asFitHandleWrist asFitProjectionWrist asFitPivotWrist; setAttr "CombinedSkinUpperBS_R.nodeState" 0;//restore move -r -os -wd ($xStep*-1) 0 0 asFitScanCurve; $hasRefinedArmStraight=1; } } } //Elbow if ($hasHitWrist && !`objExists asFitScanCurveElbow` && `objExists asFitPivotArmPit` && $hasStraightenArm) { $scanCurveTx=`getAttr asFitScanCurve.tx`; setAttr asFitScanCurve.tx ((`getAttr asFitScanCurveShoulder.tx`+`getAttr asFitScanCurveWrist.tx`)/2.0); asSaveProjection Elbow $zxy[$z] CombinedSkinUpper_R "closestToasFitPivotArmPit" 1; setAttr asFitScanCurve.tx $scanCurveTx; } //$fourFingerHit if ($zxy[$z]=="y" && $fourFingerHit==0 && $numHits==4) { $scanCurveTx=`getAttr asFitScanCurve.tx`; $fingerDetectPopDist=$zStep/-4; //Keep scanning, and find pos that is Half way to Non-4Hit for ($a=1;$a<199;$a++) { duplicate -n asFitScanCurveAgent asFitScanCurve; move -r -os -wd 0 0 (($zStep/10.0)*$a) asFitScanCurveAgent;//Move forward to check $tempString=`polyProjectCurve -ch true -direction $xDir $yDir $zDir -pointsOnEdges 0 -curveSamples 50 -automatic 1 asFitScanCurveAgent $projectOn`; rename $tempString[0] asFitScanPolyProjectionCurvesAgent; // refresh;//needed for correct $numAgentHits count $numAgentHits=size(`listRelatives -c asFitScanPolyProjectionCurvesAgent`); $agenCurveTx=`getAttr asFitScanCurveAgent.tx`; delete asFitScanCurveAgent asFitScanPolyProjectionCurvesAgent; if ($numAgentHits!=4) break; } setAttr asFitScanCurve.tx (($scanCurveTx+$agenCurveTx)/2.0); //re-project as the projected curves might be `outdated` delete asFitScanPolyProjectionCurves; $tempString=`polyProjectCurve -ch true -direction $xDir $yDir $zDir -pointsOnEdges 0 -curveSamples 50 -automatic 1 asFitScanCurve CombinedSkinUpper_M`; rename $tempString[0] asFitScanPolyProjectionCurves; parent asFitScanPolyProjectionCurves asFitScanCurves; /* spaceLocator -n asFitProjectionLocator1; setAttr asFitProjectionLocator1.overrideEnabled 1; setAttr asFitProjectionLocator1.overrideColor 13; parent asFitProjectionLocator1 AutoPlacing; duplicate -n asFitProjectionLocator2 asFitProjectionLocator1; setAttr asFitProjectionLocator1.overrideColor 17; */ for ($y=0;$y$maxFingerWidth) $maxFingerWidth=$bbMax[2]-$bbMin[2]; $posA[0]=($bbMin[0]+$bbMax[0])/2.0;$posA[1]=($bbMin[1]+$bbMax[1])/2.0;$posA[2]=($bbMin[2]+$bbMax[2])/2.0; setAttr closestSampler.inPosition $posA[0] $posA[1] $posA[2]; $closestVtxIndex=`getAttr closestSampler.closestVertexIndex`; select ("CombinedSkinUpper_M.vtx["+$closestVtxIndex+"]"); //grow outwards, until tip, detrmin how many `growth`, and redo that many (minus 1) to find a resonable end vtx(s) $posA=`xform -q -ws -t`; for ($a=0;$a<199;$a++) { $tempString=`ls -sl -fl`; polySelectConstraint -pp 1 -t 0x0001; $tempString2=`ls -sl -fl`; for ($cc=0;$cc$posA[0])select -d $tempString2[$cc];} $tempString3=`ls -sl -fl`; if (size($tempString3)==size($tempString)) break; } select ("CombinedSkinUpper_M.vtx["+$closestVtxIndex+"]"); for ($dd=0;$dd<$a-1;$dd++) { polySelectConstraint -pp 1 -t 0x0001; $tempString2=`ls -sl -fl`; for ($cc=0;$cc$posA[0])select -d $tempString2[$cc];} } $tempString=`ls -sl -fl`; polySelectConstraint -pp 1 -t 0x0001; select -d $tempString; $tempString2=`ls -sl -fl`; for ($cc=0;$cc$posA[0])select -d $tempString2[$cc];} $tempString=`ls -sl -fl`; $bb=`xform -q -ws -bb`; createNode -n ("asFitPivot"+$fingers[$y]+"Finger4") -p asFitPivotsFingers transform; xform -ws -t (($bb[0]+$bb[3])/2.0) (($bb[1]+$bb[4])/2.0) (($bb[2]+$bb[5])/2.0) ("asFitPivot"+$fingers[$y]+"Finger4"); select $tempString; //fingerTip vtx(s) selected here //then grow `in-wards` until knuckle $curveCmd="curve -d 1 -n FingerCurve"+$fingers[$y]; $numCV=0; $reachedHalfWay=0; for ($a=0;$a<199;$a++) { $tempString3=`ls -sl -fl`; polySelectConstraint -pp 1 -t 0x0001; $tempString4=`ls -sl -fl`; select -d $tempString3; $tempString5=`ls -sl -fl`; $bb=`xform -q -ws -bb`; if ($bb[3]>$posA[0]) $reachedHalfWay=1; $curveCmd+=" -p "+(($bb[0]+$bb[3])/2.0)+" "+(($bb[1]+$bb[4])/2.0)+" "+(($bb[2]+$bb[5])/2.0); $numCV++; if ($reachedHalfWay) for ($cc=0;$cc$maxFingerWidth) $maxFingerWidth=$bbMax[2]-$bbMin[2]; $posA[0]=($bbMin[0]+$bbMax[0])/2.0;$posA[1]=($bbMin[1]+$bbMax[1])/2.0;$posA[2]=($bbMin[2]+$bbMax[2])/2.0; xform -ws -t $posA[0] $posA[1] $posA[2] asFitProjectionLocator1; if (`objExists asFitScanCurveAgents`) delete asFitScanCurveAgents; createNode -n asFitScanCurveAgents -p AutoPlacing transform; createNode -n asFitScanCurveAgentScanCurves -p asFitScanCurveAgents transform; createNode -n asFitScanCurveAgentProjections -p asFitScanCurveAgents transform; setAttr asFitScanCurveAgentScanCurves.v 0; for ($a=0;$a<199;$a++) { duplicate -n ("asFitScanCurveAgent"+$a) asFitScanCurve; parent ("asFitScanCurveAgent"+$a) asFitScanCurveAgentScanCurves; move -r -os -wd 0 0 (($zStep/-10.0*$b)*$a) ("asFitScanCurveAgent"+$a);//Move forward to check $tempString=`polyProjectCurve -ch true -direction $xDir $yDir $zDir -pointsOnEdges 0 -curveSamples 50 -automatic 1 ("asFitScanCurveAgent"+$a) $projectOn`; rename $tempString[0] ("asFitScanPolyProjectionCurvesAgent"+$a); parent ("asFitScanPolyProjectionCurvesAgent"+$a) asFitScanCurveAgentProjections; $nearestCurveStepDist=999; // refresh; $agentProjectedCurves=`listRelatives -c -type transform ("asFitScanPolyProjectionCurvesAgent"+$a)`; for ($c=0;$c>`; if ($curveStepDist<$nearestCurveStepDist) { $nearestCurve=$agentProjectedCurves[$c]; $nearestCurveStepDist=$curveStepDist; xform -ws -t $posB[0] $posB[1] $posB[2] asFitProjectionLocator2; } } for ($c=0;$c$fingerDetectPopDist && $a>0) { $tempString=`listRelatives -c -type transform ("asFitScanPolyProjectionCurvesAgent"+($a-1))`; duplicate -n ("asFitProjection"+$fingers[$y]+"Finger"+$fingerSuffixNr) $tempString[0]; parent ("asFitProjection"+$fingers[$y]+"Finger"+$fingerSuffixNr) asFitProjectionsTemp; $bbMin=`getAttr ("asFitScanPolyProjectionCurvesAgent"+($a-1)+".boundingBoxMin")`; $bbMax=`getAttr ("asFitScanPolyProjectionCurvesAgent"+($a-1)+".boundingBoxMax")`; $posA[0]=($bbMin[0]+$bbMax[0])/2.0;$posA[1]=($bbMin[1]+$bbMax[1])/2.0;$posA[2]=($bbMin[2]+$bbMax[2])/2.0; createNode -n ("asFitPivot"+$fingers[$y]+"Finger"+$fingerSuffixNr) -p asFitPivotsFingers transform; xform -ws -t $posA[0] $posA[1] $posA[2] ("asFitPivot"+$fingers[$y]+"Finger"+$fingerSuffixNr); a; refresh; break; } else { $bbMin=`getAttr ($nearestCurve+".boundingBoxMin")`; $bbMax=`getAttr ($nearestCurve+".boundingBoxMax")`; $posA[0]=($bbMin[0]+$bbMax[0])/2.0;$posA[1]=($bbMin[1]+$bbMax[1])/2.0;$posA[2]=($bbMin[2]+$bbMax[2])/2.0; xform -ws -t $posA[0] $posA[1] $posA[2] asFitProjectionLocator1; $curveCmd+=" -p "+$posA[0]+" "+$posA[1]+" "+$posA[2]; $numCV++; } } eval ($curveCmd); parent ("FingerCurve"+$fingers[$y]+$fingerSuffixNr) asFitPivotsFingers; if ($b==-1) { //minimun 2cvs if (`getAttr ("FingerCurve"+$fingers[$y]+"1.spans")`==0) { rename ("FingerCurve"+$fingers[$y]+"4") ("FingerCurve"+$fingers[$y]); delete ("FingerCurve"+$fingers[$y]+"1"); } else if (`getAttr ("FingerCurve"+$fingers[$y]+"4.spans")`==0) { rename ("FingerCurve"+$fingers[$y]+"1") ("FingerCurve"+$fingers[$y]); delete ("FingerCurve"+$fingers[$y]+"4"); } if (!`objExists ("FingerCurve"+$fingers[$y])`) { attachCurve -n ("FingerCurve"+$fingers[$y]) -ch 0 -rpo 0 -kmk 1 -m 1 -bb 0.5 -bki 0 -p 0.1 ("FingerCurve"+$fingers[$y]+"1") ("FingerCurve"+$fingers[$y]+"4"); delete ("FingerCurve"+$fingers[$y]+"1") ("FingerCurve"+$fingers[$y]+"4"); parent ("FingerCurve"+$fingers[$y]) asFitPivotsFingers; } } */ } setAttr AutoPlacing.fingerWidth $maxFingerWidth; $fourFingerHit=1; } } //nCloth-fingers if ($fourFingerHit && !$hasNCloth) { createNode -n fingersConverge -p asFitPivots transform; pointConstraint asFitPivotNeck fingersConverge; for ($y=0;$y1) break; } $tempString=`listRelatives -c -type transform asFitScanPolyProjectionCurves`; createNode -n angledSamplerOffset -p AutoPlacing transform; createNode -n angledSampler -p angledSamplerOffset transform; xform -ws -t 0 $bbMaxY $bbMinZ angledSamplerOffset; setAttr angledSamplerOffset.rx 35; for ($t=0;$t$maxZ) { $maxZ=$posB[2]; $posA=$pos; $thumbCurve=$tempString[$t]; } } } setAttr closestSampler.inPosition $posA[0] $posA[1] $posA[2]; $closestVtxIndex=`getAttr closestSampler.closestVertexIndex`; select ("CombinedSkinUpper_M.vtx["+$closestVtxIndex+"]"); for ($t=0;$t<20;$t++)//20loops of growing should be enought to find the tip of the Thumb { $tempString=`ls -sl -fl`; $minXupdatedThisRound=0; for ($r=0;$r$maxX) { $posB=$pos; $maxX=$posA[0]; } } xform -ws -t $posB[0] $posB[1] $posB[2] asFitPivotThumbFinger4; delete angledSamplerOffset; setAttr asFitScanCurve.tx $scanCurveTx; $hasHitThumbBranch=1; } } } //guestimate eye placement (and scale) based upon 1st selected geo $eyeGeoText=$rightEye; tokenize $eyeGeoText $tempString; for ($i=0;$i-1;$i--) { xform -ws -t ($posXs[$i]*$newScale) ($posYs[$i]*$newScale) ($posZs[$i]*$newScale) $tempString[$i]; if (`attributeExists fat $tempString[$i]`) setAttr ($tempString[$i]+".fat") (`getAttr ($tempString[$i]+".fat")`*$newScale); } pointConstraint -skip x asFitPivotOffsetRoot Root; } //Hip if (`objExists asFitPivotHip` && `objExists Hip` && `objExists asFitPivotAnkle`) { $pos=`xform -q -ws -t asFitPivotHip`; $projectedCenterCurve=`asGetProjectedCurve asFitProjectionHip "center"`; $bbMin=`getAttr ($projectedCenterCurve+".boundingBoxMin")`; $bbMax=`getAttr ($projectedCenterCurve+".boundingBoxMax")`; xform -ws -t $pos[0] $pos[1] $pos[2] Hip; pointConstraint asFitPivotOffsetHip Hip; } //Knee if (`objExists asFitPivotKnee` && `objExists Knee`) pointConstraint asFitPivotOffsetKnee Knee; //Ankle if (`objExists asFitPivotAnkle` && `objExists Ankle`) pointConstraint asFitPivotOffsetAnkle Ankle; //Toes if (`objExists asFitPivotToes` && `objExists Toes`) pointConstraint asFitPivotOffsetToes Toes; //Toes if (`objExists asFitPivotToes` && `objExists Toes`) pointConstraint asFitPivotOffsetToes Toes; //Heel (Anchor) if (`objExists asFitAnchorHeel` && `objExists Heel`) pointConstraint asFitAnchorHeel Heel; //asFitAnchorFootSideOuter (Anchor) if (`objExists asFitAnchorFootSideOuter` && `objExists FootSideOuter`) pointConstraint asFitAnchorFootSideOuter FootSideOuter; //asFitAnchorFootSideInner (Anchor) if (`objExists asFitAnchorFootSideInner` && `objExists FootSideInner`) pointConstraint asFitAnchorFootSideInner FootSideInner; //asFitAnchorToesEnd (Anchor) if (`objExists asFitAnchorToesEnd` && `objExists ToesEnd`) pointConstraint asFitAnchorToesEnd ToesEnd; //Spine1 if (`objExists asFitPivotRoot` && `objExists asFitPivotSpine1` && `objExists Spine1`) pointConstraint -skip z asFitPivotOffsetSpine1 Spine1; //Chest if (`objExists asFitPivotRoot` && `objExists asFitPivotChest` && `objExists Chest`) pointConstraint -skip z asFitPivotOffsetChest Chest; //Neck if (`objExists asFitPivotNeck` && `objExists Neck`) pointConstraint -skip z -w 1.0 asFitPivotOffsetNeck Neck; //Head if (`objExists asFitPivotHead` && `objExists Head`) { delete `pointConstraint -skip z -w 1.0 asFitPivotOffsetHead Head`; $posA=`xform -q -ws -t asFitPivotOffsetHead`; $posB=`xform -q -ws -t asFitPivotOffsetNeck`; xform -ws -t 0 $posA[1] $posB[2] Head; pointConstraint -skip z -w 1.0 asFitPivotOffsetHead Head; if (`objExists HeadEnd`) xform -ws -t 0 $bbMaxY $posA[2] HeadEnd; if (`objExists Jaw`) xform -ws -t 0 ($posA[1]+(($bbMaxY-$posA[1])/5.0)) ($posA[2]+(`getAttr AutoPlacing.bbMaxY`/50.0)) Jaw; if (`objExists JawEnd`) setAttr JawEnd.tx (($bbMaxY-$posA[1])/3.0); } //Eye if (`objExists asFitPivotHead` && `objExists Eye`) if (`objExists asFitPivotEye`) { pointConstraint -w 1.0 asFitPivotEye Eye; if (`objExists EyeEnd`) setAttr EyeEnd.tx `getAttr asFitPivotEye.radius`; } else { $posA=`xform -q -ws -t asFitPivotHead`; $posB=`xform -q -ws -t asFitPivotNeck`; xform -ws -t (($bbMaxY-$posA[1])/-5.0) ($posA[1]+(($bbMaxY-$posA[1])/2.0)) ($posA[2]+(`getAttr AutoPlacing.bbMaxY`/15.0)) Eye; if (`objExists EyeEnd`) setAttr EyeEnd.tx (($bbMaxY-$posA[1])/10.0); } //Scapula if (`objExists asFitPivotOffsetShoulder` && `objExists Scapula`) { //Scapula as part of Shoulder if (`objExists asFitPivotOffsetScapula1`) delete asFitPivotOffsetScapula1; duplicate -n asFitPivotOffsetScapula1 asFitPivotOffsetShoulder; duplicate -n asFitPivotOffsetScapula2 asFitPivotOffsetShoulder; parent asFitPivotOffsetScapula2 asFitPivotOffsetScapula1; pointConstraint -skip x asFitPivotOffsetShoulder asFitPivotOffsetScapula1; pointConstraint -skip y -skip z -w 0.33 asFitPivotOffsetShoulder asFitPivotOffsetScapula2; pointConstraint -skip y -skip z -w 0.67 asFitPivots asFitPivotOffsetScapula2; pointConstraint -w 1.0 asFitPivotOffsetScapula2 Scapula; } //Shoulder if (`objExists asFitPivotShoulder` && `objExists Shoulder`) pointConstraint -w 1.0 asFitPivotOffsetShoulder Shoulder; //Wrist if (`objExists asFitPivotWrist` && `objExists Wrist`) pointConstraint -w 1.0 asFitPivotOffsetWrist Wrist; //Elbow if (`objExists asFitPivotElbow` && `objExists Elbow`) pointConstraint -w 1.0 asFitPivotOffsetElbow Elbow; //Fingers $offset=0; if (`objExists asFitPivotIndexFinger1` && `objExists asFitPivotMiddleFinger1`) { $posA=`xform -q -ws -t asFitPivotIndexFinger1`; $posB=`xform -q -ws -t asFitPivotMiddleFinger1`; $offset=`mag<<$posA[0]-$posB[0],$posA[1]-$posB[1],$posA[2]-$posB[2]>>`/2.0; } for ($y=0;$y(`getAttr asFitHandleShoulder.tx`*1.5))) delete ("asFitProjectionLoftCurveyLoft"+$i); } } select `listRelatives -c ("asFitLoftCurves"+$zxy)`; loft -n ("asFitLoftSurface"+$zxy) -ch 0 -u 1 -c 0 -ar 1 -d 3 -ss 2 -rn 0 -po 0 -rsn true; //extend zLoft to fingers and chest if ($zxy=="yLoft") { $maxCvNr=`getAttr asFitLoftSurfaceyLoft.spansV`+2; $pos=`xform -q -ws -t asFitLoftSurfaceyLoft.cv[0][0]`; move -r -os -wd ($bbMinX-$pos[0]) 0 0 asFitLoftSurfaceyLoft.cv[0:7][0:1]; $pos=`xform -q -ws -t asFitLoftSurfaceyLoft.cv[0][$maxCvNr]`; move -r -os -wd ($pos[0]*-1) 0 0 asFitLoftSurfaceyLoft.cv[0:7][($maxCvNr-1):$maxCvNr]; } parent ("asFitLoftSurface"+$zxy) asFitCombinedLofts; delete ("asFitLoftCurves"+$zxy); setAttr ("asFitLoftSurface"+$zxy+".v") 0; nurbsToPoly -n ("asFitLoft"+$zxy) -mnd 1 -ch 0 -f 2 -pt 1 -pc 200 -chr 0.9 -ft 0.01 -mel 0.001 -d 0.1 -ut 3 -un 1 -vt 3 -vn 1 -uch 0 -ucr 0 -cht 0.2 -es 0 -ntr 0 -mrt 0 -uss 1 ("asFitLoftSurface"+$zxy); parent ("asFitLoft"+$zxy) asFitCombinedLofts; setAttr ("asFitLoft"+$zxy+".v") 0; duplicate -n ("asFitLoft"+$zxy+"_R") ("asFitLoft"+$zxy); select ("asFitLoft"+$zxy+"_R"); polySelectConstraint -m 3 -t 1 -d 3 -db 0 999 -da 1 0 0 -dp 999 0 0; $tempString=`ls -sl -fl`; polySelectConstraint -m 0; for ($i=0;$i($bbMax[0]-$bbMin[0])) $widthAxis="z"; //print ("$widthAxis="+$widthAxis+" "+$projectedCurvesGrp+"\n"); $projectedCurves=`listRelatives -c -type transform $projectedCurvesGrp`; $bbCenterXMin=$bbCenterXABSMin=999; $bbCenterZMax=-999; for ($i=0;$i$centerCurveWidth) { $bbCenterXABSMin=$bbCenterXABS; $centerCurveNr=$i; $centerCurveWidth=$width; } if ($bbCenterX<$bbCenterXMin) { $bbCenterXMin=$bbCenterX; $rightCurveNr=$i; } if ($bbCenterZ>$bbCenterZMax) { $bbCenterZMax=$bbCenterZ; $frontCurveNr=$i; } if ($width>$widthMax) { $widthMax=$width; $widestCurveNr=$i; } } if (`gmatch $find "[0-9]"`) { $findInt=$find; $projectedCurve=$projectedCurves[$findInt]; } if ($find=="center") $projectedCurve=$projectedCurves[$centerCurveNr]; if ($find=="right") $projectedCurve=$projectedCurves[$rightCurveNr]; if ($find=="front") $projectedCurve=$projectedCurves[$frontCurveNr]; if ($find=="widest") $projectedCurve=$projectedCurves[$widestCurveNr]; if (`gmatch $find "closestTo*"`) { $closestTo=`substitute "closestTo" $find""`; // $closestToPivot=`substitute "asFitProjection" $closestTo "asFitPivot"`; $posA=`xform -q -ws -t $closestTo`; $minDist=999; for ($i=0;$i>`; if ($dist<$minDist) { $minDist=$dist; $projectedCurve=$projectedCurves[$i]; } } } return $projectedCurve; } global proc float asGetProjectedCurveWidthMin (string $projectedCurve) { float $width; float $pos[],$bbMin[],$bbMax[]; if (`objExists tempWidthMessure`) delete tempWidthMessure; createNode -n tempWidthMessure transform; createNode -n tempWidthMessure2 -p tempWidthMessure transform; $bbMin=`getAttr ($projectedCurve+".boundingBoxMin")`; $bbMax=`getAttr ($projectedCurve+".boundingBoxMax")`; xform -ws -t (($bbMin[0]+$bbMax[0])/2.0) (($bbMin[1]+$bbMax[1])/2.0) (($bbMin[2]+$bbMax[2])/2.0) tempWidthMessure; geometryConstraint -weight 1 $projectedCurve tempWidthMessure2; $pos=`getAttr tempWidthMessure2.t`; $width=`mag <<$pos[0],$pos[1],$pos[2]>>`*2; if (`objExists tempWidthMessure`) delete tempWidthMessure; return $width; } global proc asUpdateProjection (string $name, string $zxy, string $skin, string $find, int $keepHistory) { //for when we need to re-do a `asSaveProjection`, for e.g. newly existing $skin such as "CombinedSkinUpper_R" float $pos[]=`getAttr asFitScanCurve.t`; float $rot[]=`getAttr asFitScanCurve.r`; float $pos2[]=`getAttr ("asFitScanCurve"+$name+".t")`; float $rot2[]=`getAttr ("asFitScanCurve"+$name+".r")`; setAttr asFitScanCurve.t -type float3 $pos2[0] $pos2[1] $pos2[2]; setAttr asFitScanCurve.r -type float3 $rot2[0] $rot2[1] $rot2[2]; delete ("asFitScanCurve"+$name) ("asFitHandle"+$name) ("asFitProjection"+$name) ("asFitPivot"+$name); asSaveProjection $name $zxy $skin $find $keepHistory; setAttr asFitScanCurve.t -type float3 $pos[0] $pos[1] $pos[2]; setAttr asFitScanCurve.r -type float3 $rot[0] $rot[1] $rot[2]; } global proc asSaveProjection (string $name, string $zxy, string $skin, string $find, int $keepHistory) { int $widthAxisNr; float $bbMinZ=`getAttr AutoPlacing.bbMinZ`; float $bbMaxZ=`getAttr AutoPlacing.bbMaxZ`; float $bbMinX=`getAttr AutoPlacing.bbMinX`; float $xDir,$yDir,$zDir,$width; float $bbMin[],$bbMax[],$pos[]; string $projectedCurve; string $tempString[]; if (`gmatch $zxy "z*"`) {$xDir=0;$yDir=0;$zDir=1;} if ($zxy=="x") {$xDir=1;$yDir=0;$zDir=0;} if (`gmatch $zxy "y*"`) {$xDir=0;$yDir=1;$zDir=0;} duplicate -n ("asFitScanCurve"+$name) asFitScanCurve; //Override front-projections to side-projections (z to x) if (`gmatch $zxy "z*"`) { $xDir=1;$yDir=0;$zDir=0; $pos=`xform -q -ws -t asFitScanCurve`; setAttr ("asFitScanCurve"+$name+".t") -type float3 $bbMinX $pos[1] (($bbMinZ+$bbMaxZ)/2.0); setAttr ("asFitScanCurve"+$name+".ry") -90; $zxy="x"; } setAttr ("asFitScanCurve"+$name+".v") 0; setAttr ("asFitScanCurve"+$name+"Shape.dispGeometry") 1; $tempString=`polyProjectCurve -ch true -direction $xDir $yDir $zDir -pointsOnEdges 0 -curveSamples 50 -automatic 1 ("asFitScanCurve"+$name) $skin`; rename $tempString[0] ("asFitProjection"+$name); rename $tempString[1] ("polyProjectCurve"+$name); parent ("asFitProjection"+$name) asFitProjections; $pos=`xform -q -ws -t ("asFitScanCurve"+$name)`; $rot=`getAttr ("asFitScanCurve"+$name+".r")`; $tempString[0]=`curve -d 1 -p 0 0 0 -p 0 0 0 -k 0 -k 1`; rename $tempString[0] ("asFitHandle"+$name); parent ("asFitHandle"+$name) asFitHandles; setAttr ("asFitHandle"+$name+".overrideEnabled") 1; setAttr ("asFitHandle"+$name+".overrideColor") 14; addAttr -k 0 -ln "xyz" -at "enum" -en "x:y:z:" ("asFitHandle"+$name); addAttr -k 1 -ln offsetX -at double ("asFitHandle"+$name); addAttr -k 1 -ln offsetY -at double ("asFitHandle"+$name); addAttr -k 1 -ln offsetZ -at double ("asFitHandle"+$name); if (`gmatch $zxy "z*"`) { xform -ws -t $pos[0] $pos[1] 0 ("asFitHandle"+$name); xform -ws -piv $pos[0] $pos[1] $pos[2] ("asFitHandle"+$name); setAttr ("asFitHandle"+$name+".xyz") 2; } if ($zxy=="x") { xform -ws -t 0 $pos[1] $pos[2] ("asFitHandle"+$name); setAttr ("asFitHandle"+$name+".controlPoints[1].xValue") `getAttr ("asFitScanCurve"+$name+".tx")`; xform -piv `getAttr ("asFitScanCurve"+$name+".tx")` 0 0 ("asFitHandle"+$name); setAttr ("asFitHandle"+$name+".xyz") 0; } if (`gmatch $zxy "y*"`) { xform -ws -t $pos[0] 0 0 ("asFitHandle"+$name); setAttr ("asFitHandle"+$name+".controlPoints[1].yValue") `getAttr ("asFitScanCurve"+$name+".ty")`; xform -ws -piv $pos[0] $pos[1] 0 ("asFitHandle"+$name); setAttr ("asFitHandle"+$name+".overrideColor") 13; setAttr ("asFitHandle"+$name+".xyz") 1; } parentConstraint -mo ("asFitHandle"+$name) ("asFitScanCurve"+$name); setAttr ("asFitProjection"+$name+".overrideEnabled") 1; setAttr ("asFitProjection"+$name+".overrideColor") 17; $tempString=`listRelatives -c -type transform ("asFitProjection"+$name)`; for ($i=0;$i$maxY) $maxY=$pos[1]; } if (`objExists tempXforms`) delete tempXform; createNode -n tempXforms transform; for ($i=1;$i<5;$i++) { if (`objExists ("tempXform"+$i)`) delete ("tempXform"+$i); createNode -n tempXform1 -p tempXforms transform; } parent tempXform4 tempXform1; asAlign tempXform1 $endJoint 1 0 0 0; asAlign tempXform2 $middleJoint 1 0 0 0; asAlign tempXform3 $middleJoint 1 0 0 0; move -r -ls -wd 0 0 ($maxY/10.0) tempXform3; aimConstraint -aimVector 1 0 0 -upVector 0 1 0 -worldUpType "object" -worldUpObject tempXform3 tempXform2 tempXform1; delete `pointConstraint $startJoint tempXform4`; if ($limb=="Arm") setAttr tempXform4.ty ($maxY/100.0); if ($limb=="Leg") setAttr tempXform4.ty ($maxY/-100.0); setAttr tempXform4.tz 0; $pos=`xform -q -ws -t tempXform4`; $pos2=`xform -q -ws -t $startJoint`; if ($limb=="Leg") setAttr ("asFitHandle"+$startJoint+".offsetX") (($pos[0]-$pos2[0])+`getAttr ("asFitHandle"+$startJoint+".offsetX")`); if ($limb=="Arm") setAttr ("asFitHandle"+$startJoint+".offsetY") (($pos[1]-$pos2[1])+`getAttr ("asFitHandle"+$startJoint+".offsetY")`); if (($limb=="Arm" && $pos[2]>$pos2[2]) || ($limb=="Leg" && $pos[2]<$pos2[2])) setAttr ("asFitHandle"+$startJoint+".offsetZ") (($pos[2]-$pos2[2])+`getAttr ("asFitHandle"+$startJoint+".offsetZ")`); delete tempXforms; select $sel; print ("// Straightened "+$limb+" by applying Offset values to asFitHandle"+$startJoint+"\n"); } global proc asPolyGrowPastShell () { float $bbMin[],$bbMax[]; float $bbMinX; float $width; string $obj; string $sel[]=`ls -sl`; string $tempString[],$additionalSelection[]; $tempString=`ls -sl -o`; $tempString=`listRelatives -p $tempString[0]`; $obj=$tempString[0]; duplicate -n tempPolyGrowPastShell1 $obj; duplicate -n tempPolyGrowPastShell2 $obj; select `asobjSetCast "" $sel tempPolyGrowPastShell1`; ConvertSelectionToFaces; delete; select `asobjSetCast "" $sel tempPolyGrowPastShell2`; ConvertSelectionToFaces; asInvertSelection; delete; select tempPolyGrowPastShell1 tempPolyGrowPastShell2; $tempString=`doWrapArgList "7" { "1","0","0.001", "2", "1", "0", "1", "0" }`; //doWrapArgList (7) {$operation=createWrap, $threshold, $maxDist , $inflType(1=vtx2=f), $exclusiveBind, $autoWeightThreshold, $renderInfl, $falloffMode} rename $tempString[0] tempPolyGrowPastShellWrap; $bbMin=`getAttr tempPolyGrowPastShell1.boundingBoxMin`; $bbMax=`getAttr tempPolyGrowPastShell1.boundingBoxMax`; $width=$bbMax[0]-$bbMin[0]; move -r ($width*-2) 0 0 tempPolyGrowPastShell2; setAttr tempPolyGrowPastShellWrap.maxDistance $width; for ($i=0;$i<10;$i++) { //print ("$i="+$i+" "+`getAttr tempPolyGrowPastShellWrap.maxDistance`+"\n"); setAttr tempPolyGrowPastShellWrap.maxDistance (`getAttr tempPolyGrowPastShellWrap.maxDistance`/10.0); $bbMinX=`getAttr tempPolyGrowPastShell1.boundingBoxMinX`; if ($bbMin[0]<=$bbMinX) { for ($y=0;$y<100;$y++) { //print ("$y="+$y+" "+`getAttr tempPolyGrowPastShellWrap.maxDistance`+"\n"); setAttr tempPolyGrowPastShellWrap.maxDistance (`getAttr tempPolyGrowPastShellWrap.maxDistance`*1.05); $bbMinX=`getAttr tempPolyGrowPastShell1.boundingBoxMinX`; if ($bbMin[0]>$bbMinX) { // setAttr tempPolyGrowPastShellWrap.maxDistance (`getAttr tempPolyGrowPastShellWrap.maxDistance`/1.05); select tempPolyGrowPastShell1; polySelectConstraint -m 3 -t 1 -d 3 -db 0 999 -da 1 0 0 -dp (999+$bbMin[0]) 0 0; $tempString=`ls -sl`; polySelectConstraint -m 0; select $tempString; asInvertSelection; $tempString=`ls -sl`; $additionalSelection=`asobjSetCast "" $tempString $obj`; break; } } break; } } delete tempPolyGrowPastShell1 tempPolyGrowPastShell2 tempPolyGrowPastShellWrap; select $sel; if ($additionalSelection[0]=="") print ("asPolyGrowPastShell failed\n"); else select -add $additionalSelection; } global proc asOpenDemoFile () { string $asScriptLocation=`asGetScriptLocation`; string $exampleFoldersDir=$asScriptLocation+"/AdvancedSkeleton5Files/exampleFiles/downloads/"; string $exampleFolder=`optionMenu -q -v asDemoOptionMenu`; string $exampleFile=$exampleFoldersDir+$exampleFolder+"/"+$exampleFolder+".mb"; string $tempString[]; float $preMayaVersion; //backwards compatability files string $exampleFiles[]=`getFileList -fld ($exampleFoldersDir+$exampleFolder+"/")`; for ($i=0;$i>`; if ($lenght==0) $lenght=$parentLenght; float $lenghtMuliplier=1; if ($lenght!=0) $lenghtMuliplier=$parentLenght*1/$lenght; if (`objExists ($loc+"End")`) { if (!`getAttr -l ($loc+"End.tx")`) setAttr ($loc+"End.tx") ($pos[0]+($pos[0]-$pos2[0])/$lenghtMuliplier); if (!`getAttr -l ($loc+"End.ty")`) setAttr ($loc+"End.ty") ($pos[1]+($pos[1]-$pos2[1])/$lenghtMuliplier); if (!`getAttr -l ($loc+"End.tz")`) setAttr ($loc+"End.tz") ($pos[2]+($pos[2]-$pos2[2])/$lenghtMuliplier); } } } global proc asUpdateButtonEnables () { if (!`columnLayout -q -ex asColumnLayout`) return; global int $asBodyPreGameEngine; global int $asBodyPreZUpAxis; global string $asBodyPreSkin; global string $asBodyPreAll; global string $asBodyPreRightEye; global string $asBodyPreLeftEye; int $faceGameEngine,$rigTypeInt,$displayPoleVector,$displayJointOrient,$displayJointAxis,$lockCenterJoints,$worldmatch; int $showSkinLayersFrameLayout,$showTweaksFrameLayout,$bodyGameEngine,$zUpAxis,$mirTrans,$fitSkeletonVisible,$faceFitSkeletonVisible; int $primaryAxis=0; int $secondaryAxis=1; int $hasBodySetup=`objExists "Group"`; int $hasFaceSetup=`objExists FaceMotionSystem`; int $hasVisualizers=`objExists FitSkeletonVisualizers`; int $hasGeometryVisualizers=`objExists FitSkeletonVisualizers` && `objExists Aims`; int $showDelteAdvButton,$showDelteAdvFaceButton,$showAutoPlaceTweaks; if (`objExists FitSkeleton`) if (`getAttr FitSkeleton.v`) $fitSkeletonVisible=1; if (`objExists FaceFitSkeleton`) if (`getAttr FaceFitSkeleton.v`) $faceFitSkeletonVisible=1; if ($hasBodySetup && $fitSkeletonVisible) $showDelteAdvButton=1; if ($hasFaceSetup && $faceFitSkeletonVisible) $showDelteAdvFaceButton=1; string $buildLabel,$skin,$all,$rightEye,$leftEye,$layer,$autoPlaceButtonLabel; string $tempString[]; if (`attributeExists RigType FaceFitSkeleton`) $rigTypeInt=`getAttr FaceFitSkeleton.RigType`; if (`attributeExists GameEngine FaceFitSkeleton`) $faceGameEngine=`getAttr FaceFitSkeleton.GameEngine`; if (`attributeExists objectsSkin FitSkeleton`) $skin=`getAttr FitSkeleton.objectsSkin`; if (`attributeExists objectsAll FitSkeleton`) $all=`getAttr FitSkeleton.objectsAll`; if (`attributeExists objectsRightEye FitSkeleton`) $rightEye=`getAttr FitSkeleton.objectsRightEye`; if (`attributeExists objectsLeftEye FitSkeleton`) $leftEye=`getAttr FitSkeleton.objectsRightEye`; if (`attributeExists visPoleVector FitSkeleton`) $displayPoleVector=`getAttr FitSkeleton.visPoleVector`; if (`attributeExists visJointOrient FitSkeleton`) $displayJointOrient=`getAttr FitSkeleton.visJointOrient`; if (`attributeExists visJointAxis FitSkeleton`) $displayJointAxis =`getAttr FitSkeleton.visJointAxis`; if (`attributeExists lockCenterJoints FitSkeleton`) $lockCenterJoints=`getAttr FitSkeleton.lockCenterJoints`; if (`attributeExists gameEngine FitSkeleton`) $bodyGameEngine=`getAttr FitSkeleton.gameEngine`; if (`attributeExists zUpAxis FitSkeleton`) $zUpAxis=`getAttr FitSkeleton.zUpAxis`; if (`attributeExists mirTrans FitSkeleton`) $mirTrans=`getAttr FitSkeleton.mirTrans`; if (`attributeExists primaryAxis FitSkeleton`) $primaryAxis=`getAttr FitSkeleton.primaryAxis`;//else $primaryAxis=0; if (`attributeExists secondaryAxis FitSkeleton`) $secondaryAxis=`getAttr FitSkeleton.secondaryAxis`;//else $secondaryAxis=1; if (`attributeExists worldmatch FitSkeleton`) $worldmatch=`getAttr FitSkeleton.worldmatch`;//else $secondaryAxis=1; //prior to FitSkeleton exits if (!`objExists FitSkeleton`) { $bodyGameEngine=$asBodyPreGameEngine; $zUpAxis=$asBodyPreZUpAxis; $skin=$asBodyPreSkin; $all=$asBodyPreAll; $rightEye=$asBodyPreRightEye; $leftEye=$asBodyPreLeftEye; } //Body textField -e -tx $skin asBodySkinTextField; textField -e -tx $all asBodyAllTextField; textField -e -tx $rightEye asBodyRightEyeTextField; textField -e -tx $leftEye asBodyLeftEyeTextField; checkBox -e -v $bodyGameEngine asBodyGameEngineCheckBox; checkBox -e -v $zUpAxis asBodyZUpAxisCheckBox; checkBox -e -v $mirTrans asBodyMirTransCheckBox; optionMenu -e -sl ($primaryAxis+1) asPrimaryAxisOptionMenu; optionMenu -e -sl ($secondaryAxis+1) asSecondaryAxisOptionMenu; checkBox -e -v $hasGeometryVisualizers asVisGeo; optionMenu -e -en $hasVisualizers asVisGeoType; floatSliderGrp -e -en $hasVisualizers asVisGap; checkBox -e -v $displayPoleVector asVisPoleVector; checkBox -e -v $displayJointOrient asVisJointOrient; checkBox -e -v $displayJointAxis asVisJointAxis; checkBox -e -en (!$worldmatch) -v $lockCenterJoints asLockCenterJoints; optionMenu -e -en (!$worldmatch) asPrimaryAxisOptionMenu; optionMenu -e -en (!$worldmatch) asSecondaryAxisOptionMenu; checkBox -e -v $worldmatch asAutoOrientWorldMatchCheckBox; button -e -m $showDelteAdvButton asDelteAdvButton; checkBox -e -m $hasBodySetup asKeepAllCheckBox; if (!$hasBodySetup) columnLayout -e -m 0 asBodyKeepColumnLayout; button -e -m $hasBodySetup asToggleFitSkeletonButton; $buildLabel="Build AdvancedSkeleton"; $autoPlaceButtonLabel="autoPlace"; if ($hasBodySetup) $buildLabel="ReBuild AdvancedSkeleton"; if (`objExists AutoPlacing`) { $autoPlaceButtonLabel="delete guides"; $showAutoPlaceTweaks=1; } button -e -l $buildLabel asBuildAdvancedSkeletonButton; button -e -l $autoPlaceButtonLabel asFitAutoPlaceButton; columnLayout -e -m $showAutoPlaceTweaks asFitAutoPlaceTweaksColumnLayout; frameLayout -e -en (!$bodyGameEngine) asBodyDeformDeltaMushFrameLayout; frameLayout -e -en (!$bodyGameEngine) asBodyDeform3FrameLayout; //not diable all CustomControls, since SkinControl should still work with GameEngine //frameLayout -e -en (!$bodyGameEngine) asBodyCustomControlsFrameLayout; columnLayout -e -en (!$bodyGameEngine) ("asBodyCustomControlsNonGameEngineCompatiblesColumnLayout"); //Face (Face-Fit section done in "asFaceUpdateInfo") button -e -m $showDelteAdvFaceButton asDelteAdvFaceButton; checkBox -e -m $hasFaceSetup asFaceKeepAllCheckBox; if (!$hasFaceSetup) columnLayout -e -m 0 asFaceKeepColumnLayout; button -e -m $hasFaceSetup asToggleFitFaceButton; $buildLabel="Build AdvancedFace"; if ($hasFaceSetup) $buildLabel="ReBuild AdvancedFace"; button -e -m 1 -l $buildLabel asBuildAdvancedFaceButton; if (`objExists FaceBuildInProgress`) { checkBox -e -m 0 asFaceKeepAllCheckBox; columnLayout -e -m 0 asFaceKeepColumnLayout; button -e -m 0 asBuildAdvancedFaceButton; button -e -m 0 asDelteAdvFaceButton; } //DeformationLayers if ($rigTypeInt==2 && $faceGameEngine==0) $showSkinLayersFrameLayout=1; frameLayout -e -m $showSkinLayersFrameLayout asFaceSkinLayersFrameLayout; if ($showSkinLayersFrameLayout && `objExists DeformationLayers`) { $tempString=`layout -q -ca asFaceSkinLayersColumnLayout`; for ($i=0;$i>`; } $radius=($circumference/3.14)/2.0; select $skinLoopSets[$r]; select -d ($sel[$i]+".e[0:99999]"); $tempString=`polyExtrudeEdge -constructionHistory 1 -keepFacesTogether 1 -pvx 1.927402496 -pvy 3.865962148 -pvz 0.184265554 -divisions 1 -twist 0 -taper 1 -offset 0 -thickness 0 -smoothingAngle 30`; $extrudedSel=`ls -sl`; setToolTo $gMove; $pos=`manipMoveContext -q -position "Move"`; scale -r -p $pos[0] $pos[1] $pos[2] 0.25 0.25 0.25; $posB=`xform -q -ws -piv $cutName`; spaceLocator -n tempLoc1; xform -ws -t $posB[0] $posB[1] $posB[1] tempLoc1; spaceLocator -n tempLoc2; xform -ws -t $pos[0] $pos[1] $pos[1] tempLoc2; aimConstraint -offset 0 0 0 -weight 1 -aimVector 1 0 0 -upVector 0 1 0 -worldUpType "vector" -worldUpVector 0 1 0 tempLoc2 tempLoc1; parent $cutName tempLoc1; select $extrudedSel; move -r -ls -wd ($radius*0.5) 0 0; parent $cutName CutUpGeometry; parentConstraint -mo $deformJoints[$y] $cutName; scaleConstraint $deformJoints[$y] $cutName; delete tempLoc1 tempLoc2; select $cutName; DeleteHistory; sets -rm $skinLoopSets[$r] ($cutName+".e[0:99999]"); } } } } } if (!$createCutUp) { for ($y=0;$y($checkValues[$y]+0.01) || $value<($checkValues[$y]-0.01)) { $m+=$deformJointsList[$i]+"."+$checkAttr[$y]+" = "+$value+"\n"; $numNonDef++; } if ($numNonDef>$maxTextLines) { $m+="...And more..\n\n"; $y=999; $i=999; } } } if ($m!="") { $m+="It is reccomended that you Go to Build Pose"; string $dialog=`confirmDialog -t "Not in Build Pose" -m $m -b "Go to Build Pose, and Proceed" -b "Just Proceed" -b "Cancel" -ds "Cancel" -db "Cancel"`; if ($dialog=="Go to Build Pose, and Proceed") { asGoToBuildPose bodySetup; refresh; } if ($dialog=="Go to Build Pose, and Proceed") $proceed=1; else if ($dialog=="Just Proceed") $proceed=2; else $proceed=0; } return $proceed; } global proc int asGetCurveNumCvs (string $curve) { int $form,$spans,$degrees,$numCv; $form=`getAttr ($curve+".form")`; $spans=`getAttr ($curve+".spans")`; $degrees=`getAttr ($curve+".degree")`; if ($form==2) $numCv=$spans; else $numCv=$spans+$degrees; return $numCv; } global proc float asgetCharHeight () { float $height; if (`objExists "Main"`) $height=`getAttr "Main.height"`; return $height; } global proc asAxisTest () { string $name; for ($i=1;$i<7;$i++) { optionMenu -e -sl $i asPrimaryAxisOptionMenu; for ($y=1;$y<7;$y++) { if ($i==$y) continue; asDeleteSkeleton; asDeleteSkinCage; optionMenu -e -sl $y asSecondaryAxisOptionMenu; asAxisChanged; asToggleFitAdvancedSkeleton; asDeleteAdvanced; asReBuildAdvancedSkeleton; $name=$i+"_"+$y+"_"+`optionMenu -q -v asPrimaryAxisOptionMenu`+"_"+`optionMenu -q -v asSecondaryAxisOptionMenu`; print ($name+"\n"); asCreateSkeleton; asCreateSkinCage; setAttr PolySkeleton.v 0; setAttr SkinCurves1.v 0; if (`objExists locator1`) delete `orientConstraint Root_M locator1`; playblast -compression "png" -p 100 -st 0 -et 0 -f ("D:/temp/img/"+$name) -fmt image -fo -clearCache 0 -viewer 0 -showOrnaments 0; setAttr PolySkeleton.v 1; setAttr SkinCage.v 0; playblast -compression "png" -p 100 -st 0 -et 0 -f ("D:/temp/img/SkinCage_"+$name) -fmt image -fo -clearCache 0 -viewer 0 -showOrnaments 0; } } } global proc asSetWSOrient (float $x, float $y, float $z, string $transform) { if (!`objExists $transform`) return; if (`objExists tempXform`) delete tempXform; createNode -n tempXform transform; orientConstraint $transform tempXform; asSetOrientOffsetFromAxis tempXform_orientConstraint1 $transform Main; delete tempXform_orientConstraint1; orientConstraint -mo tempXform $transform; xform -ws -ro $x $y $z tempXform; delete ($transform+"_orientConstraint1"); delete tempXform; } global proc asSetOrientOffsetFromAxis (string $constraint, string $joint, string $FitSkeletonOrMain) { float $NegPriYAdd,$NegSecXAdd,$NegSecXAdd; float $NegPriMult=1; string $priAxis=`asGetAxis primary $joint $FitSkeletonOrMain 0`; string $secAxis=`asGetAxis secondary $joint $FitSkeletonOrMain 0`; string $attr="offset"; if (`objectType $constraint`=="parentConstraint") $attr="target[0].targetOffsetRotate"; if (`gmatch $priAxis "-*"`) {$NegPriMult=-1;$NegPriYAdd=180;} if (`gmatch $secAxis "-*"`) $NegSecXAdd=180;//re-added if (`gmatch $priAxis "*X"` && `gmatch $secAxis "*Y"`) setAttr -type float3 ($constraint+"."+$attr) $NegSecXAdd $NegPriYAdd 0; if (`gmatch $priAxis "*X"` && `gmatch $secAxis "*Z"`) setAttr -type float3 ($constraint+"."+$attr) ($NegSecXAdd+(90*$NegPriMult)) $NegPriYAdd 0; if (`gmatch $priAxis "*Y"` && `gmatch $secAxis "*Z"`) setAttr -type float3 ($constraint+"."+$attr) ($NegSecXAdd+(90*$NegPriMult)) $NegPriYAdd 90; if (`gmatch $priAxis "*Y"` && `gmatch $secAxis "*X"`) setAttr -type float3 ($constraint+"."+$attr) ($NegSecXAdd+(180*$NegPriMult)) $NegPriYAdd 90; if (`gmatch $priAxis "*Z"` && `gmatch $secAxis "*X"`) setAttr -type float3 ($constraint+"."+$attr) ($NegSecXAdd+(-90*$NegPriMult)) ($NegPriYAdd-90) 0; if (`gmatch $priAxis "*Z"` && `gmatch $secAxis "*Y"`) setAttr -type float3 ($constraint+"."+$attr) $NegSecXAdd ($NegPriYAdd-90) 0; } global proc asCreateSkeleton () { float $secNrml[3]; string $fitSkeletonTemplate; string $secAxis; if (`objExists SkeletonGeometry`) error "SkeletonGeometry already exists"; if (`attributeExists fitSkeletonTemplate FitSkeleton`) $fitSkeletonTemplate=`getAttr FitSkeleton.fitSkeletonTemplate`; createNode -n SkeletonGeometry -p Geometry transform; createDisplayLayer -e -name PolySkeleton; string $asGeometryFile=`asGetScriptLocation`+"/AdvancedSkeleton5Files/div/asGeometry.ma"; file -i $asGeometryFile; int $numChar,$hasBone,$b; int $vs[]; float $dist,$dist2,$dist3; float $pos[],$pos2[],$pos3[],$scale[]; string $newBone; string $tempString[],$joints[],$children[]; string $deformJointsList[]=`sets -q "DeformSet"`; string $copyBones[]={"Pelvis","Cranium","SpineVertebras","Mandible","Femur","Tibia","Fibula", "Calcaneus","Talus","Metatarsals","Phalanxs","Ribs","Humerus","Scapula","Clavicle","Ulna","Radius","CarpalA","CarpalB","Eye"}; string $joint,$side,$childJoint,$parentJoint,$sourceBone; for ($i=0;$i>`; $scale[0]=$dist; if (`attributeExists "fatFront" $joint`) { $scale[1]=`getAttr ($joint+".fat")`*`getAttr ($joint+".fatFront")`; $scale[2]=`getAttr ($joint+".fat")`*`getAttr ($joint+".fatWidth")`; } else $scale[1]=$scale[2]=$scale[0]; xform -os -a -s $scale[0] $scale[1] $scale[2] ($copyBones[$i]+"Bone"+$side); } if ($side=="_L") { $pos=`xform -q -ws -t $joint`; scale -r -p $pos[0] $pos[1] $pos[2] -1 -1 -1 ($copyBones[$i]+"Bone"+$side); } /* //some bones not to un-twist if (`gmatch $joint "*Shoulder*"` || `gmatch $joint "*Hip*"`) if (`objExists ("TwistBalancer"+$joint)`) connectAttr -f ("TwistBalancer"+$joint+".rotateX") ($copyBones[$i]+"BoneParentConstraint"+$side+"_parentConstraint1.target[0].targetOffsetRotateX"); */ //Spine / neck if ($copyBones[$i]=="SpineVertebras") { if (`objExists Root_M` && `objExists $childJoint`) { $secAxis=`asGetAxis secondary Root_M Main 0`; $secNrml=`asAxisToVector $secAxis`; delete `aimConstraint -offset 0 0 0 -weight 1 -aimVector 1 0 0 -upVector 0 1 0 -worldUpType "objectrotation" -worldUpVector $secNrml[0] $secNrml[1] $secNrml[2] -worldUpObject Root_M $childJoint SpineVertebrasBone_M`; } $scale[0]=`getAttr SpineVertebrasBone_M.sx`; setAttr -type float3 SpineVertebrasBone_M.s $scale[0] $scale[0] $scale[0]; //Coccyx select ("SpineVertebrasBone"+$side+"Shape"); $tempString=`asDeformer softMod`; rename $tempString[0] FixSoftMod; rename $tempString[1] FixSoftModHandle; $pos=`xform -q -ws -t ("SpineVertebrasBone"+$side+"|SpineVertebrasCoccyx")`; $pos2=`xform -q -ws -t ("Root"+$side)`; $pos3=`xform -q -ws -t PelvisBone_M|PelvisBoneFemur`; $dist=`mag<<$pos2[0]-$pos[0],$pos2[1]-$pos[1],$pos2[2]-$pos[2]>>`; setAttr -type float3 FixSoftModHandleShape.origin $pos[0] $pos[1] $pos[2]; setAttr FixSoftMod.falloffCenter $pos[0] $pos[1] $pos[2]; xform -piv $pos2[0] $pos2[1] $pos2[2] FixSoftModHandle; setAttr FixSoftMod.falloffRadius $dist; setAttr FixSoftMod.falloffMode 0; $scale[0]=`mag<<$pos2[0]-$pos3[0],$pos2[1]-$pos3[1],$pos2[2]-$pos3[2]>>`/$dist; setAttr -type float3 FixSoftModHandle.s $scale[0] $scale[0] $scale[0]; select ("SpineVertebrasBone"+$side+"Shape"); DeleteHistory; //Run-through Chest joint if (`objExists Root_M` && `objExists Chest_M`) { select ("SpineVertebrasBone"+$side+"Shape"); $tempString=`asDeformer softMod`; rename $tempString[0] FixSoftMod; rename $tempString[1] FixSoftModHandle; $pos=`xform -q -ws -t Root_M`; $pos2=`xform -q -ws -t Chest_M`; $pos3=`xform -q -ws -t Head_M`; $dist=`mag<<$pos2[0]-$pos[0],$pos2[1]-$pos[1],$pos2[2]-$pos[2]>>`; $dist2=`mag<<$pos3[0]-$pos[0],$pos3[1]-$pos[1],$pos3[2]-$pos[2]>>`; $dist3=`mag<<$pos3[0]-$pos[0],$pos3[1]-$pos[1],$pos3[2]-$pos[2]>>`; if (`objExists tempLoc`) delete tempLoc; spaceLocator -n tempLoc; createNode -n tempMotionPath motionPath; setAttr tempMotionPath.fractionMode 1; connectAttr SpineVertebrasBone_M|SpineVertebrasCurve.worldSpace tempMotionPath.geometryPath; connectAttr tempMotionPath.allCoordinates tempLoc.t; setAttr tempMotionPath.uValue ($dist/$dist2); $pos=`xform -q -ws -t tempLoc`; delete tempLoc tempMotionPath; setAttr -type float3 FixSoftModHandleShape.origin $pos[0] $pos[1] $pos[2]; setAttr FixSoftMod.falloffCenter $pos[0] $pos[1] $pos[2]; xform -piv $pos[0] $pos[1] $pos[2] FixSoftModHandle; setAttr FixSoftMod.falloffRadius ($dist3/2.0); setAttr FixSoftMod.falloffMode 0; delete `pointConstraint Chest_M FixSoftModHandle`; select ("SpineVertebrasBone"+$side+"Shape"); DeleteHistory; } } //Scapula if ($copyBones[$i]=="Scapula" && `objExists ("HumerusBone"+$side)` && `objExists RibsBone_M`) if ($fitSkeletonTemplate!="horse" && $fitSkeletonTemplate!="cat") { $dist=`getAttr ("HumerusBone"+$side+".sx")`; setAttr -type float3 ("ScapulaBone"+$side+".s") $dist $dist $dist; duplicate -n ("ScapulaBone"+$side+"_Copy") ("ScapulaBone"+$side); parent -w ("ScapulaBone"+$side+"_Copy"); catchQuiet (`makeIdentity -a 1 -t 1 -r 1 -s 1 ("ScapulaBone"+$side+"_Copy")`); select ("ScapulaBone"+$side+"_CopyShape"); $tempString=`asDeformer softMod`; rename $tempString[0] FixSoftMod; rename $tempString[1] FixSoftModHandle; $pos=`xform -q -ws -t ("ScapulaBone"+$side+"|ScapulaBoneLoc1")`; $pos2=`xform -q -ws -t ("ScapulaBone"+$side+"|ScapulaBoneLoc2")`; $dist=`mag<<$pos2[0]-$pos[0],$pos2[1]-$pos[1],$pos2[2]-$pos[2]>>`; setAttr -type float3 FixSoftModHandleShape.origin $pos[0] $pos[1] $pos[2]; setAttr FixSoftMod.falloffCenter $pos[0] $pos[1] $pos[2]; xform -piv $pos[0] $pos[1] $pos[2] FixSoftModHandle; setAttr FixSoftMod.falloffRadius $dist; setAttr FixSoftMod.falloffMode 0; setAttr FixSoftMod.falloffInY 0; $pos3=`xform -q -ws -t ("RibsBone_M|RibsBoneLoc1")`; move -r 0 0 (($pos3[2]-$pos[2])*1.2) FixSoftModHandle; select ("ScapulaBone"+$side+"_CopyShape") ("ScapulaBone"+$side+"Shape"); blendShape -n TempBS -w 0 1; setAttr TempBS.origin 0; select ("ScapulaBone"+$side); DeleteHistory; delete ("ScapulaBone"+$side+"_Copy"); } //Clavicle if ($copyBones[$i]=="Clavicle" && `objExists ("ScapulaBone"+$side)` && `objExists RibsBone_M`) { $secAxis=`asGetAxis secondary Chest_M Main 0`; $secNrml=`asAxisToVector $secAxis`; $pos=`xform -q -ws -t ("RibsBone_M|RibsBoneClavicle")`; xform -ws -t ($pos[0]*$b) $pos[1] $pos[2] ("ClavicleBone"+$side); $pos2=`xform -q -ws -t ("ScapulaBone"+$side+"|ScapulaBoneClavicle")`; $pos2[0]=$pos2[0]*$b; $dist=`mag<<$pos2[0]-$pos[0],$pos2[1]-$pos[1],$pos2[2]-$pos[2]>>`; $scale[0]=$dist*$b; xform -os -a -s $scale[0] $scale[0] $scale[0] ($copyBones[$i]+"Bone"+$side); delete `aimConstraint -offset 0 0 0 -weight 1 -aimVector ($b) 0 0 -upVector 0 $b 0 -worldUpType "objectrotation" -worldUpVector $secNrml[0] $secNrml[1] $secNrml[2] -worldUpObject Chest_M ("ScapulaBone"+$side+"|ScapulaBoneClavicle") ($copyBones[$i]+"Bone"+$side)`; } //PelvisBone if ($copyBones[$i]=="Pelvis") { xform -ws -ro 0 0 0 PelvisBone_M; $tempString=`listRelatives -type joint -c Root_M`; for ($y=0;$y>`; $scale[0]=$dist; $scale[1]=`getAttr ($deformJointsList[$i]+".fat")`*`getAttr ($deformJointsList[$i]+".fatFront")`; $scale[2]=`getAttr ($deformJointsList[$i]+".fat")`*`getAttr ($deformJointsList[$i]+".fatWidth")`; xform -os -a -s $scale[0] $scale[1] $scale[2] ($newBone+$side); if (`gmatch $deformJointsList[$i] "*_L"`) { $pos=`xform -q -ws -t $deformJointsList[$i]`; scale -r -p $pos[0] $pos[1] $pos[2] -1 -1 -1 ($newBone+$side+".vtx[0:9999]"); polyNormal -normalMode 0 -userNormalMode 0 -ch 0 ($newBone+$side); } select $deformJointsList[$i] ($newBone+$side); $tempString=`newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"`; rename $tempString[0] ($newBone+"BoneSC"+$side); } //MetaCarpals $sourceBone="MetacarpalBone"; for ($i=0;$i>`; if (`objExists $loc`) {// allow space for CarpalBone $pos3=`xform -q -ws -t $loc`; $dist=`mag<<$pos3[0]-$pos[0],$pos3[1]-$pos[1],$pos3[2]-$pos[2]>>`; } $scale[0]=$dist; $scale[1]=`getAttr ($deformJointsList[$i]+".fat")`*`getAttr ($deformJointsList[$i]+".fatFront")`; $scale[2]=`getAttr ($deformJointsList[$i]+".fat")`*`getAttr ($deformJointsList[$i]+".fatWidth")`; xform -os -a -s $scale[0] $scale[1] $scale[2] ($newBone+$side); if (`objExists $loc`) { move -r -os -wd `mag<<$pos2[0]-$pos3[0],$pos2[1]-$pos3[1],$pos2[2]-$pos3[2]>>` 0 0 ($newBone+$side+".vtx[0:9999]"); } select $parentJoint ($newBone+$side); $tempString=`newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"`; rename $tempString[0] ($newBone+"BoneSC"+$side); } //Generic $sourceBone="GenericBone"; for ($i=0;$i>`; $scale[0]=$dist; $scale[1]=`getAttr ($deformJointsList[$i]+".fat")`*`getAttr ($deformJointsList[$i]+".fatFront")`; $scale[2]=`getAttr ($deformJointsList[$i]+".fat")`*`getAttr ($deformJointsList[$i]+".fatWidth")`; xform -os -a -s $scale[0] $scale[1] $scale[2] ($newBone+$side); if (`gmatch $deformJointsList[$i] "*_L"`) { $pos=`xform -q -ws -t $deformJointsList[$i]`; scale -r -p $pos[0] $pos[1] $pos[2] -1 -1 -1 ($newBone+$side+".vtx[0:9999]"); polyNormal -normalMode 0 -userNormalMode 0 -ch 0 ($newBone+$side); } select $deformJointsList[$i] ($newBone+$side); $tempString=`newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"`; rename $tempString[0] ($newBone+"BoneSC"+$side); } //horseCoffinBone if ($fitSkeletonTemplate=="horse") { for ($i=0;$i-2;$b=$b-2) { if ($b==-1 && $side=="_M") continue; if ($b==-1 && $side=="_R") $side="_L"; if (!`objExists ($joint+$side)`)//could be `noMirror` continue; duplicate -n ($aimsAD[$i]+$side) $aimsAD[$i]; editDisplayLayerMembers -noRecurse ("Poly"+$geoLongName) ($aimsAD[$i]+$side); setAttr ($aimsAD[$i]+$side+".v") 1; createNode -n asMirror transform; parent ($aimsAD[$i]+$side) asMirror; if ($side=="_L") { setAttr asMirror.sx -1; polyNormal -normalMode 0 -userNormalMode 0 -ch 0 ($aimsAD[$i]+$side); // setAttr ($aimsAD[$i]+$side+".sz") (`getAttr ($aimsAD[$i]+$side+".sz")`*-1); } parent -w ($aimsAD[$i]+$side); delete asMirror; createNode -n ($aimsAD[$i]+"ParentConstraint"+$side) -p ($geoLongName+"Geometry") transform; asAlign ($aimsAD[$i]+"ParentConstraint"+$side) ($aimsAD[$i]+$side) 1 1 0 0; if (`objExists ($joint+"Part1_M")` && $geo=="Bone" && `objExists ($joint+"Bone_M")`) //Bind Spine and Neck Geo { select ($joint+"_M"); for ($z=1;$z<99;$z++) if (`objExists ($joint+"Part"+$z+"_M")`) select -add ($joint+"Part"+$z+"_M"); else break; select -add ($joint+"Bone_M"); newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"; } else { // parentConstraint -mo ($joint+$side) ($aimsAD[$i]+"ParentConstraint"+$side); pointConstraint ($joint+$side) ($aimsAD[$i]+"ParentConstraint"+$side); orientConstraint ($joint+$side) ($aimsAD[$i]+"ParentConstraint"+$side); // scaleConstraint -mo ($joint+$side) ($aimsAD[$i]+"ParentConstraint"+$side); connectAttr ($joint+$side+".s") ($aimsAD[$i]+"ParentConstraint"+$side+".s"); } parent ($aimsAD[$i]+$side) ($aimsAD[$i]+"ParentConstraint"+$side); setAttr ($aimsAD[$i]+$side+"Shape.overrideEnabled") 0; asLockAttr ($aimsAD[$i]+$side) 1 1 0 0; // if ($geo=="Box") // asMirrorGeometry Boxes 0; // slower, but looks better // refresh; } } setAttr FitSkeleton.visGap $visGap; delete FitSkeletonVisualizers; if (!$visGeo) asUpdateButtonEnables;//ensure the checkBox is back off } global proc asCreateMuscular () { int $form,$spans,$degrees,$numCv,$numChar,$skinningMethod,$numCurves; string $tempString[],$tempString2[],$muscles[],$curves[],$mirrorCurves[],$transforms[],$newTransforms[]; string $skinCluster,$attach,$newTransform,$mirrorMuscle,$nurbs,$mirrorNurbs,$loft,$mirrorLoft,$sc; string $cmd; float $values[],$pos[]; if (!`objExists SkeletonGeometry`) error "Create Skeleton Geometry first"; asFitModeEnsureShaders; if (`objExists MuscularGeometry`) error "MuscularGeometry already exists"; string $asMuscularFile=`asGetScriptLocation`+"/AdvancedSkeleton5Files/div/asMuscular.ma"; file -i $asMuscularFile; parent MuscularGeometry Geometry; $muscles=`listRelatives -c Muscular_Muscles`; createDisplayLayer -e -name NurbsMuscles; editDisplayLayerMembers -noRecurse NurbsMuscles MuscularGeometry; //Attach curves to bones by wrap for ($i=0;$i2) { $maxDist=-9999; for ($y=0;$y>`; if ($dist>$maxDist) { $maxDist=$dist; $maxDistVtx=$sel[$y]; } } select -d $maxDistVtx; $sel=`ls -sl -fl`; } $posA=`xform -q -ws -t $sel[0]`; $posB=`xform -q -ws -t $sel[1]`; move -r ($heelPos[0]-($posA[0]+$posB[0])/2.0) ($heelPos[1]-($posA[1]+$posB[1])/2.0) ($heelPos[2]-($posA[2]+$posB[2])/2.0); } } //select 4 lowest vtxs $absSecAxis=`asGetAxis secondary ($fitJoint+$side) Main 1`; $boxHeight=`getAttr ($box+".scale"+$absSecAxis)`; //scale up `height` first, to ensure correct detection of `4 lowest vtxs` setAttr ($box+".scale"+$absSecAxis) 10; select -r ($box+".vtx[0:99]"); $sel=`ls -sl -fl`; while (size($sel)>4) { $maxY=-9999; for ($y=0;$y$maxY) { $maxY=$pos[1]; $maxYVtx=$sel[$y]; } } select -d $maxYVtx; $sel=`ls -sl -fl`; } setAttr ($box+".scale"+$absSecAxis) $boxHeight; //drop to ground-plane for ($y=0;$y>`; //spine if ($deformJointsList[$i]=="Root_M" || `gmatch $deformJointsList[$i] "*Spine[0-9]*"` || `gmatch $deformJointsList[$i] "*Chest*"` || `gmatch $deformJointsList[$i] "*Head_*"`) { if (`gmatch $deformJointsList[$i] "Head_*"`) $tempString=`duplicate -n ($deformJointsList[$i]+"_Root") Mannequin_Head`; else $tempString=`duplicate -n ($deformJointsList[$i]+"_Root") Mannequin_Root`; $poly=$tempString[0]; $tempString=`parentConstraint $deformJointsList[$i] $poly`; asSetOrientOffsetFromAxis $tempString[0] $deformJointsList[$i] Main; delete $tempString[0]; parent $poly MannequinGeometry; xform -os -s ($lenght/1) ($charHeight/10) ($charHeight/10) $poly; catchQuiet (`makeIdentity -a 1 -t 0 -r 0 -s 1 $poly`); // scaleConstraint $deformJointsList[$i] $poly; select $deformJointsList[$i] $poly; newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"; refresh; } for ($y=0;$y>`; $lenght*=0.87;//slight shrink to make heel match heelposition } } $temp3=`xform -q -ws -t tempXform`; xform -ws -t $temp3[0] 0 $temp3[2] $poly; xform -os -s ($lenght/1) ($lenght/1) ($lenght/1) $poly; parent $poly MannequinGeometry; xform -ws -t $temp2[0] 0 $temp2[2] tempXform; delete `aimConstraint -offset 0 0 0 -weight 1 -aimVector 0 0 1 -upVector 0 1 0 -worldUpType "vector" -worldUpVector 0 1 0 tempXform $poly`; delete tempXform; catchQuiet (`makeIdentity -a 1 -t 0 -r 0 -s 1 $poly`); // scaleConstraint $deformJointsList[$i] $poly; select $deformJointsList[$i] $poly; newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"; refresh; } else { $tempString=`duplicate -n ($deformJointsList[$i]+"_Limb") Mannequin_Limb`; $poly=$tempString[0]; xform -os -s ($lenght) ($lenght/2) ($lenght/2) $poly; if (`gmatch $deformJointsList[$i] "Wrist*"`) setAttr ($poly+".sy") (`getAttr ($poly+".sy")`*3); if (`gmatch $deformJointsList[$i] "Toes*"`) setAttr ($poly+".sz") (`getAttr ($poly+".sz")`*3); if (`gmatch $deformJointsList[$i] "*Finger*"`) xform -os -s $lenght ($charHeight/70) ($charHeight/70) $poly; if (`gmatch $deformJointsList[$i] "*Neck*"`) xform -os -s ($lenght*1.1) ($charHeight/10) ($charHeight/10) $poly; if (`gmatch $deformJointsList[$i] "*_L"`) { setAttr ($poly+".sx") (`getAttr ($poly+".sx")`*-1); polyNormal -normalMode 0 -userNormalMode 0 -ch 0 $poly; } // parentConstraint $deformJointsList[$i] $poly; $tempString=`parentConstraint $deformJointsList[$i] $poly`; asSetOrientOffsetFromAxis $tempString[0] $deformJointsList[$i] Main; delete $tempString[0]; parent $poly MannequinGeometry; catchQuiet (`makeIdentity -a 1 -t 0 -r 0 -s 1 $poly`); setAttr ($poly+"Shape.opposite") 0; // scaleConstraint $deformJointsList[$i] $poly; select $deformJointsList[$i] $poly; newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"; refresh; } $tempString=`duplicate -n ($deformJointsList[$i]+"_Sphere") Mannequin_Sphere`; $poly=$tempString[0]; xform -os -s ($lenght/2) ($lenght/2) ($lenght/2) $poly; if (`gmatch $deformJointsList[$i] "*Finger*"`) xform -os -s ($charHeight/50) ($charHeight/50) ($charHeight/50) $poly; if (`gmatch $deformJointsList[$i] "*Neck*"`) xform -os -s ($charHeight/10) ($charHeight/10) ($charHeight/10) $poly; if (`gmatch $deformJointsList[$i] "*Ankle*"`) xform -os -s ($charHeight/10) ($charHeight/10) ($charHeight/10) $poly; if (`gmatch $deformJointsList[$i] "Wrist*"`) xform -os -s ($charHeight/20) ($charHeight/20) ($charHeight/20) $poly; if (`gmatch $deformJointsList[$i] "Shoulder_*"` || `gmatch $deformJointsList[$i] "Hip_*"`) xform -os -s ($charHeight/7) ($charHeight/7) ($charHeight/7) $poly; // parentConstraint $deformJointsList[$i] $poly; $tempString=`parentConstraint $deformJointsList[$i] $poly`; asSetOrientOffsetFromAxis $tempString[0] $deformJointsList[$i] Main; delete $tempString[0]; parent $poly MannequinGeometry; catchQuiet (`makeIdentity -a 1 -t 0 -r 0 -s 1 $poly`); // scaleConstraint $deformJointsList[$i] $poly; select $deformJointsList[$i] $poly; newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"; refresh; } if (`objExists Mannequin_Geometry`) delete Mannequin_Geometry; if (`objExists Skeleton_Geometry`) delete Skeleton_Geometry; if (`objExists SkinCage_Geometry`) delete SkinCage_Geometry; if (`objExists shaderMannequin`) delete shaderMannequin; if (`objExists shaderMannequinSG`) delete shaderMannequinSG; shadingNode -n shaderMannequin -asShader lambert; sets -renderable true -noSurfaceShader true -empty -name shaderMannequinSG; connectAttr -f shaderMannequin.outColor shaderMannequinSG.surfaceShader; setAttr -type float3 shaderMannequin.color 0.78 0.63 0.42; setAttr shaderMannequin.ambientColor -type double3 0.53 0.42 0.25; sets -e -forceElement shaderMannequinSG MannequinGeometry; print ("// Mannequin created\n"); select -cl; } global proc asDeleteMannequin () { string $deleteObjs[]={"MannequinGeometry","Mannequin_Geometry","Mannequin","wood","woodSG","woodShader"}; for ($i=0;$i($centerTolerance*-1)) continue;//Todo:should snap to center if ($L2R && $pos[0]<0) continue; if (!$L2R && $pos[0]>0) continue; setAttr closestSampler.inPosition ($pos[0]*-1) $pos[1] $pos[2]; $oppositeVtxNr=`getAttr closestSampler.closestVertexIndex`; $pos=`xform -q -ws -t ("retopo.vtx["+$i+"]")`; xform -ws -t ($pos[0]*-1) $pos[1] $pos[2] ("retopo.vtx["+$oppositeVtxNr+"]"); } delete closestSampler; select $sel; } global proc int[] asGetRetopoCenterVtxs () { int $centerVtx[]; int $numVtxs[]=`polyEvaluate -v retopo`; float $pos[]; float $scale=`asGetScale`; float $centerTolerance=0.01*$scale; for ($i=0;$i<$numVtxs[0];$i++) { $pos=`xform -q -ws -t ("retopo.vtx["+$i+"]")`; if ($pos[0]<$centerTolerance && $pos[0]>($centerTolerance*-1)) $centerVtx[size($centerVtx)]=$i; } return $centerVtx; } global proc asRestoreRetopoCenterVtx (int $centerVtx[]) { float $pos[]; for ($i=0;$i>`<0.001) $bodyHeadConnectionVtxs[size($bodyHeadConnectionVtxs)]=("retopo.vtx["+$vtxNr+"]"); if (!`attributeExists bodyHeadConnectionVtxs retopo`) addAttr -ln bodyHeadConnectionVtxs -dt "string" retopo; setAttr -type "string" retopo.bodyHeadConnectionVtxs `stringArrayToString $bodyHeadConnectionVtxs " "`; } //find headBodyConnectionVtxs if (!`attributeExists headBodyConnectionVtxs retopo`) addAttr -ln headBodyConnectionVtxs -dt "string" retopo; connectAttr -f headTopology.outMesh closestSampler.inMesh; $pos=`xform -q -ws -t HeadProfileSideLoc6`; setAttr closestSampler.inPosition $pos[0] $pos[1] $pos[2]; $vtxNr=`getAttr closestSampler.closestVertexIndex`; select ("headTopology.vtx["+$vtxNr+"]"); ConvertSelectionToEdges; string $edges[]=`ls -sl -fl`; int $minNumEdgesInLoop=999; for ($i=0;$i>`; if ($dist<$minDist) { $minDist=$dist; xform -ws -t $pos2[0] $pos2[1] $pos2[2] $neckLocs[$i]; } } } delete retopoHeadEdgeFinder; for ($obj in $deleteObjs) if (`objExists $obj`) delete $obj; asFaceUpdateInfo 1; print "// Now move the Locators, to match the head/face of your model.\n"; select -cl; } global proc asDeleteFaceRetopo (int $keepNewRetopo) { string $deleteObjs[]={"headTopology","retopoHeadDeleteComponent","retopoHeadJoint","guidesGroup","MainCurves","ProfileCurves"}; for ($obj in $deleteObjs) if (`objExists $obj`) delete $obj; $deleteObjs=`ls "guides_*"`; for ($obj in $deleteObjs) if (`objExists $obj`) delete $obj; if (`objExists guidesRN`) { lockNode -l 0 guidesRN; delete guidesRN; } if (!$keepNewRetopo) { if (`objExists headTopologyGeometry`) delete headTopologyGeometry; if (`objExists FaceGroup`) delete FaceGroup; } if (!$keepNewRetopo && `objExists bodyTopology`) { delete retopo; setAttr bodyTopology.v 1; rename bodyTopology retopo; } asFaceUpdateInfo 1; } global proc asMatchGuidesFaceRetopo () { int $numVtxs[]=`polyEvaluate -v headTopology`; float $pos[]; string $tempString[],$locators[],$curves[],$mirrorCurves[],$nonAverageVtxs[],$centerXvtxs[]; string $hiResMesh=`getAttr retopo.hiResMesh`; string $restoreLocPosCmd; $tempString[0]=`getAttr retopo.headBodyConnectionVtxs`; string $headBodyConnectionVtxs[]=`stringToStringArray $tempString[0] " "`; if (`objExists retopoHeadJoint`) error "Match guides has already been executed. You can scrube the timeline from 0 to 10, to see the alignment"; if (!`objExists headTopology`) error "headTopology object not found, click \"Geometry: Create\" first"; $tempString=`listRelatives -ad -type transform guidesGroup`; for ($i=0;$i-0.001) $centerXvtxs[size($centerXvtxs)]="headTopology.vtx["+$i+"]"; } select FaceGroup; joint -n retopoHeadJoint; select headTopology retopoHeadJoint; $tempString=`newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"`; rename $tempString[0] headTopologySC; setAttr headTopologySC.useComponents 1; select headTopology $curves $mirrorCurves; skinClusterInfluence 1 "-ug -dr 4 -ps 0 -ns 100"; eval ($restoreLocPosCmd); asAlignBodyFaceRetopo; clear $tempString; asSelectCurveVtx upperLipMainCurve2;select -add $tempString;$tempString=`ls -sl`; asSelectCurveVtx upperLipMainCurve2mirror;select -add $tempString;$tempString=`ls -sl`; asSelectCurveVtx lowerLipMainCurve2;select -add $tempString;$tempString=`ls -sl`; asSelectCurveVtx lowerLipMainCurve2mirror;select -add $tempString;$tempString=`ls -sl`; asSelectCurveVtx eyeLidMainCurve;select -add $tempString;$tempString=`ls -sl`; asSelectCurveVtx eyeLidMainCurvemirror;select -add $tempString;$tempString=`ls -sl`; asSelectCurveVtx EyeBrowMainCurve2;select -add $tempString;$tempString=`ls -sl`; asSelectCurveVtx EyeBrowMainCurve2mirror;select -add $tempString;$tempString=`ls -sl`; if (`objExists EarCurve`) {asSelectCurveVtx EarCurve;select -add $tempString;$tempString=`ls -sl`;} asSelectCurveVtx noseProfileCurve;select -add $tempString;$tempString=`ls -sl`; GrowPolygonSelectionRegion;$tempString=`ls -sl`; $nonAverageVtxs=`stringArrayCatenate $nonAverageVtxs $tempString`; select headTopology.vtx[0:9999]; select -d $headBodyConnectionVtxs; select -d $nonAverageVtxs; $tempString=`ls -sl`; select $hiResMesh $tempString; transferAttributes -transferPositions 1 -transferNormals 0 -transferUVs 0 -transferColors 0 -sampleSpace 0 -sourceUvSpace "map1" -targetUvSpace "map1" -searchMethod 3-flipUVs 0 -colorBorders 1; select $tempString; polyAverageVertex -i 10; select $hiResMesh $tempString; transferAttributes -transferPositions 1 -transferNormals 0 -transferUVs 0 -transferColors 0 -sampleSpace 0 -sourceUvSpace "map1" -targetUvSpace "map1" -searchMethod 3-flipUVs 0 -colorBorders 1; for ($i=0;$i>`; if ($mag<$minMag) { $minMag=$mag; $nearestVtx=$bodyVtxs[$y]; } } $posB=`xform -q -ws -t $nearestVtx`; xform -ws -t $posB[0] $posB[1] $posB[2] $headVtxs[$i]; } } global proc asConnectBodyFaceRetopo () { int $form,$spans,$degrees,$numCv; float $posA[]; string $sel[]=`ls -sl`; string $tempString[]; string $restoreCrvsCmd; //`detach` wrapped-on FaceFitSkeleton $tempString=`listRelatives -ad -type nurbsCurve FaceFitSkeleton`; for ($i=0;$i-2;$b=$b-2) { if ($b==-1) {$side="_L";} select ("eyeball"+$side); $tempString=`newCluster " -envelope 1"`; rename $tempString[0] ("eyeballCluster"+$side); rename $tempString[1] ("eyeballClusterHandle"+$side); setAttr ("eyeballClusterHandle"+$side+".v") 0; parent ("eyeballClusterHandle"+$side) headTopologyEyes; connectAttr headTopologyEyes.size ("eyeballClusterHandle"+$side+".sx");connectAttr headTopologyEyes.size ("eyeballClusterHandle"+$side+".sy");connectAttr headTopologyEyes.size ("eyeballClusterHandle"+$side+".sz"); // select ("eyeball"+$side); // asChooseInput ("asFaceEye"+$side+"TextField"); } //asBuildFitEyeBall; print "//Eyes created, ajust the scale with the size attribute.\n"; select headTopologyEyes; } global proc asBindEyesFaceRetopo () { string $side="_R"; for ($b=1;$b>-2;$b=$b-2) { if ($b==-1) {$side="_L";} select ("eyeball"+$side); DeleteHistory; select Head_M ("eyeball"+$side); newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"; } print "//Eyes skinned to eye-joints.\n"; select -cl; } global proc asCreateTeethFaceRetopo () { float $pos[]; float $height=`getAttr "Main.height"`; if (`objExists headTopologyTeeth`) { select teethLocator; error "headTopologyTeeth already exists"; } string $asScriptLocation=`asGetScriptLocation`; string $headTopologyTeethDir=$asScriptLocation+"/AdvancedSkeleton5Files/div/headTopologyTeeth/"; string $file=$headTopologyTeethDir+`optionMenu -q -v asCreateFaceRetopoTeethOptionMenu`; file -i $file; parent headTopologyTeeth Geometry; $pos=`xform -q -ws -t Head_M`; xform -ws -t $pos[0] $pos[1] $pos[2] -s ($height/20.0) ($height/20.0) ($height/20.0) teethLocator; $pos=`xform -q -ws -t Eye_R`; setAttr teethLocator.tz $pos[2]; select teethLocator; } global proc asBindTeethFaceRetopo () { select upperTeeth lowerTeeth tongue; DeleteHistory; delete teethLocator teethClusterHandle; select upperTeeth lowerTeeth tongue Head_M; newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"; select -cl; print "// Bind teeth complete.\n"; } global proc asFaceRigPrepRetopo () { string $sel[]=`ls -sl`; string $tempString[],$tempString2[],$tempString3[]; string $newSelectionString; setAttr FaceGroup.v 1; //Pre section select retopo; asChooseInput asFaceFaceTextField; select retopo; string $optionalAllHeadObjs[]={"eyeball_R","eyeball_L","upperTeeth","lowerTeeth","tongue"}; for ($i=0;$i0) { $side="_L"; } if ($middle) { $originPos[0]=0; setAttr ($softModHandle+".originX") 0; setAttr ($softMod+".falloffCenterX") 0; $side="_M"; } //find nearest joint (or second selected Xform) if (`objExists DeformationSystem`) $deformJoints=`listRelatives -type joint -ad DeformationSystem`; if ($face && `objExists FaceFitSkeleton`) if (`attributeExists HeadJoint FaceFitSkeleton`) { clear $deformJoints; $deformJoints[0]=`getAttr FaceFitSkeleton.HeadJoint`; } $nearestJointDist=9999; for ($i=0;$i>`; if ($mag<$nearestJointDist) { $nearestJoint=$deformJoints[$i]; $nearestJointDist=$mag; } } //(or sencond selected Xform) if ($selXforms[1]!="") if (`sets -im DeformSet $selXforms[1]` || $face) $nearestJoint=$selXforms[1]; if ($name=="") $name=`asCustomControlNameFromNearestJoint $nearestJoint "Skin" $side`; //create DeformationsJoints select -cl; joint -n ($name+"Joint"+$side); //joint -n ($name+"EndJoint"+$side); //setAttr ($name+"EndJoint"+$side+".tx") ($falloffRadius/2.0); parent ($name+"Joint"+$side) $nearestJoint; setAttr ($name+"Joint"+$side+".segmentScaleCompensate") 0; addAttr -ln "skinControlJoint" -at bool -dv 1 ($name+"Joint"+$side); xform -ws -t $originPos[0] $originPos[1] $originPos[2] ($name+"Joint"+$side); if ($local) { delete `orientConstraint $nearestJoint ($name+"Joint"+$side)`; makeIdentity -apply 1 -t 0 -r 1 -s 0 ($name+"Joint"+$side); } //create FK controls if (!`objExists ("ParentConstraintTo"+$nearestJoint)`) createNode -n ("ParentConstraintTo"+$nearestJoint) -p CustomSystem transform; createNode -n ("Offset"+$name+$side) transform; $tempString[0]=`curve -d 1 -p -0.5 0.5 0.5 -p -0.5 0.5 -0.5 -p 0.5 0.5 -0.5 -p 0.5 0.5 0.5 -p -0.5 0.5 0.5 -p -0.5 -0.5 0.5 -p 0.5 -0.5 0.5 -p 0.5 -0.5 -0.5 -p -0.5 -0.5 -0.5 -p -0.5 -0.5 0.5 -p -0.5 -0.5 -0.5 -p -0.5 0.5 -0.5 -p -0.5 -0.5 -0.5 -p 0.5 -0.5 -0.5 -p 0.5 0.5 -0.5 -p 0.5 -0.5 -0.5 -p 0.5 -0.5 0.5 -p 0.5 0.5 0.5`; rename $tempString[0] ($name+$side); addAttr -ln "localOrient" -at bool -dv $local ($name+$side); $scale=$falloffRadius/4.0; xform -ws -s $scale $scale $scale ($name+$side+".cv[0:17]"); setAttr ($name+$side+"Shape.isHistoricallyInteresting") 0; parent ($name+$side) ("Offset"+$name+$side); pointConstraint $nearestJoint ("ParentConstraintTo"+$nearestJoint); orientConstraint $nearestJoint ("ParentConstraintTo"+$nearestJoint); asAlign ("Offset"+$name+$side) ($name+"Joint"+$side) 1 0 0 0; if ($local) asAlign ("Offset"+$name+$side) ($name+"Joint"+$side) 0 1 0 0; parent ("Offset"+$name+$side) ("ParentConstraintTo"+$nearestJoint); setAttr ($name+$side+"Shape.overrideEnabled") 1; setAttr ($name+$side+"Shape.overrideColor") 17; parentConstraint ($name+$side) ($name+"Joint"+$side); parent ($name+"Joint"+$side+"_parentConstraint1") ConstraintSystem; connectAttr ($name+$side+".s") ($name+"Joint"+$side+".s"); //sets -add AllSet ("FK"+$name+$side) ("FK"+$name+$side+"Shape") ("FKExtra"+$name+$side) ("FKOffset"+$name+$side) ("FKParentConstraintTo"+$nearestJoint); //sets -add AllSet ($name+$side) ($name+"End"+$side); sets -add DeformSet ($name+"Joint"+$side); sets -add ControlSet ($name+$side); //add to $skinCluster $tempString=`listConnections -s 0 -d 1 -type mesh $softMod`; $mesh=$tempString[0]; $skinCluster=`asGetSkinCluster $mesh`; skinCluster -e -lw false -wt 0 -ai ($name+"Joint"+$side) $skinCluster; //weighting asSkinWeightBySoftMod ($name+"Joint"+$side) $mesh $skinCluster $falloffRadius 1; /* select $mesh; polySelectConstraint -m 3 -t 1 -d 1 -db 0 $falloffRadius -dp $originPos[0] $originPos[1] $originPos[2]; $vtxs=`ls -sl -fl`; polySelectConstraint -m 0; select -cl; progressBar -e -st ("Converting SoftMod ("+$side+")") -bp -ii 1 -min 0 -max (size($vtxs)) $gMainProgressBar; evalDeferred ("progressBar -e -ep "+$gMainProgressBar); for ($y=0;$y0) { $side="_L"; } if ($middle) { $originPos[0]=0; setAttr ($softModHandle+".originX") 0; setAttr ($softMod+".falloffCenterX") 0; $side="_M"; } //orientConstraint to nearest joint (or second selected Xform) if (`objExists DeformationSystem`) $deformJoints=`listRelatives -type joint -ad DeformationSystem`; if ($face && `objExists FaceFitSkeleton`) if (`attributeExists HeadJoint FaceFitSkeleton`) { clear $deformJoints; $deformJoints[0]=`getAttr FaceFitSkeleton.HeadJoint`; } $nearestJointDist=9999; for ($i=0;$i>`; if ($mag<$nearestJointDist) { $nearestJoint=$deformJoints[$i]; $nearestJointDist=$mag; } } //(or sencond selected Xform) if ($selXforms[1]!="") if (`sets -im DeformSet $selXforms[1]` || $face) $nearestJoint=$selXforms[1]; if ($name=="") $name=`asCustomControlNameFromNearestJoint $nearestJoint "Cluster" $side`; //create control if (!`objExists asClusterControlShader`) { shadingNode -n asClusterControlShader -asShader lambert; sets -renderable true -noSurfaceShader true -empty -name asClusterControlShaderSG; connectAttr -f asClusterControlShader.outColor asClusterControlShaderSG.surfaceShader; setAttr -type float3 asClusterControlShader.color 1 0 0; } float $scale=`asGetScale`; if ($face) $scale=$scale/3.0; $tempString=`sphere -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r ($scale/5.0) -d 3 -ut 0 -tol 0.01 -s 8 -nsp 4 -ch 0`; rename $tempString[0] ($name+$side); addAttr -ln "localOrient" -at bool -dv $local ($name+$side); sets -e -forceElement asClusterControlShaderSG ($name+$side); //sets -add "ControlSet" ($name+$side); setAttr ($name+$side+"Shape.overrideEnabled") 1; setAttr ($name+$side+"Shape.overrideColor") 13; createNode -n ($name+"ClusterControlGrp"+$side) -p CustomSystem transform; setAttr -l 1 ($name+"ClusterControlGrp"+$side+".inheritsTransform") 0; createNode -n ($name+"Attach"+$side) transform; parent ($name+"Attach"+$side) ($name+"ClusterControlGrp"+$side); createNode -n ($name+"Offset"+$side) transform; createNode -n ($name+"Subtract"+$side) transform; parent ($name+$side) ($name+"Subtract"+$side); parent ($name+"Subtract"+$side) ($name+"Offset"+$side); parent ($name+"Offset"+$side) ($name+"Attach"+$side); if ($face && `objExists MainAndHeadScaleMultiplyDivide`) connectAttr MainAndHeadScaleMultiplyDivide.output ($name+"Attach"+$side+".s"); else if (!$face && `objExists MainScaleMultiplyDivide`) connectAttr MainScaleMultiplyDivide.output ($name+"Attach"+$side+".s"); if (!$local) parent -w ($name+"Offset"+$side); orientConstraint $nearestJoint ($name+"Attach"+$side); if (!$local) parent ($name+"Offset"+$side) ($name+"Attach"+$side); //avoid double Xform createNode -n ($name+"PlusMinusAverage"+$side) plusMinusAverage; setAttr ($name+"PlusMinusAverage"+$side+".operation") 2; connectAttr -f ($name+$side+".t") ($name+"PlusMinusAverage"+$side+".input3D[0]"); connectAttr -f ($name+$side+".t") ($name+"PlusMinusAverage"+$side+".input3D[1]"); disconnectAttr ($name+$side+".t") ($name+"PlusMinusAverage"+$side+".input3D[0]"); parent -w ($name+"Offset"+$side); connectAttr -f ($name+"PlusMinusAverage"+$side+".output3D") ($name+"Subtract"+$side+".t"); xform -ws -t $originPos[0] $originPos[1] $originPos[2] ($name+"Offset"+$side); //create cluster select $mesh; //$tempString=`cluster -n ($name+"Cluster"+$side) -envelope 1`; $tempString=`asDeformer cluster`; rename $tempString[0] ($name+"Cluster"+$side); rename $tempString[1] ($name+"Cluster"+$side+"Handle"); $tempString=`listConnections ($name+"Cluster"+$side+".message")`; rename $tempString[0] ($name+"ClusterSet"+$side); setAttr -type float3 ($name+"Cluster"+$side+"HandleShape.origin") $originPos[0] $originPos[1] $originPos[2]; xform -piv $originPos[0] $originPos[1] $originPos[2] ($name+"Cluster"+$side+"Handle"); parent ($name+"Cluster"+$side+"Handle") ($name+"ClusterControlGrp"+$side); setAttr -l 1 ($name+"Cluster"+$side+"Handle.v") 0; if ($local) { createNode -n ($name+"LocalOrient"+$side) -p ($name+"Attach"+$side) transform; parent ($name+"LocalOrient"+$side) ($name+"ClusterControlGrp"+$side); xform -ws -t $originPos[0] $originPos[1] $originPos[2] ($name+"LocalOrient"+$side); createNode -n ($name+"LocalTranform"+$side) -p ($name+"LocalOrient"+$side) transform; connectAttr ($name+$side+".t") ($name+"LocalTranform"+$side+".t"); connectAttr ($name+$side+".r") ($name+"LocalTranform"+$side+".r"); connectAttr ($name+$side+".s") ($name+"LocalTranform"+$side+".s"); parentConstraint -mo ($name+"LocalTranform"+$side) ($name+"Cluster"+$side+"Handle"); scaleConstraint ($name+"LocalTranform"+$side) ($name+"Cluster"+$side+"Handle"); } else { connectAttr ($name+$side+".t") ($name+"Cluster"+$side+"Handle.t"); connectAttr ($name+$side+".r") ($name+"Cluster"+$side+"Handle.r"); connectAttr ($name+$side+".s") ($name+"Cluster"+$side+"Handle.s"); } //set clusterWeights select $mesh; polySelectConstraint -m 3 -t 1 -d 1 -db 0 $falloffRadius -dp $originPos[0] $originPos[1] $originPos[2]; $vtxs=`ls -sl -fl`; polySelectConstraint -m 0; //$mag=`mag<<$currentPos[0]-$originPos[0],$currentPos[1]-$originPos[1],$currentPos[2]-$originPos[2]>>`; //speed up by disable other deformers $historyNodes=`listHistory -pdo 1 -il 2 $mesh`; for ($i=0;$i>`; // $weight=$vtxMag/1.0; $weight=($vtxCurrentPos[1]-$vtxOriginPos[1])/1.0; percent -v $weight ($name+"Cluster"+$side) $vtxs[$y]; if ($weight>$maxWeight) { $maxWeightVts=$vtxs[$y]; $maxWeight=$weight; } } for ($i=0;$i>`; setAttr ($name+"PointOnCurveInfo"+$side+".parameter") 1; $tempFloatC=`getAttr ($name+"PointOnCurveInfo"+$side+".position")`; $magAC=`mag<<$tempFloatA[0]-$tempFloatC[0],$tempFloatA[1]-$tempFloatC[1],$tempFloatA[2]-$tempFloatC[2]>>`; if ($magAB<$magAC) setAttr ($name+"PointOnCurveInfo"+$side+".parameter") 0; parent ($name+"Offset"+$side) ($name+"Attach"+$side); //reorderDeformers $historyNodes=`listHistory -pdo 1 $mesh`; for ($y=0;$y0) { $side="_L"; } if ($middle) { $originPos[0]=0; setAttr ($softModHandle+".originX") 0; setAttr ($softMod+".falloffCenterX") 0; $side="_M"; } //orientConstraint to nearest joint (or second selected Xform) if (`objExists DeformationSystem`) $deformJoints=`listRelatives -type joint -ad DeformationSystem`; if ($face && `objExists FaceFitSkeleton`) if (`attributeExists HeadJoint FaceFitSkeleton`) { clear $deformJoints; $deformJoints[0]=`getAttr FaceFitSkeleton.HeadJoint`; } $nearestJointDist=9999; for ($i=0;$i>`; if ($mag<$nearestJointDist) { $nearestJoint=$deformJoints[$i]; $nearestJointDist=$mag; } } //(or sencond selected Xform) if ($selXforms[1]!="") if (`sets -im DeformSet $selXforms[1]` || $face) $nearestJoint=$selXforms[1]; if ($name=="") $name=`asCustomControlNameFromNearestJoint $nearestJoint "SoftMod" $side`; //create control if (!`objExists asSoftModControlShader`) { shadingNode -n asSoftModControlShader -asShader lambert; sets -renderable true -noSurfaceShader true -empty -name asSoftModControlShaderSG; connectAttr -f asSoftModControlShader.outColor asSoftModControlShaderSG.surfaceShader; setAttr -type float3 asSoftModControlShader.color 0 1 0; } float $scale=`asGetScale`; if ($face) $scale=$scale/3.0; $tempString=`sphere -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r ($scale/5.0) -d 3 -ut 0 -tol 0.01 -s 8 -nsp 4 -ch 0`; rename $tempString[0] ($name+$side); addAttr -ln "localOrient" -at bool -dv $local ($name+$side); sets -e -forceElement asSoftModControlShaderSG ($name+$side); //sets -add "ControlSet" ($name+$side); setAttr ($name+$side+"Shape.overrideEnabled") 1; setAttr ($name+$side+"Shape.overrideColor") 14; createNode -n ($name+"Attach"+$side) transform; parent ($name+"Attach"+$side) CustomSystem; //createsoftMod select $mesh; $tempString=`asDeformer softMod`; rename $tempString[0] ($name+"SoftMod"+$side); rename $tempString[1] ($name+"SoftModModHandle"+$side); $tempString=`listConnections ($name+"SoftMod"+$side+".message")`; rename $tempString[0] ($name+"SoftModSet"+$side); setAttr -type float3 ($name+"SoftModModHandle"+$side+".origin") $originPos[0] $originPos[1] $originPos[2]; setAttr ($name+"SoftMod"+$side+".falloffCenter") $originPos[0] $originPos[1] $originPos[2]; xform -piv $originPos[0] $originPos[1] $originPos[2] ($name+"SoftModModHandle"+$side); if (!`objExists ClusterControlMirrorSoftModHandle`) nodePreset -save $softMod "asSoftMod"; nodePreset -load ($name+"SoftMod"+$side) "asSoftMod"; if (`objExists ClusterControlMirrorSoftModHandle`) setAttr ($name+"SoftMod"+$side+".falloffCenterX") (`getAttr ($name+"SoftMod"+$side+".falloffCenterX")`*-1); $tempString[0]=`curve -d 1 -p 0 1 0 -p 0 -1 0 -p 0 0 0 -p 1 0 0 -p -1 0 0 -k 0 -k 1 -k 2 -k 3 -k 4`; rename $tempString[0] ($name+"Base"+$side); addAttr -ln "localOrient" -at bool -dv $local ($name+"Base"+$side); scale -r -p 0 0 0 ($scale/2.0) ($scale/2.0) ($scale/2.0) ($name+"Base"+$side+"Shape.cv[0:4]"); setAttr ($name+"Base"+$side+"Shape.overrideEnabled") 1; setAttr ($name+"Base"+$side+"Shape.overrideColor") 17; parent ($name+"Base"+$side) ($name+"Attach"+$side); parent ($name+$side) ($name+"Base"+$side); spaceLocator -n ($name+"BaseLocator"+$side); parent ($name+"BaseLocator"+$side) ($name+"Base"+$side); setAttr -l 1 ($name+"BaseLocator"+$side+".v") 0; setAttr -l 1 ($name+"SoftModModHandle"+$side+".v") 0; connectAttr ($name+"BaseLocator"+$side+"Shape.worldPosition[0]") ($name+"SoftMod"+$side+".falloffCenter"); xform -ws -t $originPos[0] $originPos[1] $originPos[2] ($name+"Attach"+$side); if ($local) { pointConstraint -mo $nearestJoint ($name+"Attach"+$side); orientConstraint $nearestJoint ($name+"Attach"+$side); } else parentConstraint -mo $nearestJoint ($name+"Attach"+$side); scaleConstraint $nearestJoint ($name+"Attach"+$side); disconnectAttr ($name+"SoftModModHandle"+$side+"Shape.softModTransforms[0]") ($name+"SoftMod"+$side+".softModXforms"); disconnectAttr ($name+"SoftModModHandle"+$side+".worldMatrix[0]") ($name+"SoftMod"+$side+".matrix"); delete ($name+"SoftModModHandle"+$side); //non-zero matrix, to avoid SoftMod reuse, when adding more then 1 softMod connectAttr ($name+"Attach"+$side+".worldMatrix[0]") ($name+"SoftMod"+$side+".matrix"); connectAttr ($name+"Base"+$side+".worldInverseMatrix[0]") ($name+"SoftMod"+$side+".postMatrix"); connectAttr ($name+"Base"+$side+".worldMatrix[0]") ($name+"SoftMod"+$side+".preMatrix"); createNode -n ($name+"SoftModMultMatrix"+$side) multMatrix; connectAttr ($name+$side+".worldMatrix[0]") ($name+"SoftModMultMatrix"+$side+".matrixIn[0]"); connectAttr ($name+$side+".parentInverseMatrix[0]") ($name+"SoftModMultMatrix"+$side+".matrixIn[1]"); connectAttr ($name+"SoftModMultMatrix"+$side+".matrixSum") ($name+"SoftMod"+$side+".softModXforms.weightedMatrix"); //falloffRadius addAttr -k 1 -ln falloffRadius -at double -dv 1 ($name+$side); addAttr -k 1 -ln "falloffMode" -at "enum" -en "volume:surface:" -dv $falloffMode ($name+$side); connectAttr ($name+$side+".falloffMode") ($name+"SoftMod"+$side+".falloffMode"); createNode -n ($name+"MainScaleForSoftModMPD1"+$side) multiplyDivide; connectAttr ($name+$side+".falloffRadius") ($name+"MainScaleForSoftModMPD1"+$side+".input1.input1X"); setAttr ($name+"MainScaleForSoftModMPD1"+$side+".input2.input2X") $falloffRadius; // connectAttr ($name+"MainScaleForSoftModMPD"+$side+".outputX") ($name+"SoftMod"+$side+".falloffRadius"); createNode -n ($name+"MainScaleForSoftModMPD2"+$side) multiplyDivide; connectAttr ($name+"MainScaleForSoftModMPD1"+$side+".outputX") ($name+"MainScaleForSoftModMPD2"+$side+".input1.input1X"); connectAttr ($name+"Attach"+$side+".sx") ($name+"MainScaleForSoftModMPD2"+$side+".input2.input2X"); connectAttr ($name+"MainScaleForSoftModMPD2"+$side+".outputX") ($name+"SoftMod"+$side+".falloffRadius"); //update buildPose $newCtrlBuildPoseCmd ="xform -os -t 0 0 0 -ro 0 0 0 -s 1 1 1 "+$name+$side+";"; $newCtrlBuildPoseCmd+="xform -os -t 0 0 0 -ro 0 0 0 -s 1 1 1 "+$name+"Base"+$side+";"; if ($face) { if (!`attributeExists udExtraAttr faceBuildPose`) addAttr -ln udExtraAttr -dt "string" faceBuildPose; $buildPoseCmd=`getAttr faceBuildPose.udExtraAttr`; setAttr -type "string" faceBuildPose.udExtraAttr ($buildPoseCmd+$newCtrlBuildPoseCmd); sets -add FaceControlSet ($name+$side); sets -add FaceControlSet ($name+"Base"+$side); } else { if (!`attributeExists udExtraAttr buildPose`) addAttr -ln udExtraAttr -dt "string" buildPose; $buildPoseCmd=`getAttr buildPose.udExtraAttr`; setAttr -type "string" buildPose.udExtraAttr ($buildPoseCmd+$newCtrlBuildPoseCmd); sets -add ControlSet ($name+$side); sets -add ControlSet ($name+"Base"+$side); } if ($mirror && !`objExists ClusterControlMirrorSoftModHandle`) { select $mesh; $tempString=`asDeformer softMod`; rename $tempString[0] ClusterControlMirrorSoftMod; rename $tempString[1] ClusterControlMirrorSoftModHandle; setAttr -type float3 ClusterControlMirrorSoftModHandle.origin ($originPos[0]*-1) $originPos[1] $originPos[2]; setAttr ClusterControlMirrorSoftMod.falloffCenter ($originPos[0]*-1) $originPos[1] $originPos[2]; xform -piv ($originPos[0]*-1) $originPos[1] $originPos[2] ClusterControlMirrorSoftModHandle; setAttr ClusterControlMirrorSoftMod.falloffMode $falloffMode; setAttr ClusterControlMirrorSoftMod.falloffRadius $falloffRadius; select ClusterControlMirrorSoftModHandle; select -add `substitute "_R" $nearestJoint "_L"`; asConvertSoftModToSoftModControl $face; } if (`nodePreset -exists $softMod "asSoftMod"`) nodePreset -delete $softMod "asSoftMod"; delete $softModHandle; select ($name+$side); print ("// SoftModControl created\n"); } global proc asEnsureCustomSystemGroup () { if (!`objExists CustomSystem`) { createNode -n CustomSystem transform; if (`objExists MotionSystem`) parent CustomSystem MotionSystem; else if (`objExists FaceMotionSystem`) parent CustomSystem FaceMotionSystem; if (`objExists Main`) { //Could be AdvancedFace without AdvancedBody if (!`attributeExists customVis Main`) { addAttr -k 1 -ln customVis -at bool -dv 1 Main; setAttr -k 0 -cb 1 Main.customVis; } connectAttr Main.customVis CustomSystem.v; } if (`objExists MainScaleMultiplyDivide`) connectAttr MainScaleMultiplyDivide.output CustomSystem.s; } } global proc asValidateName (string $name) { if (`gmatch $name "*_*"`) error "illegal character (Underscore) found in the name, choose a name with no underscore"; if (`gmatch $name "[0-9]*"`) error "illegal name, name can not start with a number"; } global proc string asCustomControlNameFromNearestJoint (string $nearestJoint, string $type, string $customControlside) { string $sideLess,$side,$name; string $tempString[]; tokenize $nearestJoint "_" $tempString; $sideLess=$tempString[0]; $side="_"+$tempString[1]; for ($i=1;$i<99;$i++) { $name=$type+$i+$sideLess; if (!`objExists ($name+$customControlside)`) break; } return $name; } global proc asPaintClusterControlWeights () { global string $artSelectObject; string $sel[]=`ls -sl`; if ($sel[0]=="") error "Select Control first"; string $tempString[]=`listConnections ($sel[0]+".r")`; string $clusterHandle=$tempString[0]; if ($clusterHandle=="") error "No ClusterHandle found, selected object is not a Cluster-Control"; $tempString=`listConnections ($clusterHandle+".worldMatrix")`; string $cluster=$tempString[0]; $tempString=`listConnections ($cluster+".message")`; string $clusterSet=$tempString[0]; select $clusterSet; select `ls -sl -o`; artAttrToolScript 4 "cluster"; $artSelectObject=""; eval ("artSetToolAndSelectAttr( \"artAttrCtx\", \"cluster."+$cluster+".weights\")"); evalEcho ("artSetToolAndSelectAttr( \"artAttrCtx\", \"cluster."+$cluster+".weights\")"); toolPropertyWindow; } global proc asMirrorClusterControlWeights () { global string $gMainProgressBar; string $sel[]=`ls -sl`; string $tempString[],$tempString2[]; string $mirrorCuster,$mirrorVtx,$object; float $tempFloat[],$pos[]; if ($sel[0]=="") error "Select Control first"; $tempString=`listConnections ($sel[0]+".r")`; string $clusterHandle=$tempString[0]; $tempString=`listConnections ($clusterHandle+".worldMatrix")`; string $cluster=$tempString[0]; $tempString=`listConnections ($cluster+".message")`; string $clusterSet=$tempString[0]; select $clusterSet; $tempString=`ls -sl -fl`; select `ls -sl -o`; $tempString2=`ls -sl`; $tempString2=`listRelatives -p $tempString2[0]`; $object=$tempString2[0]; if (`gmatch $cluster "*_R"`) $mirrorCuster=`substitute "_R" $cluster "_L"`; else $mirrorCuster=`substitute "_L" $cluster "_R"`; percent -v 0 $mirrorCuster $object; if (`objExists closestSampler`) delete closestSampler; createNode -n closestSampler closestPointOnMesh; connectAttr ($object+".outMesh") closestSampler.inMesh; //connectAttr -f ($object+".matrix") closestSampler.inputMatrix;\\Creates incorrect results, so just rely on Mesh have frozen xforms progressBar -e -st "Mirroring" -bp -ii 1 -min 0 -max (size($tempString)) $gMainProgressBar; evalDeferred ("progressBar -e -ep "+$gMainProgressBar); for ($i=0;$i-0.001) continue; if (`gmatch $cluster "*_L"` && $pos[0]<0.001) continue; setAttr closestSampler.inPosition ($pos[0]*-1) $pos[1] $pos[2]; $mirrorVtx=$object+".vtx["+`getAttr closestSampler.closestVertexIndex`+"]"; percent -v $tempFloat[0] $mirrorCuster $mirrorVtx; } progressBar -e -ep $gMainProgressBar; delete closestSampler; select $sel; } global proc asAddSoftModInfluencedObject () { string $set,$joint,$sc; string $tempString[],$tempString2[],$objectsToAdd[]; string $sel[]=`ls -sl`; if (size($sel)<2) error "Select the controller, AND the object that should be influenced"; for ($i=0;$i1) { if (`objExists ($tempString[0]+"SoftModSet_"+$tempString[1])`) { $set=$tempString[0]+"SoftModSet_"+$tempString[1]; continue; } else if (`objExists ($tempString[0]+"ClusterSet_"+$tempString[1])`) { $set=$tempString[0]+"ClusterSet_"+$tempString[1]; continue; } else if (`objExists ($tempString[0]+"Joint_"+$tempString[1])`) { $joint=$tempString[0]+"Joint_"+$tempString[1]; continue; } } $objectsToAdd[size($objectsToAdd)]=$sel[$i]; } if ($set=="" && $joint=="") error "No DeformerSet or Joint found, selected object is not a valid Custom-Control"; for ($i=0;$i-2;$b=$b-2) { if ($b==-1) { if ($side=="_R") $side="_L"; else if ($side=="_L") $side="_R"; else continue; if (!`objExists ($sideLess+$side)`) continue; } $joint=$sideLess+"Joint"+$side; $cluster=$sideLess+"Cluster"+$side; $softMod=$sideLess+"SoftMod"+$side; if (`objExists $joint`) $isSkinControl=1; if (`objExists $cluster`) $isClusterControl=1; if (`objExists $softMod`) $isSoftmodControl=1; $tempString=`ls -l ($sideLess+$side)`; tokenize $tempString[0] "|" $tempString2; for ($y=0;$y-2;$b=$b-2) { if ($b==-1) {$SIDE="_L";$side="_l";} $sideDestJoints={("clavicle"+$side),("upperarm"+$side),("upperarm_twist_01"+$side),("lowerarm"+$side),("lowerarm_twist_01"+$side),("hand"+$side), ("index_01"+$side),("index_02"+$side),("index_03"+$side), ("middle_01"+$side),("middle_02"+$side),("middle_03"+$side), ("ring_01"+$side),("ring_02"+$side),("ring_03"+$side), ("pinky_01"+$side),("pinky_02"+$side),("pinky_03"+$side), ("thumb_01"+$side),("thumb_02"+$side),("thumb_03"+$side), ("thigh"+$side),("thigh_twist_01"+$side),("calf"+$side),("calf_twist_01"+$side),("foot"+$side),("ball"+$side)}; } $destJoints=`stringArrayCatenate $destJoints $sideDestJoints`; for ($i=0;$i-2;$b=$b-2) { if ($b==-1) {$SIDE="_L";$side="_l";} if (`objExists ("Scapula"+$SIDE)`) { pointConstraint ("Scapula"+$SIDE) ("clavicle"+$side); orientConstraint ("Scapula"+$SIDE) ("clavicle"+$side); setAttr -type float3 ("clavicle"+$side+"_orientConstraint1.offset") 180 0 180; } if (`objExists ("Shoulder"+$SIDE)`) { pointConstraint ("Shoulder"+$SIDE) ("upperarm"+$side); orientConstraint ("Shoulder"+$SIDE) ("upperarm"+$side); setAttr -type float3 ("upperarm"+$side+"_orientConstraint1.offset") 180 0 180; } if (`objExists ("Elbow"+$SIDE)`) { pointConstraint ("Elbow"+$SIDE) ("lowerarm"+$side); orientConstraint ("Elbow"+$SIDE) ("lowerarm"+$side); setAttr -type float3 ("lowerarm"+$side+"_orientConstraint1.offset") 180 0 180; } if (`objExists ("ShoulderPart1"+$SIDE)`) { pointConstraint ("ShoulderPart1"+$SIDE) ("upperarm_twist_01"+$side); orientConstraint ("ShoulderPart1"+$SIDE) ("upperarm_twist_01"+$side); setAttr -type float3 ("upperarm_twist_01"+$side+"_orientConstraint1.offset") 180 0 180; } if (`objExists ("ElbowPart1"+$SIDE)`) { pointConstraint ("ElbowPart1"+$SIDE) ("lowerarm_twist_01"+$side); orientConstraint ("ElbowPart1"+$SIDE) ("lowerarm_twist_01"+$side); setAttr -type float3 ("lowerarm_twist_01"+$side+"_orientConstraint1.offset") 180 0 180; } if (`objExists ("Wrist"+$SIDE)`) { pointConstraint ("Wrist"+$SIDE) ("hand"+$side); orientConstraint ("Wrist"+$SIDE) ("hand"+$side); setAttr -type float3 ("hand"+$side+"_orientConstraint1.offset") 90 0 180; } if (`objExists ("PinkyFinger1"+$SIDE)`) { pointConstraint ("PinkyFinger1"+$SIDE) ("pinky_01"+$side); orientConstraint ("PinkyFinger1"+$SIDE) ("pinky_01"+$side); setAttr -type float3 ("pinky_01"+$side+"_orientConstraint1.offset") 90 0 180; } if (`objExists ("PinkyFinger2"+$SIDE)`) { pointConstraint ("PinkyFinger2"+$SIDE) ("pinky_02"+$side); orientConstraint ("PinkyFinger2"+$SIDE) ("pinky_02"+$side); setAttr -type float3 ("pinky_02"+$side+"_orientConstraint1.offset") 90 0 180; } if (`objExists ("PinkyFinger3"+$SIDE)`) { pointConstraint ("PinkyFinger3"+$SIDE) ("pinky_03"+$side); orientConstraint ("PinkyFinger3"+$SIDE) ("pinky_03"+$side); setAttr -type float3 ("pinky_03"+$side+"_orientConstraint1.offset") 90 0 180; } if (`objExists ("RingFinger1"+$SIDE)`) { pointConstraint ("RingFinger1"+$SIDE) ("ring_01"+$side); orientConstraint ("RingFinger1"+$SIDE) ("ring_01"+$side); setAttr -type float3 ("ring_01"+$side+"_orientConstraint1.offset") 90 0 180; } if (`objExists ("RingFinger2"+$SIDE)`) { pointConstraint ("RingFinger2"+$SIDE) ("ring_02"+$side); orientConstraint ("RingFinger2"+$SIDE) ("ring_02"+$side); setAttr -type float3 ("ring_02"+$side+"_orientConstraint1.offset") 90 0 180; } if (`objExists ("RingFinger3"+$SIDE)`) { pointConstraint ("RingFinger3"+$SIDE) ("ring_03"+$side); orientConstraint ("RingFinger3"+$SIDE) ("ring_03"+$side); setAttr -type float3 ("ring_03"+$side+"_orientConstraint1.offset") 90 0 180; } if (`objExists ("MiddleFinger1"+$SIDE)`) { pointConstraint ("MiddleFinger1"+$SIDE) ("middle_01"+$side); orientConstraint ("MiddleFinger1"+$SIDE) ("middle_01"+$side); setAttr -type float3 ("middle_01"+$side+"_orientConstraint1.offset") 90 0 180; } if (`objExists ("MiddleFinger2"+$SIDE)`) { pointConstraint ("MiddleFinger2"+$SIDE) ("middle_02"+$side); orientConstraint ("MiddleFinger2"+$SIDE) ("middle_02"+$side); setAttr -type float3 ("middle_02"+$side+"_orientConstraint1.offset") 90 0 180; } if (`objExists ("MiddleFinger3"+$SIDE)`) { pointConstraint ("MiddleFinger3"+$SIDE) ("middle_03"+$side); orientConstraint ("MiddleFinger3"+$SIDE) ("middle_03"+$side); setAttr -type float3 ("middle_03"+$side+"_orientConstraint1.offset") 90 0 180; } if (`objExists ("IndexFinger1"+$SIDE)`) { pointConstraint ("IndexFinger1"+$SIDE) ("index_01"+$side); orientConstraint ("IndexFinger1"+$SIDE) ("index_01"+$side); setAttr -type float3 ("index_01"+$side+"_orientConstraint1.offset") 90 0 180; } if (`objExists ("IndexFinger2"+$SIDE)`) { pointConstraint ("IndexFinger2"+$SIDE) ("index_02"+$side); orientConstraint ("IndexFinger2"+$SIDE) ("index_02"+$side); setAttr -type float3 ("index_02"+$side+"_orientConstraint1.offset") 90 0 180; } if (`objExists ("IndexFinger3"+$SIDE)`) { pointConstraint ("IndexFinger3"+$SIDE) ("index_03"+$side); orientConstraint ("IndexFinger3"+$SIDE) ("index_03"+$side); setAttr -type float3 ("index_03"+$side+"_orientConstraint1.offset") 90 0 180; } if (`objExists ("ThumbFinger1"+$SIDE)`) { pointConstraint ("ThumbFinger1"+$SIDE) ("thumb_01"+$side); orientConstraint ("ThumbFinger1"+$SIDE) ("thumb_01"+$side); setAttr -type float3 ("thumb_01"+$side+"_orientConstraint1.offset") 90 0 180; } if (`objExists ("ThumbFinger2"+$SIDE)`) { pointConstraint ("ThumbFinger2"+$SIDE) ("thumb_02"+$side); orientConstraint ("ThumbFinger2"+$SIDE) ("thumb_02"+$side); setAttr -type float3 ("thumb_02"+$side+"_orientConstraint1.offset") 90 0 180; } if (`objExists ("ThumbFinger3"+$SIDE)`) { pointConstraint ("ThumbFinger3"+$SIDE) ("thumb_03"+$side); orientConstraint ("ThumbFinger3"+$SIDE) ("thumb_03"+$side); setAttr -type float3 ("thumb_03"+$side+"_orientConstraint1.offset") 90 0 180; } if (`objExists ("Hip"+$SIDE)`) { pointConstraint ("Hip"+$SIDE) ("thigh"+$side); orientConstraint ("Hip"+$SIDE) ("thigh"+$side); } if (`objExists ("HipPart1"+$SIDE)`) { pointConstraint ("HipPart1"+$SIDE) ("thigh_twist_01"+$side); orientConstraint ("HipPart1"+$SIDE) ("thigh_twist_01"+$side); } if (`objExists ("Knee"+$SIDE)`) { pointConstraint ("Knee"+$SIDE) ("calf"+$side); orientConstraint ("Knee"+$SIDE) ("calf"+$side); } if (`objExists ("Knee"+$SIDE)` && `objExists ("Ankle"+$SIDE)`) { pointConstraint ("Knee"+$SIDE) ("Ankle"+$SIDE) ("calf_twist_01"+$side); orientConstraint ("Knee"+$SIDE) ("calf_twist_01"+$side); } if (`objExists ("Ankle"+$SIDE)`) { pointConstraint ("Ankle"+$SIDE) ("foot"+$side); orientConstraint ("Ankle"+$SIDE) ("foot"+$side); } if (`objExists ("Toes"+$SIDE)`) { pointConstraint ("Toes"+$SIDE) ("ball"+$side); orientConstraint ("Toes"+$SIDE) ("ball"+$side); setAttr ("ball"+$side+"_orientConstraint1.offsetZ") 180; } } if (`objExists Neck_M`) { pointConstraint Neck_M neck_01; orientConstraint Neck_M neck_01; setAttr neck_01_orientConstraint1.offsetX 180; } if (`objExists Head_M`) { pointConstraint Head_M head; orientConstraint Head_M head; setAttr head_orientConstraint1.offsetX 180; } //custom joints for ($i=0;$i-2;$b=$b-2) { if ($b==-1) {$SIDE="_L";$side="_l";} $sideSourceJoints={("Scapula"+$SIDE),("Shoulder"+$SIDE),("ShoulderPart1"+$SIDE),("ShoulderPart2"+$SIDE),("Elbow"+$SIDE),("ElbowPart1"+$SIDE),("ElbowPart2"+$SIDE),("Wrist"+$SIDE), // ("Cup"+$SIDE), ("IndexFinger1"+$SIDE),("IndexFinger2"+$SIDE),("IndexFinger3"+$SIDE), ("MiddleFinger1"+$SIDE),("MiddleFinger2"+$SIDE),("MiddleFinger3"+$SIDE), ("RingFinger1"+$SIDE),("RingFinger2"+$SIDE),("RingFinger3"+$SIDE), ("PinkyFinger1"+$SIDE),("PinkyFinger2"+$SIDE),("PinkyFinger3"+$SIDE), ("ThumbFinger1"+$SIDE),("ThumbFinger2"+$SIDE),("ThumbFinger3"+$SIDE), ("Hip"+$SIDE),("HipPart1"+$SIDE),("HipPart2"+$SIDE),("Knee"+$SIDE),("Knee"+$SIDE),("Ankle"+$SIDE),("Toes"+$SIDE)}; $sideDestJoints={("clavicle"+$side),("upperarm"+$side),("upperarm_twist_01"+$side),("upperarm_twist_01"+$side),("lowerarm"+$side),("lowerarm_twist_01"+$side),("lowerarm_twist_01"+$side),("hand"+$side), // ("hand"+$side), ("index_01"+$side),("index_02"+$side),("index_03"+$side), ("middle_01"+$side),("middle_02"+$side),("middle_03"+$side), ("ring_01"+$side),("ring_02"+$side),("ring_03"+$side), ("pinky_01"+$side),("pinky_02"+$side),("pinky_03"+$side), ("thumb_01"+$side),("thumb_02"+$side),("thumb_03"+$side), ("thigh"+$side),("thigh_twist_01"+$side),("thigh_twist_01"+$side),("calf"+$side),("calf_twist_01"+$side),("foot"+$side),("ball"+$side)}; $sourceJoints=`stringArrayCatenate $sourceJoints $sideSourceJoints`; $destJoints=`stringArrayCatenate $destJoints $sideDestJoints`; } if (`attributeExists skinTransferred root`) { $transferBack=`getAttr root.skinTransferred`; setAttr root.skinTransferred (!$transferBack); } else addAttr -ln skinTransferred -dv 1 -at bool root; if ($transferBack) { $tempString=$sourceJoints; $sourceJoints=$destJoints; $destJoints=$tempString; } //ReParent any FaceJoints if (`objExists FaceJoint_M`) { if ($transferBack) parent FaceJoint_M Head_M; else parent FaceJoint_M head; } //transfer $sourceJoints to $destJoints for ($i=0;$i-1;$y--) if (!`gmatch $parents[$y] "*Part[0-9]*"`) { if (!`objExists ("FK"+$parents[$y])`) continue; if (!`objExists ("GameEngineScalingSSCMPD1"+$deformJoints[$i])`) { createNode -n ("GameEngineScalingSSCMPD1"+$deformJoints[$i]) multiplyDivide; setAttr ("GameEngineScalingSSCMPD1"+$deformJoints[$i]+".input1") -type float3 1 1 1; for ($z=0;$z$maxNumKeys) { $maxNumKeys=$numKeys; $animCurve=$animCurves[$a]; } } for ($x=$numKeys+1;$x>-1;$x--) { $keyValues=`keyframe -in $x -q -fc $animCurve`; $keyValues[0]=`asRoundOff $keyValues[0] 3`; if($keyValues[0]==0) continue; $cmd="asDsEdit "+$action+" "+$drivingSystems[$i]+" "+$attrs[$y]+" "+$keyValues[0]; setParent -menu $lev2Menu; $lev3Menu=`menuItem -sm 0 -l $keyValues[0] -c $cmd`; } } } } global proc string[] asGetBlendedDrivers (string $obj, string $attr) { float $driver1Value,$driver2Value; string $mpd,$setRange,$driver1,$driver2; string $tempString[],$blendedDrivers[]; $tempString=`listConnections -s 1 -d 0 ($obj+"."+$attr)`; if (`objectType $tempString[0]`=="multiplyDivide")//version pre 5.767 { $mpd=$tempString[0]; $tempString=`listConnections -s 1 -d 0 ($mpd+".input1X")`; } $setRange=$tempString[0]; $tempString=`listConnections -s 1 -d 0 ($setRange+".valueX")`; if (`objectType $tempString[0]`=="plusMinusAverage")//version from 5.767 { $tempString=`listConnections -s 1 -d 0 ($tempString[0]+".input1D[0]")`; $mpd=$tempString[0]; $tempString=`listConnections -s 1 -d 0 ($mpd+".input1X")`; if (`objectType $tempString[0]`=="blendWeighted") $tempString=`listConnections -s 1 -d 0 -p 1 ($tempString[0]+".input[0]")`; else $tempString=`listConnections -s 1 -d 0 -p 1 ($mpd+".input1X")`; $driver1=$tempString[0]; $tempString=`listConnections -s 1 -d 0 ($mpd+".input1Y")`; if (`objectType $tempString[0]`=="blendWeighted") $tempString=`listConnections -s 1 -d 0 -p 1 ($tempString[0]+".input[0]")`; else $tempString=`listConnections -s 1 -d 0 -p 1 ($mpd+".input1Y")`; $driver2=$tempString[0]; } else { $tempString=`listConnections -s 1 -d 0 -p 1 ($setRange+".valueX")`; $driver1=$tempString[0]; $tempString=`listConnections -s 1 -d 0 -p 1 ($setRange+".valueY")`; $driver2=$tempString[0]; } $driver1Value=`getAttr ($setRange+".maxX")`; $driver2Value=`getAttr ($setRange+".maxY")`; $blendedDrivers={$driver1,$driver2}; return $blendedDrivers; } global proc float[] asGetBlendedDriverValues (string $obj, string $attr) { float $blendedDriverValues[]={1,1}; string $tempString[]; tokenize $attr "_" $tempString; if (`gmatch $tempString[0] "*Neg"`) $blendedDriverValues[0]=-1; if (`gmatch $tempString[1] "*Neg"`) $blendedDriverValues[1]=-1; return $blendedDriverValues; } global proc asVersionRequirementCheck (string $bodyFace, float $version) { string $reBuildButtonLabel="ReBuild AdvancedSkeleton"; string $versionAttrObj="Main"; if ($bodyFace=="face") { $reBuildButtonLabel="ReBuild AdvancedFace"; $versionAttrObj="FaceGroup"; } if (`attributeExists version $versionAttrObj`) if (`getAttr ($versionAttrObj+".version")`<$version) error ("AdvancedSkeleton "+$bodyFace+"-rig version older then v"+$version+" detected, You must first run \""+$reBuildButtonLabel+"\", before you can use this function"); } global proc asDsCreate () { global string $asDSMessage; global string $asDSAttrName; global string $asDSObjName; global int $asDSAttrHasMin; global int $asDSAttrHasMax; global int $asDSAttrSoftLimits; global int $asDSMirror; global int $asDSAngle; global int $asDSAdvancedOptions; global int $asBuilding; global int $asRebuilding; global float $asDSAttrMin; global float $asDSAttrMax; $asDSAdvancedOptions=0; int $modifier=`getModifiers`; if ($modifier==4) $asDSAdvancedOptions=1; int $isFace,$isEditingExisting; string $sel[]=`ls -sl`; int $reusingSdkXform,$useExistingController,$breakSideLoop,$blendedAttr,$numChar,$inControlSet,$inFaceControlSet,$testSymmetry,$otherDsIsDriver; float $runValues[],$pos[],$drivenValues[],$blendedDriverValues[],$keyXValues[]; float $poseValue,$currentValue,$maxDistAmoungDrivens,$minX,$maxX,$minY,$maxY,$minZ,$maxZ,$difX,$difY,$difZ,$controlScale,$min,$dist,$defaultValue; string $parent,$child,$obj,$attr,$drivenObj,$drivenAttr,$m,$t,$controllerName,$side,$oppositeSide,$buildPoseNode,$dialogResult,$controllerName,$attrName,$restorePoseCmd; string $attrType,$originalSideControllerName,$originalSideAttrName,$ctrl,$animCurve,$mirroredAnimCurve,$att,$driveSource,$bw,$SDKDrivingBW,$SDKDrivenBW,$bwInputAttr; string $tempString[],$tempString2[],$tempString3[],$tempString4[],$drivens[],$sdkDrivens[],$runObjAttrs[],$checkObjAttr[],$drivenObjs[],$buildPoseCmds[],$runCmds[]; string $existingSdkXforms[],$realDrivenObj[],$blendedDrivers[],$connectionAttrNames[]; float $driverValue=10; float $scale=`asGetScale`; float $sideTreshold=0.0001*$scale; asVersionRequirementCheck body 5.732; asVersionRequirementCheck face 5.732; //TestSymmetry used if (`objExists TestSymmetry`) { $testSymmetry=1; currentTime 0; // dgdirty -a; $restorePoseCmd=`getAttr TestSymmetry.udAttr`; delete TestSymmetry; catchQuiet (`eval ($restorePoseCmd)`); } //TestAnimation used asDsRemoveTestAnimation; //Do we come from AdvancedSkeleton BUILD Mode ? int $comeFromASBuild=0; if ($asBuilding || $asRebuilding) $comeFromASBuild=1; else { $asDSObjName=""; $asDSAttrName=""; } //Are we editing Existing DrivingSystem ? if (`headsUpDisplay -q -ex HUDEDSMode`) { $isEditingExisting=1; $tempString[0]=`headsUpDisplay -q -l HUDEDSMode`; tokenize $tempString[0] $tempString2; tokenize $tempString2[3] "=" $tempString3; tokenize $tempString3[0] "." $tempString4; $asDSObjName=$tempString4[0]; $asDSAttrName=$tempString4[1]; $driverValue=$tempString3[1]; //if $otherDsIsDriver switch $asDSObjName to be the coresponding FK ctrl if (`objExists ("FK"+$asDSObjName)`) { $asDSObjName="FK"+$asDSObjName; $otherDsIsDriver=1; } } //run asUpdatePoseAttributes, as we might have `dud` cmds, due to manually deleted drivingSystems asUpdatePoseAttributes; //Find driven attribute(s) //get $buildPoseCmds if (`objExists ControlSet`) { $buildPoseCmds[0]=`getAttr buildPose.udAttr`; if (`attributeExists udExtraAttr buildPose`) $buildPoseCmds[0]=$buildPoseCmds[0]+`getAttr buildPose.udExtraAttr`; } if (`objExists FaceControlSet`) { $buildPoseCmds[1]=`getAttr faceBuildPose.udAttr`; if (`attributeExists udExtraAttr faceBuildPose`) $buildPoseCmds[0]=$buildPoseCmds[0]+`getAttr faceBuildPose.udExtraAttr`; } //get $runCmds if (`objExists FitSkeleton`) if (`attributeExists run FitSkeleton`) { $runCmds[0]=`getAttr FitSkeleton.run`; $runCmds[0]=`substituteAllString $runCmds[0] "\"" ""`; } if (`objExists FaceFitSkeleton`) if (`attributeExists run FaceFitSkeleton`) { $runCmds[1]=`getAttr FaceFitSkeleton.run`; $runCmds[1]=`substituteAllString $runCmds[1] "\"" ""`; } for ($a=0;$a<2;$a++) { tokenize $runCmds[$a] ";" $tempString; for ($i=0;$i1) { if ($z==0) $poseValue=$tempString2[3];//tx if ($z==1) $poseValue=$tempString2[4];//ty if ($z==2) $poseValue=$tempString2[5];//tz if ($z==3 && $tempString2[7]!="") $poseValue=$tempString2[7];//rx (not always in the xform cmd) if ($z==4 && $tempString2[8]!="") $poseValue=$tempString2[8];//rx (not always in the xform cmd) if ($z==5 && $tempString2[9]!="") $poseValue=$tempString2[9];//rx (not always in the xform cmd) if($z>5) $poseValue=1;//scale not always in the xform cmd } //actual poseValue might come from the run attribute// for ($y=0;$y($currentValue+0.001) || $poseValue<($currentValue-0.001)) { if (`gmatch $checkObjAttr[$z] "*_L*"`) error ("Found modified values on the Left side ("+$checkObjAttr[$z]+"), Only modify Right side (or middle)"); //Creating new DrivingSystem $drivens[size($drivens)]=$checkObjAttr[$z]; if (!`stringArrayCount $obj $drivenObjs`) $drivenObjs[size($drivenObjs)]=$obj; } } } } if (!$isEditingExisting) if (size($drivens)==0) error ("Found no driven attributes, all controls are in Build-Pose"); $buildPoseNode="buildPose"; if (`objExists FaceControlSet`) if ((`objExists $drivenObjs[0]` && `sets -im FaceControlSet $drivenObjs[0]`) || (`objExists $controllerName` && `sets -im FaceControlSet $controllerName`)) {//complex check, since $drivenObjs[0] does not exist when `deleting` last SDK by editing values to zero $isFace=1; $buildPoseNode="faceBuildPose"; } $m="Create system to drive these attributes?\n\n"; for ($i=0;$i-2;$b=$b-2) { $attrName=$asDSAttrName; if ($b==-1 && `gmatch $asDSAttrName "*Right"`)//ctrlARKit_M $attrName=`substitute "Right" $attrName "Left"`; if ($b==-1 && !$asDSMirror) continue; if ($b==-1 && $side=="_R") {$side="_L";$oppositeSide="_R";} else if ($b==-1 && $side=="_L") {$side="_R";$oppositeSide="_L";} if ($b==-1 && `gmatch $attrName "*Right"`) {$side="_L";$oppositeSide="_R";}//ctrlARKit_M else if ($b==-1 && `gmatch $attrName "*Left"`) {$side="_L";$oppositeSide="_R";}//ctrlARKit_M for ($i=0;$i10) addAttr -e -softMaxValue $driverValue ($controllerName+"."+$attrName); } } if ($otherDsIsDriver) { if (`gmatch $controllerName "FK*"`) $controllerName=`substitute "FK" $controllerName ""`; if ($asDSAngle) { $attrName=`substitute "rotate" $attrName "angle"`; // if (!`attributeExists $asDSAttrName $asDSObjName`) if (!`attributeExists $attrName $controllerName`) asCreateAngleAttrs $controllerName; //find new $driverValue in angle-values if ($b==1) { //Max 90 degrees if (abs($driverValue)>90) { warning ("Angle rotation more than 90 degrees, now reducing rotation to 90."); if ($driverValue>0) $driverValue=90; if ($driverValue<0) $driverValue=-90; } setAttr ($asDSObjName+"."+`substitute "angle" $attrName "rotate"`) $driverValue; $driverValue=`getAttr ($asDSObjName+"."+$attrName)`; $driverValue=`asRoundOff $driverValue 3`; setAttr ($asDSObjName+"."+`substitute "angle" $attrName "rotate"`) 0; } } if (!`attributeExists otherDsDrivers DrivingSystem`) { if (!`objExists DrivingSystem`) createNode -n DrivingSystem -p MotionSystem transform; addAttr -m -ln otherDsDrivers -attributeType message DrivingSystem; } $tempString=`listConnections -s 0 -d 1 -type transform ($controllerName+"."+$attrName)`; // connectAttr ($controllerName+"."+$attrName) DrivingSystem.otherDsDrivers[`getAttr -s DrivingSystem.otherDsDrivers`]; //modified, as it needs update to allow for `empty slots` if (!`stringArrayCount DrivingSystem $tempString`) for ($y=0;$y<99;$y++) { $tempString2=`listConnections -s 1 -d 0 ("DrivingSystem.otherDsDrivers["+$y+"]")`; if ($tempString2[0]=="") { connectAttr ($controllerName+"."+$attrName) DrivingSystem.otherDsDrivers[$y]; $y=99; } } } asEnsureOutputBlendWeighted ($controllerName+"."+$attrName); //remove OutputBlendWeighted from AllSet if $otherDsIsDriver, so ReBuilding will work with driven CustomControllers if ($otherDsIsDriver && $isFace && `objExists ("bw"+$controllerName+"_"+$attrName)` && `objExists FaceAllSet`) sets -rm FaceAllSet ("bw"+$controllerName+"_"+$attrName); if ($otherDsIsDriver && !$isFace && `objExists ("bw"+$controllerName+"_"+$attrName)` && `objExists AllSet`) sets -rm AllSet ("bw"+$controllerName+"_"+$attrName); if (!`getAttr -se ($controllerName+"."+$attrName)` && `gmatch $attrName "*_*"`) $blendedAttr=1; for ($i=0;$i0 && $value!=$limits[1]) $colorNr=13; if ($value<0 && $value!=$limits[0]) $colorNr=13; } //sorting $animCurves, as ctrl can be both direct and in-direct driven ) e.g Phoneme drive both ctrl + CtrlBox that also drives same ctrl //sort ctrlBox ctrls to come first for ($i=0;$i$maxTextLines) { $asDSMessage=""; for ($i=0;$i<$maxTextLines;$i++) $asDSMessage+=$tempString[$i]+"\n"; $asDSMessage+="...And "+(size($tempString)-$maxTextLines)+" more.."; } columnLayout -adj 0 -w 250; columnLayout -adj 0; text -l $asDSMessage asDSMessageText; separator -h 10 -st none; setParent..; rowLayout -nc 2; separator -st none -w 20; optionMenu -cc asDSChangeDriveOption asDSDriveOptionMenu; menuItem "create new controller"; menuItem "use existing controller"; menuItem "drive from selected object"; setParent..; columnLayout -adj 1 asDSInputsColumnLayout; rowLayout -nc 3 asDSControlNameRowLayout; text -w 100 -l "Control Name:"; columnLayout; textField -w 80 asDSObjNameTextField; optionMenu -m 0 asDSObjNameOptionMenu; setParent..; setParent..; rowLayout -nc 3; text -w 100 -l "Attribute Name:"; textField -w 80 asDSAttrNameTextField; setParent..; /* rowLayout -en 0 -nc 4 asDSUseControlRowLayout; separator -w 5 -st none; checkBox -w 95 -l "Use Control:" -onc "optionMenu -e -en 1 asDSObjNameOptionMenu;rowLayout -e -en 0 asDSControlNameRowLayout;checkBox -e -en 0 asDSMirrorCheckBox;" -ofc "optionMenu -e -en 0 asDSObjNameOptionMenu;rowLayout -e -en 1 asDSControlNameRowLayout;checkBox -e -en 1 asDSMirrorCheckBox;" asDSUseControlCheckBox; setParent..; */ if ($asDSAdvancedOptions) { separator; text -l "Attribute limits:"; rowLayout -en 1 -nc 8; checkBox -w 40 -v 1 -l "min:" asDSAttrHasMin; floatField -w 30 -v 0 -pre 1 asDSAttrMin; separator -w 10 -st none; checkBox -w 40 -v 1 -l "max:" asDSAttrHasMax; floatField -w 30 -v 10 -pre 1 asDSAttrMax; setParent..; separator -h 5 -st none; checkBox -l "Use Soft limits" -v 1 asDSAttrSoftLimits; } separator -h 10 -st none; setParent..; columnLayout -adj 0; rowLayout -nc 3 asDSMirrorRowLayout; text -w 100 -l "Mirror:"; checkBox -l "" -v 1 asDSMirrorCheckBox; setParent..; rowLayout -m 0 -nc 3 asDSAngleRowLayout; text -w 100 -l "Angle Rotations:"; checkBox -l "" -v 1 -cc asDSChangeDriveOption asDSAngleCheckBox; setParent..; rowLayout -nc 4; separator -w 10 -st none; button -l "OK" -c "asDsGetName;layoutDialog -dismiss \"OK\";"; separator -w 10 -st none; button -l "Cancel" -c "layoutDialog -dismiss \"Cancel\""; setParent..; setParent..; //populate asDSObjNameOptionMenu string $drivingSystems[]=`asDsGetDrivingSystems`; //if (size($drivingSystems)) // rowLayout -e -en 1 asDSUseControlRowLayout; setParent -menu asDSObjNameOptionMenu; //This proc also used by CreateNewBlendShape, then $drivingSystems are actuall faceCtrls if ($asDSMessage=="Create New BlendShape") { clear $drivingSystems; if (`objExists ctrlBox`) { $tempString=`listRelatives -c -type transform ctrlBox`; for ($i=0;$i2) $attr+="."+$tempString[2]; if ($attr=="tx") $attr="translateX"; if ($attr=="ty") $attr="translateY"; if ($attr=="tz") $attr="translateZ"; if ($attr=="rx") $attr="rotateX"; if ($attr=="ry") $attr="rotateY"; if ($attr=="rz") $attr="rotateZ"; if ($attr=="sx") $attr="scaleX"; if ($attr=="sy") $attr="scaleY"; if ($attr=="sz") $attr="scaleZ"; if (`objExists FaceAllSet`) if (`sets -im FaceAllSet $obj`) $isFaceControl=1; if (`objExists FaceBuildingSets`) $isFaceControl=1; $blendWeighted=`substituteAllString ($obj+"."+$attr) "." "_"`; $blendWeighted=`substituteAllString $blendWeighted "[" "_"`; $blendWeighted=`substituteAllString $blendWeighted "]" "_"`; $blendWeighted="bw"+ $blendWeighted; if (`gmatch $sdkDriven "bw*"` && `objectType $obj`=="blendWeighted") $blendWeighted=$obj; if (!`objExists $blendWeighted`) { createNode -n $blendWeighted blendWeighted; if ($isFaceControl && `objExists FaceAllSet`) if (`sets -im FaceAllSet $obj`)//Add to AllSet only if controller is already in AllSet, (so not for CustomControllers) sets -add FaceAllSet $blendWeighted; if (!$isFaceControl && `objExists AllSet`) if (`sets -im AllSet $obj`)//Add to AllSet only if controller is already in AllSet, (so not for CustomControllers) sets -add AllSet $blendWeighted; if (!`objExists asEnsureOutputBlendWeighted`) { //preserve existing input, by adding to th bw $tempString=`listConnections -s 1 -d 0 -p 1 ($obj+"."+$attr)`; if ($tempString[0]!="") connectAttr -f $tempString[0] ($blendWeighted+".input[0]"); connectAttr -f ($blendWeighted+".output") ($obj+"."+$attr); } else { //changing direct connect to OutputBlendWeighted to SDK // asFaceBsSdk ($obj+"."+$attr) 1 ($blendWeighted+".input[0]") 1; connectAttr -f ($obj+"."+$attr) ($blendWeighted+".input[0]"); } } //outputBW might have existed (due to custom DS have been deleted). so just connect if (`objExists asEnsureOutputBlendWeighted` && !`isConnected ($obj+"."+$attr) ($blendWeighted+".input[0]")`) connectAttr -f ($obj+"."+$attr) ($blendWeighted+".input[0]"); return $blendWeighted; } global proc string asEnsureOutputBlendWeighted (string $sdkDriven) { if (!`objExists asEnsureOutputBlendWeighted`) createNode -n asEnsureOutputBlendWeighted transform; string $blendWeighted=`asEnsureBlendWeighted $sdkDriven`; delete asEnsureOutputBlendWeighted; return $blendWeighted; } global proc string asCtrlToBw (string $ctrl) { string $bw=$ctrl; if (`gmatch $bw "*[.]t[x-z]"`) { $bw=`substitute "[.]tx" $bw ".translateX"`; $bw=`substitute "[.]ty" $bw ".translateY"`; $bw=`substitute "[.]ty" $bw ".translateZ"`; } if (`gmatch $bw "*[.]r[x-z]"`) { $bw=`substitute "[.]rx" $bw ".rotateX"`; $bw=`substitute "[.]ry" $bw ".rotateY"`; $bw=`substitute "[.]ry" $bw ".rotateZ"`; } if (`gmatch $bw "*[.]s[x-z]"`) { $bw=`substitute "[.]sx" $bw ".scaleX"`; $bw=`substitute "[.]sy" $bw ".scaleY"`; $bw=`substitute "[.]sy" $bw ".scaleZ"`; } $bw="bw"+`substitute "[.]" $bw "_"`; return $bw; } /* global proc float asEnsureCorrectMultiDriverScaleValue (float $drivenValue, string $driveSource, string $sdkDriven) { int $bwInputNr; float $ensuredDrivenValue=$drivenValue; string $bw,$sdk; string $tempString[],$tempString2[],$tempString3[]; if (!`gmatch $sdkDriven "*[.]s[x-z]"`) return $ensuredDrivenValue; //find $bw $tempString=`listConnections -s 1 -d 0 -type blendWeighted $sdkDriven`; if (!size($tempString)) return $ensuredDrivenValue; $bw=$tempString[0]; //find $sdk $tempString=`listConnections -s 0 -d 1 -type animCurve $driveSource`; if (!size($tempString)) return $ensuredDrivenValue; for ($i=0;$i1 if ($bwInputNr>0) { print ("Scale subtract: "+$sdkDriven+" is inbutNr>1 it is:"+$bwInputNr+", value will be:"+($drivenValue-1)+" ("+$drivenValue+"-1) "+$bw+" "+$sdk+"\n"); $ensuredDrivenValue=$drivenValue-1; } return $ensuredDrivenValue; } */ global proc asEnsureSDKcurvesNamed () { int $isFaceControl; string $tempString[],$tempString2[],$tempString3[],$tempString4[]; string $newName; $tempString=`ls -type transform "*SDK*_*"`; for ($i=0;$i-1;$y--) { $numOthersHaveThisParent=0; for ($z=0;$z>`; if ($dist>$maxDist) $maxDist=$dist; delete `pointConstraint $endJoint tempSampler`; } if ($maxDist<0.01) $maxDist=0.5; delete `pointConstraint $constraintTo $drivingSystems[$a]`; if (`objExists ($drivingSystems[$a]+"_aimConstraint1")`) delete ($drivingSystems[$a]+"_aimConstraint1"); parentConstraint -mo $constraintTo $drivingSystems[$a]; setAttr -type float3 ($drivingSystems[$a]+".s") ($maxDist*1.2) ($maxDist*0.5) 1; asLockAttr $drivingSystems[$a] 1 1 1 1; } if (`objExists tempSamplerOffset`) delete tempSamplerOffset; select $sel; } global proc asDsCreateController (string $objName, string $drivenObjs[]) { int $isChildOfOtherDriven; string $tempString[],$tempString2[]; string $objectType; string $constraintTo="Root_M"; $tempString=`circle -n $objName -c 0 0 0 -nr 0 0 1 -sw 180 -r 1 -d 3 -ut 0 -tol 0.000393701 -s 8 -ch 0`; $objName=$tempString[0]; scale -r -1 1 1 ($objName+".cv[0:10]"); sets -add AllSet $objName; sets -add AllSet ($objName+"Shape"); sets -add ControlSet $objName; setAttr ($objName+"Shape.overrideEnabled") 1; setAttr ($objName+"Shape.overrideColor") 17; if (!`objExists DrivingSystem`) { createNode -n DrivingSystem -p MotionSystem transform; connectAttr Main.drvSysVis DrivingSystem.v; sets -add AllSet DrivingSystem; addAttr -m -ln otherDsDrivers -attributeType message DrivingSystem; } parent $objName DrivingSystem; string $deformJoint=$drivenObjs[0]; if (`gmatch $drivenObjs[0] "FK*"`) $deformJoint=`substitute "FK" $drivenObjs[0] ""`; //since $drivenObjs[0] could be a blendWeighted (nested DrivingSystem), we use Root $objectType=`objectType $deformJoint`; if ($objectType!="joint" && $objectType!="transform") $deformJoint="Root_M"; if (`objExists $deformJoint`) $constraintTo=$deformJoint; asAlign $objName $deformJoint 1 1 0 0; string $rlaChild=`asRlaChild $deformJoint`; if (`objExists $rlaChild`) { float $scale=`getAttr ($rlaChild+".tx")`; setAttr -type float3 ($objName+".s") $scale $scale $scale; // scale -r $scale $scale $scale ($objName+".cv[0:10]"); } string $restorePoseCmd=`asGetRestorePoseCmd`; if (`objExists ControlSet`) asGoToBuildPose bodySetup; //if (`objExists ($objName+"_pointConstraint1")`) // delete ($objName+"_pointConstraint1"); if (`objExists $constraintTo`) parentConstraint -mo $constraintTo $objName; eval($restorePoseCmd); asLockAttr $objName 1 1 1 1; } global proc asCreateAngleAttrs (string $joint) { string $sel[]=`ls -sl`; string $restorePoseCmd=`asGetRestorePoseCmd`; if (`objExists ControlSet`) asGoToBuildPose bodySetup; if (`objExists FaceControlSet`) asGoToBuildPose faceSetup; float $charHeight=`asgetCharHeight`; float $posNegMult; int $sideFactor=1; if (`gmatch $joint "*_L"`) $sideFactor=-1; string $FKjoint=$joint; if (`objExists ("FK"+$joint)`) $FKjoint="FK"+$joint; string $XYZ[]={"X","Y","Z"}; string $xyz[]={"x","y","z"}; string $RGB[]={"R","G","B"}; string $posNegs[]={"Pos","Neg"}; string $absPriAxis=`asGetAxis primary $joint Main 1`; string $absSecAxis=`asGetAxis secondary $joint Main 1`; string $absTerAxis=`asGetAxis tertiary $joint Main 1`; string $loc,$endLoc; for ($i=0;$i=0) $attr+="Pos"; else $attr+="Neg"; if ($i0) { if (`objectType $nodeA`=="multiplyDivide") { $connectedToMultDiv=1; $plug=$nodeA+".input1.input1X"; if (`attributeExists setAnglesCmd $nodeA`) $setAnglesCmd=`getAttr ($nodeA+".setAnglesCmd")`; } else if (`objectType $nodeA`=="setRange") { $setRange=$nodeA; $dvs[size($dvs)]=`getAttr ($setRange+".dvX")`; $dvs[size($dvs)]=`getAttr ($setRange+".dvY")`; $tempString=`listConnections -s 1 -d 0 -scn 1 ($setRange+".valueX")`; $pma=$tempString[0]; $tempString=`listConnections -s 1 -d 0 -scn 1 ($pma+".input1D[0]")`; $mpd=$tempString[0]; $tempString=`listConnections -s 1 -d 0 -scn 1 ($mpd+".input1X")`; if (`objectType $tempString[0]`=="blendWeighted") $tempString=`listConnections -s 1 -d 0 -p 1 -scn 1 ($tempString[0]+".input[0]")`; else $tempString=`listConnections -s 1 -d 0 -p 1 -scn 1 ($mpd+".input1X")`; $drivers[size($drivers)]=$tempString[0]; $tempString=`listConnections -s 1 -d 0 -scn 1 ($mpd+".input1Y")`; if (`objectType $tempString[0]`=="blendWeighted") $tempString=`listConnections -s 1 -d 0 -p 1 -scn 1 ($tempString[0]+".input[0]")`; else $tempString=`listConnections -s 1 -d 0 -p 1 -scn 1 ($mpd+".input1Y")`; $drivers[size($drivers)]=$tempString[0]; } } } /* //Swap "Mixed" for non-mixed, as mixed can not be directly `set`. for ($i=0;$i1) error "More than 1 object selected, Only 1 object must be selected"; if (`gmatch $sel[0] "*__*"`) error "Selected object IS a Corrective Shape. Select geometry on your character"; if ($sel[0]!="") if (`objectType $sel[0]`=="mesh") $sel=`listRelatives -p $sel[0]`; $tempString=`listRelatives -ni -s $sel[0]`; if ($tempString[0]=="") error "Selected Object is not geometry"; if (`objectType $tempString[0]`!="mesh") error "Selected object is not a mesh"; string $controlSetMembers[]; if (`objExists ControlSet`) $controlSetMembers=`sets -q ControlSet`; //string $tr[]={"t","r"}; //string $xyz[]={"x","y","z"}; string $drivers[],$keyableAttr[]; string $objAttr; float $poseValue,$currentValue; //Find driving attribute(s) string $buildPoseCmds[],$runCmds[]; //get $buildPoseCmds if (`objExists ControlSet`) $buildPoseCmds[0]=`getAttr buildPose.udAttr`; if (`objExists FaceControlSet`) $buildPoseCmds[1]=`getAttr faceBuildPose.udAttr`; //get $runCmds if (`objExists FitSkeleton`) if (`attributeExists run FitSkeleton`) { $runCmds[0]=`getAttr FitSkeleton.run`; $runCmds[0]=`substituteAllString $runCmds[0] "\"" ""`; } if (`objExists FaceFitSkeleton`) if (`attributeExists run FaceFitSkeleton`) { $runCmds[1]=`getAttr FaceFitSkeleton.run`; $runCmds[1]=`substituteAllString $runCmds[1] "\"" ""`; } string $runObjAttrs[],$checkObjAttr[]; float $runValues[]; for ($a=0;$a<2;$a++) { tokenize $runCmds[$a] ";" $tempString; for ($i=0;$i5) $poseValue=1;//scale //actual poseValue might come from the run attribute// for ($y=0;$y($currentValue+0.001) || $poseValue<($currentValue-0.001)) $drivers[size($drivers)]=$checkObjAttr[$z]; } } } if (size($drivers)==0) error ("Found no driving attribute, all values are in Build-Pose"); //For twistDistributed limbs, if not using "Angle", then rx is not excepted, neighter is any mix if (!`checkBox -q -v asCorrectiveAngleCheckBox`) { if (`gmatch $drivers[0] "*[.]rotateX"` || `size($drivers)`>1) { tokenize $drivers[0] "[.]" $tempString; int $numChar=size($tempString[0]); string $fitJoint=`substring $tempString[0] 3 ($numChar-2)`; if (`objExists $fitJoint`) if (`attributeExists twistJoints $fitJoint` || `attributeExists inbetweenJoints $fitJoint`) { warning "Due to \"twistJoints\" or \"inbetweenJoints\" beeing used, rotation values will not work, Now turning On \"Angle\" rotations."; checkBox -e -v 1 asCorrectiveAngleCheckBox; asCreateCorrectiveShape; return ""; } } } for ($i=0;$i90) { warning ("Angle rotation more than 90 degrees, now reducing rotation to 90."); if ($FKdv>0) $dv=90; if ($FKdv<0) $dv=-90; setAttr ("FK"+$drivers[0]) $dv; } for ($i=0;$i1) for ($i=0;$i0.001) if (!`stringArrayCount $check $drivers`) { $drivers[size($drivers)]=$check; $drivers=`sort $drivers`; } } } } if (size($drivers)>1) { //We might have arrived back here from already created blendAttr if (`objExists BlendedCorrectiveDriver`) { $driverObj=`getAttr BlendedCorrectiveDriver.driverObj`; $driverAttr=`getAttr BlendedCorrectiveDriver.driverAttr`; $dv=`getAttr ($driverObj+"."+$driverAttr)`; } else { string $m="Create Corrective Shape from blend of these drivers?\n\n"; for ($i=0;$i1) // BSnode and `similar` target Exists (This must be a inbetween target) { print ("// connecting inbeween shape at: "+$iv+" for targetNr: "+$existingTargetNr+"\n"); blendShape -e -inBetween -t $deformObj $inputTargetGroups[$existingTargetNr] $deltaShape $iv ($deformObj+"Corrective"); //add a key, so this inbeween can be extracted setDrivenKeyframe -v $iv -dv `getAttr ($deltaShape+".driverValue")` -cd ($driverObj+"."+$driverAttr) ($deformObj+"Corrective."+$driverObj+"__"+$driverAttr+"__"+$posNeg); } else { print ("// Creating New BlendShape\n"); $wc=`blendShape -q -wc ($deformObj+"Corrective")`; if ($wc>0) { $mi=bsMultiIndexForTarget(($deformObj+"Corrective"),$wc-1); if ($mi!=-1) $wc=$mi+1; } print ("blendShape -e -t "+$deformObj+" "+$wc+" "+$deltaShape+" 1 "+$deformObj+"Corrective;\n"); blendShape -e -t $deformObj $wc $deltaShape 1 ($deformObj+"Corrective"); } } else { // blendShape -n ($deformObj+"Corrective") -frontOfChain; asBlendShapeFrontOfChain ($deformObj+"Corrective"); } } global proc asPopulateCorrectivePopupMenu (string $action) { string $popupMenu="as"+$action+"CorrectiveShapesPopupMenu"; string $existingMenuItems[]=`popupMenu -q -ia $popupMenu`; for ($item in $existingMenuItems) deleteUI $item; string $correctiveBS[]=`ls -r 1 -type blendShape "*Corrective"`; int $menuExisted,$en; float $keyXValues[],$keyYValues[]; string $label,$menu,$lev1Menu,$lev2Menu,$lev3Menu,$lev4Menu,$lev5Menu; string $weights[],$tempString[],$menu2s[],$menu3s[],$menu4s[]; string $menu2Label,$prevMenu2Label,$menu3Label,$prevMenu3Label,$menu4Label,$prevMenu4Label; for ($i=0;$i=0 && $keyXValues[$z]==$smallestKeyXValue) || ($keyXValues[$z]<0 && $keyXValues[$z]==-1*$smallestKeyXValue)) continue; float $roundFactor; if ($keyXValues[$z]>0) $roundFactor=0.5; else $roundFactor=-0.5; $keyXValues[$z]=(trunc($keyXValues[$z]*`pow 10 3`+$roundFactor)/`pow 10 3`); //round to precition of 3 $cmd=""; if ($action=="Delete") $cmd="createNode -n DeleteCorrectiveShape transform;"; if ($action=="Edit" || $action=="Delete") $cmd+="asEditCorrectiveShape "+$deformObj+" "+$driverObj+" "+$driverAttr+" \""+$keyXValues[$z]+"\" "; if ($action=="Delete") $cmd+=";asConnectCorrectiveShape;"; $en=1; $label=$keyXValues[$z]; if ($action=="Delete") if ($keyYValues[$z]==1 && size($keyXValues)>2) // if (($keyXValues[$z]>0 && size($keyXValues)>2 && $z==size($keyXValues)-1) // || ($keyXValues[$z]<0 && size($keyXValues)>2 && $z==0)) $en=0; // if (($keyXValues[$z]>0 && $z0)) if ($keyYValues[$z]!=1) $label+=" (inbtw)"; setParent -menu $lev4Menu; menuItem -en $en -l $label -c $cmd; } } } } global proc float asSetRotationFromAngle (string $driverObj, string $driverAttr, float $dv) { //Dont set `mix` values if (`gmatch $driverAttr "*_*"`) return 1; string $XYZ=`substitute "angle" $driverAttr ""`; float $a=1-`abs($dv)`; float $c=0.707; float $b=0.707; float $rads = ((`pow $b 2`) + (`pow $c 2`) - (`pow $a 2`)) /( 2*$b*$c); float $deg=90-`acosd($rads)`; if ($dv<0) $deg*=-1; string $controller="FK"+$driverObj; if (`sets -im ControlSet $driverObj`) $controller=$driverObj; setAttr ($controller+".rotate"+$XYZ) $deg; return $deg; } global proc asGoToCorrectivePose (string $driverObj, string $driverAttr, float $dv) { string $FKIK; string $tempString[],$tempString2[],$tempString3[],$tempString4[]; string $FKDriverObj=$driverObj; if (`objExists ("FK"+$driverObj)` && !`gmatch $driverObj "IK*"`) $FKDriverObj="FK"+$driverObj; //inbetween changes the driverValue int $numChar=size($driverObj); string $fitJoint=`substring $driverObj 1 ($numChar-2)`; if (`objExists $fitJoint`) if (`attributeExists inbetweenJoints $fitJoint`) $dv=$dv*(`getAttr ($fitJoint+".inbetweenJoints")`+1); if (!`getAttr -settable ($FKDriverObj+"."+$driverAttr)`)//blended (including blended angles { asSetBlendedAttribute $driverObj $driverAttr $dv 0; if (`gmatch $driverAttr "angle*"`)//single angles (not blended angles) $idv=`asSetRotationFromAngle $driverObj $driverAttr $dv`; } else setAttr ($FKDriverObj+"."+$driverAttr) $dv; print ("setAttr "+$FKDriverObj+"."+$driverAttr+" "+$dv+";\n"); //Set FKIK to FK (if $FKIK exists) if (`objExists ("FK"+$driverObj)` && `objExists ("FKX"+$driverObj)` && `objExists ("IKX"+$driverObj)` && `objExists ("FKOffset"+$driverObj)`) { $tempString=`listConnections -s 1 -d 0 -scn 1 ($driverObj+".tx")`; if (`objExists ("BendParentConstraint"+$driverObj+"_parentConstraint1")`)//Might be bendy-limb $tempString[0]="BendParentConstraint"+$driverObj+"_parentConstraint1"; if ($tempString[0]!="") $tempString2=`listAttr -ud $tempString[0]`; if ($tempString2[1]!="") $tempString3=`listConnections -s 1 -d 0 -scn 1 ($tempString[0]+"."+$tempString2[1])`; if ($tempString3[0]!="") $FKIK=$tempString3[0]; if (`attributeExists FKIKBlend $FKIK`) setAttr ($FKIK+".FKIKBlend") 0; print ("setAttr "+$FKIK+".FKIKBlend 0;\n"); } } global proc asEditCorrectiveShape (string $deformObj, string $driverObj, string $driverAttr, float $dv) { //print ("asEditCorrectiveShape "+$deformObj+" "+$driverObj+" "+$driverAttr+" "+$dv+"\n"); float $idv; int $autoKeyframe=`autoKeyframe -q -state`; autoKeyframe -state 0; //string $restorePoseCmd=`asGetRestorePoseCmd`; if (`objExists ControlSet`) asGoToBuildPose bodySetup; if (`objExists FaceControlSet`) asGoToBuildPose faceSetup; asGoToCorrectivePose $driverObj $driverAttr $dv; string $attrCode=$deformObj+"__"+$driverObj+"__"+$driverAttr; float $iv=`asCorrectiveGetIV $deformObj $driverObj $driverAttr $dv`; if (`objExists $attrCode`) warning ("Object "+$attrCode+" already exists"); else { asCorrectiveDuplicate $attrCode $deformObj; addAttr -k 1 -ln driverValue -at double -dv $dv $attrCode; addAttr -k 1 -ln inbetweenValue -at double -dv $iv $attrCode; addAttr -k 1 -ln indirectDriverValue -at double -dv $idv $attrCode; } //asGoToBuildPose bodySetup; //eval($restorePoseCmd); autoKeyframe -state $autoKeyframe; dgdirty -a; } global proc string asRemoveNameSpace (string $name) { string $return=$name; string $tempString[]; tokenize $name ":" $tempString; if (size($tempString)>1) $return=`substitute ($tempString[0]+":") $name ""`; return $return; } global proc int asGetNextFreeMultiIndex (string $attr) { for($i=1;$i<10000000;$i++) { string $con = `connectionInfo -sfd ($attr + "["+$i+"]")`; if(size($con)==0) return($i); } return(0); } global proc asCBDCreateCurves () { string $sel[]=`ls -sl`; string $mesh=`textField -q -tx asBodyCorrectiveCBDMeshTextField`; string $fkControl=`textField -q -tx asBodyCorrectiveCBDFKControlTextField`; string $joint=`substitute "FK" $fkControl ""`; string $curveCmd,$curve,$slideSideNr,$axis,$parentJoint,$childJoint,$getXFrom,$deleteSlidersCmd; string $tempString[],$curves[],$startProfile; float $pos[],$tempPos[]; float $fat,$parentfat,$childfat; int $haveSkinCage=`objExists SkinCage`; int $rotYonly,$rotZonly,$singleAxisPositive; if (!`gmatch $fkControl "FK*"`) error "Select FK-controller(s)"; if ($mesh=="") error "Mesh must be chosen"; if (!$haveSkinCage) { asCreateSkinCage; asSkinCurvesToWidth; setAttr SkinCage.v 0; setAttr SkinCurves1.v 0; setAttr SkinCurves2.v 0; } select -cl; if (`objExists tempLoc`) delete tempLoc; if (`objExists curveDeformationObjects`) delete `sets -q curveDeformationObjects`; createNode -n curveDeformationObjects objectSet; createNode -n curveDeformationSetup transform; sets -add curveDeformationObjects curveDeformationSetup; addAttr -ln mesh -dt "string" curveDeformationSetup; setAttr -l 1 -type "string" curveDeformationSetup.mesh $mesh; addAttr -ln fkControl -dt "string" curveDeformationSetup; setAttr -l 1 -type "string" curveDeformationSetup.fkControl $fkControl; $tempString=`listRelatives -type joint -p $joint`; while (`gmatch $tempString[0] "*Part[0-9]*"`) $tempString=`listRelatives -type joint -p $tempString[0]`; $parentJoint=$tempString[0]; $tempString=`listRelatives -type joint -c $joint`; while (`gmatch $tempString[0] "*Part[0-9]*"`) $tempString=`listRelatives -type joint -c $tempString[0]`; $childJoint=$tempString[0]; $fat=`getAttr ($joint+".fat")`*`getAttr ($joint+".fatWidth")`; $parentfat=`getAttr ($parentJoint+".fat")`*`getAttr ($parentJoint+".fatWidth")`; $childfat=`getAttr ($childJoint+".fat")`*`getAttr ($childJoint+".fatWidth")`; //find $startProfile & $endProfile if (`objExists ($joint+"_startProfile")`) $startProfile=$joint+"_startProfile"; else for ($y=20;$y>0;$y--) if (`objExists ($parentJoint+"_twistProfile"+$y)`) { $startProfile=$parentJoint+"_twistProfile"+$y; break; } if (`objExists ($joint+"_endProfile")`) $endProfile=$joint+"_endProfile"; else if (`objExists ($joint+"_twistProfile1")`) $endProfile=$joint+"_twistProfile1"; //if (!`objExists $endProfile`) // $endProfile=$childJoint+"_middleProfile"; //Ensure sliders if (!`objExists ($joint+"_middleSlider0")`) {select ($joint+"_middleProfile");asCreateSliders;$deleteSlidersCmd+="select "+$joint+"_middleProfile;asDeleteSliders;";} if (!`objExists ($joint+"_startSlider0")`) if (`objExists $startProfile`){select $startProfile;asCreateSliders;$deleteSlidersCmd+="select "+$startProfile+";asDeleteSliders;";} else { for ($i=0;$i<5;$i++) if (`objExists ($joint+"_middleSlider"+$i)`) { duplicate -n ($joint+"_startSlider"+$i) ($joint+"_middleSlider"+$i); parent ($joint+"_startSlider"+$i) $joint; setAttr ($joint+"_startSlider"+$i+".tx") `getAttr ($joint+".tx")`; } } if (!`objExists ($joint+"_endSlider0")`) if (`objExists $endProfile`){select $endProfile;asCreateSliders;$deleteSlidersCmd+="select "+$endProfile+";asDeleteSliders;";} else { for ($i=0;$i<5;$i++) if (`objExists ($joint+"_middleSlider"+$i)`) { duplicate -n ($joint+"_endSlider"+$i) ($joint+"_middleSlider"+$i); parent ($joint+"_endSlider"+$i) $joint; setAttr ($joint+"_endSlider"+$i+".tx") `getAttr ($childJoint+".tx")`; } } //$rotYonly,$rotZonly & $singleAxisPositive $rotYonly=$rotZonly=0; if (!`objExists ($joint+"_middleSlider0")`) $rotYonly=1; if (!`objExists ($joint+"_middleSlider1")`) $rotZonly=1; $singleAxisPositive=0; if ($rotYonly && `getAttr ($joint+".jointOrientY")`>0) $singleAxisPositive=1; if ($rotZonly && `getAttr ($joint+".jointOrientZ")`>0) $singleAxisPositive=1; addAttr -k 1 -ln "rotYonly" -at bool -dv $rotYonly curveDeformationSetup; addAttr -k 1 -ln "rotZonly" -at bool -dv $rotZonly curveDeformationSetup; addAttr -k 1 -ln "singleAxisPositive" -at bool -dv $singleAxisPositive curveDeformationSetup; spaceLocator -n tempLoc; pointConstraint $parentJoint $joint $childJoint tempLoc; parent tempLoc $joint; setAttr -type float3 tempLoc.r 0 0 0; for ($a=1;$a>-2;$a=$a-2) { if ($a==1) $axis="Y"; if ($a==-1) $axis="Z"; if ($rotYonly && $axis=="Y") continue; if ($rotZonly && $axis=="Z") continue; for ($b=1;$b>-2;$b=$b-2) { $curveCmd="curve -d 3"; if ($b==1) $curve="deformationCurve"+$axis+"1"; if ($b==-1) $curve="deformationCurve"+$axis+"2"; if ($a==1 && $b==1) $slideSideNr="2"; if ($a==1 && $b==-1) $slideSideNr="0"; if ($a==-1 && $b==1) $slideSideNr="3"; if ($a==-1 && $b==-1) $slideSideNr="1"; $curves[size($curves)]=$curve; setAttr -type float3 ("tempLoc_pointConstraint1.offset") 0 0 0; for ($y=0;$y<9;$y++) { if ($y==0) { setAttr ("tempLoc_pointConstraint1."+$parentJoint+"W0") 1; setAttr ("tempLoc_pointConstraint1."+$joint+"W1") 0; setAttr ("tempLoc_pointConstraint1."+$childJoint+"W2") 0; setAttr ("tempLoc_pointConstraint1.offset"+$axis) ($parentfat*$b); $pos=`xform -q -ws -t tempLoc`; } if ($y==1) { setAttr ("tempLoc_pointConstraint1."+$parentJoint+"W0") 3; setAttr ("tempLoc_pointConstraint1."+$joint+"W1") 1; setAttr ("tempLoc_pointConstraint1."+$childJoint+"W2") 0; $pos=`xform -q -ws -t tempLoc`; } if ($y==2) { setAttr ("tempLoc_pointConstraint1."+$parentJoint+"W0") 1; setAttr ("tempLoc_pointConstraint1."+$joint+"W1") 1; setAttr ("tempLoc_pointConstraint1."+$childJoint+"W2") 0; setAttr ("tempLoc_pointConstraint1.offset"+$axis) ((($fat+$parentfat)/2.0)*$b); $pos=`xform -q -ws -t tempLoc`; } if ($y<3 && `gmatch $joint "*_R"` && `gmatch $parentJoint "*_M"` && $curve!="deformationCurveZ1") {//Branching such as Hip, not to extend to far across axis setAttr ("tempLoc_pointConstraint1."+$parentJoint+"W0") 0; setAttr ("tempLoc_pointConstraint1."+$joint+"W1") 1; $tempPos=`xform -q -ws -t tempLoc`; $pos[0]=$tempPos[0]; } if ($y<3 && `gmatch $joint "*_R"` && $pos[0]>0) $pos[0]=0; if ($y==3) { $pos=`xform -q -ws -t ($joint+"_startSlider"+$slideSideNr)`; } if ($y==4) { $pos=`xform -q -ws -t ($joint+"_middleSlider"+$slideSideNr)`; } if ($y==5) { $pos=`xform -q -ws -t ($joint+"_endSlider"+$slideSideNr)`; } if ($y==6) { setAttr ("tempLoc_pointConstraint1."+$parentJoint+"W0") 0; setAttr ("tempLoc_pointConstraint1."+$joint+"W1") 1; setAttr ("tempLoc_pointConstraint1."+$childJoint+"W2") 1; setAttr ("tempLoc_pointConstraint1.offset"+$axis) ((($fat+$childfat)/2.0)*$b); $pos=`xform -q -ws -t tempLoc`; } if ($y==7) { setAttr ("tempLoc_pointConstraint1."+$parentJoint+"W0") 0; setAttr ("tempLoc_pointConstraint1."+$joint+"W1") 1; setAttr ("tempLoc_pointConstraint1."+$childJoint+"W2") 3; $pos=`xform -q -ws -t tempLoc`; } if ($y==8) { setAttr ("tempLoc_pointConstraint1."+$parentJoint+"W0") 0; setAttr ("tempLoc_pointConstraint1."+$joint+"W1") 0; setAttr ("tempLoc_pointConstraint1."+$childJoint+"W2") 1; setAttr ("tempLoc_pointConstraint1.offset"+$axis) ($childfat*$b); $pos=`xform -q -ws -t tempLoc`; } $curveCmd+=" -p "+$pos[0]+" "+$pos[1]+" "+$pos[2]; } $curveCmd+=" -k 0 -k 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 6 -k 6"; $tempString[0]=`eval ($curveCmd)`; rename $tempString[0] $curve; setAttr ($curve+".dispCV") 1; parent $curve curveDeformationSetup; select $childJoint $parentJoint ($joint+"_startSlider"+$slideSideNr) ($joint+"_middleSlider"+$slideSideNr) ($joint+"_endSlider"+$slideSideNr) $curve; $tempString=`newSkinCluster "-toSelectedBones -mi 3 -dr 4 -rui false"`; rename $tempString[0] ($curve+"SC"); for ($y=0;$y<9;$y++) { if ($y==0) skinPercent -tv $parentJoint 1 ($curve+"SC") ($curve+".cv["+$y+"]"); if ($y==1) skinPercent -tv $parentJoint 1 ($curve+"SC") ($curve+".cv["+$y+"]"); if ($y==2) skinPercent -tv $parentJoint 1 ($curve+"SC") ($curve+".cv["+$y+"]"); if ($y==3) skinPercent -tv ($joint+"_startSlider"+$slideSideNr) 1 ($curve+"SC") ($curve+".cv["+$y+"]"); if ($y==4) skinPercent -tv ($joint+"_middleSlider"+$slideSideNr) 1 ($curve+"SC") ($curve+".cv["+$y+"]"); if ($y==5) skinPercent -tv ($joint+"_endSlider"+$slideSideNr) 1 ($curve+"SC") ($curve+".cv["+$y+"]"); if ($y==6) skinPercent -tv $childJoint 1 ($curve+"SC") ($curve+".cv["+$y+"]"); if ($y==7) skinPercent -tv $childJoint 1 ($curve+"SC") ($curve+".cv["+$y+"]"); if ($y==8) skinPercent -tv $childJoint 1 ($curve+"SC") ($curve+".cv["+$y+"]"); } } } if (`objExists deformationCurveZ1` && `objExists deformationCurveY2`) reorder -relative -1 deformationCurveZ1; delete tempLoc; addAttr -k 1 -ln haveSkinCage -at bool -dv $haveSkinCage curveDeformationSetup; addAttr -ln deleteSlidersCmd -dt "string" curveDeformationSetup; setAttr -type "string" curveDeformationSetup.deleteSlidersCmd $deleteSlidersCmd; select $curves; } global proc asCBDCreateTestAnim () { string $mesh=`getAttr curveDeformationSetup.mesh`; string $fkControl=`getAttr curveDeformationSetup.fkControl`; int $rotYonly=`getAttr curveDeformationSetup.rotYonly`; int $rotZonly=`getAttr curveDeformationSetup.rotZonly`; int $singleAxisPositive=`getAttr curveDeformationSetup.singleAxisPositive`; float $singleAxisRotValue=-90; if ($singleAxisPositive) $singleAxisRotValue=90; currentTime 0; if ($rotYonly || $rotZonly) { playbackOptions -min 0 -ast 0 -aet 10 -max 10; if ($rotYonly) setKeyframe ($fkControl+".ry"); if ($rotZonly) setKeyframe ($fkControl+".rz"); currentTime 10; if ($rotYonly) {setAttr ($fkControl+".ry") $singleAxisRotValue;setKeyframe ($fkControl+".ry");} if ($rotZonly) {setAttr ($fkControl+".rz") $singleAxisRotValue;setKeyframe ($fkControl+".rz");} } else { playbackOptions -min 0 -ast 0 -aet 80 -max 80; setKeyframe ($fkControl+".r"); currentTime 10;setAttr ($fkControl+".ry") 90;setKeyframe ($fkControl+".r"); currentTime 20;setAttr ($fkControl+".ry") 0;setKeyframe ($fkControl+".r"); currentTime 30;setAttr ($fkControl+".ry") -90;setKeyframe ($fkControl+".r"); currentTime 40;setAttr ($fkControl+".ry") 0;setKeyframe ($fkControl+".r"); currentTime 50;setAttr ($fkControl+".rz") 90;setKeyframe ($fkControl+".r"); currentTime 60;setAttr ($fkControl+".rz") 0;setKeyframe ($fkControl+".r"); currentTime 70;setAttr ($fkControl+".rz") -90;setKeyframe ($fkControl+".r"); currentTime 80;setAttr ($fkControl+".rz") 0;setKeyframe ($fkControl+".r"); } refresh; currentTime 5; } global proc asCBDHideMesh () { string $source=`textField -q -tx asBodyCorrectiveCBDMeshTextField`; if (`objExists $source`) setAttr ($source+".v") 0; } global proc asCBDCreateDeformMesh () { float $pos[]; float $radius; float $currentTime=`currentTime -q`; string $tempString[]; string $existingSkinCluster,$newSkinCluster; currentTime 0; if (`objExists Corrective`) delete Corrective; if (`objExists deformationLoft`) delete deformationLoft; string $mesh=`getAttr curveDeformationSetup.mesh`; string $fkControl=`getAttr curveDeformationSetup.fkControl`; string $joint=`substitute "FK" $fkControl ""`; int $rotYonly=`getAttr curveDeformationSetup.rotYonly`; int $rotZonly=`getAttr curveDeformationSetup.rotZonly`; int $singleAxisPositive=`getAttr curveDeformationSetup.singleAxisPositive`; string $curves[]=`listRelatives -c curveDeformationSetup`; select $curves; // select $curves[0] $curves[2] $curves[1] $curves[3]; $tempString=`loft -n deformationLoft -ch 1 -u 1 -c 1 -ar 1 -d 3 -ss 2 -rn 0 -po 0 -rsn true`; setAttr deformationLoftShape.curvePrecisionShaded 4; setAttr deformationLoft.v 0; parent deformationLoft curveDeformationSetup; duplicate -n Corrective $mesh; asLockAttr Corrective 0 0 0 0; parent Corrective curveDeformationSetup; setAttr Corrective.v 1; $tempString=`listRelatives -s Corrective`; for ($z=0;$z0;$y--) if (`objExists ($parentJoint+"_twistProfile"+$y)`) { $aboveBelowProfile=$parentJoint+"_twistProfile"+$y; break; } } if ($aboveBelowProfile=="") continue; } if ($a==1) { if (`objExists ($joint+"_endProfile")`) $aboveBelowProfile=$joint+"_endProfile"; else { for ($y=1;$y<21;$y++) if (`objExists ($joint+"_twistProfile"+$y)`) { $aboveBelowProfile=$joint+"_twistProfile"+$y; break; } } } if ($aboveBelowProfile=="" || `gmatch $aboveBelowProfile "Neck*"`)//skip neck continue; // place profile int $targetIds[2]={0,1}; $tempString=`listRelatives -p $aboveBelowProfile`; string $offsetNode=$tempString[0]; string $parentConstraint=$offsetNode+"_pointConstraint1"; string $scaleConstraint=$offsetNode+"_scaleConstraint1"; string $targetAttrs[]=`listAttr -ud $parentConstraint`; setAttr -type float3 ($parentConstraint+".offset") 0 0 0; $tempString=`listConnections ($parentConstraint+".target[0].targetParentMatrix")`; if ($tempString[0]==`substitute "Profile" $skinCurves1[$i] "Curve"`) { $targetIds={1,0}; $tempString=`listConnections ($parentConstraint+".target[1].targetParentMatrix")`; if ($tempString[0]=="") continue; } $parentTarget=$tempString[0]; $pos=`xform -q -ws -t $skinCurves1[$i]`; $pos2=`xform -q -ws -t $parentTarget`; float $toParentDist=`mag<<$pos2[0]-$pos[0],$pos2[1]-$pos[1],$pos2[2]-$pos[2]>>`; $tempString=`listRelatives -c $skinCurves1[$i]`; $innerCurve=$tempString[0]; $pos=`xform -q -ws -t ($innerCurve+".cv[0]")`; $pos2=`xform -q -ws -t ($innerCurve+".cv[1]")`; float $curveHeight=`mag<<$pos2[0]-$pos[0],$pos2[1]-$pos[1],$pos2[2]-$pos[2]>>`; $pos=`xform -q -ws -t ($innerCurve+".cv[1]")`; $pos2=`xform -q -ws -t ($innerCurve+".cv[2]")`; float $curveWidth=`mag<<$pos2[0]-$pos[0],$pos2[1]-$pos[1],$pos2[2]-$pos[2]>>`; float $hwAverage=($curveHeight+$curveWidth)/2.0; if ($targetAttrs[1]!="") { float $weight=($hwAverage/2.0)/$toParentDist; if ($weight>0.45) $weight=0.45; setAttr ($parentConstraint+"."+$targetAttrs[$targetIds[0]]) $weight; setAttr ($parentConstraint+"."+$targetAttrs[$targetIds[1]]) (1-$weight); setAttr ($scaleConstraint+"."+$targetAttrs[$targetIds[0]]) $weight; setAttr ($scaleConstraint+"."+$targetAttrs[$targetIds[1]]) (1-$weight); } } } } global proc asCreateGroinLocators () { if (`objExists GroinStart`) delete GroinStart; if (`objExists GroinSide`) delete GroinSide; spaceLocator -n GroinStart; spaceLocator -n GroinSide; float $posA[]=`xform -q -ws -t Root`; float $posB[]=`xform -q -ws -t Root_M_middleCurve.cv[2]`; xform -ws -t 0 ($posA[1]*0.9) $posA[2] GroinStart; xform -ws -t $posB[0] ($posB[1]*1.03) $posA[2] GroinSide; select -cl; } global proc asAdjustGroinArea () { float $pos[]; float $posGroinStart[]=`xform -q -ws -t GroinStart`; float $posGroinSide[]=`xform -q -ws -t GroinSide`; if (!`objExists Root_M_middleCurve` || !`objExists Hip_R_startProfileShape`) { if (`objExists GroinStart`) delete GroinStart; if (`objExists GroinSide`) delete GroinSide; warning "Skipped, because required profile-curves not found"; return; } $pos=`xform -q -ws -t Root_M_middleProfile`; xform -ws -t 0 $posGroinSide[1] $pos[2] Root_M_middleProfile; $pos=`xform -q -ws -t Root_M_middleCurve.cv[2]`; xform -ws -t $pos[0] ($pos[1]*1.00) $pos[2] Hip_R_startProfileShape.cv[3]; $pos=`xform -q -ws -t Root_M_middleProfileShape.cv[2]`; xform -ws -t $pos[0] ($pos[1]*0.95) $pos[2] Hip_R_middleProfileShape.cv[3]; $pos=`xform -q -ws -t Root_M_middleCurve.cv[1]`; xform -ws -t $pos[0] ($pos[1]*1.00) $pos[2] Hip_R_startProfileShape.cv[0] Hip_R_startProfileShape.cv[4]; $pos=`xform -q -ws -t Root_M_middleProfileShape.cv[1]`; xform -ws -t $pos[0] ($pos[1]*0.95) $pos[2] Hip_R_middleProfileShape.cv[0] Hip_R_middleProfileShape.cv[4]; $pos=`xform -q -ws -t Hip_R_middleProfileShape.cv[2]`; xform -ws -t $pos[0] ($posGroinStart[1]*0.95) $pos[2] Hip_R_middleProfileShape.cv[2]; $pos=`xform -q -ws -t Hip_R_middleProfileShape.cv[1]`; xform -ws -t $pos[0] ($posGroinStart[1]*0.95) $pos[2] Hip_R_middleProfileShape.cv[1]; $pos=`xform -q -ws -t Hip_R_startProfileShape.cv[2]`; xform -ws -t 0 ($posGroinStart[1]*1.00) $pos[2] Hip_R_startProfileShape.cv[2]; $pos=`xform -q -ws -t Hip_R_startProfileShape.cv[1]`; xform -ws -t 0 ($posGroinStart[1]*1.00) $pos[2] Hip_R_startProfileShape.cv[1]; scale -r 1.2 1.2 1.2 Hip_R_startProfile; //might overlap with twistProfiles int $twistJoints=`getAttr Hip.twistJoints`; for ($i=1;$i<$twistJoints+1;$i++) { $pos=`xform -q -ws -t ("Hip_R_twistProfileShape"+$i+".cv[1]")`; if ($pos[1]>$posGroinStart[1]) move -r 0 (($pos[1]-$posGroinStart[1])*-1.2) 0 ("Hip_R_twistProfileShape"+$i+".cv[1:2]"); } asMirrorControlCurves 0 SkinCageCurvesSet; if (`objExists GroinStart`) delete GroinStart; if (`objExists GroinSide`) delete GroinSide; } global proc asCreateSkinCage () { string $upAxisDirection=`optionVar -q "upAxisDirection"`; string $absSecAxis,$absTerAxis; string $secAxis="Y"; string $terAxis="Z"; if (!`asConfirmIfNotInBuildPose`) return; if (`exists softSelect`) softSelect -e -softSelectEnabled 0; if (`symmetricModelling -q -s`) symmetricModelling -e -s 0; string $tempString[]; if (`objExists MeshGeometry`) { asRebuildSkinCage; return; } if ($upAxisDirection=="z") asSceneUpAxisFlip Group y; asEnsureAllFitJointAttrs;//v 5.813 upgrade new fat attributes createNode -n Cages transform; parent Cages Geometry; createNode -n MeshGeometry transform; parent MeshGeometry Geometry; setAttr "MeshGeometry.overrideEnabled" 1; createNode -n MeshCurves transform; parent MeshCurves Geometry; createNode -n NurbsGeometry transform; setAttr NurbsGeometry.v 0; parent NurbsGeometry Geometry; sets -em -name SkinCageCurvesSet; sets -add "Sets" SkinCageCurvesSet; select -cl; createDisplayLayer -e -name "SkinCage" -number 1 -nr; createDisplayLayer -e -name "SkinCurves1" -number 2 -nr; createDisplayLayer -e -name "SkinCurves2" -number 3 -nr; setAttr SkinCurves2.visibility 0; setAttr SkinCurves2.displayType 0; setAttr SkinCurves2.color 13; setAttr SkinCurves1.visibility 1; setAttr SkinCurves1.displayType 0; setAttr SkinCurves1.color 14; setAttr SkinCage.displayType 2; //Build tubes string $topNodes[]=`listRelatives -type joint -c DeformationSystem`; asAnalyzeChainJoints $topNodes[0]; //pickup single brancers string $children[]; $tempString=`asListAllDecents $topNodes[0]`; for ($i=0;$i0) if (!`objExists ($tempString[$i]+"_middleCurve")`) asBuildChainCurves {$tempString[$i]}; } //Branch asCreateBranchBoxes; //merge copies. select `ls -as "*_copy" "*_branch"`; $tempString=`polyUnite -ch 0 -n skinCage`; setAttr skinCage.keepBorder 0; polyMergeVertex -d 0.0001 -am 1 -ch 1 skinCage; select skinCage; DeleteHistory; //polyNormal -normalMode 2 -userNormalMode 0 -ch 0 skinCage; //DeleteHistory; parent skinCage Cages; editDisplayLayerMembers -noRecurse SkinCage skinCage; string $middleCurves[]=`ls -type transform "*_middleCurve"`; //UV polyAutoProjection -ch 0 -lm 0 -pb 0 -ibd 0 -cm 0 -l 2 -sc 1 -o 1 -p 6 -ps 0.2 -ws 0 skinCage; //skinn string $joint,$twistJoint; select -cl; for ($i=0;$i-2;$b=$b-2) for ($i=0;$i(-1*$sideTreshold)) $fitSkeletonSide[$i]="_M"; $side=$fitSkeletonSide[$i]; if ($b==-1 && $fitSkeletonSide[$i]=="_M") continue; if ($b==-1) $side="_L"; string $profileCurve=$fitSkeletonJoints[$i]+$side+"_middleProfile"; if (`objExists $profileCurve`) { if (!`attributeExists fat $fitSkeletonJoints[$i]`) continue; float $fat=`getAttr ($fitSkeletonJoints[$i]+$side+".fat")`; float $fatFront=`getAttr ($fitSkeletonJoints[$i]+$side+".fatFront")`; float $fatWidth=`getAttr ($fitSkeletonJoints[$i]+$side+".fatWidth")`; $absSecAxis=`asGetAxis secondary $fitSkeletonJoints[$i] FitSkeleton 1`; $absTerAxis=`asGetAxis tertiary $fitSkeletonJoints[$i] FitSkeleton 1`; setAttr ($profileCurve+".scale"+$absSecAxis) ($fat*$fatFront); setAttr ($profileCurve+".scale"+$absTerAxis) ($fat*$fatWidth); refresh; } } //Profiles tweaks asProfileTweaks; asMirrorControlCurves 0 SkinCageCurvesSet; if ($upAxisDirection=="z") asSceneUpAxisFlip Group z; print "// SkinCage created\n"; select -cl; } global proc asDeleteSkinCage () { string $deleteObjs[]={"skinCage","SkinSub","Cages","MeshGeometry","MeshCurves","NurbsGeometry","SkinCage","SkinCurves1","SkinCurves2","SkinCageCurvesSet"}; for ($obj in $deleteObjs) if (`objExists $obj`) delete $obj; } global proc asRebuildSkinCage () { string $restoreShapesCmds[]; string $profileCurveShapes[]=`ls -type nurbsCurve "*ProfileShape*"`; int $form,$spans,$degrees,$numCv; for ($i=0;$iabs($jo[2])) $bendAxis=1;// .joY greater than .joZ, so not a Zbender if (abs($jo[2])>abs($jo[1])) $bendAxis=2;// .joZ greater than .joY, so not a Ybender } for ($y=0;$y<4;$y++) { //only 2 for elbow/knee, determine $bendAxis if (`gmatch $deformJoint "*Elbow*"` || `gmatch $deformJoint "*Knee*"`) { if ($bendAxis==1) if ($y==0 || $y==2) continue; if ($bendAxis==2) if ($y==1 || $y==3) continue; } if ($skinCurveSliderInfo[1]=="start") select $firstPa; if ($skinCurveSliderInfo[1]=="middle") select ($deformJoint+"_Slide50"); if ($skinCurveSliderInfo[1]=="end") select $deformJoint; joint -n ($deformJoint+"_"+$stEnMid+"Slider"+$y); sets -add ("DeformSet") ($deformJoint+"_"+$stEnMid+"Slider"+$y); float $posA[3]=`xform -q -ws -t ($sel[$i]+".cv["+$y+"]")`; float $posB[3]=`xform -q -ws -t ($sel[$i]+".cv["+($y+1)+"]")`; float $pos[3]={(($posA[0]+$posB[0])/2.0), (($posA[1]+$posB[1])/2.0), (($posA[2]+$posB[2])/2.0)}; xform -ws -t $pos[0] $pos[1] $pos[2] ($deformJoint+"_"+$stEnMid+"Slider"+$y); $widthFactorY=`getAttr ($deformJoint+"_"+$stEnMid+"Slider"+$y+".ty")`; $widthFactorZ=`getAttr ($deformJoint+"_"+$stEnMid+"Slider"+$y+".tz")`; $widthFactorY=`abs($widthFactorY)`; $widthFactorZ=`abs($widthFactorZ)`; $widthFactor=`max $widthFactorY $widthFactorZ`; if (!$baseStrucExists) { // recylcle these between starters, enders, and middlers createNode -n ($deformJoint+"_SlideDist"+$y) distanceBetween ; createNode -n ($deformJoint+"_SlideStart"+$y) transform; createNode -n ($deformJoint+"_SlideEnd"+$y) transform; // connectAttr -f ($deformJoint+"_SlideStart"+$y+".t") ($deformJoint+"_SlideDist"+$y+".point1"); connectAttr -f ($deformJoint+"_SlideEnd"+$y+".t") ($deformJoint+"_SlideDist"+$y+".point2"); // $tempString=`spaceLocator`;rename $tempString[0] ($deformJoint+"_SlideStart"+$y); // $tempString=`spaceLocator`;rename $tempString[0] ($deformJoint+"_SlideEnd"+$y); // setAttr -type float3 ($deformJoint+"_SlideStart"+$y+".localScale") ($charHeight/120) ($charHeight/120) ($charHeight/120); // setAttr -type float3 ($deformJoint+"_SlideEnd"+$y+".localScale") ($charHeight/120) ($charHeight/120) ($charHeight/120); parent ($deformJoint+"_SlideStart"+$y) $firstPa; parent ($deformJoint+"_SlideEnd"+$y) $firstPa; xform -ws -t $pos[0] $pos[1] $pos[2] ($deformJoint+"_SlideStart"+$y); xform -ws -t $pos[0] $pos[1] $pos[2] ($deformJoint+"_SlideEnd"+$y); parent ($deformJoint+"_SlideEnd"+$y) ($deformJoint+"_Slide50"); setAttr ($deformJoint+"_SlideEnd"+$y+".tx") 0; float $temp[3]=`getAttr ($deformJoint+"_SlideEnd"+$y+".t")`; float $mag=`mag <<$temp[0],$temp[1],$temp[2]>>`*$sideFactor; $temp[0]=`getAttr ($deformJoint+".tx")`; setAttr -type float3 ($deformJoint+"_SlideStart"+$y+".t") ($temp[0]-$mag) 0 0; parent ($deformJoint+"_SlideStart"+$y) SlideSystem; parent ($deformJoint+"_SlideEnd"+$y) ($deformJoint+"_SlideStart"+$y); // parentConstraint -mo $firstPa ($deformJoint+"_SlideStart"+$y); parentConstraint -mo $deformJoint ($deformJoint+"_SlideStart"+$y); parentConstraint -mo ($deformJoint+"_Slide50") ($deformJoint+"_SlideEnd"+$y); //behaviour createNode -n ($deformJoint+"_SlideDistNormalize"+$y) multiplyDivide; setAttr ($deformJoint+"_SlideDistNormalize"+$y+".operation") 2; connectAttr ($deformJoint+"_SlideDist"+$y+".distance") ($deformJoint+"_SlideDistNormalize"+$y+".input1X"); setAttr ($deformJoint+"_SlideDistNormalize"+$y+".input2X") `getAttr ($deformJoint+"_SlideDistNormalize"+$y+".input1X")`; } //they all share `_SlideMultiply` & `SlideReducer` & `_SlidePlusOffset` createNode -n ($deformJoint+"_"+$stEnMid+"SlideReducer"+$y) multiplyDivide; setAttr ($deformJoint+"_"+$stEnMid+"SlideReducer"+$y+".input2X") $widthFactor; if ($skinCurveSliderInfo[1]=="start") setAttr ($deformJoint+"_"+$stEnMid+"SlideReducer"+$y+".input2X") ($widthFactor*-1); //on opposide side, the start and end must move opposite direction if ($skinCurveSliderInfo[1]=="start" || $skinCurveSliderInfo[1]=="end") setAttr ($deformJoint+"_"+$stEnMid+"SlideReducer"+$y+".input2X") (`getAttr ($deformJoint+"_"+$stEnMid+"SlideReducer"+$y+".input2X")`*$sideFactor); createNode -n ($deformJoint+"_"+$stEnMid+"SlideMultiply"+$y) multiplyDivide; addAttr -k 1 -ln slide -at double -dv 1 ($deformJoint+"_"+$stEnMid+"Slider"+$y); connectAttr ($deformJoint+"_"+$stEnMid+"Slider"+$y+".slide") ($deformJoint+"_"+$stEnMid+"SlideMultiply"+$y+".input2X"); connectAttr ($deformJoint+"_"+$stEnMid+"SlideReducer"+$y+".outputX") ($deformJoint+"_"+$stEnMid+"SlideMultiply"+$y+".input1X"); createNode -n ($deformJoint+"_"+$stEnMid+"SlidePlusOffset"+$y) plusMinusAverage; connectAttr ($deformJoint+"_"+$stEnMid+"SlideMultiply"+$y+".outputX") ($deformJoint+"_"+$stEnMid+"SlidePlusOffset"+$y+".input1D[0]"); if ($skinCurveSliderInfo[1]=="start" || $skinCurveSliderInfo[1]=="end") { createNode -n ($deformJoint+"_"+$stEnMid+"SlideMinusOne"+$y) plusMinusAverage; setAttr ($deformJoint+"_"+$stEnMid+"SlideMinusOne"+$y+".operation") 2; connectAttr ($deformJoint+"_SlideDistNormalize"+$y+".outputX") ($deformJoint+"_"+$stEnMid+"SlideMinusOne"+$y+".input1D[0]"); setAttr ($deformJoint+"_"+$stEnMid+"SlideMinusOne"+$y+".input1D[1]") 1; connectAttr ($deformJoint+"_"+$stEnMid+"SlideMinusOne"+$y+".output1D") ($deformJoint+"_"+$stEnMid+"SlideReducer"+$y+".input1X"); setAttr ($deformJoint+"_"+$stEnMid+"SlidePlusOffset"+$y+".input1D[1]") $xOffset; connectAttr ($deformJoint+"_"+$stEnMid+"SlidePlusOffset"+$y+".output1D") ($deformJoint+"_"+$stEnMid+"Slider"+$y+".tx"); } if ($skinCurveSliderInfo[1]=="middle") { string $slideAxis="z"; if ($bendAxis==2) $slideAxis="y"; if (($bendAxis==0) && ($y==0 || $y==2)) $slideAxis="y"; createNode -n ($deformJoint+"_"+$stEnMid+"SlideReverse"+$y) reverse; connectAttr ($deformJoint+"_SlideDistNormalize"+$y+".outputX") ($deformJoint+"_"+$stEnMid+"SlideReverse"+$y+".inputX"); createNode -n ($deformJoint+"_"+$stEnMid+"SlideAbsolutor"+$y) condition; if (`getAttr ($deformJoint+"_"+$stEnMid+"Slider"+$y+".t"+$slideAxis)`>0) setAttr ($deformJoint+"_"+$stEnMid+"SlideAbsolutor"+$y+".operation") 4; else setAttr ($deformJoint+"_"+$stEnMid+"SlideAbsolutor"+$y+".operation") 2; connectAttr ($deformJoint+"_"+$stEnMid+"SlideReverse"+$y+".outputX") ($deformJoint+"_"+$stEnMid+"SlideAbsolutor"+$y+".firstTerm"); connectAttr ($deformJoint+"_"+$stEnMid+"SlideReverse"+$y+".outputX") ($deformJoint+"_"+$stEnMid+"SlideAbsolutor"+$y+".colorIfFalseR"); createNode -n ($deformJoint+"_"+$stEnMid+"SlideReducer"+$y) multiplyDivide; createNode -n ($deformJoint+"_"+$stEnMid+"SlideTimesMinusOne"+$y) multiplyDivide; connectAttr ($deformJoint+"_"+$stEnMid+"SlideReverse"+$y+".outputX") ($deformJoint+"_"+$stEnMid+"SlideTimesMinusOne"+$y+".input1X"); setAttr ($deformJoint+"_"+$stEnMid+"SlideTimesMinusOne"+$y+".input2X") -1; connectAttr ($deformJoint+"_"+$stEnMid+"SlideTimesMinusOne"+$y+".outputX") ($deformJoint+"_"+$stEnMid+"SlideAbsolutor"+$y+".colorIfTrueR"); connectAttr ($deformJoint+"_"+$stEnMid+"SlideAbsolutor"+$y+".outColorR") ($deformJoint+"_"+$stEnMid+"SlideReducer"+$y+".input1X"); setAttr ($deformJoint+"_"+$stEnMid+"SlidePlusOffset"+$y+".input1D[1]") `getAttr ($deformJoint+"_"+$stEnMid+"Slider"+$y+".t"+$slideAxis)`; connectAttr ($deformJoint+"_"+$stEnMid+"SlidePlusOffset"+$y+".output1D") ($deformJoint+"_"+$stEnMid+"Slider"+$y+".t"+$slideAxis); } //skinning skinCluster -e -lw false -wt 0 -ai ($deformJoint+"_"+$stEnMid+"Slider"+$y) skinClusterSkinCage; float $temp[]=`xform -q -ws -t ($sel[$i]+".cv["+$y+"]")`; setAttr closestSampler.inPosition $temp[0] $temp[1] $temp[2]; $vtxNr[$y]=`getAttr closestSampler.closestVertexIndex`; skinPercent -tv ($deformJoint+"_"+$stEnMid+"Slider"+$y) 1 skinClusterSkinCage ("skinCage.vtx["+$vtxNr[$y]+"]"); if ($bendAxis==0) //all directions { if ($y>0) skinPercent -tv ($deformJoint+"_"+$stEnMid+"Slider"+($y-1)) 0.5 skinClusterSkinCage ("skinCage.vtx["+$vtxNr[$y]+"]"); if ($y==3) skinPercent -tv ($deformJoint+"_"+$stEnMid+"Slider3") 0.5 skinClusterSkinCage ("skinCage.vtx["+$vtxNr[0]+"]"); } if (($bendAxis==1 && $y==3) || ($bendAxis==2 && $y==2)) //last loop for Z or Ybender { int $pickupVtx=2; int $sliderNr=1; if ($bendAxis==2) {$pickupVtx=1;$sliderNr=0;} float $temp[]=`xform -q -ws -t ($sel[$i]+".cv["+$pickupVtx+"]")`; setAttr closestSampler.inPosition $temp[0] $temp[1] $temp[2]; $vtxNr[$pickupVtx]=`getAttr closestSampler.closestVertexIndex`; skinPercent -tv ($deformJoint+"_"+$stEnMid+"Slider"+$sliderNr) 1 skinClusterSkinCage ("skinCage.vtx["+$vtxNr[$pickupVtx]+"]"); $pickupVtx=4; $sliderNr=3; if ($bendAxis==2) {$pickupVtx=3;$sliderNr=2;} $temp=`xform -q -ws -t ($sel[$i]+".cv["+$pickupVtx+"]")`; setAttr closestSampler.inPosition $temp[0] $temp[1] $temp[2]; $vtxNr[$pickupVtx]=`getAttr closestSampler.closestVertexIndex`; skinPercent -tv ($deformJoint+"_"+$stEnMid+"Slider"+$sliderNr) 1 skinClusterSkinCage ("skinCage.vtx["+$vtxNr[$pickupVtx]+"]"); } } //branchVtx`s edgeloopCheck to see if there`s a extra vtx, if so.. this is a `brancher` select -cl; for ($y=0;$y<4;$y++) select -add ("skinCage.vtx["+$vtxNr[$y]+"]"); $tempString=`ls -sl -fl`; $branchVtxs=`asGetBranchedVtx $tempString 0`; $branchVtxSliderNrs=`asGetBranchedVtx $tempString 1`; for ($y=0;$y1) $tempString[$i]=$tempStringFullPath[$i]; $skip=0; for ($y=0;$y1) for ($y=0;$y0 && $downTwist[$i-1]) $upTwist[$i]=$downTwist[$i-1]; } //Startcurves for ($i=0;$i1) && !`attributeExists noStartCurve $chainJoints[0]`) { $startCurve=$chainJoints[$i]+"_startCurve"; $startCurves[size($startCurves)]=$startCurve; asCreateMeshCurve $startCurve; $profileCurve=`substitute "Curve" $startCurve "Profile"`; createNode -n ($chainJoints[$i]+"_startCurveOffset") transform; parent ($chainJoints[$i]+"_startProfile") ($chainJoints[$i]+"_startCurveOffset"); parent ($chainJoints[$i]+"_startCurveOffset") MeshCurves; editDisplayLayerMembers -noRecurse SkinCurves2 $profileCurve; parent ($chainJoints[$i]+"_startCurveOffset") ($chainJoints[$i]+"_middleCurve"); setAttr -type float3 ($chainJoints[$i]+"_startCurveOffset.t") 0 0 0; setAttr -type float3 ($chainJoints[$i]+"_startCurveOffset.r") 0 0 0; setAttr -type float3 ($chainJoints[$i]+"_startCurveOffset.s") 1 1 1; parent ($chainJoints[$i]+"_startCurveOffset") MeshCurves; //first startCurve if ($i==0) { if ($firstChildMinusX[$i]) setAttr ($chainJoints[$i]+"_startProfile.translate"+$absPriAxis[$i]) 0.482; else setAttr ($chainJoints[$i]+"_startProfile.translate"+$absPriAxis[$i]) -0.482; } pointConstraint -w 0.75 ($chainJoints[$i]+"_middleCurve") ($chainJoints[$i]+"_startCurveOffset"); scaleConstraint -w 0.75 ($chainJoints[$i]+"_middleCurve") ($chainJoints[$i]+"_startCurveOffset"); if ($i>0) { pointConstraint -w 0.25 ($chainJoints[$i-1]+"_middleCurve") ($chainJoints[$i]+"_startCurveOffset"); scaleConstraint -w 0.25 ($chainJoints[$i-1]+"_middleCurve") ($chainJoints[$i]+"_startCurveOffset"); } } } //Endcurves for ($i=0;$i1) && !`attributeExists noEndCurve $chainJoints[0]`) { $endCurve=$chainJoints[$i]+"_endCurve"; $endCurves[size($endCurves)]=$endCurve; asCreateMeshCurve $endCurve; $profileCurve=`substitute "Curve" $endCurve "Profile"`; createNode -n ($chainJoints[$i]+"_endCurveOffset") transform; parent ($chainJoints[$i]+"_endProfile") ($chainJoints[$i]+"_endCurveOffset"); parent ($chainJoints[$i]+"_endCurveOffset") MeshCurves; editDisplayLayerMembers -noRecurse SkinCurves2 $profileCurve; parent ($chainJoints[$i]+"_endCurveOffset") ($chainJoints[$i]+"_middleCurve"); setAttr -type float3 ($chainJoints[$i]+"_endCurveOffset.t") 0 0 0; setAttr -type float3 ($chainJoints[$i]+"_endCurveOffset.r") 0 0 0; setAttr -type float3 ($chainJoints[$i]+"_endCurveOffset.s") 1 1 1; parent ($chainJoints[$i]+"_endCurveOffset") MeshCurves; //last endCurve if ($i==size($chainJoints)-1) { if ($firstChildMinusX[$i]) setAttr ($chainJoints[$i]+"_endProfile.translate"+$absPriAxis[$i]) -0.482; else setAttr ($chainJoints[$i]+"_endProfile.translate"+$absPriAxis[$i]) 0.482; } pointConstraint -w 0.75 ($chainJoints[$i]+"_middleCurve") ($chainJoints[$i]+"_endCurveOffset"); scaleConstraint -w 0.75 ($chainJoints[$i]+"_middleCurve") ($chainJoints[$i]+"_endCurveOffset"); if ($i1) && !`attributeExists noStartCurve $chainJoints[0]`) $curves[size($curves)]=$chainJoints[$i]+"_startCurve"; $curves[size($curves)]=$chainJoints[$i]+"_middleCurve"; if (!$terminator[$i] && !$spineJoint[$i] && !$downTwist[$i] && (size($chainJoints)>1) && !`attributeExists noEndCurve $chainJoints[0]`) $curves[size($curves)]=$chainJoints[$i]+"_endCurve"; for ($y=1;$y<$downTwist[$i]+1;$y++) $curves[size($curves)]=$chainJoints[$i]+"_twistCurve"+$y; //branch $children=`asListChildren $chainJoints[$i]`; $tempString[0]=`asListParent $chainJoints[$i]`; $parent=$tempString[0]; if ($parent!="") $siblings=`asListChildren $parent`; if (!(size($children)>1 || size($siblings)>1)) continue; } //unTwist curves for ($i=0;$i0 && ($twistRot>90 || $twistRot<-90) && $joint!=$previousJoint)//only detect flip once per joint $flip=!$flip; //if ($joint=="Toes_R") $flip=!$flip; $previousJoint=$joint; if ($flip) setAttr ($curves[$i]+"_copy.rotate"+$absPA) 180; } $surface=$chainJoints[0]+"_surface"; $poly=$chainJoints[0]+"_poly"; if (size($chainJoints)==1) extrude -n $surface -ch 1 -rn false -po 0 -et 0 -upn 1 -length ($charHeight/-250) -rotation 0 -scale 1 -dl 3 $copyCurves; else loft -n $surface -ch 1 -u 1 -c 0 -ar 1 -d 1 -ss 1 -rn 0 -po 0 -rsn true $copyCurves; parent $surface NurbsGeometry; nurbsToPoly -n $poly -mnd 1 -ch 1 -f 3 -pt 0 -pc 200 -chr 0.9 -ft 0.01 -mel 0.001 -d 0.1 -ut 1 -un 3 -vt 1 -vn 3 -uch 0 -ucr 0 -cht 0 -es 0 -ntr 0 -mrt 0 -uss 1 $surface; polySoftEdge -angle 0 -ch 1 $poly; if (`gmatch $chainJoints[0] "*_L"`) polyNormal -normalMode 0 -userNormalMode 0 -ch 1 $poly; //polyMergeVertex -d 0.01 -am 1 -ch 1 $poly; polyMergeVertex -d 0.0001 -am 1 -ch 1 $poly; //displaySmoothness -polygonObject 3; duplicate -n ($poly+"_copy") $poly; parent $poly MeshGeometry; //Create SkinCluster select $chainJoints; //include parentJoint $tempString=`listRelatives -type joint -p $chainJoints[0]`; if (size($tempString)) select -add $tempString[0]; //deselect endJoints for ($i=0;$i1) && !`attributeExists noStartCurve $chainJoints[0]`) { for ($y=0;$y<4;$y++) { $temp=`xform -q -ws -t ($chainJoints[$i]+"_startCurve.cv["+$y+"]")`; setAttr closestSampler.inPositionX $temp[0]; setAttr closestSampler.inPositionY $temp[1]; setAttr closestSampler.inPositionZ $temp[2]; $vertIndex=`getAttr closestSampler.closestVertexIndex`; if ($i>0) skinPercent -tv $chainJoints[$i-1] 1 $skinCluster ($poly+".vtx["+$vertIndex+"]"); else { $tempString=`listRelatives -type joint -p $chainJoints[0]`; skinPercent -tv $tempString[0] 1 $skinCluster ($poly+".vtx["+$vertIndex+"]"); } } } //Endcurves if (!$terminator[$i] && !$spineJoint[$i] && !$downTwist[$i] && (size($chainJoints)>1) && !`attributeExists noEndCurve $chainJoints[0]`) { for ($y=0;$y<4;$y++) { $temp=`xform -q -ws -t ($chainJoints[$i]+"_endCurve.cv["+$y+"]")`; setAttr closestSampler.inPositionX $temp[0]; setAttr closestSampler.inPositionY $temp[1]; setAttr closestSampler.inPositionZ $temp[2]; $vertIndex=`getAttr closestSampler.closestVertexIndex`; skinPercent -tv $chainJoints[$i] 1 $skinCluster ($poly+".vtx["+$vertIndex+"]"); } } } if (size($children)==0) { $endJoint=$chainJoints[size($chainJoints)-1]; $priAxis=`asGetAxis primary $endJoint Main 0`; $priNrml=`asAxisToVector $priAxis`; polyPlane -n ($endJoint+"_cap_copy") -w 1 -h 1 -sx 1 -sy 1 -ax $priNrml[0] $priNrml[1] $priNrml[2] -cuv 2 -ch 0; if (`gmatch $endJoint "*_L"`) polyNormal -normalMode 0 -userNormalMode 0 -ch 1 ($endJoint+"_cap_copy"); setAttr -type float3 ($endJoint+"_cap_copy.s") ($scale*2*(1/1.2)) ($scale*2*(1/1.2)) ($scale*2*(1/1.2)); asAlign ($endJoint+"_cap_copy") $endJoint 1 1 0 0; asAlign ($endJoint+"_cap_copy") `asListParent $endJoint` 0 1 0 0; } } global proc asCreateMeshCurve (string $curve) { string $joint; string $tempString[]; tokenize $curve "_" $tempString; for ($y=0;$y0) { //bridge from FaceOnExistingBridge instead tokenize $joints[$i] "_" $tempString; $bridgeSide="_"+$tempString[size($tempString)-1]; $bridgeCurve="bridgeCurve_"+$joints[$i]+$bridgeSide+"_middleProfile"; select $childCurve; $tempString=`cluster -n tempCluster -envelope 1`; $posA=`getAttr tempClusterHandleShape.origin`; delete tempCluster; $minDist=999; $minDot=999; $tempInts=`polyEvaluate -f bridgeMesh`; $maxNumFaces=$tempInts[0]; for ($z=0;$z<$maxNumFaces;$z++) { $v2=`asGetPolyFaceNormal ("bridgeMesh.f["+$z+"]")`; $dot=`dotProduct $v1 $v2 0`; if ($dot<$minDot) { $minDot=$dot; $closestFaceNr=$z; } } select ("bridgeMesh.f["+$closestFaceNr+"]"); ConvertSelectionToEdges; DuplicateCurve -ch 0; $tempString=`ls -sl`; AttachCurve -ch 0; delete $tempString; $tempString=`ls -sl`; rename $tempString[0] $bridgeCurve; } for ($b=1;$b>-2;$b=$b-2) { $extrudeDirectionFlip=1; if ($b==1) {$curve=$parentCurve;$mesh="parentMesh";$extrudeDirectionFlip=-1;} if ($b==-1) {$curve=$childCurve;$mesh="childMesh";} if ($y>0 && $b==1) $curve=$bridgeCurve; if (`gmatch $curve "*_L_*"`) $extrudeDirectionFlip*=-1; if (`gmatch $curve "*Root_M_*"`) $extrudeDirectionFlip*=-1; extrude -n parentSurface -ch 1 -rn false -po 0 -et 0 -upn 1 -length ($height/100*$extrudeDirectionFlip) -rotation 0 -scale 1 -dl 3 $curve; if (`objExists $bridgeCurve`) delete $bridgeCurve; nurbsToPoly -n $mesh -mnd 1 -ch 0 -f 2 -pt 1 -pc 200 -chr 0.9 -ft 0.01 -mel 0.001 -d 0.1 -ut 3 -un 1 -vt 3 -vn 1 -uch 0 -ucr 0 -cht 0.2 -es 0 -ntr 0 -mrt 0 -uss 1 parentSurface; delete parentSurface; select ($mesh+".e[2]") ($mesh+".e[6]") ($mesh+".e[9]") ($mesh+".e[11]"); FillHole; if ($extrudeDirectionFlip==-1) polyNormal -normalMode 0 -userNormalMode 0 -ch 1 $mesh; } select parentMesh childMesh; DeleteHistory; polyUnite -mergeUVSets 1 -name ("bridgeMesh"+$y); select ("bridgeMesh"+$y); DeleteHistory; //Use high `divisions` for bridge, as it is more likly to not `flip`, then later remove excess topology. polyBridgeEdge -ch 1 -divisions 20 -twist 0 -taper 1 -curveType 0 -smoothingAngle 30; select ("bridgeMesh"+$y+".f[0:9]"); delete; select -cl; for ($z=0;$z$maxValue) { $maxValue=$values[$z]; $maxTransform=$transforms[$z]; } } skinPercent -tv $maxTransform 1 $skinCluster ($sel[$i]+".vtx["+$y+"]"); } progressBar -e -ep $gMainProgressBar; } } global proc asApplyDeltaMush () { string $tempString[]; string $confirmResult,$systemCmd; int $useWBDeltaMush=1; if (`checkBox -q -ex wbDeltaMush`) $useWBDeltaMush=`checkBox -q -v wbDeltaMush`; if (!$useWBDeltaMush) { deltaMush -smoothingIterations 10 -smoothingStep 0.5 -pinBorderVertices 1 -envelope 1; asConnectDeltaMushScale; print "// DeltaMush applied\n"; return; } asLoadWbDeltaMushPlugin; eval ("wbDeltaMush -smoothingIterations 10 -smoothingStep 0.5 -pinBorderVertices 1"); asConnectDeltaMushScale; print "// DeltaMush applied\n"; } global proc asLoadWbDeltaMushPlugin () { int $haveASPlugPath=0; string $envVarString=`getenv MAYA_PLUG_IN_PATH`; string $pluginPaths[]; tokenize $envVarString ";" $pluginPaths; for ($i=0;$i($charHeight/-5000.0) && $pos[0]<($charHeight/5000.0)) skinPercent -tv $smoothJoints[$z] 1 $skinCluster ($sel[$i]+".vtx["+$y+"]"); } } } if (size(`ls -sl`)) weightHammerVerts; } progressBar -e -ep $gMainProgressBar; } global proc asDeleteSkinCurves () { if (!`objExists skinCageShape` || !`objExists skinClusterSkinCage`) return; setAttr skinClusterSkinCage.envelope 0; duplicate -n asTempMesh skinCageShape; setAttr skinClusterSkinCage.envelope 1; string $deleteObjs[]={"SkinCurves1","SkinCurves2","MeshGeometry","MeshCurves","NurbsGeometry"}; for ($obj in $deleteObjs) if (`objExists $obj`) delete $obj; string $tempString[]=`listRelatives -s -type mesh skinCage`; for ($mesh in $tempString) if ($mesh!="skinCageShape") { connectAttr asTempMesh.outMesh ($mesh+".inMesh"); evalDeferred -lp ("delete asTempMesh"); break; } } global proc string asNrToLetter (int $nr) { string $letter; if ($nr==0) $letter="";if ($nr==1) $letter="A";if ($nr==2) $letter="B"; if ($nr==3) $letter="C";if ($nr==4) $letter="D";if ($nr==5) $letter="E"; if ($nr==6) $letter="F";if ($nr==7) $letter="G";if ($nr==8) $letter="H"; if ($nr==9) $letter="I";if ($nr==10) $letter="J";if ($nr==11) $letter="K"; if ($nr==12) $letter="L";if ($nr==13) $letter="M";if ($nr==14) $letter="N"; if ($nr==15) $letter="O";if ($nr==16) $letter="P";if ($nr==17) $letter="Q"; if ($nr==18) $letter="R";if ($nr==19) $letter="S";if ($nr==20) $letter="T"; if ($nr==21) $letter="U";if ($nr==22) $letter="V";if ($nr==23) $letter="W"; if ($nr==24) $letter="X";if ($nr==25) $letter="Y";if ($nr==26) $letter="Z"; return $letter; } global proc asAlign (string $object, string $alignToObject, int $translate, int $rotate, int $jointOrient, int $rotateOrder) { string $parents[]=`listRelatives -p $object`; string $orientConstraint[]; float $rotation[]; parent $object $alignToObject; //Might have generated a Xform string $generatedXform; string $tempString[]=`listRelatives -p $object`; if ($tempString[0]!=$alignToObject) $generatedXform=$tempString[0]; if ($translate) { xform -os -t 0 0 0 $object; if ($generatedXform!="") xform -os -t 0 0 0 $generatedXform; } if ($rotateOrder) setAttr ($object+".rotateOrder") `getAttr ($alignToObject+".rotateOrder")`; if ($rotate) { xform -os -ro 0 0 0 $object; if ($generatedXform!="") xform -os -ro 0 0 0 $generatedXform; } if ($jointOrient && $rotate) setAttr -type float3 ($object+".jointOrient") 0 0 0; if (`objExists $parents[0]`) parent $object $parents[0]; else parent -w $object; if ($jointOrient && !$rotate) { if (`getAttr ($alignToObject+".rotateOrder")`!=0) warning "Aligning jointOrient for objects without aligning rotation, and non-default rotationOrder, may cause problems."; $orientConstraint=`orientConstraint $alignToObject $object`; $rotation=`xform -q -os -ro $object`; delete $orientConstraint[0]; setAttr -type float3 ($object+".jointOrient") $rotation[0] $rotation[1] $rotation[2]; setAttr -type float3 ($object+".rotate") 0 0 0; } } global proc asImportIconsFile (string $iconsFile) { string $beforeObj[]=`ls -l -as`; string $afterObj[]; int $fromBefore[]; int $readLine; $fileId=`fopen $iconsFile "r"`; string $nextLine = `fgetline $fileId`; string $previousLine; while ( size( $nextLine ) > 0 ) { if (!$readLine) if (`gmatch $nextLine "\t*"`) { $previousLine += $nextLine; $nextLine = `fgetline $fileId`; continue; } if (`gmatch $nextLine "createNode nurbsCurve*"`) { $readLine=1; eval ($previousLine); $previousLine = $nextLine; $nextLine = `fgetline $fileId`; continue; } if ($readLine) if (`gmatch $nextLine "\t*"`) { $previousLine += $nextLine; $nextLine = `fgetline $fileId`; continue; } else { $readLine=0; eval ($previousLine); } $previousLine=$nextLine; $nextLine = `fgetline $fileId`; } fclose $fileId; $afterObj=`ls -l -as`; for ($i=0;$i 3 ) && ( $tokens[0] == "FACE_NORMAL" ) ) { $x = ($tokens[$numTokens-3]); $y = ($tokens[$numTokens-2]); $z = ($tokens[$numTokens-1]); $normal = << $x, $y, $z >>; $normal = `unit $normal`; } return $normal; } global proc string asGetAxis (string $priSecTer, string $fitJoint, string $FitSkeletonOrMain, int $abs) { int $worldmatch; string $axis; string $priAxis="X"; string $secAxis="Y"; string $terAxis="Z"; if (!`objExists $FitSkeletonOrMain`) error ("Object \""+$FitSkeletonOrMain+"\" does not exist"); if (`attributeExists worldmatch FitSkeleton`) $worldmatch=`getAttr FitSkeleton.worldmatch`; if (`objExists $FitSkeletonOrMain`) if (`attributeExists primaryAxis $FitSkeletonOrMain`) { $priAxis=`getAttr -asString ($FitSkeletonOrMain+".primaryAxis")`; $secAxis=`getAttr -asString ($FitSkeletonOrMain+".secondaryAxis")`; } if ($worldmatch) if (`objExists $fitJoint`) if (`attributeExists primaryAxis $fitJoint`) { $priAxis=`getAttr -asString ($fitJoint+".primaryAxis")`; $secAxis=`getAttr -asString ($fitJoint+".secondaryAxis")`; } if ($priSecTer=="primary") $axis=$priAxis; if ($priSecTer=="secondary") $axis=$secAxis; if ($priSecTer=="tertiary") $axis=`asGetTerAxis $priAxis $secAxis`; if ($abs) $axis=`asAbsAxis $axis`; return $axis; } global proc asCreateController (string $type, string $name, string $side, string $fitJoint) { int $rotOrder,$mirTrans,$ikLocalType2,$noFlip; float $defaultCtrlScale,$boneLenght,$fat,$fatFront,$fatWidth; float $pos[3],$rot[3],$sca[3],$axisRot[3],$pos1[3],$pos2[3]; float $s[3]={-1,-1,-1}; //string $absPriAxis=`asGetAxis primary $fitJoint Main 1`; //string $absSecAxis=`asGetAxis secondary $fitJoint Main 1`; string $sel[]=`ls -sl`; string $shapes[],$tempString[]; if (`attributeExists ikLocal $fitJoint`) if (`getAttr ($fitJoint+".ikLocal")`==2)//$ikLocal=localOrient $ikLocalType2=1; //if (`gmatch $name "*Temp"`)//IKToes (behaves as FKToes but for the IK) // $FKTemp=1; if (`attributeExists noFlip $fitJoint`) $noFlip=`getAttr ($fitJoint+".noFlip")`; if (`attributeExists mirTrans FitSkeleton`) $mirTrans=`getAttr FitSkeleton.mirTrans`; select -cl; $rotOrder=`getAttr ($fitJoint+".rotateOrder")`; if ($type=="FK") createNode -n ($type+"Offset"+$name+$side) transform; else { createNode -n ($type+"Offset"+$name+$side) transform; parent ($type+"Offset"+$name+$side) "IKHandle"; } createNode -n ($type+"Extra"+$name+$side) transform; sets -add ControlSet ($type+"Extra"+$name+$side); parent ($type+"Extra"+$name+$side) ($type+"Offset"+$name+$side); asLockAttr ($type+"Extra"+$name+$side) 0 0 1 1; if (`gmatch $name "*Scapula*"`) duplicate -n ($type+$name+$side) "Scapula_icon"; else duplicate -n ($type+$name+$side) ($type+"_icon"); xform -os -t 0 0 0 -ro 0 0 0 ($type+$name+$side); if ($type=="FK" || $type=="IKLocal" || $type=="Bend" || $type=="IKhybrid" || $ikLocalType2) { if ($noFlip) $s={1,1,1}; setAttr ($type+"Offset"+$name+$side+".rotateOrder") $rotOrder; setAttr ($type+"Extra"+$name+$side+".rotateOrder") $rotOrder; setAttr ($type+$name+$side+".rotateOrder") $rotOrder; //Mirrored translation if ($mirTrans) { createNode -n ($type+"Flip"+$name+$side) -p ($type+"Offset"+$name+$side) transform; if ($side=="_L") setAttr ($type+"Flip"+$name+$side+".s") -type float3 $s[0] $s[1] $s[2]; parent -r ($type+"Extra"+$name+$side) ($type+"Flip"+$name+$side); createNode -n ($type+"UnFlip"+$name+$side) transform; if ($side=="_L") setAttr ($type+"UnFlip"+$name+$side+".s") -type float3 $s[0] $s[1] $s[2]; } } if ($side=="_L" && !$mirTrans) setAttr -type float3 ($type+$name+$side+".s") -1 -1 -1; $height=`getAttr "Main.height"`; $defaultCtrlScale=$height/30.0; $sca={$defaultCtrlScale,$defaultCtrlScale,$defaultCtrlScale}; $tempString=`listRelatives -c -type joint $fitJoint`; if ($tempString[0]!="") { $pos1=`xform -q -ws -t $fitJoint`; $pos2=`xform -q -ws -t $tempString[0]`; $boneLenght=`mag<<$pos2[0]-$pos1[0],$pos2[1]-$pos1[1],$pos2[2]-$pos1[2]>>`; if ($boneLenght>1) $boneLenght=$boneLenght/2.0; else $boneLenght=$boneLenght+((1-$boneLenght)/2.0); $defaultCtrlScale=$defaultCtrlScale*$boneLenght; $sca={$defaultCtrlScale,$defaultCtrlScale,$defaultCtrlScale}; } if (`attributeExists fat $fitJoint` && `attributeExists fatFront $fitJoint` && `attributeExists fatWidth $fitJoint`) { $fat=`getAttr ($fitJoint+$side+".fat")`; $fatFront=`getAttr ($fitJoint+$side+".fatFront")`; $fatWidth=`getAttr ($fitJoint+$side+".fatWidth")`; // $sca={$defaultCtrlScale,$fat*$fatFront*$scale,$fat*$fatWidth*$scale}; $sca={$defaultCtrlScale,$fat*$fatFront,$fat*$fatWidth}; } $shapes=`listRelatives -s -f ($type+$name+$side)`; for ($i=0;$i1) $weight=1; $vtx=`substitute tempMesh $tempString[$i] $geometry`; if ($clusterWeighting) catchQuiet (`percent -v $weight $skinCluster $vtx`); else catchQuiet (`skinPercent -tv $joint $weight $skinCluster $vtx`); } setAttr TempSoftModHandle.ty 0; //update FitJoint radius & falloffCurveString tokenize $joint "_" $tempString; $fitJoint=`substitute "Joint" $tempString[0] ""`; if (`attributeExists falloffRadius $fitJoint`) setAttr ($fitJoint+".falloffRadius") $falloffRadius; if (`objExists $fitJoint`) { if (!`attributeExists falloffCurve $fitJoint`) addAttr -ln falloffCurve -dt "string" $fitJoint; $numCurvePoints=`getAttr -s TempSoftMod.falloffCurve`; for ($i=0;$i<$numCurvePoints;$i++) { $falloffCurveString+="setAttr TempSoftMod.falloffCurve["+$i+"].falloffCurve_Position "+`getAttr ("TempSoftMod.falloffCurve["+$i+"].falloffCurve_Position")`+";"; $falloffCurveString+="setAttr TempSoftMod.falloffCurve["+$i+"].falloffCurve_Interp "+`getAttr ("TempSoftMod.falloffCurve["+$i+"].falloffCurve_Interp")`+";"; $falloffCurveString+="setAttr TempSoftMod.falloffCurve["+$i+"].falloffCurve_FloatValue "+`getAttr ("TempSoftMod.falloffCurve["+$i+"].falloffCurve_FloatValue")`+";"; } setAttr -type "string" ($fitJoint+".falloffCurve") $falloffCurveString; } delete tempMesh; if (`objExists tempSoftModCopy`) delete tempSoftModCopy; progressBar -e -ep $gMainProgressBar; select $sel; } global proc asSkinWeightBySoftModMayaLT (string $joint, string $geometry, string $skinCluster, float $falloffRadius, float $maxWeight) { global string $gMainProgressBar; int $numCurvePoints; float $weight; float $pos[]=`xform -q -ws -t $joint`; float $posAs[]; string $vtx,$fitJoint,$falloffCurveString; string $sel[]=`ls -sl`; string $tempString[]; int $clusterWeighting; if (`objectType $skinCluster`=="cluster") { $clusterWeighting=1; $pos=`xform -q -ws -piv $joint`; } duplicate -n tempMesh $geometry; select tempMesh; $tempString=`asDeformer softMod`; rename $tempString[0] TempSoftMod; rename $tempString[1] TempSoftModHandle; if (`objExists tempSoftModCopy`)//coming from asFaceConvertSoftModBackToControl proc { setAttr TempSoftMod.falloffRadius `getAttr tempSoftModCopy.falloffRadius`; setAttr TempSoftMod.falloffMode `getAttr tempSoftModCopy.falloffMode `; for ($i=0;$i<`getAttr -s tempSoftModCopy.falloffCurve`;$i++) connectAttr -f ("tempSoftModCopy.falloffCurve["+$i+"]") ("TempSoftMod.falloffCurve["+$i+"]"); } setAttr -type float3 TempSoftModHandleShape.origin $pos[0] $pos[1] $pos[2]; setAttr TempSoftMod.falloffCenter $pos[0] $pos[1] $pos[2]; xform -piv $pos[0] $pos[1] $pos[2] TempSoftModHandle; setAttr TempSoftMod.falloffMode 1; setAttr TempSoftMod.falloffRadius $falloffRadius; if ($joint=="SmilePullJoint_R" && !`objExists tempSoftModCopy`) { setAttr TempSoftMod.falloffCurve[0].falloffCurve_Position 0; setAttr TempSoftMod.falloffCurve[0].falloffCurve_FloatValue 1; setAttr TempSoftMod.falloffCurve[0].falloffCurve_Interp 3; setAttr TempSoftMod.falloffCurve[1].falloffCurve_Position 1; setAttr TempSoftMod.falloffCurve[1].falloffCurve_FloatValue 0; setAttr TempSoftMod.falloffCurve[1].falloffCurve_Interp 3; setAttr TempSoftMod.falloffCurve[2].falloffCurve_Position 0.3043; setAttr TempSoftMod.falloffCurve[2].falloffCurve_FloatValue 0.439273; setAttr TempSoftMod.falloffCurve[2].falloffCurve_Interp 3; setAttr TempSoftMod.falloffCurve[3].falloffCurve_Position 0.0806; setAttr TempSoftMod.falloffCurve[3].falloffCurve_FloatValue 0.945397; setAttr TempSoftMod.falloffCurve[3].falloffCurve_Interp 3; } if ($joint=="MouthNarrowJoint_R" && !`objExists tempSoftModCopy`) { setAttr TempSoftMod.falloffCurve[0].falloffCurve_Interp 1; } select tempMesh; polySelectConstraint -m 3 -t 1 -d 1 -db 0 $falloffRadius -dp $pos[0] $pos[1] $pos[2]; $tempString=`ls -sl -fl`; if ($clusterWeighting) { select $geometry; polySelectConstraint -m 3 -t 1 -d 1 -db 0 $falloffRadius -dp $pos[0] $pos[1] $pos[2]; asInvertSelection; percent -v 0 $skinCluster `ls -sl`; } polySelectConstraint -m 0; progressBar -e -st ("SkinWeight by SoftMod ("+$joint+")") -bp -ii 1 -min 0 -max ((size($tempString))+1) $gMainProgressBar; for ($i=0;$i1) $weight=1; $vtx=`substitute tempMesh $tempString[$i] $geometry`; if ($clusterWeighting) catchQuiet (`percent -v $weight $skinCluster $vtx`); else catchQuiet (`skinPercent -tv $joint $weight $skinCluster $vtx`); } setAttr TempSoftModHandle.ty 0; /* if ($joint=="SmileBulgeJoint_R") { //not to include lips in weights select lipArea; $tempString=`ls -sl -fl`; select `asobjSetCast "" $tempString SmileBulgeLayer`; skinPercent -tv Face_M 1 SmileBulgeSC `ls -sl`; asSmoothFlood SmileBulgeJoint_R Face_M 1; } if ($joint=="FrownBulgeJoint_R") { //not to include lips in weights select lipArea; $tempString=`ls -sl -fl`; select `asobjSetCast "" $tempString CheekRaiserLayer`; skinPercent -tv Face_M 1 CheekRaiserSC `ls -sl`; asSmoothFlood FrownBulgeJoint_R Face_M 1; } */ //update FitJoint radius & falloffCurveString tokenize $joint "_" $tempString; $fitJoint=`substitute "Joint" $tempString[0] ""`; if (`attributeExists falloffRadius $fitJoint`) setAttr ($fitJoint+".falloffRadius") $falloffRadius; if (`objExists $fitJoint`) { if (!`attributeExists falloffCurve $fitJoint`) addAttr -ln falloffCurve -dt "string" $fitJoint; $numCurvePoints=`getAttr -s TempSoftMod.falloffCurve`; for ($i=0;$i<$numCurvePoints;$i++) { $falloffCurveString+="setAttr TempSoftMod.falloffCurve["+$i+"].falloffCurve_Position "+`getAttr ("TempSoftMod.falloffCurve["+$i+"].falloffCurve_Position")`+";"; $falloffCurveString+="setAttr TempSoftMod.falloffCurve["+$i+"].falloffCurve_Interp "+`getAttr ("TempSoftMod.falloffCurve["+$i+"].falloffCurve_Interp")`+";"; $falloffCurveString+="setAttr TempSoftMod.falloffCurve["+$i+"].falloffCurve_FloatValue "+`getAttr ("TempSoftMod.falloffCurve["+$i+"].falloffCurve_FloatValue")`+";"; } setAttr -type "string" ($fitJoint+".falloffCurve") $falloffCurveString; } delete tempMesh; if (`objExists tempSoftModCopy`) delete tempSoftModCopy; progressBar -e -ep $gMainProgressBar; select $sel; } global proc asFollow (string $driver, string $driven, string $target) { int $mirroredTranslation,$mirTrans; string $setRange=$driver+"SetRangeFollow"; if (!`objExists $target`) return; if (!`attributeExists "follow" $driver`) { addAttr -k 1 -ln follow -at double -min 0 -max 10 -dv 0 $driver; createNode -n $setRange setRange; setAttr ($setRange+".maxX") 1; setAttr ($setRange+".minY") 1; setAttr ($setRange+".oldMaxX") 10; setAttr ($setRange+".oldMaxY") 10; connectAttr ($driver+".follow") ($setRange+".value.valueX"); connectAttr ($driver+".follow") ($setRange+".value.valueY"); } createNode -n ($driven+"FollowNoScaleOffset") transform; createNode -n ($driven+"FollowNoScale") -p ($driven+"FollowNoScaleOffset") transform; pointConstraint $target ($driven+"FollowNoScaleOffset"); orientConstraint $target ($driven+"FollowNoScaleOffset"); parent ($driven+"FollowNoScaleOffset") ("IKFollow"); createNode -n ($driven+"FollowOffset") transform; createNode -n ($driven+"Follow") -p ($driven+"FollowOffset") transform; asAlign ($driven+"FollowOffset") $driven 1 1 0 0; parent ($driven+"FollowOffset") ("IKFollow"); parentConstraint -mo ($driven+"FollowNoScale") ($driven+"Follow"); createNode -n ($driven+"StaticOffset") transform; createNode -n ($driven+"Static") -p ($driven+"StaticOffset") transform; asAlign ($driven+"StaticOffset") $driven 1 1 0 0; parent ($driven+"StaticOffset") ("IKStatic"); string $tempString[]=`parentConstraint ($driven+"Static") ($driven+"Follow") $driven`; string $constraint=$tempString[0]; select $constraint; connectAttr ($setRange+".outValue.outValueY") ($constraint+"."+$driven+"Static"+"W0"); connectAttr($setRange+".outValue.outValueX") ($constraint+"."+$driven+"Follow"+"W1"); } global proc asConstraintToFKIK (string $type, string $fitJointIK, string $fk, string $ik, string $target) { string $contraintCmd="pointConstraint "; if ($type=="orient") $contraintCmd="orientConstraint "; if ($type=="parent") $contraintCmd="parentConstraint "; if ($type=="scale") $contraintCmd="scaleConstraint "; $contraintCmd+=$fk; if (`objExists $ik`) $contraintCmd+=" "+$ik; $contraintCmd+=" "+$target; string $tempString[]; tokenize $target "_" $tempString; string $side="_"+$tempString[size($tempString)-1]; tokenize $fk "_" $tempString; string $contraintToSide="_"+$tempString[size($tempString)-1]; $tempString=`eval ($contraintCmd)`; string $constraint=$tempString[0]; if (`objExists $ik` && `objExists ("FKIKBlend"+$fitJointIK+"Reverse"+$contraintToSide)`) { connectAttr ("FKIKBlend"+$fitJointIK+"Reverse"+$contraintToSide+".outputX") ($constraint+"."+$fk+"W0"); connectAttr ("FKIKBlend"+$fitJointIK+"UnitConversion"+$contraintToSide+".output") ($constraint+"."+$ik+"W1"); } } global proc asFaceModelCheck () { string $geometry=`textField -q -tx asFaceFaceTextField`; if (!`objExists $geometry`) error "No geometry choosen for \"Face\""; select $geometry; asModelChecker; } global proc asModelCheckerUI () { if (`window -q -ex asModelChecker`) deleteUI asModelChecker; window -t "Model Checker" asModelChecker; columnLayout; separator -st none -h 10; text -l "Check for default Transformation values,"; text -l "and Model Symmetry."; separator -st none -h 5; text -l "Select the model, then:"; separator -st none -h 10; button -w 50 -l "Check" -c asModelChecker; showWindow; } global proc asModelChecker () { global string $gMainProgressBar; int $tempInt[]; int $numVtxs,$mirrortVtx,$i,$gameEngine; float $mag; float $posA[],$posB[],$tempFloat[]; string $sel[]=`ls -sl`; string $m,$warningM,$objectType; string $okMessage="Continue anyway"; string $historyNodes[],$tempString[],$checkTransforms[]; if (!size($sel)) error "Nothing Selected"; $tempString=`listRelatives -c -type mesh`; if (!`size($tempString)`) error "Selected object is not a Mesh, Select the your model instead."; $warningM="This can cause error when building FaceSetup.\n\n" +"It is recommended that you use the \"Model Clean\" tool,\n" +"before rigging.\n"; if (`checkBox -q -ex asFaceGameEngineCheckBox`) $gameEngine=`checkBox -q -v asFaceGameEngineCheckBox`; //find parent Transforms $tempString=`ls -l $sel[0]`; tokenize $tempString[0] "|" $checkTransforms; for ($i=0;$i0.001) continue; setAttr closestSampler.inPosition ($posA[0]*-1) $posA[1] $posA[2]; $mirrortVtx=`getAttr closestSampler.closestVertexIndex`; $posB=`xform -q -ws -t ($sel[0]+".vtx["+$mirrortVtx+"]")`; $mag=`mag <<($posA[0]-($posB[0]*-1)),($posA[1]-$posB[1]),($posA[2]-$posB[2])>>`; if ($mag>0.001) select -add ($sel[0]+".vtx["+$i+"]") ($sel[0]+".vtx["+$mirrortVtx+"]"); } progressBar -e -ep $gMainProgressBar; delete closestSampler; refresh; if (size(`ls -sl`)) { $dialog=`confirmDialog -t "Confirm" -m "Selected verticies are not symmetrical" -b $okMessage -b "Cancel" -db "Cancel" -ds "Cancel"`; if ($dialog!=$okMessage) error "Operation cancelled. It is recommended that you make the model symmetrical."; } else print "// Model is symmetrical.\n"; } global proc asRemoveForthEdge (string $poly) { int $tempInts[]; int $numVtxs; //string $poly="Chest_M_branch"; string $vtxA,$vtxB; string $tempString[],$tempString2[],$tempString3[],$tempString4[]; $tempInts=`polyEvaluate -v $poly`; $numVtxs=$tempInts[0]; for ($i=0;$i<$numVtxs;$i++) { $vtxA=$poly+".vtx["+$i+"]"; select $vtxA; ConvertSelectionToEdges; if (size(`ls -sl -fl`)<4) continue; ConvertSelectionToVertices; select -d $vtxA; $tempString=`ls -sl -fl`; for ($y=0;$y-2;$b=$b-2)//2ways (positive and negative values) { if ($b==-1 && !$posNeg) continue; if ($r[$z]==0) continue; if ($selectedXYZ!="" && $xyz[$z]!=$selectedXYZ) continue; setKeyframe -v 0 ($ctrl+".r"+$xyz[$z]); $currentTime+=$frames;currentTime $currentTime; setKeyframe -v ($r[$z]*$b) ($ctrl+".r"+$xyz[$z]); $currentTime+=$frames;currentTime $currentTime; setKeyframe -v 0 ($ctrl+".r"+$xyz[$z]); } } $currentTime+=$frames;currentTime $currentTime; } } $currentTime=$currentTime-$frames; playbackOptions -min 0 -ast 0 -max $currentTime -aet $currentTime; currentTime 0; } global proc asAnimationTesterPaintWeights () { float $t[],$r[],$s[]; string $objAttr; string $joint="Root_M"; string $sel[]=`ls -sl`; string $controlSetMembers[],$tempString[],$tempString2[]; if (`objExists ControlSet`) $controlSetMembers=`sets -q ControlSet`; string $trs[]={"t","r"}; string $xyz[]={"x","y","z"}; for ($i=0;$i0.001) { print ("detected motion on:"+$controlSetMembers[$i]+"."+$trs[$y]+$xyz[$z]+" : "+$value+"\n"); $tempString[0]=`substitute "FK" $controlSetMembers[$i] ""`; if (`objExists $tempString[0]`) $joint=$tempString[0]; $i=$y=$z=999; break; } } //Select objects bound to $joint (if nothing selected); if (size($sel)==0) { $tempString=`listConnections -s 0 -d 1 ($joint+".worldMatrix")`; for ($i=0;$i>`; if ($dist<$minDist) { $minDist=$dist; $nearestJoint=$curveGuideFitJoints[$i]; } } $tempString=`ls -l $nearestJoint`; tokenize $tempString[0] "|" $tempString; for ($i=size($tempString)-1;$i>-1;$i--) { if ($arrivedAtTaggedJoint) { $nearestFeatherParent=$tempString[$i]; break; } if (`attributeExists curveGuide $tempString[$i]`) $arrivedAtTaggedJoint=1; } if (`gmatch $ctrl "*_R"` && `objExists ($nearestFeatherParent+"_R")`) $nearestFeatherParent+="_R"; else if (`gmatch $ctrl "*_L"` && `objExists ($nearestFeatherParent+"_L")`) $nearestFeatherParent+="_L"; else $nearestFeatherParent+="_M"; return $nearestFeatherParent; } global proc asRemoveAllUnusedInfluences () { string $sel[]=`ls -sl`; string $tempString[],$tempString2[]; string $meshes[]=`ls -type mesh`; for ($i=0;$i2) $nonFullWeightedVtxs[size($nonFullWeightedVtxs)]=$tempString[$i]; } if (size(`ls -sl`)) weightHammerVerts; select -cl; select `listRelatives -c -type transform LidCurves_R LidCurves_L`; DeleteHistory; asFaceLockWeights 0; for ($b=1;$b>-2;$b=$b-2) { if ($b==1) {$side="_R";$leftSuffix="";} else {$side="_L";$leftSuffix="Left";} for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) {$upperLower="upper";$upperLowerOpposite="lower";} else {$upperLower="lower";$upperLowerOpposite="upper";} progressBar -e -s 1 $gMainProgressBar; $existingJoints=`ls -type joint ($upperLower+"LidMain*"+$side)`; if ($side=="_R" || $nonSymmetrical) { $tyValueForCloseLid=`getAttr ($upperLower+"Lid"+$side+".tyValueForCloseLid")`; $tempString[0]=`asGetFaceFitSelection ($upperLower+"EyeLidMainCurve"+$leftSuffix)`; select -cl; $fitVtxs=`stringToStringArray $tempString[0] " "`; } //For the lower, re-use the first and last joint from upper if ($upperLower=="lower") { $tempString=`ls -type joint ("upperLidMain*"+$side)`; stringArrayInsertAtIndex(0, $existingJoints, $tempString[0]); stringArrayInsertAtIndex(size($existingJoints), $existingJoints, $tempString[size($tempString)-1]); } //find $midNr from closest joint $posMid=`xform -q -ws -t ($upperLower+"Lid"+$side)`; $minMidDist=999; for ($i=1;$i>`; if ($midDist<$minMidDist) {$midNr=$i;$minMidDist=$midDist;} } $outerNr=size($existingJoints)-1; if ($upperLower=="upper") { $upperMidNr=$midNr; $upperOuterNr=$outerNr; } //change the aim to aim directly at controller delete ($upperLower+"LidMain"+$midNr+"Aim"+$side+"_aimConstraint1"); aimConstraint -mo -worldUpType objectrotation -worldUpObject ("LidSetup"+$side) -worldUpVector 0 1 0 ($upperLower+"Lid"+$side) ($upperLower+"LidMain"+$midNr+"Aim"+$side); if ($upperLower=="upper") { delete ($upperLower+"LidMain0Aim"+$side+"_aimConstraint1"); aimConstraint -worldUpType objectrotation -worldUpObject ("LidSetup"+$side) -worldUpVector 0 1 0 ("innerLid"+$side) ($upperLower+"LidMain0Aim"+$side); delete ($upperLower+"LidMain"+$outerNr+"Aim"+$side+"_aimConstraint1"); aimConstraint -worldUpType objectrotation -worldUpObject ("LidSetup"+$side) -worldUpVector 0 1 0 ("outerLid"+$side) ($upperLower+"LidMain"+$outerNr+"Aim"+$side); } if ($side=="_R" || $nonSymmetrical) { //move eyeLid ctrl until reach opposite side for ($i=0;$i<99;$i++) { move -r -os 0 (-0.05*$upperLowerFactor) 0 ($upperLower+"Lid"+$side); $ty=`getAttr ($upperLower+"Lid"+$side+".ty")`; if ($upperLower=="upper") $tyUpper=$ty; $posA=`xform -q -ws -t $fitVtxs[$midNr]`; xform -ws -t $posA[0] $posA[1] $posA[2] tempXform; setAttr -l 1 tempXform.tx; setAttr -l 1 tempXform.tz; delete `geometryConstraint ($upperLowerOpposite+"LidMainCurve1"+$side) tempXform`; $posB=`xform -q -ws -t tempXform`; $tyDif=$posA[1]-$posB[1]; setAttr -l 0 tempXform.tx; setAttr -l 0 tempXform.tz; if ($upperLower=="upper" && $tyDif<=0) break; if ($upperLower=="lower" && $tyDif>=0) break; } //inner->outer for ($i=1;$i<$outerNr;$i++) { $vtxs=`asInfluenceVerts $existingJoints[$i] $skinCluster 1.0`; if (size($vtxs)==0) continue; if ($i==$midNr) continue; else if ($i<$midNr) skinPercent -tv $existingJoints[0] 1 $skinCluster $vtxs; else if ($i>$midNr) skinPercent -tv $existingJoints[$outerNr] 1 $skinCluster $vtxs; for ($y=0;$y<101;$y++) { $value=$y*0.01; skinPercent -tv $existingJoints[$midNr] $value $skinCluster $vtxs; $posA=`xform -q -ws -t $fitVtxs[$i]`; xform -ws -t $posA[0] $posA[1] $posA[2] tempXform; setAttr -l 1 tempXform.tx; setAttr -l 1 tempXform.tz; delete `geometryConstraint ($upperLowerOpposite+"LidMainCurve1"+$side) tempXform`; $posB=`xform -q -ws -t tempXform`; $tyDif=$posA[1]-$posB[1]; setAttr -l 0 tempXform.tx; setAttr -l 0 tempXform.tz; if ($upperLower=="upper" && $tyDif<=0) break; if ($upperLower=="lower" && $tyDif>=0) break; } // skinPercent -tv $existingJoints[$midNr] $value $skinCluster $vtxs; refresh; } } setAttr ($upperLower+"Lid"+$side+".ty") 0; if ($upperLower=="upper") { $blinkCenter=`getAttr ($upperLower+"Lid"+$side+".blinkCenter")`; asDsSdk ("bw"+$upperLower+"Lid"+$side+"_blink.output") ("bwSDK"+$upperLower+"Lid"+$side+"_translateY.input") 10 ($tyUpper*(1-($blinkCenter/10.0))); delete ("bw"+$upperLower+"Lid"+$side+"_blinkCenter"); deleteAttr ($upperLower+"Lid"+$side+".blinkCenter"); } if ($upperLower=="lower") { asDsSdk ("bw"+$upperLower+"Lid"+$side+"_blink.output") ("bwSDK"+$upperLower+"Lid"+$side+"_translateY.input") 10 ($ty*($blinkCenter/10.0)); // delete ("bw"+$upperLower+"Lid"+$side+"_blink"); // deleteAttr ($upperLower+"Lid"+$side+".blink"); } deleteAttr ($upperLower+"Lid"+$side+".closeAutoShape"); //remove joints for ($i=1;$i-2;$b=$b-2) { if ($b==1) $side="_R"; else $side="_L"; rename ("LidMainInner"+$side) ("innerLidJoint"+$side); rename ("LidMainOuter"+$side) ("outerLidJoint"+$side); rename ("LidMainUpper"+$side) ("upperLidJoint"+$side); rename ("LidMainLower"+$side) ("lowerLidJoint"+$side); } //other affected objects (eyeLashes) if ($eyeLash!="" && !`gmatch $eyeLash "*[.]*"`) { $tempString=`stringToStringArray $eyeLash " "`; for ($i=0;$i-2;$b=$b-2) { if ($b==1) {$side="_R";$leftSuffix="";} else {$side="_L";$leftSuffix="Left";} for ($upperLowerFactor=1;$upperLowerFactor>-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; progressBar -e -s 1 $gMainProgressBar; $existingJoints=`ls -type joint ($upperLower+"LipJoint*"+$side)`; stringArrayInsertAtIndex(0, $existingJoints, ($upperLower+"LipJoint0_M")); //find $aNr,$bNr from closest joint $posA=`xform -q -ws -t ($upperLower+"LipA"+$side)`; $posB=`xform -q -ws -t ($upperLower+"LipB"+$side)`; $minADist=$minBDist=999; for ($i=0;$i>`; $bDist=`mag<<$posB[0]-$pos[0],$posB[1]-$pos[1],$posB[2]-$pos[2]>>`; if ($aDist<$minADist) {$aNr=$i;$minADist=$aDist;} if ($bDist<$minBDist) {$bNr=$i;$minBDist=$bDist;} } //override $bNr jsut use the last before crn $bNr=size($existingJoints)-1; //these will be renamed later if ($side=="_R" && $upperLower=="upper") {$upperLipAJointR=$existingJoints[$aNr];$upperLipBJointR=$existingJoints[$bNr];} if ($side=="_L" && $upperLower=="upper") {$upperLipAJointL=$existingJoints[$aNr];$upperLipBJointL=$existingJoints[$bNr];} if ($side=="_R" && $upperLower=="lower") {$lowerLipAJointR=$existingJoints[$aNr];$lowerLipBJointR=$existingJoints[$bNr];} if ($side=="_L" && $upperLower=="lower") {$lowerLipAJointL=$existingJoints[$aNr];$lowerLipBJointL=$existingJoints[$bNr];} //center->a asFaceLockWeights 1; setAttr ($existingJoints[0]+".lockInfluenceWeights") 0; setAttr ($existingJoints[$aNr]+".lockInfluenceWeights") 0; for ($i=1;$i<$aNr;$i++) { $vtxs=`asInfluenceVerts $existingJoints[$i] $skinCluster 1.0`; if (!size($vtxs)) continue; setAttr ($existingJoints[$i]+".lockInfluenceWeights") 0; skinPercent -tv $existingJoints[0] 1 $skinCluster $vtxs; $value=`asDistFactor $existingJoints[$i] $existingJoints[0] $existingJoints[$aNr]`; skinPercent -tv $existingJoints[$aNr] $value $skinCluster $vtxs; skinCluster -e -ri $existingJoints[$i] $skinCluster; } //a->b asFaceLockWeights 1; setAttr ($existingJoints[$aNr]+".lockInfluenceWeights") 0; setAttr ($existingJoints[$bNr]+".lockInfluenceWeights") 0; for ($i=$aNr+1;$i-2;$upperLowerFactor=$upperLowerFactor-2) { if ($upperLowerFactor==1) $upperLower="upper"; else $upperLower="lower"; createNode -n ($upperLower+"LipReduceAutoVolMPD") multiplyDivide; setAttr ($upperLower+"LipReduceAutoVolMPD.operation") 2; setAttr ($upperLower+"LipReduceAutoVolMPD.input1X") 1; // connectAttr ($upperLower+"LipScaleAutoVolume_M.sz") ($upperLower+"LipReduceAutoVolMPD.input2X"); connectAttr ($upperLower+"LipAutoVolumeMPD_M.outputX") ($upperLower+"LipReduceAutoVolMPD.input2X"); connectAttr -f ($upperLower+"LipReduceAutoVolMPD.outputX") ($upperLower+"LipScaleAutoVolume_M.sx"); } asFaceLockWeights 0; //rename remaining joints to match onFaceJoint convention rename upperLipJoint0_M upperLipJoint_M; rename lowerLipJoint0_M lowerLipJoint_M; rename $upperLipAJointR upperLipAJoint_R; rename $upperLipAJointL upperLipAJoint_L; rename $upperLipBJointR upperLipBJoint_R; rename $upperLipBJointL upperLipBJoint_L; rename $lowerLipAJointR lowerLipAJoint_R; rename $lowerLipAJointL lowerLipAJoint_L; rename $lowerLipBJointR lowerLipBJoint_R; rename $lowerLipBJointL lowerLipBJoint_L; //other affected objects (mustache etc) $tempString=`listConnections upperLipJoint_M.worldMatrix`; for ($i=0;$i>`; float $distToB=`mag<<$pos[0]-$posB[0],$pos[1]-$posB[1],$pos[2]-$posB[2]>>`; $distFactor=$distToA/($distToA+$distToB); //if ($distFactor<0.5) // $distFactor=`smoothstep 0 1 $distFactor`; return $distFactor; } global proc string[] asInfluenceVerts (string $joint, string $skinCluster, float $threshold) { string $sel[]=`ls -sl`; select -cl; string $vtx[],$tempString[],$infs[]; skinCluster -e -selectInfluenceVerts $joint $skinCluster; $tempString=`ls -sl -fl`; for ($i=0;$i$maxY) $maxY=$pos[1]; } if ($maxY>0) $scale=$maxY/17.176163; return $scale; } global proc asPublish () { string $sceneName=`file -q -sn`; if ($sceneName=="") error "File not saved, can not publish"; string $tempString[],$controlSetMembers[],$animatedCtrls[],$attrs[]; string $publishFile; string $basename=`basenameEx $sceneName`; string $filePath=`asStripPath $sceneName 1`; //check for animation if (`objExists ControlSet`) $controlSetMembers=`sets -q ControlSet`; if (`objExists FaceControlSet`) { $tempString=`sets -q FaceControlSet`; $controlSetMembers=`stringArrayCatenate $controlSetMembers $tempString`; } for ($i=0;$i1) error ("ObjectName not unique "+$children[$y]+"\n"); $childIsMember=0; for ($z=0;$z "+$connections[$y+1]+"\n"); continue; } $connectCmds[size($connectCmds)]="connectAttr -f "+$connections[$y]+" "+$connections[$y+1]+";"; $connectCmdsSource[size($connectCmds)-1]=$connections[$y]; $connectCmdsDest[size($connectCmds)-1]=$connections[$y+1]; } } //Pre Rebuild $transformLimits for ($i=0;$i$sideTreshold || $firstJointPos[0]<(-1*$sideTreshold))) {//Existing Root but not centered, gets renamed, so new centered root gets generated rename Root RootSide; $tempString=`listRelatives -c -type joint FitSkeleton`; } if ($tempString[0]!="Root") { if (`objExists "Root"`) error "The top-level joint must be named \"Root\", but another object in this scene is already called Root"; if ($firstJointPos[0]<$sideTreshold && $firstJointPos[0]>(-1*$sideTreshold)) rename $tempString[0] Root; else { select FitSkeleton; joint -n Root; xform -ws -t 0 $firstJointPos[1] $firstJointPos[2] Root; parent $tempString[0]; } } //Ensure not starting on Right side float $tempFloat[]; string $fitJoints[]=`listRelatives -ad -type joint FitSkeleton`; for ($i=0;$i$sideTreshold) { $ancestorNoMiror=0; $tempString=`ls -l $fitJoints[$i]`; tokenize $tempString[0] "|" $tempString; for ($y=0;$y$sideTreshold || $rootIKJointPos[0]<($sideTreshold*-1)) $nonCenteredSpineJoints+="\""+$rootIKJoints[$i]+"\" "; } if ($nonCenteredSpineJoints!="") error ("These Spine joints are not in the center: "+$nonCenteredSpineJoints); } //Pre rebuild Z-up string $upAxisDirection=`optionVar -q "upAxisDirection"`; if ($upAxisDirection=="z") asSceneUpAxisFlip FitSkeleton y; setToolTo $gSelect; asSetFixedWrapOptions; int $numLetters,$centerBtwFeet,$inbetweenJoints,$reachedQtoes,$hasChildWithToesLabel,$stiffCtrl1Nr,$stiffCtrl2Nr,$stiffLocNr,$closestIkCtrlNr1,$closestIkCtrlNr2,$ikControlNr,$numChar,$segmentScaleCompensate; int $numMainExtras,$worldOrientUp,$worldmatch,$mirTrans,$sideFactor,$ancestorNoMiror; int $fitJointTwistJoints[],$fitJointUpTwistJoints[],$fitJointBendyJoints[],$fitJointUpBendyJoints[],$fitJointBend[],$fitJointInbetweenJoints[],$fitJointUnTwister[],$fitJointRotOrder[]; int $fitJointIsEndJoint[],$ikLocal[],$ikLocalType[],$fitJointGlobal[],$fitJointsWheel[],$fitJointUserSegScaleComp[],$fitJointSegScaleComp[],$fitJointFirstAfterIK[],$fitJointNonDef[]; int $fitJointsAim[],$fitJointNoMirror[],$fitJointNoFlip[],$fitJointNoControl[],$fitJointNoSkin[],$fitJointGlobalTranslate[],$fitJointControl[]; int $isIKStart[],$isIKEnd[],$isIKBelowIKEnd[],$fitJointIKNumCtrls[],$fitJointIKNumCtrlsFakeMid[],$priAxisNr[],$secAxisNr[]; int $fitJointLockTx[],$fitJointLockTy[],$fitJointLockTz[],$fitJointLockRx[],$fitJointLockRy[],$fitJointLockRz[],$fitJointLockSx[],$fitJointLockSy[],$fitJointLockSz[],$fitJointsAimAxis[],$fitJointsAimUpAxis[]; float $pos[3],$pos2[3],$rot[3],$sca[3],$parentPos[3],$parentRot[3],$temp[3],$temp2[3],$temp3[3],$aimV[3],$jo[3],$pa[3],$priNrml[3],$secNrml[3],$terNrml[3]; float $priNrmlX[],$priNrmlY[],$priNrmlZ[],$secNrmlX[],$secNrmlY[],$secNrmlZ[],$terNrmlX[],$terNrmlY[],$terNrmlZ[],$priAxisIsNeg[],$priAxisMult[],$terAxisMult[]; float $footRotOut[],$ikLenght[],$fitJointGlobalValue[]; float $dist,$minDist,$minDist1,$minDist2,$defaultDistance,$posFactor,$invPosFactor,$weight,$fat,$fatFront,$fatWidth,$lockCenterTolerance,$height,$lenght,$width,$maxFitJoint,$minFitJoint,$iconScaleFactor,$twistDistance,$w, $aimX,$aimY,$aimZ,$xUp,$yUp,$zUp,$xOff,$yOff,$zOff,$xWorldUp,$yWorldUp,$zWorldUp,$c,$d; float $defaultAngleDirection,$defaultAngle,$defaultUnstretchedLenght,$defaultOffsetAngle,$yy,$zz,$scalerWeight,$parameter,$hf,$diameter,$scaleFactor; $scale=`asGetScale`; string $side,$childSide,$parentSide,$parent,$joint,$multipleDivide,$childLabel,$ankle,$heel,$toes,$toesEnd,$bigToe,$pinkyToe,$scapula,$label,$offsetParent,$curveGuide,$ctrl,$ikParentConstraintTo,$worldUpObject,$inbetweenJoint; string $startJoint,$endJoint,$middleJoint,$IKEndJoint,$blendWeighted,$newSDK,$ds,$dsObjName,$dsSide,$aimAtSide,$aimUpSide,$worldUpType,$alignToObject,$bw; string $priAxis="X"; string $secAxis="Y"; string $terAxis="Z"; string $absPriAxis,$absSecAxis,$absTerAxis,$rootAbsPriAxis; string $fitJointAbsPriAxis[],$fitJointAbsSecAxis[],$fitJointAbsTerAxis[],$fitJointParentAbsPriAxis[]; string $fitJointLabel[],$fitJointSide[],$fitJointParent[],$fitJointParentSide[],$fitJointChild[],$fitJointChildSide[],$fitJointsFollowSide[],$fitJointQtoes[],$deformJoints[]; string $fitJointsFollow[],$fitJointsAttachTo[],$fitJointsAttachMode[],$fitJointsAimAt[],$fitJointsAimConstraint[],$fitJointsCurveGuide[],$tempString2[],$tempString3[],$FKXJoints[],$sdks[],$sdkPlugs[]; string $asFitJointIKInfo[],$fitJointIK[],$fitJointIKStartJoint[],$fitJointIKMiddleJoint[],$fitJointIKEndJoint[],$fitJointIKSolver[],$IKJoints[],$userAttrs[],$footRollJoints[]; string $primarySecondary[]={"primary","secondary"}; string $allBefore[]=`ls`; if (`objExists FitSkeletonVisualizers`) { delete FitSkeletonVisualizers; asUpdateButtonEnables; } if (`attributeExists numMainExtras FitSkeleton`)//pre 5.732 $numMainExtras=`getAttr FitSkeleton.numMainExtras`; if (`attributeExists numMainExtras Root`)//post 5.732 $numMainExtras=`getAttr Root.numMainExtras`; if (`attributeExists primaryAxis FitSkeleton`) $priAxis=`getAttr -asString FitSkeleton.primaryAxis`; if (`attributeExists secondaryAxis FitSkeleton`) $secAxis=`getAttr -asString FitSkeleton.secondaryAxis`; if (`checkBox -q -ex asBodyMirTransCheckBox`) $mirTrans=`checkBox -q -v asBodyMirTransCheckBox`; createNode -n "iconsGroup" transform; setAttr "iconsGroup.visibility" 0; asImportIconsFile $iconsFile; //--Sets--// select -cl; sets -name ControlSet; sets -name DeformSet; sets -name AllSet; sets -name "Sets"; sets -add "Sets" AllSet ControlSet DeformSet; sets -add ControlSet `listRelatives -c iconsGroup`; createNode -n "Group" transform; asLockAttr "Group" 1 1 1 0; //--2nd level transforms--// parent FitSkeleton "Group"; createNode -n MotionSystem -p "Group" transform; createNode -n DeformationSystem -p "Group" transform; if (!$asRebuilding || !`objExists Geometry`) { createNode -n Geometry transform; setAttr -l 1 Geometry.inheritsTransform 0; parent Geometry "Group"; //auto-parent geo $tempString=`ls -type transform -r 1 "geo"`; if (size($tempString)) parent $tempString Geometry; } //Main createNode -n MainSystem -p MotionSystem transform; duplicate -n Main Main_icon; parent Main MainSystem; xform -s (0.285*$scale) (0.285*$scale) (0.285*$scale) Main.cv[0:7]; connectAttr -f FitSkeletonShape.worldSpace[0] MainShape.create; refresh; disconnectAttr FitSkeletonShape.worldSpace[0] MainShape.create; for ($i=1;$i<$numMainExtras+1;$i++) { if ($i==1) duplicate -n ("MainExtra"+$i) Main; else duplicate -n ("MainExtra"+$i) ("MainExtra"+($i-1)); xform -s 1.1 1.1 1.1 ("MainExtra"+$i+".cv[0:7]"); setAttr ("MainExtra"+$i+"Shape.overrideColor") (19+$i); } for ($i=1;$i<$numMainExtras;$i++) parent ("MainExtra"+$i) ("MainExtra"+($i+1)); if ($numMainExtras>0) parent Main MainExtra1; createNode -n MainScaleMultiplyDivide multiplyDivide; connectAttr Main.scale MainScaleMultiplyDivide.input1; for ($i=1;$i<$numMainExtras+1;$i++) { createNode -n ("MainScaleMultiplyDivide"+$i) multiplyDivide; if ($i==1) connectAttr Main.scale ("MainScaleMultiplyDivide"+$i+".input1"); else connectAttr ("MainScaleMultiplyDivide"+($i-1)+".output") ("MainScaleMultiplyDivide"+$i+".input1"); connectAttr ("MainExtra"+$i+".scale") ("MainScaleMultiplyDivide"+$i+".input2"); connectAttr -f ("MainScaleMultiplyDivide"+$i+".output") MainScaleMultiplyDivide.input1; } setAttr -l 0 FitSkeleton.v; setAttr -l 1 FitSkeleton.v 0; connectAttr -f MotionSystem.visibility MainShape.visibility; for ($i=1;$i<$numMainExtras+1;$i++) connectAttr -f MotionSystem.visibility ("MainExtra"+$i+"Shape.visibility"); //--4th level transforms--// createNode -n FKSystem -p MotionSystem transform; createNode -n IKSystem -p MotionSystem transform; createNode -n FKIKSystem -p MotionSystem transform; createNode -n BendSystem -p MotionSystem transform; createNode -n AimSystem -p MotionSystem transform; createNode -n RootSystem -p MotionSystem transform; createNode -n TwistSystem -p MotionSystem transform; createNode -n GlobalSystem -p MotionSystem transform; createNode -n ConstraintSystem -p MotionSystem transform; createNode -n DynamicSystem -p MotionSystem transform; createNode -n DrivingSystem -p MotionSystem transform; setAttr BendSystem.inheritsTransform 0; //--5th level transforms--// createNode -n IKJoints -p IKSystem transform; createNode -n IKHandle -p IKSystem transform; createNode -n IKFollow -p IKSystem transform; createNode -n IKStatic -p IKSystem transform; createNode -n IKCurve -p IKSystem transform; setAttr IKCurve.inheritsTransform 0; createNode -n IKMessure -p IKSystem transform; //--FollowMain--// createNode -n IKHandleFollowMain -p IKHandle transform; createNode -n RootFollowMain -p RootSystem transform; createNode -n GlobalFollowMain -p GlobalSystem transform; $tempString={"IKHandleFollowMain","RootFollowMain","GlobalFollowMain","IKStatic"}; for ($i=0;$i$sideTreshold) { $fitJointSide[$i]="_L"; break; } if ($pos[0]<($sideTreshold*-1)) { $fitJointSide[$i]="_R"; break; } } //Analyze $fitJointNoMirror & $fitJointNoFlip $tempString=`ls -l $fitJoints[$i]`; tokenize $tempString[0] "|" $tempString; for ($y=0;$y$sideTreshold) { $fitJointParentSide[$i]="_L"; break; } if ($pos[0]<($sideTreshold*-1)) { $fitJointParentSide[$i]="_R"; break; } } } //Analyze ParentPriAxis $fitJointParentAbsPriAxis[$i]=$fitJointAbsPriAxis[$i]; if ($fitJointParent[$i]!="" && `attributeExists primaryAxis $fitJointParent[$i]`) $fitJointParentAbsPriAxis[$i]=`asGetAxis primary $fitJointParent[$i] FitSkeleton 1`; //Analyze Child $tempString=`listRelatives -c -type joint $fitJoints[$i]`; $fitJointChild[$i]=$tempString[0]; //Prefer X-down child if (size($tempString)>1) for ($y=0;$y-0.01 && $temp[1]<0.01 && $temp[2]>-0.01 && $temp[2]<0.01) { $fitJointChild[$i]=$tempString[$y]; break; } } //Analyze ChildSide if ($fitJointChild[$i]!="") { $fitJointChildSide[$i]="_R"; $temp=`xform -q -ws -t $fitJointChild[$i]`; if ($temp[0]<$sideTreshold && $temp[0]>(-1*$sideTreshold)) $fitJointChildSide[$i]="_M"; if ($temp[0]>$sideTreshold) $fitJointChildSide[$i]="_L"; } //TwistJoints, BendyJoints & inbetweenJoints Require a RlaChild if (`asRlaChild $fitJoints[$i]`!="") { //Analyze TwistJoints if (`attributeExists twistJoints $fitJoints[$i]`) $fitJointTwistJoints[$i]=`getAttr ($fitJoints[$i]+".twistJoints")`; //Analyze BendyJoints if (`attributeExists bendyJoints $fitJoints[$i]`) $fitJointBendyJoints[$i]=`getAttr ($fitJoints[$i]+".bendyJoints")`; //Analyze inbetweenJoints if (`attributeExists inbetweenJoints $fitJoints[$i]`) $fitJointInbetweenJoints[$i]=`getAttr ($fitJoints[$i]+".inbetweenJoints")`; if (`attributeExists unTwister $fitJoints[$i]`) if ($fitJointInbetweenJoints[$i]>0) $fitJointUnTwister[$i]=`getAttr ($fitJoints[$i]+".unTwister")`; } //Analyze UpTwistJoints if ($fitJointParent[$i]!="") if (`attributeExists twistJoints $fitJointParent[$i]`) if ($fitJoints[$i]==`asRlaChild $fitJointParent[$i]`) $fitJointUpTwistJoints[$i]=`getAttr ($fitJointParent[$i]+".twistJoints")`; //Analyze UpBendyJoints if ($fitJointParent[$i]!="") if (`attributeExists bendyJoints $fitJointParent[$i]`) if ($fitJoints[$i]==`asRlaChild $fitJointParent[$i]`) $fitJointUpBendyJoints[$i]=`getAttr ($fitJointParent[$i]+".bendyJoints")`; //Analyze global if (`attributeExists "global" $fitJoints[$i]`) { $fitJointGlobal[$i]=1; $fitJointGlobalValue[$i]=`getAttr ($fitJoints[$i]+".global")`; if (`attributeExists "globalTranslate" $fitJoints[$i]`) $fitJointGlobalTranslate[$i]=`getAttr ($fitJoints[$i]+".globalTranslate")`; } //Analyze Aim if (`attributeExists aim $fitJoints[$i]`) $fitJointsAim[$i]=1; //Analyze follow if (`attributeExists follow $fitJoints[$i]`) { $fitJointsFollow[$i]=`getAttr -asString ($fitJoints[$i]+".follow")`; $pos=`xform -q -ws -t $fitJointsFollow[$i]`; $fitJointsFollowSide[$i]="_M"; if ($pos[0]>$sideTreshold) $fitJointsFollowSide[$i]="_L"; if ($pos[0]<($sideTreshold*-1)) $fitJointsFollowSide[$i]="_R"; } //Analyze geoAttach if (`attributeExists geoAttach $fitJoints[$i]`) { $fitJointsAttachTo[$i]=`getAttr -asString ($fitJoints[$i]+".geoAttach")`; if (`gmatch $fitJointsAttachTo[$i] "*__*"` && !`objExists $fitJointsAttachTo[$i]`) { $tempString[0]=`substitute "__" $fitJointsAttachTo[$i] ":"`; if (`objExists $tempString[0]`) $fitJointsAttachTo[$i]=$tempString[0]; } if (`attributeExists geoAttachMode $fitJoints[$i]`) $fitJointsAttachMode[$i]=`getAttr -asString ($fitJoints[$i]+".geoAttachMode")`; } //Analyze aimAt if (`attributeExists aimAt $fitJoints[$i]`) { $fitJointsAimAt[$i]=`getAttr -asString ($fitJoints[$i]+".aimAt")`; $fitJointsAimAxis[$i]=`getAttr ($fitJoints[$i]+".aimAxis")`; $fitJointsAimUpAxis[$i]=`getAttr ($fitJoints[$i]+".aimUpAxis")`; } //Analyze aimConstraint $tempString=`listConnections -s 1 -d 0 -type aimConstraint $fitJoints[$i]`; if ($tempString[0]!="") { $fitJointsAimConstraint[$i]=$tempString[0]; $tempString=`listConnections -s 1 -d 0 ($fitJointsAimConstraint[$i]+".target[0].targetParentMatrix")`; $fitJointsAimAt[$i]=$tempString[0]; } //Analyze curveGuide if (`attributeExists curveGuide $fitJoints[$i]`) { $fitJointsCurveGuide[$i]=`getAttr -asString ($fitJoints[$i]+".curveGuide")`; if (`gmatch $fitJointsCurveGuide[$i] "*__*"` && !`objExists $fitJointsCurveGuide[$i]`) { $tempString[0]=`substitute "__" $fitJointsCurveGuide[$i] ":"`; if (`objExists $tempString[0]`) $fitJointsCurveGuide[$i]=$tempString[0]; } } //Analyze Wheel if (`attributeExists wheel $fitJoints[$i]`) $fitJointsWheel[$i]=1; //Analyze SegScaleComp if (`attributeExists segScaleComp $fitJoints[$i]`) { $fitJointUserSegScaleComp[$i]=1; $fitJointSegScaleComp[$i]=`getAttr ($fitJoints[$i]+".segScaleComp")`; } //Analyze IK $asFitJointIKInfo=`asFitJointIKInfo $fitJoints[$i]`; $fitJointIK[$i]=$asFitJointIKInfo[0]; $fitJointIKStartJoint[$i]=$asFitJointIKInfo[1]; $fitJointIKMiddleJoint[$i]=$asFitJointIKInfo[2]; $fitJointIKEndJoint[$i]=$asFitJointIKInfo[3]; $fitJointIKSolver[$i]=$asFitJointIKInfo[4]; if ($asFitJointIKInfo[5]!="") { $fitJointIKNumCtrls[$i]=$asFitJointIKInfo[5]; //fake IK-mid ctrl, to control mid locs if ($fitJointIKNumCtrls[$i]==2) { $fitJointIKNumCtrls[$i]=3; $fitJointIKNumCtrlsFakeMid[$i]=1; } } if ($fitJointIKStartJoint[$i]==$fitJoints[$i]) $isIKStart[$i]=1; if ($fitJointIKEndJoint[$i]==$fitJoints[$i]) if (!`gmatch $fitJointLabel[$i] "*Toes*"`) $isIKEnd[$i]=1; //Not to use UnTwister, if in IK, as the untwisting conflicts if ($fitJointIK[$i]!="" && $fitJointUnTwister[$i]) { warning ("Setting "+$fitJoints[$i]+".unTwister to \"0\", since FK-unTwister will not work for joint that is in IK-chain"); setAttr ($fitJoints[$i]+".unTwister") 0; $fitJointUnTwister[$i]=0; } //Analyze $isIKBelowIKEnd ($toes/qtoes) if ($fitJointIK[$i]!="") { $asFitJointIKInfo=`asFitJointIKInfo $fitJointIKStartJoint[$i]`; $IKEndJoint=$asFitJointIKInfo[3]; $tempString=`listRelatives -type joint -ad $fitJoints[$i]`; if ($fitJoints[$i]!=$IKEndJoint) if (!`stringArrayCount $IKEndJoint $tempString`) $isIKBelowIKEnd[$i]=1; } //Analyze $fitJointQtoes (for IKEndJoint) $fitJointQtoes[$i]=""; if ($isIKEnd[$i]) { $tempString=`listRelatives -type joint -ad $fitJoints[$i]`; for ($y=0;$y$lockCenterTolerance) { if (`getAttr -l ($fitJoints[$i]+".tx")`) $fitJointLockTx[$i]=1; if (`getAttr -l ($fitJoints[$i]+".ty")`) $fitJointLockTx[$i]=1; if (`getAttr -l ($fitJoints[$i]+".tz")`) $fitJointLockTx[$i]=1; if (`getAttr -l ($fitJoints[$i]+".rx")`) $fitJointLockRx[$i]=1; if (`getAttr -l ($fitJoints[$i]+".ry")`) $fitJointLockRy[$i]=1; if (`getAttr -l ($fitJoints[$i]+".rz")`) $fitJointLockRz[$i]=1; if (`getAttr -l ($fitJoints[$i]+".sx")`) $fitJointLockSx[$i]=1; if (`getAttr -l ($fitJoints[$i]+".sy")`) $fitJointLockSy[$i]=1; if (`getAttr -l ($fitJoints[$i]+".sz")`) $fitJointLockSz[$i]=1; } } //Analyze $centerBtwFeet if (`attributeExists centerBtwFeet Root`) $centerBtwFeet=`getAttr Root.centerBtwFeet`; //Analyze $ikLenght for ($i=0;$i>`; } $ikLenght[$i]=abs($ikLenght[$i]); } //height for ($a=0;$a<3;$a++) { $maxFitJoint=0; $minFitJoint=99; for ($i=0;$i$maxFitJoint) $maxFitJoint=$pos[$a]; if ($pos[$a]<$minFitJoint) $minFitJoint=$pos[$a]; } if ($a==0) $width=$maxFitJoint-$minFitJoint; if ($a==1) $height=$maxFitJoint-$minFitJoint; if ($a==2) $lenght=$maxFitJoint-$minFitJoint; } addAttr -ln height -at double Main; setAttr -l 1 Main.height $height; //$iconScaleFactor $iconScaleFactor=$height; if ($lenght>$height && $lenght>$width) $iconScaleFactor=$lenght; if ($width>$height && $width>$lenght) $iconScaleFactor=$width; $iconScaleFactor=$iconScaleFactor/80.0; //--Creation--// for ($b=1;$b>-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i0) { parent -w ($fitJointChild[$i]+$childSide);//parent to world first, as this ensures auto-inverseScale connect parent ($fitJointChild[$i]+$childSide) ($fitJoints[$i]+"Part"+($fitJointTwistJoints[$i])+$side); // setAttr ($fitJointChild[$i]+$childSide+".segmentScaleCompensate") 0; } } //Freeze rotation(move to jointOrient) //in some cases this is not accurate enought, and it will leave small values of jointOrient on axes that should be zero //updating to `constraint-align` with FitSkeleton (orientConstraint + set jointOrients) //temporary mirror FitSkeleton, to have Left side joints to `constraint-align` to $tempString=`listRelatives -ad -type joint FitSkeleton`; for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$iabs($jo[2])) { if ($jo[1]>0) $pa={0, 90,0}; if ($jo[1]<0) $pa={0,-90,0}; } if (abs($jo[1])0) $pa={0,0, 90}; if ($jo[2]<0) $pa={0,0,-90}; } setAttr ($startJoint+".preferredAngle") -type float3 ($pa[0]*-1) ($pa[1]*-1) ($pa[2]*-1); setAttr ($middleJoint+".preferredAngle") -type float3 $pa[0] $pa[1] $pa[2]; } */ $tempString=`ikHandle -n ("IK"+$fitJointIK[$i]+"Handle"+$side) -ccv 0 -ns 2 -sol $fitJointIKSolver[$i] -sj $startJoint -ee $endJoint`; rename $tempString[1] ("IK"+$fitJointIK[$i]+"Effector"+$side); setAttr -l 1 ("IK"+$fitJointIK[$i]+"Handle"+$side+".v") 0; setAttr -l 1 ("IK"+$fitJointIK[$i]+"Effector"+$side+".v") 0; setAttr ("IK"+$fitJointIK[$i]+"Effector"+$side+".rotateOrder") $fitJointRotOrder[$i]; if ($fitJointIKSolver[$i]=="ikRPsolver") { //controller asCreateController "IK" $fitJointIK[$i] $side $fitJoints[$i]; if ($fitJointQtoes[$i]!="") asAlign ("IKOffset"+$fitJointIK[$i]+$side) ($fitJointQtoes[$i]+$side) 1 0 0 0; parent ("IKOffset"+$fitJointIK[$i]+$side) IKHandleFollowMain; $parent="IK"+$fitJointIK[$i]+$side; if (`objExists ("IKUnFlip"+$fitJointIK[$i]+$side)`) $parent="IKUnFlip"+$fitJointIK[$i]+$side; parent ("IK"+$fitJointIK[$i]+"Handle"+$side) $parent; //pole asCreateController "Pole" $fitJointIK[$i] $side $fitJoints[$i]; asLockAttr ("Pole"+$fitJointIK[$i]+$side) 0 1 1 1; //place poleVector // $tempString=`listRelatives -c -type joint $fitJointIKStartJoint[$i]`; // $startJointChildJoint=$tempString[0]; createNode -n tempPoleVecPlacer1 transform; createNode -n tempPoleVecPlacer2 -p tempPoleVecPlacer1 transform; createNode -n tempPoleVecPlacer3 -p tempPoleVecPlacer2 transform; $tempString=`pointConstraint $fitJointIKStartJoint[$i] $fitJointIKEndJoint[$i] tempPoleVecPlacer1`; $pos=`xform -q -ws -t $fitJointIKMiddleJoint[$i]`; $pos2=`xform -q -ws -t $fitJointIKEndJoint[$i]`; $dist=`mag<<$pos[0]-$pos2[0],$pos[1]-$pos2[1],$pos[2]-$pos2[2]>>`; setAttr ($tempString[0]+"."+$fitJointIKStartJoint[$i]+"W0") $dist; $pos=`xform -q -ws -t $fitJointIKStartJoint[$i]`; $pos2=`xform -q -ws -t $fitJointIKMiddleJoint[$i]`; $dist=`mag<<$pos[0]-$pos2[0],$pos[1]-$pos2[1],$pos[2]-$pos2[2]>>`; setAttr ($tempString[0]+"."+$fitJointIKEndJoint[$i]+"W1") $dist; if ($fitJointIKMiddleJoint[$i]!=$fitJointIKStartJoint[$i]) { aimConstraint -aimVector 1 0 0 -upVector 0 1 0 -worldUpType "object" -worldUpObject $fitJointIKStartJoint[$i] $fitJointIKMiddleJoint[$i] tempPoleVecPlacer2; setAttr tempPoleVecPlacer3.tx $ikLenght[$i]; //Arms/Legs with excatly 0 rotation, will get PreferredAngles set to rotZ $pos=`xform -q -ws -t tempPoleVecPlacer2`; $pos2=`xform -q -ws -t $fitJointIKMiddleJoint[$i]`; $dist=`mag<<$pos[0]-$pos2[0],$pos[1]-$pos2[1],$pos[2]-$pos2[2]>>`; if ($dist<0.001 && $dist>-0.001) { delete tempPoleVecPlacer1_pointConstraint1; parent tempPoleVecPlacer1 $fitJointIKStartJoint[$i]; move -r -ls -wd 0 -1 0 tempPoleVecPlacer1; setAttr ("IKX"+$fitJointIKMiddleJoint[$i]+$side+".preferredAngle") -type float3 0 0 -90; } } else //no knee joint setAttr tempPoleVecPlacer3.tz $ikLenght[$i]; $temp=`xform -q -ws -t tempPoleVecPlacer3`; delete tempPoleVecPlacer1; xform -ws -t ($temp[0]*$b) $temp[1] $temp[2] ("PoleOffset"+$fitJointIK[$i]+$side); poleVectorConstraint ("Pole"+$fitJointIK[$i]+$side) ("IK"+$fitJointIK[$i]+"Handle"+$side); //in case of 3 joint-XigZag-IK, the default created IK-handle`s poleVector could be Flipped, reverse this by set handle_M.twist 180; if (size($IKJoints)>3) { $pos=`xform -q -ws -t ($fitJointIKMiddleJoint[$i]+$side)`; $pos2=`xform -q -ws -t ("IKX"+$fitJointIKMiddleJoint[$i]+$side)`; $dist=`mag<<$pos[0]-$pos2[0],$pos[1]-$pos2[1],$pos[2]-$pos2[2]>>`; if ($dist>0.01) { print ("// "+(size($IKJoints)-1)+" joint-XigZag-IK detected, setting \"IK"+$fitJointIK[$i]+"Handle"+$side+".twist\" to 180, to avoid IK-flip.\n"); setAttr ("IK"+$fitJointIK[$i]+"Handle"+$side+".twist") 180; } } $parent="IK"+$fitJointIK[$i]+$side; if (`objExists ("IKUnFlip"+$fitJointIK[$i]+$side)`) $parent="IKUnFlip"+$fitJointIK[$i]+$side; $tempString[0]=`createNode annotationShape`; $tempString=`listRelatives -p $tempString[0]`; string $direction=`rename $tempString[0] ("PoleAnnotation"+$fitJointIK[$i]+$side)`; setAttr ($direction+"Shape.overrideEnabled") 1; setAttr ($direction+"Shape.overrideDisplayType") 2; connectAttr Main.arrowVis ($direction+".v"); // $tempString=`listRelatives -c -type joint $fitJointIKStartJoint[$i]`; parent $direction ("IKX"+$fitJointIKMiddleJoint[$i]+$side); xform -os -t 0 0 0 -ro 0 0 0 -s 1 1 1 $direction; connectAttr ("Pole"+$fitJointIK[$i]+$side+"Shape.worldMatrix[0]") ($direction+"Shape.dagObjectMatrix[0]"); //orientCnstraint last segment to controller createNode -n ("IKFKAlignedOffset"+$fitJointIK[$i]+$side) -p $parent transform; createNode -n ("IKFKAligned"+$fitJointIK[$i]+$side) -p ("IKFKAlignedOffset"+$fitJointIK[$i]+$side) transform; asAlign ("IKFKAlignedOffset"+$fitJointIK[$i]+$side) ($fitJointIKEndJoint[$i]+$side) 0 1 0 0; orientConstraint ("IKFKAligned"+$fitJointIK[$i]+$side) ("IKX"+$fitJointIKEndJoint[$i]+$side); //$ikLocal if ($ikLocal[$i] && $ikLocalType[$i]==0)//$ikLocal=addCtrl { asCreateController "IKLocal" $fitJointIK[$i] $side $fitJoints[$i]; asAlign ("IKLocalOffset"+$fitJointIK[$i]+$side) ($fitJointIKEndJoint[$i]+$side) 0 1 0 0; parent ("IKLocalOffset"+$fitJointIK[$i]+$side) $parent; asLockAttr ("IKLocal"+$fitJointIK[$i]+$side) 1 0 1 1; parent ("IKFKAligned"+$fitJointIK[$i]+$side) ("IKLocal"+$fitJointIK[$i]+$side); if (`objExists ("IKLocalUnFlip"+$fitJointIK[$i]+$side)`) parent ("IKFKAligned"+$fitJointIK[$i]+$side) ("IKLocalUnFlip"+$fitJointIK[$i]+$side); } if ($ikLocal[$i] && $ikLocalType[$i]==1)//$ikLocal=nonZero { parent -w ("IKFKAlignedOffset"+$fitJointIK[$i]+$side); // asAlign ("IK"+$fitJointIK[$i]+$side) $fitJoints[$i] 0 1 0 0; // setAttr -type float3 ("IKFKAlignedOffset"+$fitJointIK[$i]+$side+".r") (90*$b) 0 180; createNode -n tempXform transform; asAlign tempXform ($fitJointIKMiddleJoint[$i]+$side) 1 1 0 0; // delete `aimConstraint -aimVector (1*$b) 0 0 -upVector 0 1 0 -worldUpType "object" -worldUpObject tempXform tempXform ("IK"+$fitJointIK[$i]+$side)`; delete `aimConstraint -aimVector 1 0 0 -upVector 0 1 0 -worldUpType "object" -worldUpObject tempXform tempXform ("IK"+$fitJointIK[$i]+$side)`; if (`gmatch $fitJointLabel[$i] "*Foot*"`) delete `aimConstraint -aimVector 0 1 0 -upVector 0 0 1 -worldUpVector 0 1 0 -worldUpType "objectrotation" -worldUpObject tempXform tempXform ("IK"+$fitJointIK[$i]+$side)`; delete tempXform; parent ("IKFKAlignedOffset"+$fitJointIK[$i]+$side) $parent; asAlign ("AlignIKTo"+$fitJointIKEndJoint[$i]+$side) ("IK"+$fitJointIK[$i]+$side) 0 1 0 0; } if ($ikLocal[$i] && $ikLocalType[$i]==2)//$ikLocal=localOrient { parent -w ("IKFKAlignedOffset"+$fitJointIK[$i]+$side); // asAlign ("IKOffset"+$fitJointIK[$i]+$side) ($fitJoints[$i]+$side) 0 1 0 0;//causes Warning Cycle createNode -n tempXform transform; asAlign tempXform ("FKX"+$fitJoints[$i]+$side) 0 1 0 0; parent -w ("IK"+$fitJointIK[$i]+"Handle"+$side); asAlign ("IKOffset"+$fitJointIK[$i]+$side) tempXform 0 1 0 0; parent ("IK"+$fitJointIK[$i]+"Handle"+$side) ("IKFKAlignedOffset"+$fitJointIK[$i]+$side) $parent; delete tempXform; setAttr -type float3 ("IKFKAlignedOffset"+$fitJointIK[$i]+$side+".r") 0 0 0; setAttr -type float3 ("AlignIKTo"+$fitJointIKEndJoint[$i]+$side+".r") 0 0 0; addAttr -k 0 -ln ikLocal -at bool -dv 1 ("IK"+$fitJointIK[$i]+$side); addAttr -k 0 -ln ikLocal -at bool -dv 1 ("IKExtra"+$fitJointIK[$i]+$side); addAttr -k 0 -ln ikLocal -at bool -dv 1 ("Pole"+$fitJointIK[$i]+$side); addAttr -k 0 -ln ikLocal -at bool -dv 1 ("PoleExtra"+$fitJointIK[$i]+$side); } } if ($fitJointIKSolver[$i]=="ikSplineSolver") { parent ("IK"+$fitJointIK[$i]+"Handle"+$side) IKHandle; // $numCVs=$fitJointIKNumCtrls[$i]*2; $numCVs=size($IKJoints); if ($fitJointIKNumCtrls[$i]==2) $numCVs=$numCVs+2;//2 extra middle CV when only 2 IKctrls string $crvCmd="curve -n IK"+$fitJointIK[$i]+"Curve"+$side+" -d 3"; if ($numCVs<4)//for less then 4cv`s change to degree==1 $crvCmd="curve -n IK"+$fitJointIK[$i]+"Curve"+$side+" -d 1"; for ($z=0;$z<$numCVs;$z++) $crvCmd+=" -p 0 0 0"; eval ($crvCmd); $tempString=`listRelatives -s ("IK"+$fitJointIK[$i]+"Curve"+$side)`; rename $tempString[0] ("IK"+$fitJointIK[$i]+"Curve"+$side+"Shape"); setAttr ("IK"+$fitJointIK[$i]+"Curve"+$side+"Shape.overrideEnabled") 1; setAttr ("IK"+$fitJointIK[$i]+"Curve"+$side+"Shape.overrideDisplayType") 1; parent ("IK"+$fitJointIK[$i]+"Curve"+$side) IKCurve; $tempString=`listRelatives -type joint -p ($fitJointIKStartJoint[$i]+$side)`; if ($tempString[0]=="") //Root $ikParentConstraintTo="IKSystem"; else { $ikParentConstraintTo="IKParentConstraintTo"+$tempString[0]; if (!`objExists $ikParentConstraintTo`) { createNode -n $ikParentConstraintTo -p IKSystem transform; if ($tempString[0]=="Root_M")//tails should be affected to LegLock as well parentConstraint LegLockConstrained $ikParentConstraintTo; else parentConstraint $tempString[0] $ikParentConstraintTo; } } createNode -n tempMotionPath motionPath; createNode -n tempPos transform; setAttr tempMotionPath.fractionMode 1; connectAttr ("IK"+$fitJointIK[$i]+"Curve"+$side+".worldSpace") tempMotionPath.geometryPath; connectAttr tempMotionPath.allCoordinates tempPos.t; connectAttr tempMotionPath.rotate tempPos.rotate; setAttr tempMotionPath.worldUpType 2; setAttr tempMotionPath.frontAxis $priAxisNr[$i]; setAttr tempMotionPath.upAxis $secAxisNr[$i]; setAttr tempMotionPath.worldUpVector $secNrmlX[$i] $secNrmlY[$i] $secNrmlZ[$i]; connectAttr ($fitJointIKStartJoint[$i]+$side+".worldMatrix[0]") tempMotionPath.worldUpMatrix; if ($side=="_L") setAttr tempMotionPath.inverseFront 1; // if ($side=="_L") // setAttr tempMotionPath.inverseUp 1; //create IKcv ctrls for ($z=0;$z<$numCVs;$z++) { spaceLocator -n ("IK"+$fitJointIK[$i]+"Locator"+$z+$side); setAttr -l 1 ("IK"+$fitJointIK[$i]+"Locator"+$z+$side+".v") 0; connectAttr ("IK"+$fitJointIK[$i]+"Locator"+$z+$side+"Shape.worldPosition[0]") ("IK"+$fitJointIK[$i]+"Curve"+$side+"Shape.controlPoints["+$z+"]"); $pos=`xform -q -ws -t $IKJoints[$z]`; xform -ws -t ($pos[0]*$b) $pos[1] $pos[2] ("IK"+$fitJointIK[$i]+"Locator"+$z+$side); if ($z!=0 && $z!=$numCVs-1) { asCreateController "Pole" ("cv"+$fitJointIK[$i]+$z) $side $fitJointIKStartJoint[$i]; rename ("Polecv"+$fitJointIK[$i]+$z+$side) ("IKcv"+$fitJointIK[$i]+$z+$side); rename ("PoleExtracv"+$fitJointIK[$i]+$z+$side) ("IKExtracv"+$fitJointIK[$i]+$z+$side); rename ("PoleOffsetcv"+$fitJointIK[$i]+$z+$side) ("IKOffsetcv"+$fitJointIK[$i]+$z+$side); asLockAttr ("IKcv"+$fitJointIK[$i]+$z+$side) 0 1 1 0; setAttr ("IKcv"+$fitJointIK[$i]+$z+$side+"Shape.overrideColor") 17; // xform -s 0.01 1 1 ("IKcv"+$fitJointIK[$i]+$z+$side+".cv[0:99]"); // connectAttr Main.ikCvVis ("IKOffsetcv"+$fitJointIK[$i]+$z+$side+".v"); asAlign ("IKOffsetcv"+$fitJointIK[$i]+$z+$side) ("IK"+$fitJointIK[$i]+"Locator"+$z+$side) 1 1 0 0; parent ("IK"+$fitJointIK[$i]+"Locator"+$z+$side) ("IKcv"+$fitJointIK[$i]+$z+$side); } } //orient IKcv ctrls for ($z=0;$z<$numCVs;$z++) if ($z!=0 && $z!=$numCVs-1) { setAttr "tempMotionPath.uValue" ((1.0/($numCVs-1))*$z); $rot=`xform -q -ws -ro tempPos`; xform -s 0.01 1 1 ("IKcv"+$fitJointIK[$i]+$z+$side+".cv[0:99]"); xform -ws -ro $rot[0] $rot[1] $rot[2] ("IKcv"+$fitJointIK[$i]+$z+$side+".cv[0:99]"); } //create IK ctrls for ($q=1;$q<$fitJointIKNumCtrls[$i]+1;$q++) { $ikControlNr=$q; asCreateController "IK" ($fitJointIK[$i]+$ikControlNr) $side $fitJointIKStartJoint[$i]; $parent="IK"+$fitJointIK[$i]+$ikControlNr+$side; if (`objExists ("IKUnFlip"+$fitJointIK[$i]+$ikControlNr+$side)`) $parent="IKUnFlip"+$fitJointIK[$i]+$ikControlNr+$side; createNode -n ("IK"+$fitJointIK[$i]+$ikControlNr+"LocalOrient0"+$side) transform; if ($q==1 || $q==$fitJointIKNumCtrls[$i])//Start and End { // xform -s 0.1 1 1 ("IK"+$fitJointIK[$i]+$ikControlNr+$side+".cv[0:99]"); // if ($ikLocal[$i]) { if ($fitJointAbsPriAxis[$i]=="X") xform -s 0.1 1 1 ("IK"+$fitJointIK[$i]+$ikControlNr+$side+".cv[0:99]"); if ($fitJointAbsPriAxis[$i]=="Y") xform -s 1 0.1 1 ("IK"+$fitJointIK[$i]+$ikControlNr+$side+".cv[0:99]"); if ($fitJointAbsPriAxis[$i]=="Z") xform -s 1 1 0.1 ("IK"+$fitJointIK[$i]+$ikControlNr+$side+".cv[0:99]"); } // else // xform -s 0.1 1 1 ("IK"+$fitJointIK[$i]+$ikControlNr+$side+".cv[0:99]"); if ($q==1) parent -r ("IK"+$fitJointIK[$i]+$ikControlNr+"LocalOrient0"+$side) ("FKX"+$fitJointIKStartJoint[$i]+$side); if ($q==$fitJointIKNumCtrls[$i]) parent -r ("IK"+$fitJointIK[$i]+$ikControlNr+"LocalOrient0"+$side) ("FKX"+$IKJoints[size($IKJoints)-2]+$side); parent -w ("IK"+$fitJointIK[$i]+$ikControlNr+"LocalOrient0"+$side); $rot=`xform -q -ws -ro ("IK"+$fitJointIK[$i]+$ikControlNr+"LocalOrient0"+$side)`; if ($ikLocal[$i]) xform -ws -ro $rot[0] $rot[1] $rot[2] ("IKOffset"+$fitJointIK[$i]+$ikControlNr+$side); else xform -ws -ro $rot[0] $rot[1] $rot[2] ("IK"+$fitJointIK[$i]+$ikControlNr+$side+".cv[0:99]"); if ($q==1) $alignToObject=$fitJointIKStartJoint[$i]; else $alignToObject=$fitJointIKEndJoint[$i]; delete `pointConstraint ($alignToObject+$side) ("IKOffset"+$fitJointIK[$i]+$ikControlNr+$side)`; } else//inbetween-spline-ik-ctrls { circle -n tempCircle -c 0 0 0 -nr $priNrmlX[$i] $priNrmlY[$i] $priNrmlZ[$i] -sw 360 -r (`getAttr ("IK"+$fitJointIK[$i]+$ikControlNr+$side+"Shape.controlPoints[0].xValue")`*1.2) -d 3 -ut 0 -tol 0.000393701 -s 8 -ch 0; parent -add -s tempCircleShape ("IK"+$fitJointIK[$i]+$ikControlNr+$side); delete tempCircle; delete ("IK"+$fitJointIK[$i]+$ikControlNr+$side+"Shape"); rename tempCircleShape ("IK"+$fitJointIK[$i]+$ikControlNr+$side+"Shape"); setAttr ("IK"+$fitJointIK[$i]+$ikControlNr+$side+"Shape.overrideEnabled") 1; setAttr ("IK"+$fitJointIK[$i]+$ikControlNr+$side+"Shape.overrideColor") 13; setAttr "tempMotionPath.uValue" ((1.0/($fitJointIKNumCtrls[$i]-1))*($q-1)); asAlign ("IK"+$fitJointIK[$i]+$ikControlNr+"LocalOrient0"+$side) tempPos 1 1 0 0; asAlign ("IKOffset"+$fitJointIK[$i]+$ikControlNr+$side) ("IK"+$fitJointIK[$i]+$ikControlNr+"LocalOrient0"+$side) 1 0 0 0; if ($ikLocal[$i]) asAlign ("IKOffset"+$fitJointIK[$i]+$ikControlNr+$side) ("IK"+$fitJointIK[$i]+$ikControlNr+"LocalOrient0"+$side) 0 1 0 0; else { $rot=`xform -q -ws -ro ("IK"+$fitJointIK[$i]+$ikControlNr+"LocalOrient0"+$side)`; xform -ws -ro $rot[0] $rot[1] $rot[2] ("IK"+$fitJointIK[$i]+$ikControlNr+$side+".cv[0:99]"); } } parent ("IK"+$fitJointIK[$i]+$ikControlNr+"LocalOrient0"+$side) $parent; setAttr ("IK"+$fitJointIK[$i]+$ikControlNr+"LocalOrient0"+$side+".t") -type float3 0 0 0; if ($q==1) { $parent2="IK"+$fitJointIK[$i]+"1"+$side; if (`objExists ("IKUnFlip"+$fitJointIK[$i]+"1"+$side)`) $parent2="IKUnFlip"+$fitJointIK[$i]+"1"+$side; parent ("IK"+$fitJointIK[$i]+"Locator"+"0"+$side) $parent2; } if ($q==$fitJointIKNumCtrls[$i]) { $parent2="IK"+$fitJointIK[$i]+$fitJointIKNumCtrls[$i]+$side; if (`objExists ("IKUnFlip"+$fitJointIK[$i]+$fitJointIKNumCtrls[$i]+$side)`) $parent2="IKUnFlip"+$fitJointIK[$i]+$fitJointIKNumCtrls[$i]+$side; parent ("IK"+$fitJointIK[$i]+"Locator"+($numCVs-1)+$side) $parent2; } //LocalOrient1 & 2, for scaling createNode -n ("IK"+$fitJointIK[$i]+$ikControlNr+"LocalOrient1"+$side) -p $parent transform; if ($ikControlNr==$fitJointIKNumCtrls[$i]) asAlign ("IK"+$fitJointIK[$i]+$ikControlNr+"LocalOrient1"+$side) ("FKX"+$fitJointIKEndJoint[$i]+$side) 0 1 0 0; else asAlign ("IK"+$fitJointIK[$i]+$ikControlNr+"LocalOrient1"+$side) ("FKX"+$fitJointIKStartJoint[$i]+$side) 0 1 0 0; createNode -n ("IK"+$fitJointIK[$i]+$ikControlNr+"LocalOrient2"+$side) -p ("IK"+$fitJointIK[$i]+$ikControlNr+"LocalOrient1"+$side) transform; } for ($q=1;$q<$fitJointIKNumCtrls[$i]+1;$q++) { $ikControlNr=$q; asCreateController "IKhybrid" ($fitJointIK[$i]+$ikControlNr) $side $fitJointIKStartJoint[$i]; asAlign ("IKhybridOffset"+$fitJointIK[$i]+$ikControlNr+$side) ("FKX"+$fitJointIKStartJoint[$i]+$side) 1 1 0 0; if ($ikControlNr>1) asAlign ("IKhybridOffset"+$fitJointIK[$i]+$ikControlNr+$side) ("IK"+$fitJointIK[$i]+$ikControlNr+"LocalOrient0"+$side) 0 1 0 0; if ($ikControlNr==1) { parent ("IKhybridOffset"+$fitJointIK[$i]+$ikControlNr+$side) $fitJointIKStartJoint[$i]; parent ("IKhybridOffset"+$fitJointIK[$i]+$ikControlNr+$side) IKHandle; } else delete `pointConstraint ("IK"+$fitJointIK[$i]+$ikControlNr+$side) ("IKhybridOffset"+$fitJointIK[$i]+$ikControlNr+$side)`; } //IKhybrid parenting $parent="IKhybrid"+$fitJointIK[$i]+($fitJointIKNumCtrls[$i])+$side; if (`objExists ("IKhybridUnFlip"+$fitJointIK[$i]+($fitJointIKNumCtrls[$i])+$side)`) $parent="IKhybridUnFlip"+$fitJointIK[$i]+($fitJointIKNumCtrls[$i])+$side; parent ("IKOffset"+$fitJointIK[$i]+$fitJointIKNumCtrls[$i]+$side) $parent; //adding IKHybrid affected SplineIK follow Off, base of Spline not following, instead of just end of Spline not following. //changing 1st IK ctrl to be not parented to hybrid // parent ("IKOffset"+$fitJointIK[$i]+"1"+$side) ("IKhybrid"+$fitJointIK[$i]+"1"+$side); parent ("IKOffset"+$fitJointIK[$i]+"1"+$side) ("IKhybridOffset"+$fitJointIK[$i]+"1"+$side); for ($q=$fitJointIKNumCtrls[$i];$q>1;$q--) { $parent="IKhybrid"+$fitJointIK[$i]+($q-1)+$side; if (`objExists ("IKhybridUnFlip"+$fitJointIK[$i]+($q-1)+$side)`) $parent="IKhybridUnFlip"+$fitJointIK[$i]+($q-1)+$side; parent ("IKhybridOffset"+$fitJointIK[$i]+$q+$side) $parent; } //IkcvVis (both from ikCvVis attribute and from FKIK.IKVis addAttr -k 1 -ln ikCvVis -at bool -dv 0 ("IK"+$fitJointIK[$i]+$fitJointIKNumCtrls[$i]+$side); addAttr -k 1 -ln ikHybridVis -at bool -dv 1 ("IK"+$fitJointIK[$i]+$fitJointIKNumCtrls[$i]+$side); setAttr -k 0 -cb 1 ("IK"+$fitJointIK[$i]+$fitJointIKNumCtrls[$i]+$side+".ikHybridVis"); setAttr -k 0 -cb 1 ("IK"+$fitJointIK[$i]+$fitJointIKNumCtrls[$i]+$side+".ikCvVis"); for ($z=0;$z<$numCVs;$z++) if ($z!=0 && $z!=$numCVs-1) connectAttr ("IK"+$fitJointIK[$i]+$fitJointIKNumCtrls[$i]+$side+".ikCvVis") ("IKOffsetcv"+$fitJointIK[$i]+$z+$side+".v"); //Ikcv constrained, to the 2 nearest IKctrls, and contrain-weighted according to distance to IKctrls for ($z=1;$z<$numCVs-1;$z++) { $pos=`xform -q -ws -t ("IKcv"+$fitJointIK[$i]+$z+$side)`; //$minDist1 $minDist1=9999; for ($q=1;$q<$fitJointIKNumCtrls[$i]+1;$q++) { $pos2=`xform -q -ws -t ("IK"+$fitJointIK[$i]+$q+$side)`; $dist=`mag<<$pos[0]-$pos2[0],$pos[1]-$pos2[1],$pos[2]-$pos2[2]>>`; if ($dist<$minDist1) { $closestIkCtrlNr1=$q; $minDist1=$dist; } } //$minDist2 $minDist2=9999; for ($q=1;$q<$fitJointIKNumCtrls[$i]+1;$q++) { if ($q==$closestIkCtrlNr1) continue; $pos2=`xform -q -ws -t ("IK"+$fitJointIK[$i]+$q+$side)`; $dist=`mag<<$pos[0]-$pos2[0],$pos[1]-$pos2[1],$pos[2]-$pos2[2]>>`; if ($dist<$minDist2) { $closestIkCtrlNr2=$q; $minDist2=$dist; } } //ensure $closestIkCtrlNr1 & $closestIkCtrlNr2 are sorted, for stiffness to work if ($z==1 && $closestIkCtrlNr2=="1") { $tempString[0]=$closestIkCtrlNr1; $tempString[1]=$minDist1; $closestIkCtrlNr1=$closestIkCtrlNr2; $minDist1=$minDist2; $closestIkCtrlNr2=$tempString[0]; $minDist2=$tempString[1]; } parentConstraint -mo ("IK"+$fitJointIK[$i]+$closestIkCtrlNr1+$side) ("IK"+$fitJointIK[$i]+$closestIkCtrlNr2+$side) ("IKOffsetcv"+$fitJointIK[$i]+$z+$side); setAttr ("IKOffsetcv"+$fitJointIK[$i]+$z+$side+"_parentConstraint1.IK"+$fitJointIK[$i]+$closestIkCtrlNr1+$side+"W0") ($minDist2/($minDist1+$minDist2)); setAttr ("IKOffsetcv"+$fitJointIK[$i]+$z+$side+"_parentConstraint1.IK"+$fitJointIK[$i]+$closestIkCtrlNr2+$side+"W1") ($minDist1/($minDist1+$minDist2)); //stiffness if ($z==1 || $z==$numCVs-2) { if ($z==1) $stiffCtrl1Nr=1; if ($z==$numCVs-2) $stiffCtrl1Nr=$fitJointIKNumCtrls[$i]; addAttr -k 1 -ln stiff -at double -min 0 -max 10 -dv 5 ("IK"+$fitJointIK[$i]+$stiffCtrl1Nr+$side); createNode -n ("IKStiff"+$fitJointIK[$i]+$stiffCtrl1Nr+"SetRange"+$side) setRange; connectAttr ("IK"+$fitJointIK[$i]+$stiffCtrl1Nr+$side+".stiff") ("IKStiff"+$fitJointIK[$i]+$stiffCtrl1Nr+"SetRange"+$side+".valueX"); connectAttr ("IK"+$fitJointIK[$i]+$stiffCtrl1Nr+$side+".stiff") ("IKStiff"+$fitJointIK[$i]+$stiffCtrl1Nr+"SetRange"+$side+".valueY"); setAttr ("IKStiff"+$fitJointIK[$i]+$stiffCtrl1Nr+"SetRange"+$side+".minX") `getAttr ("IKOffsetcv"+$fitJointIK[$i]+$z+$side+"_parentConstraint1.IK"+$fitJointIK[$i]+$closestIkCtrlNr1+$side+"W0")`; setAttr ("IKStiff"+$fitJointIK[$i]+$stiffCtrl1Nr+"SetRange"+$side+".minY") `getAttr ("IKOffsetcv"+$fitJointIK[$i]+$z+$side+"_parentConstraint1.IK"+$fitJointIK[$i]+$closestIkCtrlNr2+$side+"W1")`; setAttr ("IKStiff"+$fitJointIK[$i]+$stiffCtrl1Nr+"SetRange"+$side+".maxX") 1; setAttr ("IKStiff"+$fitJointIK[$i]+$stiffCtrl1Nr+"SetRange"+$side+".oldMax") -type float3 10 10 0; connectAttr ("IKStiff"+$fitJointIK[$i]+$stiffCtrl1Nr+"SetRange"+$side+".outValueX") ("IKOffsetcv"+$fitJointIK[$i]+$z+$side+"_parentConstraint1.IK"+$fitJointIK[$i]+$closestIkCtrlNr1+$side+"W0"); connectAttr ("IKStiff"+$fitJointIK[$i]+$stiffCtrl1Nr+"SetRange"+$side+".outValueY") ("IKOffsetcv"+$fitJointIK[$i]+$z+$side+"_parentConstraint1.IK"+$fitJointIK[$i]+$closestIkCtrlNr2+$side+"W1"); } } delete tempPos tempMotionPath; connectAttr -f ("IK"+$fitJointIK[$i]+"Curve"+$side+".worldSpace[0]") ("IK"+$fitJointIK[$i]+"Handle"+$side+".inCurve"); createNode -n ("IKCurveInfo"+$fitJointIK[$i]+$side) curveInfo; connectAttr ("IK"+$fitJointIK[$i]+"Curve"+$side+"Shape.worldSpace[0]") ("IKCurveInfo"+$fitJointIK[$i]+$side+".inputCurve"); //IK spline stretchy addAttr -k 1 -ln stretchy -at double -min 0 -max 10 -dv 10 ("IK"+$fitJointIK[$i]+$fitJointIKNumCtrls[$i]+$side); createNode -n ("IKCurveInfoNormalize"+$fitJointIK[$i]+$side) multiplyDivide; setAttr ("IKCurveInfoNormalize"+$fitJointIK[$i]+$side+".operation") 2; createNode -n ("IKCurveInfoAllMultiply"+$fitJointIK[$i]+$side) multiplyDivide; setAttr ("IKCurveInfoAllMultiply"+$fitJointIK[$i]+$side+".operation") 2; connectAttr ("IKCurveInfoNormalize"+$fitJointIK[$i]+$side+".outputX") ("IKCurveInfoAllMultiply"+$fitJointIK[$i]+$side+".input1X"); connectAttr MainScaleMultiplyDivide.outputX ("IKCurveInfoAllMultiply"+$fitJointIK[$i]+$side+".input2X"); connectAttr ("IKCurveInfo"+$fitJointIK[$i]+$side+".arcLength") ("IKCurveInfoNormalize"+$fitJointIK[$i]+$side+".input1X"); setAttr ("IKCurveInfoNormalize"+$fitJointIK[$i]+$side+".input2X") `getAttr ("IKCurveInfo"+$fitJointIK[$i]+$side+".arcLength")`; createNode -n ("stretchy"+$fitJointIK[$i]+"UnitConversion"+$side) unitConversion; setAttr ("stretchy"+$fitJointIK[$i]+"UnitConversion"+$side+".conversionFactor") 0.1; connectAttr ("IK"+$fitJointIK[$i]+$fitJointIKNumCtrls[$i]+$side+".stretchy") ("stretchy"+$fitJointIK[$i]+"UnitConversion"+$side+".input"); createNode -n ("stretchy"+$fitJointIK[$i]+"Reverse"+$side) reverse; connectAttr ("stretchy"+$fitJointIK[$i]+"UnitConversion"+$side+".output") ("stretchy"+$fitJointIK[$i]+"Reverse"+$side+".inputX"); select `listRelatives -ad -type joint $startJoint`; select -d ("IKSp"+$fitJointIKEndJoint[$i]+$side); $tempString=`ls -sl`; for ($x=0;$x0) { pointConstraint -mo ("IKAc"+$IKJoints[$y]+$side) ("IKAc"+$IKJoints[$y]+"FollowOffset"+$side); orientConstraint -mo ("IKAc"+$IKJoints[$y]+$side) ("IKAc"+$IKJoints[$y]+"FollowOffset"+$side); } parentConstraint ("IKAc"+$IKJoints[$y]+"FollowOffset"+$side) ("IKX"+$IKJoints[$y]+$side); //connect scale so the Offset scales along connectAttr ("IKCurveInfoNormalize"+$fitJointIK[$i]+$side+".output.outputX") ("IKAc"+$IKJoints[$y]+$side+".sx"); connectAttr ("IKCurveInfoNormalize"+$fitJointIK[$i]+$side+".output.outputX") ("IKAc"+$IKJoints[$y]+$side+".sy"); connectAttr ("IKCurveInfoNormalize"+$fitJointIK[$i]+$side+".output.outputX") ("IKAc"+$IKJoints[$y]+$side+".sz"); } //changing 1st IK joint due to FixedOrient // parent ("IKAc"+$fitJointIKStartJoint[$i]+"FollowOffset"+$side) IKJoints; //Constraint to IKSp jointChain for ($y=0;$y0) { pointConstraint -mo ("IKSp"+$IKJoints[$y]+$side) ("IKSp"+$IKJoints[$y]+"FollowOffset"+$side); orientConstraint -mo ("IKSp"+$IKJoints[$y]+$side) ("IKSp"+$IKJoints[$y]+"FollowOffset"+$side); } parentConstraint ("IKSp"+$IKJoints[$y]+"FollowOffset"+$side) ("IKX"+$IKJoints[$y]+$side); connectAttr ("stretchy"+$fitJointIK[$i]+"UnitConversion"+$side+".output") ("IKX"+$IKJoints[$y]+$side+"_parentConstraint1.IKAc"+$IKJoints[$y]+"FollowOffset"+$side+"W0"); connectAttr ("stretchy"+$fitJointIK[$i]+"Reverse"+$side+".outputX") ("IKX"+$IKJoints[$y]+$side+"_parentConstraint1.IKSp"+$IKJoints[$y]+"FollowOffset"+$side+"W1"); if ($IKJoints[$y]==$fitJointIKEndJoint[$i]) //fixedEnd replacement (always fixedEnd) { delete ("IKX"+$IKJoints[$y]+$side+"_parentConstraint1"); $tempString=`pointConstraint ("IKSp"+$IKJoints[$y]+"FollowOffset"+$side) ("IK"+$fitJointIK[$i]+$fitJointIKNumCtrls[$i]+"LocalOrient2"+$side) ("IKX"+$IKJoints[$y]+$side)`; $constraint=$tempString[0]; $attrs=`listAttr -k -ud $constraint`; connectAttr ("stretchy"+$fitJointIK[$i]+"Reverse"+$side+".outputX") ($tempString[0]+"."+$attrs[0]); connectAttr ("stretchy"+$fitJointIK[$i]+"UnitConversion"+$side+".output") ($tempString[0]+"."+$attrs[1]); //not sure why this was change, but now qpeds gets non-def pose warning, so chaning back //chaning this again, to remove -mo, as dragon got non-def pose warning orientConstraint ("IK"+$fitJointIK[$i]+$fitJointIKNumCtrls[$i]+"LocalOrient2"+$side) ("IKX"+$IKJoints[$y]+$side); // orientConstraint -mo ("IK"+$fitJointIK[$i]+$fitJointIKNumCtrls[$i]+"LocalOrient2"+$side) ("IKX"+$IKJoints[$y]+$side); // orientConstraint -mo ("IK"+$fitJointIK[$i]+$fitJointIKNumCtrls[$i]+$side) ("IKX"+$IKJoints[$y]+$side); } else parentConstraint ("IKSp"+$IKJoints[$y]+"FollowOffset"+$side) ("IKX"+$IKJoints[$y]+$side); } //changing 1st IK joint due to FixedOrient // parent ("IKSp"+$fitJointIKStartJoint[$i]+"FollowOffset"+$side) IKJoints; //adding FixedOrient Attribute added to first IK controller createNode -n ("IKFixedOrient"+$fitJointIKStartJoint[$i]+$side) -p ("IKfake0"+$fitJointIK[$i]+$side) transform; createNode -n ("IK"+$fitJointIK[$i]+"1"+"LocalOrient3"+$side) -p ("IK"+$fitJointIK[$i]+"1"+"LocalOrient2"+$side) transform; // asAlign ("IK"+$fitJointIK[$i]+"1"+"LocalOrient3"+$side) ("IKfake0"+$fitJointIK[$i]+$side) 1 1 0 0; //was causing tail misaligment on spinosaurus asAlign ("IK"+$fitJointIK[$i]+"1"+"LocalOrient3"+$side) ("IKfake0"+$fitJointIK[$i]+$side) 1 0 0 0; createNode -n ("IKNonFixedOrient"+$fitJointIKStartJoint[$i]+$side) -p ("IK"+$fitJointIK[$i]+"1"+"LocalOrient3"+$side) transform; parent ("IKNonFixedOrient"+$fitJointIKStartJoint[$i]+$side) ("IKfake0"+$fitJointIK[$i]+$side); orientConstraint ("IKNonFixedOrient"+$fitJointIKStartJoint[$i]+$side) ("IK"+$fitJointIK[$i]+"1"+"LocalOrient3"+$side) ("IKFixedOrient"+$fitJointIKStartJoint[$i]+$side); addAttr -k 1 -ln "FixedOrient" -at double -min 0 -max 10 -dv 0 ("IK"+$fitJointIK[$i]+"1"+$side); asUnitConvertAndReverse ("IKFixedOrient"+$fitJointIK[$i]+"1"+$side) ("IK"+$fitJointIK[$i]+"1"+$side+".FixedOrient"); connectAttr ("IKFixedOrient"+$fitJointIK[$i]+"1"+$side+"Reverse.outputX") ("IKFixedOrient"+$fitJointIKStartJoint[$i]+$side+"_orientConstraint1.IKNonFixedOrient"+$fitJointIKStartJoint[$i]+$side+"W0"); connectAttr ("IKFixedOrient"+$fitJointIK[$i]+"1"+$side+"UnitConversion.output") ("IKFixedOrient"+$fitJointIKStartJoint[$i]+$side+"_orientConstraint1.IK"+$fitJointIK[$i]+"1"+"LocalOrient3"+$side+"W1"); parent ("IKAc"+$fitJointIKStartJoint[$i]+"FollowOffset"+$side) ("IKSp"+$fitJointIKStartJoint[$i]+"FollowOffset"+$side) ("IKFixedOrient"+$fitJointIKStartJoint[$i]+$side); } $tempString=`listRelatives -p ($fitJointIKStartJoint[$i]+$side)`; string $ikParent=$tempString[0]; if ($fitJointIKSolver[$i]=="ikRPsolver") { //PoleAim (PoleLeg avoid flipping in the forward plane) if (`gmatch $fitJointIK[$i] "*Leg*"`) { createNode -n ("PoleAim"+$fitJointIK[$i]+$side) transform; asAlign ("PoleAim"+$fitJointIK[$i]+$side) ("IKX"+$fitJointIKStartJoint[$i]+$side) 1 0 0 0; // if ($msLegAim[$i]!="") // asAlign ("PoleAim"+$fitJointIK[$i]+$side) ($msLegAim[$i]+$side) 1 0 0 0; $tempString=`aimConstraint -aimVector ($priNrmlX[$i]*$b) ($priNrmlY[$i]*$b) ($priNrmlZ[$i]*$b) -upVector $terNrmlX[$i] $terNrmlY[$i] $terNrmlZ[$i] -worldUpVector $terNrmlX[$i] $terNrmlY[$i] $terNrmlZ[$i] -worldUpType "objectrotation" -worldUpObject ("IKFKAlignedOffset"+$fitJointIK[$i]+$side) ("IK"+$fitJointIK[$i]+$side) ("PoleAim"+$fitJointIK[$i]+$side)`; $constraint=$tempString[0]; parent ("PoleAim"+$fitJointIK[$i]+$side) ("IKHandle"); // pointConstraint Root_M ("PoleAim"+$fitJointIK[$i]+$side); // pointConstraint -mo $ikParent ("PoleAim"+$fitJointIK[$i]+$side);//this was used in 5.820 and cause polePos to scew upon rot Main.ry 90, so reverting pointConstraint $ikParent ("PoleAim"+$fitJointIK[$i]+$side); } //Follow if (!`gmatch $fitJointIK[$i] "*Leg*"`) { asFollow ("IK"+$fitJointIK[$i]+$side) ("IKOffset"+$fitJointIK[$i]+$side) $ikParent; } if (`gmatch $fitJointIK[$i] "*Leg*"`) asFollow ("Pole"+$fitJointIK[$i]+$side) ("PoleOffset"+$fitJointIK[$i]+$side) ("PoleAim"+$fitJointIK[$i]+$side); else asFollow ("Pole"+$fitJointIK[$i]+$side) ("PoleOffset"+$fitJointIK[$i]+$side) ("IK"+$fitJointIK[$i]+$side); } } //Advanced FKIK for ($b=1;$b>-2;$b=$b-2) for ($i=0;$i>`*$b; setAttr ("FKIK"+$fitJointIK[$i]+$side+".translate"+$fitJointAbsTerAxis[$i]) (((`getAttr ($fitJoints[$i]+".fat")`*`getAttr ($fitJoints[$i]+".fatWidth")`*$b)+($dist/2.0))*$terAxisMult[$i]); } //ensure its moved to `outside` direction if ($side!="_M") { $pos=`xform -q -ws -t ($fitJointIKStartJoint[$i]+$side)`; $pos2=`xform -q -ws -t ("FKIK"+$fitJointIK[$i]+$side)`; if ($side=="_R" && $pos2[0]>$pos[0]) setAttr ("FKIK"+$fitJointIK[$i]+$side+".translate"+$fitJointAbsTerAxis[$i]) (`getAttr ("FKIK"+$fitJointIK[$i]+$side+".translate"+$fitJointAbsTerAxis[$i])`*-1); if ($side=="_L" && $pos2[0]<$pos[0]) setAttr ("FKIK"+$fitJointIK[$i]+$side+".translate"+$fitJointAbsTerAxis[$i]) (`getAttr ("FKIK"+$fitJointIK[$i]+$side+".translate"+$fitJointAbsTerAxis[$i])`*-1); } parent ("FKIK"+$fitJointIK[$i]+$side) ("FKIKParentConstraint"+$fitJointIK[$i]+$side); asLockAttr ("FKIK"+$fitJointIK[$i]+$side) 1 1 1 1; addAttr -k 1 -ln FKIKBlend -at double -min 0 -max 10 -dv 0 ("FKIK"+$fitJointIK[$i]+$side); addAttr -k 1 -ln autoVis -at bool -dv 1 ("FKIK"+$fitJointIK[$i]+$side); setAttr -k 0 -cb 1 ("FKIK"+$fitJointIK[$i]+$side+".autoVis"); addAttr -k 1 -ln FKVis -at bool -dv 1 ("FKIK"+$fitJointIK[$i]+$side); addAttr -k 1 -ln IKVis -at bool -dv 1 ("FKIK"+$fitJointIK[$i]+$side); addAttr -ln startJoint -dt "string" ("FKIK"+$fitJointIK[$i]+$side); setAttr -l 1 -type "string" ("FKIK"+$fitJointIK[$i]+$side+".startJoint") $fitJointIKStartJoint[$i]; addAttr -ln middleJoint -dt "string" ("FKIK"+$fitJointIK[$i]+$side); setAttr -l 1 -type "string" ("FKIK"+$fitJointIK[$i]+$side+".middleJoint") $fitJointIKMiddleJoint[$i]; addAttr -ln endJoint -dt "string" ("FKIK"+$fitJointIK[$i]+$side); setAttr -l 1 -type "string" ("FKIK"+$fitJointIK[$i]+$side+".endJoint") $fitJointIKEndJoint[$i]; createNode -n ("FKIKBlend"+$fitJointIK[$i]+"UnitConversion"+$side) unitConversion; setAttr ("FKIKBlend"+$fitJointIK[$i]+"UnitConversion"+$side+".conversionFactor") 0.1; connectAttr ("FKIK"+$fitJointIK[$i]+$side+".FKIKBlend") ("FKIKBlend"+$fitJointIK[$i]+"UnitConversion"+$side+".input"); createNode -n ("FKIKBlend"+$fitJointIK[$i]+"Reverse"+$side) reverse; connectAttr ("FKIKBlend"+$fitJointIK[$i]+"UnitConversion"+$side+".output") ("FKIKBlend"+$fitJointIK[$i]+"Reverse"+$side+".inputX"); createNode -n ("FKIKBlend"+$fitJointIK[$i]+"Condition"+$side) condition; createNode -n ("FKIKBlend"+$fitJointIK[$i]+"setRange"+$side) setRange; setAttr ("FKIKBlend"+$fitJointIK[$i]+"setRange"+$side+".minX") 10; setAttr ("FKIKBlend"+$fitJointIK[$i]+"setRange"+$side+".oldMaxX") 10; connectAttr ("FKIK"+$fitJointIK[$i]+$side+".autoVis") ("FKIKBlend"+$fitJointIK[$i]+"Condition"+$side+".firstTerm"); connectAttr ("FKIK"+$fitJointIK[$i]+$side+".IKVis") ("FKIKBlend"+$fitJointIK[$i]+"Condition"+$side+".colorIfTrueR"); connectAttr ("FKIK"+$fitJointIK[$i]+$side+".FKVis") ("FKIKBlend"+$fitJointIK[$i]+"Condition"+$side+".colorIfTrueG"); connectAttr ("FKIK"+$fitJointIK[$i]+$side+".FKIKBlend") ("FKIKBlend"+$fitJointIK[$i]+"setRange"+$side+".valueX"); connectAttr ("FKIK"+$fitJointIK[$i]+$side+".FKIKBlend") ("FKIKBlend"+$fitJointIK[$i]+"Condition"+$side+".colorIfFalseR"); connectAttr ("FKIKBlend"+$fitJointIK[$i]+"setRange"+$side+".outValueX") ("FKIKBlend"+$fitJointIK[$i]+"Condition"+$side+".colorIfFalseG"); if ($fitJointIKSolver[$i]=="ikRPsolver") { connectAttr -f ("FKIKBlend"+$fitJointIK[$i]+"Condition"+$side+".outColorR") ("IKOffset"+$fitJointIK[$i]+$side+".visibility"); connectAttr -f ("FKIKBlend"+$fitJointIK[$i]+"Condition"+$side+".outColorR") ("PoleOffset"+$fitJointIK[$i]+$side+".visibility"); } if ($fitJointIKSolver[$i]=="ikSplineSolver") { for ($z=1;$z<$fitJointIKNumCtrls[$i]+1;$z++) // connectAttr -f ("FKIKBlend"+$fitJointIK[$i]+"Condition"+$side+".outColorR") ("IKOffset"+$fitJointIK[$i]+$z+$side+".visibility"); //changed, as "paralell mode" makes the connected visibility cause the node to not update, so FKIKSwitch would cause IK to not follow RootX_M //(when Switch to FK the switch back to IK) connectAttr -f ("FKIKBlend"+$fitJointIK[$i]+"Condition"+$side+".outColorR") ("IK"+$fitJointIK[$i]+$z+$side+"Shape.visibility"); connectAttr -f ("FKIKBlend"+$fitJointIK[$i]+"Condition"+$side+".outColorR") ("IK"+$fitJointIK[$i]+"Curve"+$side+".visibility"); setAttr ("IK"+$fitJointIK[$i]+"Curve"+$side+".overrideEnabled") 1; setAttr ("IK"+$fitJointIK[$i]+"Curve"+$side+".overrideDisplayType") 1; createNode -n ("FKIKBlend"+$fitJointIK[$i]+"HybridVisPMA"+$side) plusMinusAverage; setAttr ("FKIKBlend"+$fitJointIK[$i]+"HybridVisPMA"+$side+".operation") 3; // connectAttr ("IK"+$fitJointIK[$i]+"1"+$side+"Shape.visibility") ("FKIKBlend"+$fitJointIK[$i]+"HybridVisPMA"+$side+".input1D[0]"); // connectAttr ("FKIKBlend"+$fitJointIK[$i]+"Condition"+$side+".outColorR") ("FKIKBlend"+$fitJointIK[$i]+"HybridVisPMA"+$side+".input1D[0]"); //was attempt to move away from using another shape`s vis as source, as it could be curveSwapped, but gets 0-10 range instead of 0-1 //so UnitConversion this to 0-1 range createNode -n ("FKIKBlend"+$fitJointIK[$i]+"ConditionUnitConversion"+$side) unitConversion; setAttr ("FKIKBlend"+$fitJointIK[$i]+"ConditionUnitConversion"+$side+".conversionFactor") 0.1; connectAttr ("FKIKBlend"+$fitJointIK[$i]+"Condition"+$side+".outColorR") ("FKIKBlend"+$fitJointIK[$i]+"ConditionUnitConversion"+$side+".input"); connectAttr -f ("FKIKBlend"+$fitJointIK[$i]+"ConditionUnitConversion"+$side+".output") ("FKIKBlend"+$fitJointIK[$i]+"HybridVisPMA"+$side+".input1D[0]"); connectAttr ("IK"+$fitJointIK[$i]+$fitJointIKNumCtrls[$i]+$side+".ikHybridVis") ("FKIKBlend"+$fitJointIK[$i]+"HybridVisPMA"+$side+".input1D[1]"); setAttr ("FKIKBlend"+$fitJointIK[$i]+"HybridVisPMA"+$side+".input1D[2]") -0.5; for ($q=1;$q<$fitJointIKNumCtrls[$i]+1;$q++) connectAttr ("FKIKBlend"+$fitJointIK[$i]+"HybridVisPMA"+$side+".output1D") ("IKhybrid"+$fitJointIK[$i]+$q+$side+"Shape.v"); } connectAttr -f ("FKIKBlend"+$fitJointIK[$i]+"Condition"+$side+".outColorR") ("IKParentConstraint"+$fitJointIKStartJoint[$i]+$side+".visibility"); connectAttr -f ("FKIKBlend"+$fitJointIK[$i]+"Condition"+$side+".outColorG") ("FKOffset"+$fitJointIKStartJoint[$i]+$side+".visibility"); for ($y=1;$y<99;$y++) { if (!`objExists ("IKExtracv"+$fitJointIK[$i]+$y+$side)`) break; setAttr -l 0 ("IKExtracv"+$fitJointIK[$i]+$y+$side+".v"); connectAttr ("FKIKBlend"+$fitJointIK[$i]+"Condition"+$side+".outColorR") ("IKExtracv"+$fitJointIK[$i]+$y+$side+".v"); } } //FKIK connect to constraints for ($b=1;$b>-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-1;$y--) { $childLabel=`asLabel $tempString[$y]`; if (`gmatch $childLabel "*Heel*"`) $heel=$tempString[$y]; if (`gmatch $childLabel "*Toes*"` && !`gmatch $childLabel "*ToesEnd*"`) { $toes=$tempString[$y]; $footRollJoints[size($footRollJoints)]=$tempString[$y]; } if (`gmatch $childLabel "*BigToe*"`) $bigToe=$tempString[$y]; if (`gmatch $childLabel "*PinkyToe*"`) $pinkyToe=$tempString[$y]; if (`gmatch $childLabel "*ToesEnd*"`) { $toesEnd=$tempString[$y]; $footRollJoints[size($footRollJoints)]=$tempString[$y]; } //skip joints below Toes (that is not ToesEnd) $tempString2=`ls -l $tempString[$y]`; if (`gmatch $tempString2[0] ("*|"+$toes+"|*")` && $tempString[$y]!=$toesEnd) continue; //skip joints that end-up at Toes label $hasChildWithToesLabel (e.g claw attached to Ankle) $hasChildWithToesLabel=0; $tempString2=`listRelatives -ad -type joint $tempString[$y]`; for ($z=0;$zHeel->ToeEnd->Toes->Hocks for ($y=0;$y0) parent ("RollOffset"+$footRollJoints[$y-1]+$side) ("Roll"+$footRollJoints[$y]+$side); } parent ("RollOffset"+$footRollJoints[size($footRollJoints)-1]+$side) $parent; //Pinky/index toe side2side rocking if (`objExists $toes` && `objExists $bigToe` && `objExists $pinkyToe`) { addAttr -k 1 -ln rock -at double -dv 0 ("IK"+$fitJointIK[$i]+$side); createNode -n ("IK"+$fitJointIK[$i]+"FootRockInnerPivot"+$side) -p $parent transform; // createNode -n ("IK"+$fitJointIK[$i]+"FootRockOuterPivot"+$side) -p $parent transform; setAttr ("IK"+$fitJointIK[$i]+"FootRockInnerPivot"+$side+".rotateOrder") 5; asAlign ("IK"+$fitJointIK[$i]+"FootRockInnerPivot"+$side) ("Roll"+$toes+$side) 1 1 0 0; $pos=`xform -q -ws -t $toes`; if (`objExists $bigToe`) $pos=`xform -q -ws -t $bigToe`; xform -ws -t ($pos[0]*$b) 0 $pos[2] ("IK"+$fitJointIK[$i]+"FootRockInnerPivot"+$side); parent ("IK"+$fitJointIK[$i]+"FootRockInnerPivot"+$side) ("Roll"+$toes+$side); duplicate -n ("IK"+$fitJointIK[$i]+"FootRockOuterPivot"+$side) ("IK"+$fitJointIK[$i]+"FootRockInnerPivot"+$side); $pos=`xform -q -ws -t $toes`; if (`objExists $pinkyToe`) $pos=`xform -q -ws -t $pinkyToe`; xform -ws -t ($pos[0]*$b) 0 $pos[2] ("IK"+$fitJointIK[$i]+"FootRockOuterPivot"+$side); parent ("IK"+$fitJointIK[$i]+"FootRockInnerPivot"+$side) ("IK"+$fitJointIK[$i]+"FootRockOuterPivot"+$side) $parent; createNode -n ("IK"+$fitJointIK[$i]+"FootRockInnerPivotClamp"+$side) clamp; setAttr ("IK"+$fitJointIK[$i]+"FootRockInnerPivotClamp"+$side+".minR") -200; connectAttr ("IK"+$fitJointIK[$i]+$side+".rock") ("IK"+$fitJointIK[$i]+"FootRockInnerPivotClamp"+$side+".inputR"); connectAttr ("IK"+$fitJointIK[$i]+"FootRockInnerPivotClamp"+$side+".outputR") ("IK"+$fitJointIK[$i]+"FootRockInnerPivot"+$side+".rz"); if ($side=="_L") { $tempString=`listConnections ("IK"+$fitJointIK[$i]+"FootRockInnerPivot"+$side+".rz")`; setAttr ($tempString[0]+".conversionFactor") (`getAttr ($tempString[0]+".conversionFactor")`*-1); } createNode -n ("IK"+$fitJointIK[$i]+"FootRockOuterPivotClamp"+$side) clamp; setAttr ("IK"+$fitJointIK[$i]+"FootRockOuterPivotClamp"+$side+".maxR") 200; connectAttr ("IK"+$fitJointIK[$i]+$side+".rock") ("IK"+$fitJointIK[$i]+"FootRockOuterPivotClamp"+$side+".inputR"); connectAttr ("IK"+$fitJointIK[$i]+"FootRockOuterPivotClamp"+$side+".outputR") ("IK"+$fitJointIK[$i]+"FootRockOuterPivot"+$side+".rz"); if ($side=="_L") { $tempString=`listConnections ("IK"+$fitJointIK[$i]+"FootRockOuterPivot"+$side+".rz")`; setAttr ($tempString[0]+".conversionFactor") (`getAttr ($tempString[0]+".conversionFactor")`*-1); } parent ("IK"+$fitJointIK[$i]+"FootRockOuterPivot"+$side) ("IK"+$fitJointIK[$i]+"FootRockInnerPivot"+$side); parent ("IKFKAligned"+$fitJointIK[$i]+$side) ("IK"+$fitJointIK[$i]+"FootRoll"+$side) ("IK"+$fitJointIK[$i]+"FootRockOuterPivot"+$side); parent ("RollOffset"+$footRollJoints[size($footRollJoints)-1]+$side) ("IK"+$fitJointIK[$i]+"FootRockOuterPivot"+$side); if (`objExists ("IKLocalOffset"+$fitJointIK[$i]+$side)`) parent ("IKLocalOffset"+$fitJointIK[$i]+$side) ("IK"+$fitJointIK[$i]+"FootRockOuterPivot"+$side); } if ($ikLocal[$i] && $ikLocalType[$i]==0 && $heel!="")//$ikLocal=addCtrl { createNode -n ("RollOffsetOffset"+$heel+$side) -p $parent transform; asAlign ("RollOffsetOffset"+$heel+$side) ("RollOffset"+$heel+$side) 1 1 0 0; parent ("RollOffset"+$heel+$side) ("RollOffsetOffset"+$heel+$side); parent ("RollOffsetOffset"+$heel+$side) ("IKLocal"+$fitJointIK[$i]+$side); parent ("IK"+$fitJointIK[$i]+"FootRoll"+$side) ("IKLocal"+$fitJointIK[$i]+$side); } for ($y=-1;$y-2;$b=$b-2) for ($i=0;$i0) $defaultAngle=-90; $defaultUnstretchedLenght=0; $parent=$fitJointIKEndJoint[$i]; while ($parent!=$fitJointIKStartJoint[$i]) { $defaultUnstretchedLenght+=`getAttr ($parent+".tx")`; $tempString=`listRelatives -p $parent`; $parent=$tempString[0]; } $defaultUnstretchedLenght+=`getAttr ($parent+".tx")`; createNode -n tempSampler -p ("FK"+$scapula+$side) transform; parent tempSampler ("LegAim"+$scapula+$side); $defaultOffsetAngle=`getAttr tempSampler.rz`; delete tempSampler; } //Advanced Scaling for ($b=1;$b>-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i1) $scalerWeight=1-($scalerWeight-1); addAttr -k 1 -ln scalerWeight -at double -dv $scalerWeight ("IKScaler"+$IKJoints[$y]+$side); } } } } //Advanced Stretchy (arms/legs) for ($b=1;$b>-2;$b=$b-2) for ($i=0;$i1) parent ("HipSwingReverseXPart"+$y) HipSwingReverse; orientConstraint ("HipSwingReversePart"+$y) ("HipSwingReverseXPart"+$y); $parent="HipSwingReversePart"+$y; } createNode -n HipSwingReverseRoot transform; asAlign HipSwingReverseRoot Root_M 1 1 0 0; for ($y=1;$y<$inbetweenJoints+1;$y++) { orientConstraint HipSwingerStabilizerTarget HipSwinger_M ("HipSwingReversePart"+$y); setAttr ("HipSwingReversePart"+$y+"_orientConstraint1.HipSwingerStabilizerTargetW0") (1-((1.0/($inbetweenJoints+1))*$y)); setAttr ("HipSwingReversePart"+$y+"_orientConstraint1.HipSwinger_MW1") ((1.0/($inbetweenJoints+1))*$y); setAttr ("HipSwingReversePart"+$y+"_orientConstraint1.interpType") 2; } //inbetween done by constraint-blend, hipSwing done with constraint-offset for ($y=1;$y<$inbetweenJoints+1;$y++) { if ($y==$inbetweenJoints) connectAttr ("HipSwingReverseXPart"+$y+".r") FKXRoot_M_orientConstraint1.offset; else connectAttr ("HipSwingReverseXPart"+($inbetweenJoints-$y)+".r") ("FKXRootPart"+$y+"_M_orientConstraint1.offset"); } createNode -n HipSwingerStabilizer transform; if ($inbetweenJoints==0) { parent HipSwingReverseRoot HipSwingReverse; orientConstraint HipSwinger_M HipSwingReverse; parentConstraint HipSwingReverseRoot FKXRoot_M; parent HipSwingerStabilizer FKOffsetSpine1_M; xform -os -t 0 0 0 -ro 0 0 0 HipSwingerStabilizer; parent FKExtraSpine1_M HipSwingerStabilizer; } else { parent HipSwingReverseRoot ("HipSwingReversePart"+$inbetweenJoints); orientConstraint HipSwinger_M HipSwingReverseRoot; pointConstraint HipSwingReverseRoot FKXRoot_M; parent HipSwingerStabilizer ("FKXRootPart"+$inbetweenJoints+"_M"); xform -os -t 0 0 0 -ro 0 0 0 HipSwingerStabilizer; if (`objExists FKOffsetSpine1_M`) parent FKOffsetSpine1_M HipSwingerStabilizer; } orientConstraint HipSwingerStabilizerTarget HipSwingerStabilizer; } //CenterBetweenFeet string $ikLegs[]; $tempString=`ls "IKLeg*_*"`; for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i0) { delete ("Bend"+$fitJoints[$i]+"Curve"+$side); break; } spaceLocator -n ("Bend"+$fitJoints[$i]+"Locator"+$z+$side); setAttr -l 1 ("Bend"+$fitJoints[$i]+"Locator"+$z+$side+".v") 0; connectAttr ("Bend"+$fitJoints[$i]+"Locator"+$z+$side+"Shape.worldPosition[0]") ("Bend"+$fitJoints[$i]+"Curve"+$side+"Shape.controlPoints["+$z+"]"); $posFactor=(1.0/4.0)*$z; $invPosFactor=1-$posFactor; $tempString=`pointConstraint -w $invPosFactor ($fitJoints[$i]+$side) ("Bend"+$fitJoints[$i]+"Locator"+$z+$side)`; pointConstraint -w $posFactor ($fitJointChild[$i]+$childSide) ("Bend"+$fitJoints[$i]+"Locator"+$z+$side); delete $tempString[0]; if ($z==0)//Start parent ("Bend"+$fitJoints[$i]+"Locator"+$z+$side) ("BendParentConstraint"+$fitJoints[$i]+$side); if ($z==2 || $z==0)//Controllers { asCreateController "Bend" ($fitJoints[$i]+$bendControlNr) $side $fitJoints[$i]; parent ("BendOffset"+$fitJoints[$i]+$bendControlNr+$side) BendSystem; asAlign ("BendOffset"+$fitJoints[$i]+$bendControlNr+$side) ("Bend"+$fitJoints[$i]+"Locator"+$z+$side) 1 0 0 0; asAlign ("BendOffset"+$fitJoints[$i]+$bendControlNr+$side) ("FKX"+$fitJoints[$i]+$side) 0 1 0 0; parent ("BendOffset"+$fitJoints[$i]+$bendControlNr+$side) ("BendParentConstraint"+$fitJoints[$i]+$side); $parent="Bend"+$fitJoints[$i]+$bendControlNr+$side; if (`objExists ("BendUnFlip"+$fitJoints[$i]+$bendControlNr+$side)`) $parent="BendUnFlip"+$fitJoints[$i]+$bendControlNr+$side; parent ("Bend"+$fitJoints[$i]+"Locator"+$z+$side) $parent; $rot=`xform -q -ws -ro ($fitJoints[$i]+$side)`; // xform -s 0.1 1 1 ("Bend"+$fitJoints[$i]+$bendControlNr+$side+".cv[0:99]"); $bendControlNr++; } if ($z==0)//Create BendStiff node { createNode -n ("BendStiff"+$fitJoints[$i]+$side) setRange; setAttr ("BendStiff"+$fitJoints[$i]+$side+".minX") 0;setAttr ("BendStiff"+$fitJoints[$i]+$side+".minY") 1; setAttr ("BendStiff"+$fitJoints[$i]+$side+".maxX") 1;setAttr ("BendStiff"+$fitJoints[$i]+$side+".maxY") 0; setAttr ("BendStiff"+$fitJoints[$i]+$side+".oldMinX") -10;setAttr ("BendStiff"+$fitJoints[$i]+$side+".oldMinY") -10; setAttr ("BendStiff"+$fitJoints[$i]+$side+".oldMaxX") 10;setAttr ("BendStiff"+$fitJoints[$i]+$side+".oldMaxY") 10; } if ($z==2)//`Bezier handles`(stiffness) { addAttr -k 1 -ln stiff -at double -min -10 -max 10 -dv 10 ("Bend"+$fitJoints[$i]+"2"+$side); connectAttr ("Bend"+$fitJoints[$i]+"2"+$side+".stiff") ("BendStiff"+$fitJoints[$i]+$side+".valueX"); connectAttr ("Bend"+$fitJoints[$i]+"2"+$side+".stiff") ("BendStiff"+$fitJoints[$i]+$side+".valueY"); } if ($z==1 || $z==3)//`Bezier handles`(stiffness) { createNode -n ("Bend"+$fitJoints[$i]+"BezOff"+$z+$side) -p ("BendParentConstraint"+$fitJoints[$i]+$side) transform; if ($z==1) { $parent="Bend"+$fitJoints[$i]+"1"+$side; if (`objExists ("BendUnFlip"+$fitJoints[$i]+"1"+$side)`) $parent="BendUnFlip"+$fitJoints[$i]+"1"+$side; parent ("Bend"+$fitJoints[$i]+"BezOff"+$z+$side) $parent; } if ($z==3 && `objExists ("Bend"+$fitJointChild[$i]+"1"+$side)`) { $parent="Bend"+$fitJointChild[$i]+"1"+$side; if (`objExists ("BendnFlip"+$fitJointChild[$i]+"1"+$side)`) $parent="BendnFlip"+$fitJointChild[$i]+"1"+$side; parent ("Bend"+$fitJoints[$i]+"BezOff"+$z+$side) $parent; } asAlign ("Bend"+$fitJoints[$i]+"BezOff"+$z+$side) ("Bend"+$fitJoints[$i]+"Locator"+$z+$side) 1 1 0 0; duplicate -n ("Bend"+$fitJoints[$i]+"BezOn"+$z+$side) ("Bend"+$fitJoints[$i]+"BezOff"+$z+$side); parent ("Bend"+$fitJoints[$i]+"Locator"+$z+$side) ("BendParentConstraint"+$fitJoints[$i]+$side); pointConstraint ("Bend"+$fitJoints[$i]+"BezOn"+$z+$side) ("Bend"+$fitJoints[$i]+"BezOff"+$z+$side) ("Bend"+$fitJoints[$i]+"Locator"+$z+$side); connectAttr ("BendStiff"+$fitJoints[$i]+$side+".outValueX") ("Bend"+$fitJoints[$i]+"Locator"+$z+$side+"_pointConstraint1.Bend"+$fitJoints[$i]+"BezOn"+$z+$side+"W0"); connectAttr ("BendStiff"+$fitJoints[$i]+$side+".outValueY") ("Bend"+$fitJoints[$i]+"Locator"+$z+$side+"_pointConstraint1.Bend"+$fitJoints[$i]+"BezOff"+$z+$side+"W1"); } if ($z==4) parent ("Bend"+$fitJoints[$i]+"Locator"+$z+$side) ("BendParentConstraint"+$fitJoints[$i]+$side); if ($z==3) { createNode -n ("Bend"+$fitJoints[$i]+"BezScale"+$side) -p ("Bend"+$fitJoints[$i]+"2"+$side) transform; parent ("Bend"+$fitJoints[$i]+"BezOn"+"1"+$side) ("Bend"+$fitJoints[$i]+"BezOn"+"3"+$side) ("Bend"+$fitJoints[$i]+"BezScale"+$side); if (`objExists ("IKmessureDiv"+$fitJointIK[$i]+$side)`) { if (!`objExists ("BendBezScale"+$fitJointIK[$i]+"BlendTwo"+$side)`) { createNode -n ("BendBezScale"+$fitJointIK[$i]+"BlendTwo"+$side) blendTwoAttr; connectAttr ("FKIKBlend"+$fitJointIK[$i]+"UnitConversion"+$side+".output") ("BendBezScale"+$fitJointIK[$i]+"BlendTwo"+$side+".attributesBlender"); setAttr ("BendBezScale"+$fitJointIK[$i]+"BlendTwo"+$side+".input[0]") 1; connectAttr ("IKmessureDiv"+$fitJointIK[$i]+$side+".outputX") ("BendBezScale"+$fitJointIK[$i]+"BlendTwo"+$side+".input[1]"); } connectAttr ("BendBezScale"+$fitJointIK[$i]+"BlendTwo"+$side+".output") ("Bend"+$fitJoints[$i]+"BezScale"+$side+".scale"+$fitJointAbsPriAxis[$i]); } // parent ("Bend"+$fitJoints[$i]+"BezOn"+"1"+$side) ("Bend"+$fitJoints[$i]+"2"+$side); // parent ("Bend"+$fitJoints[$i]+"BezOn"+"3"+$side) ("Bend"+$fitJoints[$i]+"2"+$side); } } //Bend1 adds to ConstraintOffset // if ($fitJoints[$i]=="Root") // ;//special case, Root untwister cycle avoidance, for when Bendy ctrl is added to Root-joint // else if (`objExists ($fitJoints[$i]+$side+"_orientConstraint1")`) { connectAttr ("Bend"+$fitJoints[$i]+"1"+$side+".rotateY") ($fitJoints[$i]+$side+"_orientConstraint1.offsetY"); connectAttr ("Bend"+$fitJoints[$i]+"1"+$side+".rotateZ") ($fitJoints[$i]+$side+"_orientConstraint1.offsetZ"); } //connect to twistJoints for ($y=0;$y<($fitJointTwistJoints[$i]+1);$y++) { if ($y==0) $joint=$fitJoints[$i]+$side; else { $joint=$fitJoints[$i]+"Part"+$y+$side; delete ($joint+"_orientConstraint1"); } if ($y==0) { delete (`listConnections -s 1 -d 0 ($fitJoints[$i]+$side+".tx")`);//could be point or parent constraint if ($fitJointTwistJoints[$i]==0 && `objExists ("Bend"+$fitJoints[$i]+"1"+$side)`) // Bendy Root orientConstraint ("Bend"+$fitJoints[$i]+"1"+$side) ($fitJoints[$i]+$side); } //bend hookup if ($y==0) { pointConstraint ("Bend"+$fitJoints[$i]+"1"+$side) $joint; parent ($joint+"_pointConstraint1") ConstraintSystem; //First BendyJoint spesial case if (`objExists ("Twister"+$fitJoints[$i]+"0"+$side)`) { delete ($joint+"_orientConstraint1"); $parent="Bend"+$fitJoints[$i]+"1"+$side; if (`objExists ("BendUnFlip"+$fitJoints[$i]+"1"+$side)`) $parent="BendUnFlip"+$fitJoints[$i]+"1"+$side; createNode -p $parent -n ($fitJoints[$i]+"BendTangent"+$side) transform; createNode -p $parent -n ($fitJoints[$i]+"BendStatic"+$side) transform; tangentConstraint -weight 1 -aimVector ($priNrmlX[$i]*$b) ($priNrmlY[$i]*$b) ($priNrmlZ[$i]*$b) -upVector $terNrmlX[$i] $terNrmlY[$i] $terNrmlZ[$i] -worldUpType "objectrotation" -worldUpVector $terNrmlX[$i] $terNrmlY[$i] $terNrmlZ[$i] -worldUpObject ("Twister"+$fitJoints[$i]+"0"+$side) ("Bend"+$fitJoints[$i]+"Curve"+$side) ($fitJoints[$i]+"BendTangent"+$side); //Also use the X axis from the tangentConstraint, to set the X of BendStatic, since with NoFollow, we still want the X to follow, to avoid hard X disorientation connectAttr -f ($fitJoints[$i]+"BendTangent"+$side+"_tangentConstraint1.constraintRotate"+$fitJointAbsPriAxis[$i]) ($fitJoints[$i]+"BendStatic"+$side+".rotate"+$fitJointAbsPriAxis[$i]); orientConstraint ($fitJoints[$i]+"BendTangent"+$side) ($fitJoints[$i]+"BendStatic"+$side) $joint; addAttr -k 1 -ln follow -at double -min 0 -max 10 -dv 5 ("Bend"+$fitJoints[$i]+"1"+$side); asUnitConvertAndReverse ("BendFollow"+$fitJoints[$i]+"1"+$side) ("Bend"+$fitJoints[$i]+"1"+$side+".follow"); connectAttr ("BendFollow"+$fitJoints[$i]+"1"+$side+"UnitConversion.output") ($fitJoints[$i]+$side+"_orientConstraint1."+$fitJoints[$i]+"BendTangent"+$side+"W0"); connectAttr ("BendFollow"+$fitJoints[$i]+"1"+$side+"Reverse.outputX") ($fitJoints[$i]+$side+"_orientConstraint1."+$fitJoints[$i]+"BendStatic"+$side+"W1"); parent ($joint+"_orientConstraint1") ConstraintSystem; connectAttr ("Bend"+$fitJoints[$i]+"1"+$side+".rotate"+$fitJointAbsSecAxis[$i]) ($fitJoints[$i]+$side+"_orientConstraint1.offset"+$fitJointAbsSecAxis[$i]); connectAttr ("Bend"+$fitJoints[$i]+"1"+$side+".rotate"+$fitJointAbsTerAxis[$i]) ($fitJoints[$i]+$side+"_orientConstraint1.offset"+$fitJointAbsTerAxis[$i]); } } else { createNode -n ($fitJoints[$i]+"PointOnCurveInfo"+$y+$side) pointOnCurveInfo; connectAttr -f ("Bend"+$fitJoints[$i]+"Curve"+$side+"Shape.worldSpace[0]") ($fitJoints[$i]+"PointOnCurveInfo"+$y+$side+".inputCurve"); createNode -p BendSystem -n ($fitJoints[$i]+"PointOnCurveXform"+$y+$side) transform; connectAttr -f ($fitJoints[$i]+"PointOnCurveInfo"+$y+$side+".position") ($fitJoints[$i]+"PointOnCurveXform"+$y+$side+".t"); // setAttr ($fitJoints[$i]+"PointOnCurveInfo"+$y+$side+".turnOnPercentage") 1; //make tempSurface, so a closestPointOnSurface node can find $parameter extrude -n tempSurface -ch true -rn false -po 0 -et 0 -upn 1 -length 1 -rotation 0 -scale 1 -dl 3 ("Bend"+$fitJoints[$i]+"Curve"+$side); createNode -n tempClosestPointOnSurface closestPointOnSurface; spaceLocator -n tempClosestPointOnSurfaceLoc; connectAttr tempSurface.worldSpace[0] tempClosestPointOnSurface.inputSurface; connectAttr tempClosestPointOnSurfaceLoc.worldPosition[0] tempClosestPointOnSurface.inPosition; pointConstraint ($fitJoints[$i]+$side) ($fitJointChild[$i]+$childSide) tempClosestPointOnSurfaceLoc; setAttr ("tempClosestPointOnSurfaceLoc_pointConstraint1."+$fitJoints[$i]+$side+"W0") (1-((1.0/($fitJointTwistJoints[$i]+1.0))*$y)); setAttr ("tempClosestPointOnSurfaceLoc_pointConstraint1."+$fitJointChild[$i]+$childSide+"W1")((1.0/($fitJointTwistJoints[$i]+1.0))*$y); $parameter=`getAttr tempClosestPointOnSurface.parameterU`; delete tempClosestPointOnSurface tempSurface tempClosestPointOnSurfaceLoc; setAttr ($fitJoints[$i]+"PointOnCurveInfo"+$y+$side+".parameter") $parameter; pointConstraint ($fitJoints[$i]+"PointOnCurveXform"+$y+$side) $joint; parent ($joint+"_pointConstraint1") ConstraintSystem; tangentConstraint -weight 1 -aimVector ($priNrmlX[$i]*$b) ($priNrmlY[$i]*$b) ($priNrmlZ[$i]*$b) -upVector $terNrmlX[$i] $terNrmlY[$i] $terNrmlZ[$i] -worldUpType "objectrotation" -worldUpVector $terNrmlX[$i] $terNrmlY[$i] $terNrmlZ[$i] -worldUpObject ("Twister"+$fitJoints[$i]+$y+$side) ("Bend"+$fitJoints[$i]+"Curve"+$side) $joint; parent ($joint+"_tangentConstraint1") ConstraintSystem; } } } //Advanced BendyJoints (attached to parent) for ($b=1;$b>-2;$b=$b-2) for ($i=0;$i$fitJointTwistJoints[$i]/2) $hf=2-$hf; setAttr ("BendTwistMult"+$fitJoints[$i]+"1"+"_"+$y+$side+".input2Y") $hf; connectAttr ("BendTwistMult"+$fitJoints[$i]+"1"+"_"+$y+$side+".outputY") ("twistAddition"+$fitJoints[$i]+"Part"+$y+$side+".input1D[4]"); //endTwister if (`objExists ("Bend"+$fitJointChild[$i]+"1"+$childSide)`) { connectAttr ("Bend"+$fitJointChild[$i]+"1"+$childSide+".rotate"+$fitJointAbsPriAxis[$i]) ("BendTwistMult"+$fitJoints[$i]+"1"+"_"+$y+$side+".input1Z"); setAttr ("BendTwistMult"+$fitJoints[$i]+"1"+"_"+$y+$side+".input2Z") ((1/($fitJointTwistJoints[$i]+0.00))*$y); connectAttr ("BendTwistMult"+$fitJoints[$i]+"1"+"_"+$y+$side+".outputZ") ("twistAddition"+$fitJoints[$i]+"Part"+$y+$side+".input1D[5]"); } } } //Advanced distribution of twistJoints for ($b=1;$b>-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i(-1*$sideTreshold)) $aimAtSide="_M"; if (!`objExists ("FK"+$fitJointsAimAt[$i]+$aimAtSide)`) { warning ("Unable to add aimAt, target not found:\"FK"+$fitJointsAimAt[$i]+$aimAtSide+"\""); continue; } createNode -n ("FKAimAt"+$fitJoints[$i]+$side) -p ("FKOffset"+$fitJoints[$i]+$side) transform; createNode -n ("AimAt"+$fitJoints[$i]+$side) -p ("FKOffset"+$fitJoints[$i]+$side) transform; createNode -n ("Static"+$fitJoints[$i]+$side) -p ("FKOffset"+$fitJoints[$i]+$side) transform; asAlign ("AimAt"+$fitJoints[$i]+$side) ("FK"+$fitJointsAimAt[$i]+$aimAtSide) 1 1 0 0; asAlign ("Static"+$fitJoints[$i]+$side) ("FK"+$fitJointsAimAt[$i]+$aimAtSide) 1 1 0 0; $parent="FKExtra"+$fitJoints[$i]+$side; if (`objExists ("FKFlip"+$fitJoints[$i]+$side)`) $parent="FKFlip"+$fitJoints[$i]+$side; parent $parent ("FKAimAt"+$fitJoints[$i]+$side); parent ("AimAt"+$fitJoints[$i]+$side) ("FK"+$fitJointsAimAt[$i]+$aimAtSide); aimConstraint -offset $xOff $yOff $zOff -aimVector ($aimX*$c) ($aimY*$c) ($aimZ*$c) -upVector ($xUp*$d) ($yUp*$d) ($zUp*$d) -worldUpType $worldUpType -worldUpVector $xWorldUp $yWorldUp $zWorldUp -worldUpObject ($worldUpObject+$aimUpSide) ("AimAt"+$fitJoints[$i]+$side) ("Static"+$fitJoints[$i]+$side) ("FKAimAt"+$fitJoints[$i]+$side); addAttr -k 1 -ln aimAt -at double -min 0 -max 10 -dv 10 ("FK"+$fitJoints[$i]+$side); createNode -n ("FK"+$fitJoints[$i]+$side+"AimAtSetRange") setRange; setAttr ("FK"+$fitJoints[$i]+$side+"AimAtSetRange.minX") 0;setAttr ("FK"+$fitJoints[$i]+$side+"AimAtSetRange.minY") 1; setAttr ("FK"+$fitJoints[$i]+$side+"AimAtSetRange.maxX") 1;setAttr ("FK"+$fitJoints[$i]+$side+"AimAtSetRange.maxY") 0; setAttr ("FK"+$fitJoints[$i]+$side+"AimAtSetRange.oldMinX") 0;setAttr ("FK"+$fitJoints[$i]+$side+"AimAtSetRange.oldMinY") 0; setAttr ("FK"+$fitJoints[$i]+$side+"AimAtSetRange.oldMaxX") 10;setAttr ("FK"+$fitJoints[$i]+$side+"AimAtSetRange.oldMaxY") 10; connectAttr ("FK"+$fitJoints[$i]+$side+".aimAt") ("FK"+$fitJoints[$i]+$side+"AimAtSetRange.value.valueX"); connectAttr ("FK"+$fitJoints[$i]+$side+".aimAt") ("FK"+$fitJoints[$i]+$side+"AimAtSetRange.value.valueY"); connectAttr ("FK"+$fitJoints[$i]+$side+"AimAtSetRange.outValue.outValueX") ("FKAimAt"+$fitJoints[$i]+$side+"_aimConstraint1."+"AimAt"+$fitJoints[$i]+$side+"W0"); connectAttr ("FK"+$fitJoints[$i]+$side+"AimAtSetRange.outValue.outValueY") ("FKAimAt"+$fitJoints[$i]+$side+"_aimConstraint1."+"Static"+$fitJoints[$i]+$side+"W1"); } //Advanced CurveGuide for ($b=1;$b>-2;$b=$b-2) for ($i=0;$i>`; delete ("CurveGuideOnCurve"+$fitJoints[$i]+$side+"_geometryConstraint1"); if ($mirTrans) setAttr -type float3 ("CurveGuideOnCurve"+$fitJoints[$i]+$side+".t") ($dist*$priNrmlX[$i]) ($dist*$priNrmlY[$i]) ($dist*$priNrmlZ[$i]); else setAttr -type float3 ("CurveGuideOnCurve"+$fitJoints[$i]+$side+".t") ($dist*$priNrmlX[$i]*$c) ($dist*$priNrmlY[$i]*$c) ($dist*$priNrmlZ[$i]*$c); geometryConstraint $curveGuide ("CurveGuideOnCurve"+$fitJoints[$i]+$side); for ($y=0;$y<99;$y++) { setAttr ("CurveGuideOnCurve"+$fitJoints[$i]+$side+".translate"+$fitJointAbsSecAxis[$i]) 0; setAttr ("CurveGuideOnCurve"+$fitJoints[$i]+$side+".translate"+$fitJointAbsTerAxis[$i]) 0; } delete ("CurveGuideOnCurve"+$fitJoints[$i]+$side+"_geometryConstraint1"); parent ("CurveGuideOnCurve"+$fitJoints[$i]+$side) CurveGuideSystem; extrude -n tempSurface -ch true -rn false -po 0 -et 0 -upn 1 -length 1 -rotation 0 -scale 1 -dl 3 $curveGuide; createNode -n tempSampler closestPointOnSurface; connectAttr tempSurface.worldSpace[0] tempSampler.inputSurface; connectAttr ("CurveGuideOnCurve"+$fitJoints[$i]+$side+".translate") tempSampler.inPosition; createNode -n ("CurveGuideInfo"+$fitJoints[$i]+$side) pointOnCurveInfo; connectAttr -f ($curveGuide+".worldSpace") ("CurveGuideInfo"+$fitJoints[$i]+$side+".inputCurve"); setAttr ("CurveGuideInfo"+$fitJoints[$i]+$side+".parameter") `getAttr tempSampler.result.parameterU`; connectAttr ("CurveGuideInfo"+$fitJoints[$i]+$side+".position") ("CurveGuideOnCurve"+$fitJoints[$i]+$side+".t"); tangentConstraint -weight 1 -aimVector ($priNrmlX[$i]*$c) ($priNrmlY[$i]*$c) ($priNrmlZ[$i]*$c) -upVector $terNrmlX[$i] $terNrmlY[$i] $terNrmlZ[$i] -worldUpType "objectrotation" -worldUpVector $terNrmlX[$i] $terNrmlY[$i] $terNrmlZ[$i] -worldUpObject ("FK"+$fitJointParent[$i]+$parentSide) $curveGuide ("CurveGuideOnCurve"+$fitJoints[$i]+$side); createNode -n ("CurveGuideStaticOffset"+$fitJoints[$i]+$side) transform; $tempString=`listRelatives -p ("FKCurveGuide"+$fitJoints[$i]+$side)`; parent ("CurveGuideStaticOffset"+$fitJoints[$i]+$side) $tempString[0]; createNode -n ("CurveGuideStatic"+$fitJoints[$i]+$side) -p ("CurveGuideStaticOffset"+$fitJoints[$i]+$side) transform; asAlign ("CurveGuideStatic"+$fitJoints[$i]+$side) ("CurveGuideOnCurve"+$fitJoints[$i]+$side) 1 1 0 0; delete tempSurface tempSampler; asCreateController "IK" $fitJoints[$i] $side $fitJoints[$i]; if (!`attributeExists guideTargetsVis Main`) { addAttr -k 1 -ln guideTargetsVis -at bool -dv 0 Main; setAttr -k 0 -cb 1 Main.guideTargetsVis; } connectAttr Main.guideTargetsVis ("IKOffset"+$fitJoints[$i]+$side+".v"); xform -os -t 0 0 0 ("IKOffset"+$fitJoints[$i]+$side); scale -r -p 0 0 0 0.3 0.3 0.3 ("IK"+$fitJoints[$i]+$side+".cv[0:99]"); // asAlign ("IKOffset"+$fitJoints[$i]+$side) ("CurveGuideOnCurve"+$fitJoints[$i]+$side) 1 1 0 0; parentConstraint ("CurveGuideOnCurve"+$fitJoints[$i]+$side) ("CurveGuideStatic"+$fitJoints[$i]+$side) ("IKOffset"+$fitJoints[$i]+$side); aimConstraint -aimVector ($priNrmlX[$i]*$c) ($priNrmlY[$i]*$c) ($priNrmlZ[$i]*$c) -upVector $terNrmlX[$i] $terNrmlY[$i] $terNrmlZ[$i] -worldUpType "objectrotation" -worldUpVector $terNrmlX[$i] $terNrmlY[$i] $terNrmlZ[$i] -worldUpObject ("IK"+$fitJoints[$i]+$side) ("IK"+$fitJoints[$i]+$side) ("FKCurveGuide"+$fitJoints[$i]+$side); // aimConstraint -offset 0 0 0 -aimVector 1 0 0 -upVector 0 0 -1 -worldUpType "objectrotation" -worldUpVector 1 0 0 -worldUpObject ("CurveGuideOnCurve"+$fitJoints[$i]+$side) ("CurveGuideOnCurve"+$fitJoints[$i]+$side) ("CurveGuideStatic"+$fitJoints[$i]+$side) ("FKCurveGuide"+$fitJoints[$i]+$side); // aimConstraint -offset 0 0 90 -aimVector 1 0 0 -upVector 0 0 1 -worldUpType "objectrotation" -worldUpVector 1 0 0 -worldUpObject ("FK"+$fitJointParent[$i]+$side) ("CurveGuideOnCurve"+$fitJoints[$i]+$side) ("FKCurveGuide"+$fitJoints[$i]+$side); // aimConstraint -offset 0 0 0 -aimVector (1*$b) 0 0 -upVector 1 0 0 -worldUpType "objectrotation" -worldUpVector 1 0 0 -worldUpObject ("FKCurveGuideUpVec"+$fitJoints[$i]+$side) ("CurveGuideOnCurve"+$fitJoints[$i]+$side) ("FKCurveGuide"+$fitJoints[$i]+$side); if (!`attributeExists blend $curveGuide`) addAttr -k 1 -ln blend -at double -min 0 -max 10 -dv 10 $curveGuide; if (!`objExists ($curveGuide+"BlendUnitConversion")`) { createNode -n ($curveGuide+"BlendUnitConversion") unitConversion; setAttr ($curveGuide+"BlendUnitConversion.conversionFactor") 0.1; connectAttr ($curveGuide+".blend") ($curveGuide+"BlendUnitConversion.input"); createNode -n ($curveGuide+"BlendReverse") reverse; connectAttr ($curveGuide+"BlendUnitConversion.output") ($curveGuide+"BlendReverse.inputX"); } // connectAttr ($curveGuide+"BlendUnitConversion.output") ("FKCurveGuide"+$fitJoints[$i]+$side+"_aimConstraint1.CurveGuideOnCurve"+$fitJoints[$i]+$side+"W0"); // connectAttr ($curveGuide+"BlendReverse.outputX") ("FKCurveGuide"+$fitJoints[$i]+$side+"_aimConstraint1.CurveGuideStatic"+$fitJoints[$i]+$side+"W1"); connectAttr ($curveGuide+"BlendUnitConversion.output") ("IKOffset"+$fitJoints[$i]+$side+"_parentConstraint1.CurveGuideOnCurve"+$fitJoints[$i]+$side+"W0"); connectAttr ($curveGuide+"BlendReverse.outputX") ("IKOffset"+$fitJoints[$i]+$side+"_parentConstraint1.CurveGuideStatic"+$fitJoints[$i]+$side+"W1"); createNode -n ("FKCurveGuideOffset"+$fitJoints[$i]+$side) -p $offsetParent transform; asAlign ("FKCurveGuideOffset"+$fitJoints[$i]+$side) ("FKCurveGuide"+$fitJoints[$i]+$side) 1 1 0 0; parent ("FKCurveGuide"+$fitJoints[$i]+$side) ("FKCurveGuideOffset"+$fitJoints[$i]+$side); parent ("FKOffset"+$fitJoints[$i]+$side) ("FKCurveGuide"+$fitJoints[$i]+$side); // $tempString=`listRelatives -c -type transform ("FKOffset"+$fitJoints[$i]+$side)`; // $tempString=`stringArrayRemove {("FKCurveGuide"+$fitJoints[$i]+$side)} $tempString`; // parent $tempString ("FKCurveGuide"+$fitJoints[$i]+$side); //CurveGuide controllers $spans=`getAttr ($curveGuide+".spans")`; $degree=`getAttr ($curveGuide+".degree")`; $numCVs=$spans+$degree; for ($y=0;$y<$numCVs;$y++) { $side="_R"; $pos=`xform -q -ws -t ($curveGuide+".cv["+$y+"]")`; if ($pos[0]==0) $side="_M"; if ($pos[0]>0) $side="_L"; $ctrl="IK"+$fitJointsCurveGuide[$i]+"Ctrl"+$y+$side; if (`objExists $ctrl`) continue; $tempString[0]=`curve -d 1 -p 0 1 0 -p 0 -1 0 -p 0 0 0 -p 1 0 0 -p -1 0 0 -k 0 -k 1 -k 2 -k 3 -k 4`; rename $tempString[0] $ctrl; $tempString=`listRelatives -s $ctrl`; rename $tempString[0] ($ctrl+"Shape"); setAttr ($ctrl+"Shape.overrideEnabled") 1; setAttr ($ctrl+"Shape.overrideColor") 17; sets -add ControlSet $ctrl; scale -r -p 0 0 0 ($scale/1.0) ($scale/1.0) ($scale/1.0) ($ctrl+".cv[0:4]"); createNode -n ($ctrl+"Offset") -p CurveGuideSystem transform; parent $ctrl ($ctrl+"Offset"); $tempString=`spaceLocator`; rename $tempString[0] ($ctrl+"Loc"); parent ($ctrl+"Loc") $ctrl; setAttr -l 1 ($ctrl+"Loc.v") 0; $pos=`xform -q -ws -t ($curveGuide+".cv["+$y+"]")`; xform -ws -t $pos[0] $pos[1] $pos[2] ($ctrl+"Offset"); connectAttr -f ($ctrl+"Loc.worldPosition[0]") ($curveGuide+".controlPoints["+$y+"]"); addAttr -k 1 -ln follow -at double -min 0 -max 10 -dv 10 $ctrl; createNode -n ($ctrl+"FollowSetRange") setRange; setAttr ($ctrl+"FollowSetRange.minX") 0;setAttr ($ctrl+"FollowSetRange.minY") 1; setAttr ($ctrl+"FollowSetRange.maxX") 1;setAttr ($ctrl+"FollowSetRange.maxY") 0; setAttr ($ctrl+"FollowSetRange.oldMinX") 0;setAttr ($ctrl+"FollowSetRange.oldMinY") 0; setAttr ($ctrl+"FollowSetRange.oldMaxX") 10;setAttr ($ctrl+"FollowSetRange.oldMaxY") 10; connectAttr ($ctrl+".follow") ($ctrl+"FollowSetRange.value.valueX"); connectAttr ($ctrl+".follow") ($ctrl+"FollowSetRange.value.valueY"); createNode -n ($ctrl+"FollowOn") -p $ctrl transform; createNode -n ($ctrl+"FollowOff") -p $ctrl transform; parent ($ctrl+"FollowOn") CurveGuideSystem; parent ($ctrl+"FollowOff") GlobalFollowMain; parentConstraint -mo `asNearestFeatherParent $ctrl $fitJointsCurveGuide[$i]` ($ctrl+"FollowOn"); parentConstraint ($ctrl+"FollowOn") ($ctrl+"FollowOff") ($ctrl+"Offset"); connectAttr ($ctrl+"FollowSetRange.outValue.outValueX") ($ctrl+"Offset_parentConstraint1."+$ctrl+"FollowOnW0"); connectAttr ($ctrl+"FollowSetRange.outValue.outValueY") ($ctrl+"Offset_parentConstraint1."+$ctrl+"FollowOffW1"); scaleConstraint MotionSystem ($ctrl+"Offset"); } } //Advanced Wheel for ($b=1;$b>-2;$b=$b-2) for ($i=0;$inurbs $scaleFactor=$diameter/2.0; xform -ws -s $scaleFactor $scaleFactor $scaleFactor ("FK"+$fitJoints[$i]+$side+"Shape.cv[0:999]"); addAttr -k 1 -ln "diameter" -at double -dv $diameter ("FK"+$fitJoints[$i]+$side); addAttr -k 1 -ln "autoRoll" -at double -smn 0 -hsn 1 -smx 1 -hsx 1 -dv 1 ("FK"+$fitJoints[$i]+$side); addAttr -k 0 -ln "prevPosX" -at double -dv $diameter ("FK"+$fitJoints[$i]+$side); addAttr -k 0 -ln "prevPosY" -at double -dv $diameter ("FK"+$fitJoints[$i]+$side); addAttr -k 0 -ln "prevPosZ" -at double -dv $diameter ("FK"+$fitJoints[$i]+$side); createNode -n ("prevPosOffset"+$fitJoints[$i]+$side) -p WheelSystem transform; createNode -n ("prevPos"+$fitJoints[$i]+$side) -p ("prevPosOffset"+$fitJoints[$i]+$side) transform; createNode -n ("prevPosAngler"+$fitJoints[$i]+$side) -p ("prevPos"+$fitJoints[$i]+$side) transform; createNode -n ("nowPos"+$fitJoints[$i]+$side) -p WheelSystem transform; pointConstraint ("FK"+$fitJoints[$i]+$side) ("nowPos"+$fitJoints[$i]+$side); asAlign ("prevPosOffset"+$fitJoints[$i]+$side) ("FK"+$fitJoints[$i]+$side) 1 0 0 0; $temp=`xform -q -ws -ro ("FK"+$fitJoints[$i]+$side)`; setAttr ("prevPosOffset"+$fitJoints[$i]+$side+".rz") 90; setAttr ("prevPosOffset"+$fitJoints[$i]+$side+".rx") $temp[1]; duplicate -n ("prevPosSteer"+$fitJoints[$i]+$side) ("prevPosAngler"+$fitJoints[$i]+$side); parent ("prevPosSteer"+$fitJoints[$i]+$side) ("FK"+$fitJoints[$i]+$side); orientConstraint ("prevPosSteer"+$fitJoints[$i]+$side) ("prevPosAngler"+$fitJoints[$i]+$side); aimConstraint -offset 0 0 0 -weight 1 -aimVector 0 1 0 -upVector 1 0 0 -worldUpType "vector" -worldUpVector 0 1 0 ("FK"+$fitJoints[$i]+$side) ("prevPos"+$fitJoints[$i]+$side); $sideFactor=$b; if ($mirTrans) $sideFactor=1; string $exp=""; $exp+="float $diameter = FK"+$fitJoints[$i]+$side+".diameter;\n"; $exp+="float $autoRoll = FK"+$fitJoints[$i]+$side+".autoRoll;\n"; $exp+="float $sideAngle=prevPosAngler"+$fitJoints[$i]+$side+".rotateX;\n"; $exp+="float $scale = MainScaleMultiplyDivide.input1Y;\n"; $exp+="float $prevPosX=FK"+$fitJoints[$i]+$side+".prevPosX;\n"; $exp+="float $prevPosY=FK"+$fitJoints[$i]+$side+".prevPosY;\n"; $exp+="float $prevPosZ=FK"+$fitJoints[$i]+$side+".prevPosZ;\n"; $exp+="prevPosOffset"+$fitJoints[$i]+$side+".translateX=$prevPosX;\n"; $exp+="prevPosOffset"+$fitJoints[$i]+$side+".translateY=$prevPosY;\n"; $exp+="prevPosOffset"+$fitJoints[$i]+$side+".translateZ=$prevPosZ;\n"; $exp+="float $nowPosX=nowPos"+$fitJoints[$i]+$side+".translateX;\n"; $exp+="float $nowPosY=nowPos"+$fitJoints[$i]+$side+".translateY;\n"; $exp+="float $nowPosZ=nowPos"+$fitJoints[$i]+$side+".translateZ;\n"; $exp+="float $distance=`mag<<$nowPosX-$prevPosX,$nowPosY-$prevPosY,$nowPosZ-$prevPosZ>>`;\n"; $exp+="float $curRotX=FKX"+$fitJoints[$i]+$side+".rotateX;\n"; $exp+="float $piD = 3.14 * $diameter;\n"; $exp+="FKX"+$fitJoints[$i]+$side+".rotateX=$curRotX+($distance/$piD)*360 * $autoRoll * "+($sideFactor*-1)+" * sin(deg_to_rad($sideAngle)) / $scale;\n"; $exp+="FK"+$fitJoints[$i]+$side+".prevPosX=$nowPosX;\n"; $exp+="FK"+$fitJoints[$i]+$side+".prevPosY=$nowPosY;\n"; $exp+="FK"+$fitJoints[$i]+$side+".prevPosZ=$nowPosZ;\n"; expression -n ($fitJoints[$i]+"WheelExpression"+$side) -s $exp -o ("FKX"+$fitJoints[$i]+$side) -ae 1 -uc all ; } //Lock FK for ($b=1;$b>-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i$temp2[2]) xform -ws -t $temp[0] 0 $temp3[2] ("IK"+$fitJointIK[$i]+$side+".cv["+$y+"]"); } } $temp=`xform -q -ws -t ($fitJoints[$i]+$side)`; rotate -r -p $temp[0] $temp[1] $temp[2] -ws 0 ($footRotOut[$i]*$b) 0 ("IK"+$fitJointIK[$i]+$side+".cv[0:99]"); } } //Default System values for ($b=1;$b>-2;$b=$b-2) for ($i=0;$i-2;$b=$b-2) for ($i=0;$i$maxNumUnderS[$dsNum]) $maxNumUnderS[$dsNum]=$numUnderS; } } for ($i=0;$i<99;$i++) for ($y=0;$y