// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== /* * Includes */ /* * globals */ global int $gJob_SelectionChanged = 0 ; // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- // Worker Procs // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- /* * cMuscle_cMuscleCreatorUI() - Main UI entry */ global proc cMuscle_cMuscleCreatorUI() { global int $gJob_SelectionChanged ; if (!`pluginInfo -q -loaded "MayaMuscle"`) error (uiRes("m_cMuscleCreatorUI.kMustLoadMusclePlugin")); if (`window -q -ex cMuscleCreatorWin`) { showWindow cMuscleCreatorWin ; return ; } window -w 420 -h 630 -t (uiRes("m_cMuscleCreatorUI.kMuscleCreator")) cMuscleCreatorWin ; formLayout mainTabForm ; tabLayout -childResizable true -scrollable true -innerMarginWidth 2 -innerMarginHeight 2 -sc ("") createMainTabs ; formLayout -e -af createMainTabs "top" 5 -af createMainTabs "bottom" 0 -af createMainTabs "left" 0 -af createMainTabs "right" 0 mainTabForm ; // Create // formLayout -p createMainTabs mcreatorForm ; tabLayout -e -tabLabelIndex 1 (uiRes("m_cMuscleCreatorUI.kCreateTab")) createMainTabs ; // text -l (uiRes("m_cMuscleCreatorUI.kCreateTabMuscleName")) txName ; textField -tx "Mus" tfName ; intSliderGrp -label (uiRes("m_cMuscleCreatorUI.kCreateTabNumControlsCrossSections")) -field true -minValue 1 -maxValue 24 -fieldMinValue 3 -fieldMaxValue 128 -value 5 -adj 3 -cw3 170 50 100 isgControls ; intSliderGrp -label (uiRes("m_cMuscleCreatorUI.kCreateTabNumSegments")) -field true -minValue 1 -maxValue 24 -fieldMinValue 3 -fieldMaxValue 128 -value 8 -adj 3 -cw3 170 50 100 isgAround ; text -l (uiRes("m_cMuscleCreatorUI.kCreateTabAttachStart")) txAttachStart ; textField -tx "" tfAttachStart ; button -l "<<<" -c ("cMCUI_loadSel(\"tfAttachStart\", 0);") -w 30 -ann (uiRes("m_cMuscleCreatorUI.kCreateTabLoadSelectedObject")) btnLoadAttachStart ; text -l (uiRes("m_cMuscleCreatorUI.kCreateTabAttachEnd")) txAttachEnd ; textField -tx "" tfAttachEnd ; button -l "<<<" -c ("cMCUI_loadSel(\"tfAttachEnd\", 1);") -w 30 -ann (uiRes("m_cMuscleCreatorUI.kCreateTabLoadSelectedObject2")) btnLoadAttachEnd ; checkBox -l (uiRes("m_cMuscleCreatorUI.kCreateTabCreateMuscleObjectShape")) -v 1 -ann (uiRes("m_cMuscleCreatorUI.kCreateTabCreateMuscleObjectShapeAnnot")) cbMakeMO ; button -l (uiRes("m_cMuscleCreatorUI.kCreateTabCreateMuscle")) -c ("cMuscle_createMuscleCB();") -ann (uiRes("m_cMuscleCreatorUI.kCreateTabCreateMuscleAnnot")) btnCreate ; frameLayout -l (uiRes("m_cMuscleCreatorUI.kMirrorFrame")) -cl 0 -cll 1 -cc ("") -ec ("") -p mcreatorForm frameMirror ; formLayout mirrorForm ; radioButtonGrp -l (uiRes("m_cMuscleCreatorUI.kMirrorFrameMirrorAxis")) -nrb 3 -la3 (uiRes("m_cMuscleCreatorUI.kMirrorFrameX")) (uiRes("m_cMuscleCreatorUI.kMirrorFrameY")) (uiRes("m_cMuscleCreatorUI.kMirrorFrameZ")) -sl 1 -cw4 70 40 40 40 rbgMirrorAxis ; text -l (uiRes("m_cMuscleCreatorUI.kMirrorFrameSearch")) txCMCUISearch ; textField -tx "" tfCMCUISearch ; text -l (uiRes("m_cMuscleCreatorUI.kMirrorFrameReplace")) txCMCUIReplace ; textField -tx "" tfCMCUIReplace ; popupMenu -p tfCMCUISearch pmSearch ; menuItem -l (uiRes("m_cMuscleCreatorUI.kSearchNone")) -c ("textField -e -tx \"\" tfCMCUISearch; textField -e -tx \"\" tfCMCUIReplace; ") ; menuItem -l "Lf" -c ("textField -e -tx \"Lf\" tfCMCUISearch; textField -e -tx \"Rt\" tfCMCUIReplace; ") ; menuItem -l "Rt" -c ("textField -e -tx \"Rt\" tfCMCUISearch; textField -e -tx \"Lf\" tfCMCUIReplace; ") ; menuItem -l "Lt" -c ("textField -e -tx \"Lt\" tfCMCUISearch; textField -e -tx \"Rt\" tfCMCUIReplace; ") ; menuItem -l "Rt" -c ("textField -e -tx \"Rt\" tfCMCUISearch; textField -e -tx \"Lt\" tfCMCUIReplace; ") ; menuItem -l "_L" -c ("textField -e -tx \"_L\" tfCMCUISearch; textField -e -tx \"_R\" tfCMCUIReplace; ") ; menuItem -l "_R" -c ("textField -e -tx \"_R\" tfCMCUISearch; textField -e -tx \"_L\" tfCMCUIReplace; ") ; menuItem -l "Left" -c ("textField -e -tx \"Left\" tfCMCUISearch; textField -e -tx \"Right\" tfCMCUIReplace; ") ; menuItem -l "Right" -c ("textField -e -tx \"Right\" tfCMCUISearch; textField -e -tx \"Left\" tfCMCUIReplace; ") ; button -l (uiRes("m_cMuscleCreatorUI.kMirrorFrameMirrorMuscleFromSelection")) -c ("cMCUI_createMirror()") -ann (uiRes("m_cMuscleCreatorUI.kMirrorFrameMirrorMuscleFromSelctionAnnot")) btnMirror ; formLayout -e -af rbgMirrorAxis "top" 5 -an rbgMirrorAxis "bottom" -af rbgMirrorAxis "left" 5 -an rbgMirrorAxis "right" -ac txCMCUISearch "top" 7 rbgMirrorAxis -an txCMCUISearch "bottom" -af txCMCUISearch "left" 5 -an txCMCUISearch "right" -ac tfCMCUISearch "top" 5 rbgMirrorAxis -an tfCMCUISearch "bottom" -ac tfCMCUISearch "left" 5 txCMCUISearch -ap tfCMCUISearch "right" 0 49 -ac txCMCUIReplace "top" 7 rbgMirrorAxis -an txCMCUIReplace "bottom" -ap txCMCUIReplace "left" 0 50 -an txCMCUIReplace "right" -ac tfCMCUIReplace "top" 5 rbgMirrorAxis -an tfCMCUIReplace "bottom" -ac tfCMCUIReplace "left" 5 txCMCUIReplace -af tfCMCUIReplace "right" 5 -ac btnMirror "top" 5 tfCMCUISearch -af btnMirror "bottom" 5 -af btnMirror "left" 5 -af btnMirror "right" 5 mirrorForm ; frameLayout -l (uiRes("m_cMuscleCreatorUI.kCopyPasteFrame")) -cl 0 -cll 1 -cc ("") -ec ("") -p mcreatorForm frameCopyPaste ; formLayout copyPasteForm ; button -l (uiRes("m_cMuscleCreatorUI.kCopyPasteFrameCopyPaste")) -c ("cMuscle_copyPasteUI();") -ann (uiRes("m_cMuscleCreatorUI.kCopyPasteFrameCopyPasteAnnot")) btnCopyPaste ; formLayout -e -af btnCopyPaste "top" 5 -af btnCopyPaste "bottom" 5 -af btnCopyPaste "left" 5 -af btnCopyPaste "right" 5 copyPasteForm ; formLayout -e -af txName "top" 7 -an txName "bottom" -af txName "left" 5 -an txName "right" -af tfName "top" 5 -an tfName "bottom" -ac tfName "left" 5 txName -af tfName "right" 5 -ac isgControls "top" 5 tfName -an isgControls "bottom" -af isgControls "left" 5 -af isgControls "right" 5 -ac isgAround "top" 5 isgControls -an isgAround "bottom" -af isgAround "left" 5 -af isgAround "right" 5 -ac txAttachStart "top" 8 isgAround -an txAttachStart "bottom" -af txAttachStart "left" 5 -an txAttachStart "right" -ac tfAttachStart "top" 5 isgAround -an tfAttachStart "bottom" -ac tfAttachStart "left" 5 txAttachStart -ac tfAttachStart "right" 5 btnLoadAttachStart -ac btnLoadAttachStart "top" 5 isgAround -an btnLoadAttachStart "bottom" -an btnLoadAttachStart "left" -ap btnLoadAttachStart "right" 0 50 -ac txAttachEnd "top" 8 isgAround -an txAttachEnd "bottom" -ac txAttachEnd "left" 5 btnLoadAttachStart -an txAttachEnd "right" -ac tfAttachEnd "top" 5 isgAround -an tfAttachEnd "bottom" -ac tfAttachEnd "left" 5 txAttachEnd -ac tfAttachEnd "right" 5 btnLoadAttachEnd -ac btnLoadAttachEnd "top" 5 isgAround -an btnLoadAttachEnd "bottom" -an btnLoadAttachEnd "left" -af btnLoadAttachEnd "right" 5 -ac cbMakeMO "top" 5 tfAttachStart -an cbMakeMO "bottom" -af cbMakeMO "left" 5 -an cbMakeMO "right" -ac btnCreate "top" 5 cbMakeMO -an btnCreate "bottom" -af btnCreate "left" 5 -af btnCreate "right" 5 -ac frameMirror "top" 5 btnCreate -an frameMirror "bottom" -af frameMirror "left" 5 -af frameMirror "right" 5 -ac frameCopyPaste "top" 5 frameMirror -an frameCopyPaste "bottom" -af frameCopyPaste "left" 5 -af frameCopyPaste "right" 5 mcreatorForm ; // Edit // formLayout -p createMainTabs cmcEditForm ; tabLayout -e -tabLabelIndex 2 (uiRes("m_cMuscleCreatorUI.kEdit")) createMainTabs ; frameLayout -l (uiRes("m_cMuscleCreatorUI.kSculptingFrame")) -cl 0 -cll 1 -cc ("") -ec ("") -p cmcEditForm frameSculpt ; formLayout sculptForm ; text -l (uiRes("m_cMuscleCreatorUI.kSculptingFrameAffect")) txAffect ; iconTextCheckBox -style "textOnly" -label (uiRes("m_cMuscleCreatorUI.kSculptingFrameAffectX")) -v 1 -w 32 -h 24 -ann (uiRes("m_cMuscleCreatorUI.kSculptingFrameAffectXAnnot")) itcbX ; iconTextCheckBox -style "textOnly" -label (uiRes("m_cMuscleCreatorUI.kSculptingFrameY")) -v 0 -w 32 -h 24 -ann (uiRes("m_cMuscleCreatorUI.kSculptingFrameYAnnot")) itcbY ; iconTextCheckBox -style "textOnly" -label (uiRes("m_cMuscleCreatorUI.kSculptingFrameZ")) -v 1 -w 32 -h 24 -ann (uiRes("m_cMuscleCreatorUI.kSculptingFrameZAnnot")) itcbZ ; iconTextCheckBox -style "textOnly" -label (uiRes("m_cMuscleCreatorUI.kSculptingFrameRest")) -v 1 -w 32 -h 24 -ann (uiRes("m_cMuscleCreatorUI.kSculptingFrameRestAnnot")) itcbRest ; iconTextCheckBox -style "textOnly" -label (uiRes("m_cMuscleCreatorUI.kSculptingFrameSq")) -v 1 -w 32 -h 24 -ann (uiRes("m_cMuscleCreatorUI.kSculptingFrameSqAnnot")) itcbSq ; iconTextCheckBox -style "textOnly" -label (uiRes("m_cMuscleCreatorUI.kSculptingFrameSt")) -v 1 -w 32 -h 24 -ann (uiRes("m_cMuscleCreatorUI.kSculptingFrameStAnnot")) itcbSt ; floatSliderGrp -label (uiRes("m_cMuscleCreatorUI.kSculptingFrameStrength")) -field true -minValue 0.0 -maxValue 10.0 -fieldMinValue 0.0 -fieldMaxValue 10000.0 -value 1.0 -pre 3 -adj 3 -cw3 60 60 100 fsgStr ; floatSliderGrp -label (uiRes("m_cMuscleCreatorUI.kSculptingFrameLocation")) -field false -minValue 0.0 -maxValue 1.0 -fieldMinValue 0.0 -fieldMaxValue 1.0 -value 0.5 -pre 3 -adj 2 -cw2 60 100 fsgLocation ; popupMenu -button 3 -p fsgLocation ; menuItem -l "0.0" -c ("floatSliderGrp -e -v 0.0 fsgLocation; ") ; menuItem -l "0.1" -c ("floatSliderGrp -e -v 0.1 fsgLocation; ") ; menuItem -l "0.2" -c ("floatSliderGrp -e -v 0.2 fsgLocation; ") ; menuItem -l "0.3" -c ("floatSliderGrp -e -v 0.3 fsgLocation; ") ; menuItem -l "0.4" -c ("floatSliderGrp -e -v 0.4 fsgLocation; ") ; menuItem -l "0.5" -c ("floatSliderGrp -e -v 0.5 fsgLocation; ") ; menuItem -l "0.6" -c ("floatSliderGrp -e -v 0.6 fsgLocation; ") ; menuItem -l "0.7" -c ("floatSliderGrp -e -v 0.7 fsgLocation; ") ; menuItem -l "0.8" -c ("floatSliderGrp -e -v 0.8 fsgLocation; ") ; menuItem -l "0.9" -c ("floatSliderGrp -e -v 0.9 fsgLocation; ") ; menuItem -l "1.0" -c ("floatSliderGrp -e -v 1.0 fsgLocation; ") ; floatSliderGrp -label (uiRes("m_cMuscleCreatorUI.kSculptingFrameFalloff")) -field false -minValue 0.0 -maxValue 1.5 -fieldMinValue 0.0 -fieldMaxValue 1.5 -value 0.5 -pre 3 -adj 2 -cw2 60 100 fsgFalloff ; popupMenu -button 3 -p fsgFalloff ; menuItem -l "0.0" -c ("floatSliderGrp -e -v 0.0 fsgFalloff; ") ; menuItem -l "0.1" -c ("floatSliderGrp -e -v 0.1 fsgFalloff; ") ; menuItem -l "0.2" -c ("floatSliderGrp -e -v 0.2 fsgFalloff; ") ; menuItem -l "0.3" -c ("floatSliderGrp -e -v 0.3 fsgFalloff; ") ; menuItem -l "0.4" -c ("floatSliderGrp -e -v 0.4 fsgFalloff; ") ; menuItem -l "0.5" -c ("floatSliderGrp -e -v 0.5 fsgFalloff; ") ; menuItem -l "0.6" -c ("floatSliderGrp -e -v 0.6 fsgFalloff; ") ; menuItem -l "0.7" -c ("floatSliderGrp -e -v 0.7 fsgFalloff; ") ; menuItem -l "0.8" -c ("floatSliderGrp -e -v 0.8 fsgFalloff; ") ; menuItem -l "0.9" -c ("floatSliderGrp -e -v 0.9 fsgFalloff; ") ; menuItem -l "1.0" -c ("floatSliderGrp -e -v 1.0 fsgFalloff; ") ; floatSliderGrp -label (uiRes("m_cMuscleCreatorUI.kSculptingFrameSculpt")) -field false -minValue -1.0 -maxValue 1.0 -fieldMinValue -1.0 -fieldMaxValue 1.0 -value 0.0 -pre 3 -adj 2 -cw2 60 100 -cc ("sculptChangeCB") -dc ("sculptDragCB") fsgSculpt ; formLayout -e -af txAffect "top" 8 -an txAffect "bottom" -af txAffect "left" 5 -an txAffect "right" -af itcbX "top" 5 -an itcbX "bottom" -ac itcbX "left" 5 txAffect -an itcbX "right" -af itcbY "top" 5 -an itcbY "bottom" -ac itcbY "left" 5 itcbX -an itcbY "right" -af itcbZ "top" 5 -an itcbZ "bottom" -ac itcbZ "left" 5 itcbY -an itcbZ "right" -af fsgStr "top" 5 -an fsgStr "bottom" -ac fsgStr "left" 5 itcbZ -af fsgStr "right" 5 -ac itcbRest "top" 5 itcbX -an itcbRest "bottom" -ac itcbRest "left" 5 txAffect -an itcbRest "right" -ac itcbSq "top" 5 itcbX -an itcbSq "bottom" -ac itcbSq "left" 5 itcbRest -an itcbSq "right" -ac itcbSt "top" 5 itcbX -an itcbSt "bottom" -ac itcbSt "left" 5 itcbSq -an itcbSt "right" -ac fsgLocation "top" 5 itcbRest -an fsgLocation "bottom" -af fsgLocation "left" 5 -ap fsgLocation "right" 0 49 -ac fsgFalloff "top" 5 itcbRest -an fsgFalloff "bottom" -ap fsgFalloff "left" 0 51 -af fsgFalloff "right" 5 -ac fsgSculpt "top" 5 fsgLocation -af fsgSculpt "bottom" 5 -af fsgSculpt "left" 5 -af fsgSculpt "right" 5 sculptForm ; frameLayout -l (uiRes("m_cMuscleCreatorUI.kPosesFrame")) -cl 0 -cll 1 -cc ("") -ec ("") -p cmcEditForm framePoses ; formLayout posesForm ; text -l (uiRes("m_cMuscleCreatorUI.kPosesFrameSetState")) txSetCurState ; button -l (uiRes("m_cMuscleCreatorUI.kPosesFrameRest")) -c ("cMCUI_setPoseCB(\"Default\");") -ann (uiRes("m_cMuscleCreatorUI.kPosesFrameRestAnnot")) btnPoseRest ; button -l (uiRes("m_cMuscleCreatorUI.kPosesFrameSquash")) -c ("cMCUI_setPoseCB(\"Squash\");") -ann (uiRes("m_cMuscleCreatorUI.kPosesFrameSquashAnnot")) btnPoseSquash ; button -l (uiRes("m_cMuscleCreatorUI.kPosesFrameStretch")) -c ("cMCUI_setPoseCB(\"Stretch\");") -ann (uiRes("m_cMuscleCreatorUI.kPosesFrameStretchAnnot")) btnPoseStretch ; button -l (uiRes("m_cMuscleCreatorUI.kPosesFrameResetWidth")) -c ("cMCUI_setCreatorDistanceAsDefault();") -ann (uiRes("m_cMuscleCreatorUI.kPosesFrameResetWidthAnnot")) btnResetWidth ; formLayout -e -af txSetCurState "top" 8 -an txSetCurState "bottom" -af txSetCurState "left" 5 -an txSetCurState "right" -af btnPoseRest "top" 5 -af btnPoseRest "bottom" 5 -ac btnPoseRest "left" 5 txSetCurState -an btnPoseRest "right" -af btnPoseSquash "top" 5 -af btnPoseSquash "bottom" 5 -ac btnPoseSquash "left" 5 btnPoseRest -an btnPoseSquash "right" -af btnPoseStretch "top" 5 -af btnPoseStretch "bottom" 5 -ac btnPoseStretch "left" 5 btnPoseSquash -an btnPoseStretch "right" -af btnResetWidth "top" 5 -af btnResetWidth "bottom" 5 -ac btnResetWidth "left" 10 btnPoseStretch -an btnResetWidth "right" posesForm ; frameLayout -l (uiRes("m_cMuscleCreatorUI.kGrowFrame")) -cl 0 -cll 1 -cc ("") -ec ("") -p cmcEditForm frameGrow ; formLayout growForm ; text -l (uiRes("m_cMuscleCreatorUI.kGrowFrameGrowSurface")) txGrowSurf ; textField -tx "" -ann (uiRes("m_cMuscleCreatorUI.kGrowFrameGrowSurfaceAnnot")) tfGrowSurf ; button -l "<<<" -c ("cMCUI_loadSelMult(\"tfGrowSurf\");") -w 30 -ann (uiRes("m_cMuscleCreatorUI.kGrowFrameSelectSurface")) btnGrowSurf ; text -l (uiRes("m_cMuscleCreatorUI.kGrowFrameMainBone")) txMainBone ; textField -tx "" -ann (uiRes("m_cMuscleCreatorUI.kGrowFrameMainBoneAnnot")) tfMainBone ; button -l "<<<" -c ("cMCUI_loadSel(\"tfMainBone\", 0); cMCUI_guessTipBone();") -w 30 -ann (uiRes("m_cMuscleCreatorUI.kGrowFrameSelectMainBone")) btnMainBone ; text -l (uiRes("m_cMuscleCreatorUI.kGrowFrameMainBoneTip")) txMainBoneTip ; textField -tx "" -ann (uiRes("m_cMuscleCreatorUI.kGrowFrameMainBoneTipAnnot")) tfMainBoneTip ; button -l "<<<" -c ("cMCUI_loadSel(\"tfMainBoneTip\", 0);") -w 30 -ann (uiRes("m_cMuscleCreatorUI.kGrowFrameSelectMainBoneTip")) btnMainBoneTip ; floatSliderGrp -label (uiRes("m_cMuscleCreatorUI.kGrowFrameAngle")) -field true -minValue 0.0 -maxValue 180.0 -fieldMinValue 0.0 -fieldMaxValue 180.0 -value 120.0 -pre 2 -adj 3 -cw3 53 60 100 fsgBoneAngle ; floatSliderGrp -label (uiRes("m_cMuscleCreatorUI.kGrowFrameFat")) -field true -minValue 0.0 -maxValue 10.0 -fieldMinValue 0.0 -fieldMaxValue 1000000.0 -value 0.0 -pre 3 -adj 3 -cw3 53 60 100 fsgFat ; floatSliderGrp -label (uiRes("m_cMuscleCreatorUI.kGrowFrameRest")) -field true -minValue 0.0 -maxValue 200.0 -fieldMinValue 0.0 -fieldMaxValue 1000000.0 -value 100.0 -pre 1 -adj 3 -cw3 53 60 100 fsgPctRest ; floatSliderGrp -label (uiRes("m_cMuscleCreatorUI.kGrowFrameSq")) -field true -minValue 0.0 -maxValue 200.0 -fieldMinValue 0.0 -fieldMaxValue 1000000.0 -value 150.0 -pre 1 -adj 3 -cw3 30 60 100 fsgPctSq ; floatSliderGrp -label (uiRes("m_cMuscleCreatorUI.kGrowFrameSt")) -field true -minValue 0.0 -maxValue 200.0 -fieldMinValue 0.0 -fieldMaxValue 1000000.0 -value 70.0 -pre 1 -adj 3 -cw3 30 60 100 fsgPctSt ; button -l (uiRes("m_cMuscleCreatorUI.kGrowFrameGrowMuscle")) -c ("cMuscle_growMuscle") -ann (uiRes("m_cMuscleCreatorUI.kGrowFrameGrowMuscleAnnot")) btnGrow ; button -l (uiRes("m_cMuscleCreatorUI.kGrowFrameGrowSelPoints")) -c ("cMuscle_growSelPts") -ann (uiRes("m_cMuscleCreatorUI.kGrowFrameGrowSelPointsAnnot")) btnGrowPts ; button -l (uiRes("m_cMuscleCreatorUI.kGrwFrameResetToCyl")) -c ("cMuscle_resetToCyl") -ann (uiRes("m_cMuscleCreatorUI.kGrwFrameResetToCylAnnot")) btnResetCyl ; formLayout -e -af txGrowSurf "top" 8 -an txGrowSurf "bottom" -af txGrowSurf "left" 5 -an txGrowSurf "right" -af tfGrowSurf "top" 5 -an tfGrowSurf "bottom" -ac tfGrowSurf "left" 5 txGrowSurf -ac tfGrowSurf "right" 5 btnGrowSurf -af btnGrowSurf "top" 5 -an btnGrowSurf "bottom" -an btnGrowSurf "left" -af btnGrowSurf "right" 5 -ac txMainBone "top" 8 tfGrowSurf -an txMainBone "bottom" -af txMainBone "left" 5 -an txMainBone "right" -ac tfMainBone "top" 5 tfGrowSurf -an tfMainBone "bottom" -ac tfMainBone "left" 5 txMainBone -ac tfMainBone "right" 5 btnMainBone -ac btnMainBone "top" 5 tfGrowSurf -an btnMainBone "bottom" -an btnMainBone "left" -ap btnMainBone "right" 0 50 -ac txMainBoneTip "top" 8 tfGrowSurf -an txMainBoneTip "bottom" -ap txMainBoneTip "left" 0 51 -an txMainBoneTip "right" -ac tfMainBoneTip "top" 5 tfGrowSurf -an tfMainBoneTip "bottom" -ac tfMainBoneTip "left" 5 txMainBoneTip -ac tfMainBoneTip "right" 5 btnMainBoneTip -ac btnMainBoneTip "top" 5 tfGrowSurf -an btnMainBoneTip "bottom" -an btnMainBoneTip "left" -af btnMainBoneTip "right" 5 -ac fsgBoneAngle "top" 5 tfMainBone -an fsgBoneAngle "bottom" -af fsgBoneAngle "left" 5 -af fsgBoneAngle "right" 5 -ac fsgFat "top" 5 fsgBoneAngle -an fsgFat "bottom" -af fsgFat "left" 5 -af fsgFat "right" 5 -ac fsgPctRest "top" 5 fsgFat -an fsgPctRest "bottom" -af fsgPctRest "left" 5 -ap fsgPctRest "right" 0 33 -ac fsgPctSq "top" 5 fsgFat -an fsgPctSq "bottom" -ap fsgPctSq "left" 0 34 -ap fsgPctSq "right" 0 66 -ac fsgPctSt "top" 5 fsgFat -an fsgPctSt "bottom" -ap fsgPctSt "left" 0 67 -af fsgPctSt "right" 5 -ac btnGrow "top" 5 fsgPctRest -af btnGrow "bottom" 5 -af btnGrow "left" 5 -ap btnGrow "right" 0 33 -ac btnGrowPts "top" 5 fsgPctRest -af btnGrowPts "bottom" 5 -ap btnGrowPts "left" 0 34 -ap btnGrowPts "right" 0 66 -ac btnResetCyl "top" 5 fsgPctRest -af btnResetCyl "bottom" 5 -ap btnResetCyl "left" 0 67 -af btnResetCyl "right" 5 growForm ; setParent cmcEditForm ; text -l (uiRes("m_cMuscleCreatorUI.kEditTabCreator")) txCreator ; textField -tx "" -en 0 tfCreator ; popupMenu -p txCreator pmCreator ; menuItem -l (uiRes("m_cMuscleCreatorUI.kCreatorSelectCreator")) -c ("string $creators[] = cMCUI_getCreatorsFromList() ; if (size($creators) > 0) { select -r $creators ; } ") ; text -l (uiRes("m_cMuscleCreatorUI.kCreatorContols")) txControl ; text -l (uiRes("m_cMuscleCreatorUI.kCreatorCSestRest")) txCSectRest ; text -l (uiRes("m_cMuscleCreatorUI.kCreatorCSestSquash")) txCSectSq ; text -l (uiRes("m_cMuscleCreatorUI.kCreatorCSestStretch")) txCSectSt ; text -l (uiRes("m_cMuscleCreatorUI.kCreatorAttachLocs")) txAttachLocs ; text -l (uiRes("m_cMuscleCreatorUI.kCreatorAttachRest")) txAttachRest ; text -l (uiRes("m_cMuscleCreatorUI.kCreatorAttachSquash")) txAttachSq ; text -l (uiRes("m_cMuscleCreatorUI.kCreatorAttachStretch")) txAttachSt ; textScrollList -ams true -sc ("cMCUI_selectFromLists(\"tslControls\");") tslControls ; textScrollList -ams true -sc ("cMCUI_selectFromLists(\"tslCSectRest\");") tslCSectRest ; textScrollList -ams true -sc ("cMCUI_selectFromLists(\"tslCSectSq\");") tslCSectSq ; textScrollList -ams true -sc ("cMCUI_selectFromLists(\"tslCSectSt\");") tslCSectSt ; textScrollList -ams true -sc ("cMCUI_selectFromLists(\"tslAttachLocs\");") tslAttachLocs ; textScrollList -ams true -sc ("cMCUI_selectFromLists(\"tslAttachRest\");") tslAttachRest ; textScrollList -ams true -sc ("cMCUI_selectFromLists(\"tslAttachSq\");") tslAttachSq ; textScrollList -ams true -sc ("cMCUI_selectFromLists(\"tslAttachSt\");") tslAttachSt ; string $labelShow = (uiRes("m_cMuscleCreatorUI.kCreatorShow")) ; string $labelHide = (uiRes("m_cMuscleCreatorUI.kCreatorHide")) ; popupMenu -p tslControls pmControls ; menuItem -l $labelShow -c ("cMCUI_showHideControls(\"controls\", 1); ") ; menuItem -l $labelHide -c ("cMCUI_showHideControls(\"controls\", 0); ") ; popupMenu -p tslCSectRest pmCSectRest ; menuItem -l $labelShow -c ("cMCUI_showHideControls(\"rest\", 1); ") ; menuItem -l $labelHide -c ("cMCUI_showHideControls(\"rest\", 0); ") ; popupMenu -p tslCSectSq pmCSectSq ; menuItem -l $labelShow -c ("cMCUI_showHideControls(\"sq\", 1); ") ; menuItem -l $labelHide -c ("cMCUI_showHideControls(\"sq\", 0); ") ; popupMenu -p tslCSectSt pmCSectSt ; menuItem -l $labelShow -c ("cMCUI_showHideControls(\"st\", 1); ") ; menuItem -l $labelHide -c ("cMCUI_showHideControls(\"st\", 0); ") ; popupMenu -p tslAttachLocs pmAttachLocs ; menuItem -l $labelShow -c ("cMCUI_showHideControls(\"locs\", 1); ") ; menuItem -l $labelHide -c ("cMCUI_showHideControls(\"locs\", 0); ") ; popupMenu -p tslAttachRest pmAttachRest ; menuItem -l $labelShow -c ("cMCUI_showHideControls(\"rest\", 1); ") ; menuItem -l $labelHide -c ("cMCUI_showHideControls(\"rest\", 0); ") ; popupMenu -p tslAttachSq pmAttachSq ; menuItem -l $labelShow -c ("cMCUI_showHideControls(\"sq\", 1); ") ; menuItem -l $labelHide -c ("cMCUI_showHideControls(\"sq\", 0); ") ; popupMenu -p tslAttachSt pmAttachSt ; menuItem -l $labelShow -c ("cMCUI_showHideControls(\"st\", 1); ") ; menuItem -l $labelHide -c ("cMCUI_showHideControls(\"st\", 0); ") ; formLayout -e -af frameSculpt "top" 5 -an frameSculpt "bottom" -af frameSculpt "left" 5 -af frameSculpt "right" 5 -ac frameGrow "top" 5 frameSculpt -an frameGrow "bottom" -af frameGrow "left" 5 -af frameGrow "right" 5 -ac framePoses "top" 5 frameGrow -an framePoses "bottom" -af framePoses "left" 5 -af framePoses "right" 5 -ac txCreator "top" 8 framePoses -an txCreator "bottom" -af txCreator "left" 5 -an txCreator "right" -ac tfCreator "top" 5 framePoses -an tfCreator "bottom" -ac tfCreator "left" 5 txCreator -af tfCreator "right" 5 -ac txControl "top" 5 tfCreator -an txControl "bottom" -af txControl "left" 5 -ap txControl "right" 0 24 -ac txCSectRest "top" 5 tfCreator -an txCSectRest "bottom" -ap txCSectRest "left" 0 25 -ap txCSectRest "right" 0 49 -ac txCSectSq "top" 5 tfCreator -an txCSectSq "bottom" -ap txCSectSq "left" 0 50 -ap txCSectSq "right" 0 74 -ac txCSectSt "top" 5 tfCreator -an txCSectSt "bottom" -ap txCSectSt "left" 0 75 -af txCSectSt "right" 5 -ac tslControls "top" 5 txControl -ap tslControls "bottom" 0 70 -af tslControls "left" 5 -ap tslControls "right" 0 24 -ac tslCSectRest "top" 5 txCSectRest -ap tslCSectRest "bottom" 0 70 -ap tslCSectRest "left" 0 25 -ap tslCSectRest "right" 0 49 -ac tslCSectSq "top" 5 txCSectSq -ap tslCSectSq "bottom" 0 70 -ap tslCSectSq "left" 0 50 -ap tslCSectSq "right" 0 74 -ac tslCSectSt "top" 5 txCSectSt -ap tslCSectSt "bottom" 0 70 -ap tslCSectSt "left" 0 75 -af tslCSectSt "right" 5 -ac txAttachLocs "top" 5 tslControls -an txAttachLocs "bottom" -af txAttachLocs "left" 5 -ap txAttachLocs "right" 0 24 -ac txAttachRest "top" 5 tslCSectRest -an txAttachRest "bottom" -ap txAttachRest "left" 0 25 -ap txAttachRest "right" 0 49 -ac txAttachSq "top" 5 tslCSectSq -an txAttachSq "bottom" -ap txAttachSq "left" 0 50 -ap txAttachSq "right" 0 74 -ac txAttachSt "top" 5 tslCSectSt -an txAttachSt "bottom" -ap txAttachSt "left" 0 75 -af txAttachSt "right" 5 -ac tslAttachLocs "top" 5 txAttachLocs -af tslAttachLocs "bottom" 5 -af tslAttachLocs "left" 5 -ap tslAttachLocs "right" 0 24 -ac tslAttachRest "top" 5 txAttachRest -af tslAttachRest "bottom" 5 -ap tslAttachRest "left" 0 25 -ap tslAttachRest "right" 0 49 -ac tslAttachSq "top" 5 txAttachSq -af tslAttachSq "bottom" 5 -ap tslAttachSq "left" 0 50 -ap tslAttachSq "right" 0 74 -ac tslAttachSt "top" 5 txAttachSt -af tslAttachSt "bottom" 5 -ap tslAttachSt "left" 0 75 -af tslAttachSt "right" 5 cmcEditForm ; showWindow cMuscleCreatorWin ; scriptJob -p cMuscleCreatorWin -uiDeleted "cMuscleCreatorWin" "cMCUI_CBQuit" ; $gJob_SelectionChanged = `scriptJob -p cMuscleCreatorWin -event "SelectionChanged" "cMCUI_CBSelChanged"` ; cMCUI_CBSelChanged() ; } // -------------------------------------------------------------------------- /* * cMCUI_CBQuit() - Quit proc callback */ global proc cMCUI_CBQuit() { } // -------------------------------------------------------------------------- /* * cMCUI_CBSelChanged() - Selection changed callback */ global proc cMCUI_CBSelChanged() { // Get the list of creators from the selection... string $creators[] = cMuscle_getSelectedDeformers("cMuscleCreator") ; string $creator ; if (size($creators) > 0) { textScrollList -e -removeAll tslControls ; textScrollList -e -removeAll tslCSectRest ; textScrollList -e -removeAll tslCSectSq ; textScrollList -e -removeAll tslCSectSt ; textScrollList -e -removeAll tslAttachLocs ; textScrollList -e -removeAll tslAttachRest ; textScrollList -e -removeAll tslAttachSq ; textScrollList -e -removeAll tslAttachSt ; } string $list = "" ; for ($creator in $creators) { $list += $creator + " " ; int $nCtrls = `getAttr -size ($creator+".controlData")` ; int $c ; for ($c=1; $c < $nCtrls-1; ++$c) { string $cons[] ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".controlData["+$c+"].insertMatrix")` ; for ($con in $cons) textScrollList -e -a $con tslControls ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".controlData["+$c+"].curveRest")` ; for ($con in $cons) textScrollList -e -a $con tslCSectRest ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".controlData["+$c+"].curveSq")` ; for ($con in $cons) textScrollList -e -a $con tslCSectSq ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".controlData["+$c+"].curveSt")` ; for ($con in $cons) textScrollList -e -a $con tslCSectSt ; } int $nAttach = `getAttr -size ($creator+".attachData")` ; int $a ; for ($a=0; $a < $nAttach; ++$a) { string $cons[] ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".attachData["+$a+"].attachMatrix")` ; for ($con in $cons) textScrollList -e -a $con tslAttachRest ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".attachData["+$a+"].attachMatrixSq")` ; for ($con in $cons) textScrollList -e -a $con tslAttachSq ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".attachData["+$a+"].attachMatrixSt")` ; for ($con in $cons) textScrollList -e -a $con tslAttachSt ; } // Attach Locs too... string $cons[] ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".startPointA")` ; textScrollList -e -a $cons[0] tslAttachLocs ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".startPointB")` ; textScrollList -e -a $cons[0] tslAttachLocs ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".endPointA")` ; textScrollList -e -a $cons[0] tslAttachLocs ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".endPointB")` ; textScrollList -e -a $cons[0] tslAttachLocs ; } if ($list != "") textField -e -tx $list tfCreator ; } // -------------------------------------------------------------------------- /* * cMCUI_selectFromLists() - */ global proc cMCUI_selectFromLists(string $tslUsing) { global int $gJob_SelectionChanged ; string $tslList[] = {"tslControls", "tslCSectRest", "tslCSectSq", "tslCSectSt", "tslAttachLocs", "tslAttachRest", "tslAttachSq", "tslAttachSt" } ; int $mods = `getModifiers`; // If user is not holding down Ctrl or Shift, then clear out the other lists... if ( !((($mods / 1) % 2) || (($mods / 4) % 2)) ) { string $tsl ; for ($tsl in $tslList) { if ($tsl == $tslUsing) continue ; textScrollList -e -deselectAll $tsl ; } } string $ctrls[] = `textScrollList -q -selectItem tslControls` ; string $csect[] = `textScrollList -q -selectItem tslCSectRest` ; string $csectSq[] = `textScrollList -q -selectItem tslCSectSq` ; string $csectSt[] = `textScrollList -q -selectItem tslCSectSt` ; string $attachLocs[] = `textScrollList -q -selectItem tslAttachLocs` ; string $attach[] = `textScrollList -q -selectItem tslAttachRest` ; string $attachSq[] = `textScrollList -q -selectItem tslAttachSq` ; string $attachSt[] = `textScrollList -q -selectItem tslAttachSt` ; //select -cl ; scriptJob -kill $gJob_SelectionChanged ; select -r $ctrls $csect $csectSq $csectSt $attachLocs $attach $attachSq $attachSt ; $gJob_SelectionChanged = `scriptJob -p cMuscleCreatorWin -event "SelectionChanged" "cMCUI_CBSelChanged"` ; } // -------------------------------------------------------------------------- /* * cMCUI_getCreatorsFromList() - */ global proc string[] cMCUI_getCreatorsFromList() { string $list = `textField -q -tx tfCreator` ; string $creators[] ; tokenize($list, $creators) ; return $creators ; } // -------------------------------------------------------------------------- /* * cMCUI_loadSel() - Load sel items into a textfield */ global proc cMCUI_loadSel(string $tf, int $idx) { string $objs[] = `ls -sl`; if (size($objs) >= 2 && $idx > 0) $objs[0] = $objs[1] ; // Fake to use second selection if we have 2 objects textField -e -tx $objs[0] $tf ; } // -------------------------------------------------------------------------- /* * cMCUI_loadSelMult() - Load sel items into a textfield */ global proc cMCUI_loadSelMult(string $tf) { string $objs[] = `ls -sl`; string $txt = "" ; string $obj ; for ($obj in $objs) $txt += $obj + " " ; textField -e -tx $txt $tf ; } // -------------------------------------------------------------------------- /* * cMuscle_createCreatorLocsCB() - Creates 4 locators for a muscle to attach to * so the user doesn't have to make them by hand. */ global proc cMuscle_createCreatorLocsCB() { string $baseName = `textField -q -tx tfName` ; string $attachStart = `textField -q -tx tfAttachStart` ; string $attachEnd = `textField -q -tx tfAttachEnd` ; string $locStart1s[] = `spaceLocator -n ("loc"+$baseName+"Start1")` ; string $locStart1 = $locStart1s[0] ; string $locStart2s[] = `spaceLocator -n ("loc"+$baseName+"Start2")` ; string $locStart2 = $locStart2s[0] ; string $locEnd1s[] = `spaceLocator -n ("loc"+$baseName+"End1")` ; string $locEnd1 = $locEnd1s[0] ; string $locEnd2s[] = `spaceLocator -n ("loc"+$baseName+"End2")` ; string $locEnd2 = $locEnd2s[0] ; if ($attachStart != "") { cMuscle_snap($attachStart, $locStart1) ; cMuscle_snap($attachStart, $locStart2) ; } if ($attachEnd != "") { cMuscle_snap($attachEnd, $locEnd1) ; cMuscle_snap($attachEnd, $locEnd2) ; } // TODO: make spread nice.... // Now to make it spread out we look at the trans value of the end relative to the start // and take the smallest one as the axis... // So we temporarily parent the end to the start to read parent $locEnd1 $locStart1 ; parent $locEnd2 $locStart2 ; float $tx1 = `getAttr ($locEnd1+".tx")` ; float $tx2 = `getAttr ($locEnd2+".tx")` ; float $ty1 = `getAttr ($locEnd1+".ty")` ; float $ty2 = `getAttr ($locEnd2+".ty")` ; float $tz1 = `getAttr ($locEnd1+".tz")` ; float $tz2 = `getAttr ($locEnd2+".tz")` ; float $avgX = ( abs( $tx1 ) + abs( $tx2 ) ) / 2.0 ; float $avgY = ( abs( $ty1 ) + abs( $ty2 ) ) / 2.0 ; float $avgZ = ( abs( $tz1 ) + abs( $tz2 ) ) / 2.0 ; // Also calc avg distance... float $avgDist = ( cMuscle_objDist($locStart1, $locEnd1) + cMuscle_objDist($locStart2, $locEnd2) ) / 2.0 ; float $fShift = $avgDist / 8.0 ; float $mx=0, $my=0, $mz=0 ; if ($avgX <= $avgY && $avgX <= $avgZ) $mx = 1.0 ; else if ($avgY <= $avgX && $avgY <= $avgZ) $my = 1.0 ; else $mz = 1.0 ; xform -r -os -t (-$fShift * $mx) (-$fShift * $my) (-$fShift * $mz) $locStart1 ; xform -r -os -t ( $fShift * $mx) ( $fShift * $my) ( $fShift * $mz) $locStart2 ; // Now everything is made nice...parent if ($attachStart != "") { parent $locStart1 $locStart2 $attachStart ; } if ($attachEnd != "") { parent $locEnd1 $locEnd2 $attachEnd ; } select -r $locStart1 $locStart2 $locEnd1 $locEnd2 ; } // -------------------------------------------------------------------------- /* * cMuscle_MuscleExists() - Checks if the muscle with $baseName already * exists */ proc int cMuscle_MuscleExists(string $baseName) { string $locStart1 = "loc"+$baseName+"Start1"; string $locStart2 = "loc"+$baseName+"Start2"; string $locEnd1 = "loc"+$baseName+"End1"; string $locEnd2 = "loc"+$baseName+"End2"; string $muscleCreatorNodeName = "cMuscleCreator"+$baseName; if(`objExists $locStart1` || `objExists $locStart2` || `objExists $locEnd1` || `objExists $locEnd2`) { return 1; } string $muscleCreatorNodes[] = `ls -type cMuscleCreator`; for($muscleCreator in $muscleCreatorNodes) { if($muscleCreatorNodeName == $muscleCreator) return 1; } return 0; } // -------------------------------------------------------------------------- /* * cMuscle_createMuscleCB() - */ global proc cMuscle_createMuscleCB() { string $baseName = `textField -q -tx tfName` ; int $nMidControls = `intSliderGrp -q -v isgControls` ; int $nAround = `intSliderGrp -q -v isgAround` ; string $attachStart = `textField -q -tx tfAttachStart` ; string $attachEnd = `textField -q -tx tfAttachEnd` ; int $bMakeMO = `checkBox -q -v cbMakeMO` ; if(cMuscle_MuscleExists($baseName)) { error (uiRes("m_cMuscleCreatorUI.kMuscleAlreadyExists")); return; } cMuscle_createCreatorMuscleFromSel( $baseName, $nMidControls, $nAround, $attachStart, $attachEnd, $bMakeMO) ; } // -------------------------------------------------------------------------- /* * cMCUI_setPoseCB() - */ global proc cMCUI_setPoseCB(string $poseToSet) { // Get the list of creators ... string $creators[] = cMCUI_getCreatorsFromList() ; for ($creator in $creators) { cMuscle_storePoseState($poseToSet, $creator) ; } string $msg = (uiRes("m_cMuscleCreatorUI.kSetPoseAs")); $msg = `format -stringArg $poseToSet $msg`; print ($msg) ; } // -------------------------------------------------------------------------- /* * cMCUI_selectAttachMoversCB() - */ /* global proc cMCUI_selectAttachMoversCB(string $poseTest) { // Get the list of creators ... string $creators[] = cMCUI_getCreatorsFromList() ; string $attaches[] ; for ($creator in $creators) { int $nAttach = `getAttr -size ($creator+".attachData")` ; int $a ; for ($a=0; $a < $nAttach; ++$a) { string $cons[] ; if ($poseTest == "Default" || $poseTest == "Rest") $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".attachData["+$a+"].attachMatrix")` ; else if ($poseTest == "Squash") $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".attachData["+$a+"].attachMatrixSq")` ; else if ($poseTest == "Stretch") $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".attachData["+$a+"].attachMatrixSt")` ; string $attachNode = $cons[0] ; $attaches[size($attaches)] = $attachNode ; } } if (size($attaches) > 0) select -r $attaches ; } */ // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- // Build Procs // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- /* * cMuscle_createCreatorMuscleFromSel() - Creates a cMuscleCreator style * muscle based on 4 select CV's or points etc... */ global proc string[] cMuscle_createCreatorMuscleFromSel(string $baseName, int $nMidControls, int $nAround, string $attachStart, string $attachEnd, int $bMakeMO ) { string $origSel[] = `ls -fl -sl` ; int $nSel = size($origSel) ; // if ($nSel < 4) // error -sl 0 ("You must select 4 Transforms, CV's, Faces, or Double-Edges or a combination thereof that will result in 4 transforms/cMuscleSurfAttach nodes!") ; // I decided it just makes sense to always create the locators...then that way one can just move/adjust later as needed and then reset the // lengths as needed anyhow...less work/confusion for the rigger...simpler UI...and easier to deal with, since always the same. // Users can always reparent the locators to other stuff if desired... // HOWEVER....this works only if less than 4 items are selected...if something is selected...then it's assuming the user is choosing edges // or points or something to use as an attach,...like locators/transforms... if ($nSel < 4) { cMuscle_createCreatorLocsCB() ; $origSel = `ls -fl -sl` ; $nSel = size($origSel) ; } string $attaches[] ; int $a = 0 ; int $i ; for ($i=0; $i < $nSel; ++$i) { if (gmatch($origSel[$i], "*.uv*") || (gmatch($origSel[$i], "*.f*"))) { select -r $origSel[$i] ; cMuscleSurfAttachSetup() ; // First convert selection to attach nodes... string $temp[] = `ls -sl` ; $attaches[$a] = $temp[0] ; // Store this attach node ++$a ; } else if (gmatch($origSel[$i], "*.e*")) // We should have -2- Edges! { select -r $origSel[$i] $origSel[$i+1] ; cMuscleSurfAttachSetup() ; // First convert selection to attach nodes... string $temp[] = `ls -sl` ; $attaches[$a] = $temp[0] ; // Store this attach node ++$a ; ++$i ; // do this too since we grabbed two off! } else // else assume it's a transform... { $attaches[$a] = $origSel[$i] ; ++$a ; } } // Make the Node and Surface! // string $creator = `createNode cMuscleCreator -n ("cMuscleCreator"+$baseName+"#")` ; string $surf = `createNode nurbsSurface -n ("cMuscleSurfaceShape"+$baseName+"#")` ; string $parents[] = `listRelatives -p $surf` ; string $xform = $parents[0] ; // Store some internal attrs so we can mirror easily later... addAttr -ln "nMidControls" -at "long" -k 0 -dv $nMidControls $creator ; addAttr -ln "nAround" -at "long" -k 0 -dv $nAround $creator ; int $nPrimaryAxis = cMuscle_guessPrimaryAxis($attachStart, $attachEnd) ; // Make in nice hierarchy string $grpMain ; if (objExists("grp"+$xform+"RIG")) $grpMain = `group -em -w -n ("grp"+$xform+"RIG#")` ; else $grpMain = `group -em -w -n ("grp"+$xform+"RIG")` ; parent $xform $grpMain ; if (objExists("grpMUSCLES") != true) { group -em -w -n "grpMUSCLES" ; } parent $grpMain "grpMUSCLES" ; string $grpCTRLs = `group -em -w -n ("grp"+$xform+"Controls#")` ; string $grpATTACHs = `group -em -w -n ("grp"+$xform+"Attaches#")` ; parent $grpCTRLs $grpMain ; parent $grpATTACHs $grpMain ; // Lock down nicely since it should never really move... setAttr ($grpMain+".inheritsTransform") 0 ; setAttr ($xform+".inheritsTransform") 0 ; setAttr -l 1 -k 0 ($xform+".tx") ; setAttr -l 1 -k 0 ($xform+".ty") ; setAttr -l 1 -k 0 ($xform+".tz") ; setAttr -l 1 -k 0 ($xform+".rx") ; setAttr -l 1 -k 0 ($xform+".ry") ; setAttr -l 1 -k 0 ($xform+".rz") ; setAttr -l 1 -k 0 ($xform+".sx") ; setAttr -l 1 -k 0 ($xform+".sy") ; setAttr -l 1 -k 0 ($xform+".sz") ; float $fWidthStart = cMuscle_objDist($attaches[0], $attaches[1]) ; float $fWidthEnd = cMuscle_objDist($attaches[2], $attaches[3]) ; setAttr ($creator+".defWidthStart") ( $fWidthStart ) ; setAttr ($creator+".defWidthEnd") ( $fWidthEnd ) ; // Get avg length and scale curves nicely float $fDist = (cMuscle_objDist($attaches[0], $attaches[2]) + cMuscle_objDist($attaches[1], $attaches[3])) /2.0 ; float $fRadius = 0.3 * ($fWidthStart + $fWidthEnd) /2.0 ; // Make the Start/End Parents up... string $startParent = `curve -d 1 -p 0 1 0 -p 0 -1 0 -p 0 0 0 -p -1 0 0 -p 1 0 0 -p 0 0 0 -p 0 0 1 -p 0 0 -1 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -n ("StartParent"+$baseName+"#")` ; string $endParent = `curve -d 1 -p 0 1 0 -p 0 -1 0 -p 0 0 0 -p -1 0 0 -p 1 0 0 -p 0 0 0 -p 0 0 1 -p 0 0 -1 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -n ("EndParent"+$baseName+"#")` ; cMuscle_snapBetween($attaches[0], $attaches[1], $startParent) ; cMuscle_snapBetween($attaches[2], $attaches[3], $endParent) ; select -r ($startParent+".cv[*]") ; xform -r -os -s ($fDist*0.2) ($fDist*0.2) ($fDist*0.2) ; select -r ($endParent+".cv[*]") ; xform -r -os -s ($fDist*0.2) ($fDist*0.2) ($fDist*0.2) ; setAttr ($startParent+".overrideEnabled") 1; // on setAttr ($startParent+".overrideColor") 14 ; // green setAttr ($endParent+".overrideEnabled") 1; // on setAttr ($endParent+".overrideColor") 14 ; // green parent $startParent $endParent $grpMain ; if ($attachStart != "") parent $startParent $attachStart ; if ($attachEnd != "") parent $endParent $attachEnd ; // make end move down length a bit so distance pose works not only rotation...this just makes it better... // Do AFTER parenting... since we are moving in object space of the parent...ie: locally. float $fixMove[3] = {0,0,0} ; if ($nPrimaryAxis >= 3) { $fixMove[$nPrimaryAxis-3] = -1 * $fDist ; } else $fixMove[$nPrimaryAxis] = $fDist ; xform -r -os -t $fixMove[0] $fixMove[1] $fixMove[2] $endParent ; string $aCons[] = `aimConstraint -w 1 -aim 0 1 0 -wut "object" -u 1 0 0 -wuo $attaches[1] $attaches[2] $attaches[3] $startParent` ; delete $aCons ; $aCons = `orientConstraint -w 1 $startParent $endParent` ; delete $aCons ; // Make all the mid controls and connect in.... int $m ; for ($m=0; $m < $nMidControls; ++$m) { int $cIdx = $m+1 ; float $fPct = ($m+1.0) / ($nMidControls+2.0-1.0) ; // +1 since after start and +2 since extra start/end but these are mid float $fPctHalf = 1.0 - (abs($fPct-0.5) / 0.5 ) ; float $fPctHalfSmooth = $fPctHalf * $fPctHalf * (3.0 - (2.0 * $fPctHalf) ) ; float $fRadCur = $fRadius + ($fPctHalfSmooth * $fRadius) ; string $ctrl = `curve -d 1 -p -0.25 0.25 0.25 -p 0.25 0.25 0.25 -p 0.25 0.25 -0.25 -p -0.25 0.25 -0.25 -p -0.25 0.25 0.25 -p -0.25 -0.25 0.25 -p -0.25 -0.25 -0.25 -p 0.25 -0.25 -0.25 -p 0.25 -0.25 0.25 -p -0.25 -0.25 0.25 -p 0.25 -0.25 0.25 -p 0.25 0.25 0.25 -p 0.25 0.25 -0.25 -p 0.25 -0.25 -0.25 -p -0.25 -0.25 -0.25 -p -0.25 0.25 -0.25 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -n ("iControlMid"+$baseName+($m+1)+"#")`; string $linearZERO = `group -em -w -n ("linear"+$baseName+($m+1)+"ZERO#")` ; string $linearAUTO = `group -em -w -n ("linear"+$baseName+($m+1)+"AUTO#")` ; string $attach = `curve -d 1 -p -0.25 0.25 0.25 -p 0.25 0.25 0.25 -p 0.25 0.25 -0.25 -p -0.25 0.25 -0.25 -p -0.25 0.25 0.25 -p -0.25 -0.25 0.25 -p -0.25 -0.25 -0.25 -p 0.25 -0.25 -0.25 -p 0.25 -0.25 0.25 -p -0.25 -0.25 0.25 -p 0.25 -0.25 0.25 -p 0.25 0.25 0.25 -p 0.25 0.25 -0.25 -p 0.25 -0.25 -0.25 -p -0.25 -0.25 -0.25 -p -0.25 0.25 -0.25 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -n ("AttachMid"+$baseName+($m+1)+"#")`; string $attachSq = `curve -d 1 -p 0.0632965 -0.00545365 0.178093 -p 0.0632965 -0.00545365 0.115934 -p 0.187614 -0.00545365 0.115934 -p 0.187614 -0.00545365 0.0537749 -p 0.0632965 -0.00545365 0.0537749 -p 0.0632965 -0.00545365 -0.194861 -p 0.249773 -0.00545365 -0.194861 -p 0.249773 -0.00545365 -0.132702 -p 0.125455 -0.00545365 -0.132702 -p 0.125455 -0.00545365 -0.008384 -p 0.249773 -0.00545365 -0.008384 -p 0.249773 -0.00545365 0.178093 -p 0.0632965 -0.00545365 0.178093 -p 0.00113762 -0.00545365 0.178093 -p 0.00113762 -0.00545365 -0.194861 -p -0.185339 -0.00545365 -0.194861 -p -0.259148 -0.00545365 -0.293355 -p -0.328421 -0.00545365 -0.251323 -p -0.247498 -0.00545365 -0.194861 -p -0.247498 -0.00545365 0.178093 -p 0.00113762 -0.00545365 0.178093 -p 0.00113762 -0.00545365 0.115934 -p -0.0610213 -0.00545365 0.115934 -p -0.0610213 -0.00545365 -0.132702 -p -0.185339 -0.00545365 -0.132702 -p -0.185339 -0.00545365 0.115934 -p -0.0610213 -0.00545365 0.115934 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16 -k 17 -k 18 -k 19 -k 20 -k 21 -k 22 -k 23 -k 24 -k 25 -k 26 -n ("AttachMidSquash"+$baseName+($m+1)+"#")` ; string $attachSt = `curve -d 1 -p 0.0515658 -0.00505248 0.178209 -p 0.0515658 -0.00505248 0.11605 -p 0.175884 -0.00505248 0.11605 -p 0.175884 -0.00505248 0.0538911 -p 0.0515658 -0.00505248 0.0538911 -p 0.0515658 -0.00505248 -0.194744 -p 0.238042 -0.00505248 -0.194744 -p 0.238042 -0.00505248 -0.132586 -p 0.113725 -0.00505248 -0.132586 -p 0.113725 -0.00505248 -0.00826775 -p 0.238042 -0.00505248 -0.00826775 -p 0.238042 -0.00505248 0.178209 -p -0.259229 -0.00505248 0.178209 -p -0.259229 -0.00505248 0.11605 -p -0.134911 -0.00505248 0.11605 -p -0.134911 -0.00505248 -0.194744 -p -0.072752 -0.00505248 -0.194744 -p -0.072752 -0.00505248 0.11605 -p 0.0515658 -0.00505248 0.11605 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16 -k 17 -k 18 -n ("AttachMidStretch"+$baseName+($m+1)+"#")` ; select -r ($ctrl+".cv[*]") ; xform -r -os -s ($fDist*1.0) ($fDist*0.3) ($fDist*0.3) ; select -r ($attach+".cv[*]") ; xform -r -os -s ($fDist*0.8) ($fDist*0.25) ($fDist*0.25) ; select -r ($attachSq+".cv[*]") ; xform -r -os -s ($fDist*0.1) ($fDist*0.1) ($fDist*0.1) ; select -r ($attachSt+".cv[*]") ; xform -r -os -s ($fDist*0.1) ($fDist*0.1) ($fDist*0.1) ; string $ctrlZERO = `group -em -w -n ("grpiControlMid"+$baseName+($m+1)+"ZERO#")` ; string $ctrlAUTO = `group -em -w -n ("grpiControlMid"+$baseName+($m+1)+"AUTO#")` ; // Color pretty.... setAttr ($ctrl+".overrideEnabled") 1; // on setAttr ($ctrl+".overrideColor") 23 ; // dark green setAttr ($attach+".overrideEnabled") 1; // on setAttr ($attach+".overrideColor") 13 ; // red setAttr ($attachSq+".overrideEnabled") 1; // on setAttr ($attachSq+".overrideColor") 18 ; // cyan setAttr ($attachSt+".overrideEnabled") 1; // on setAttr ($attachSt+".overrideColor") 6 ; // blue string $shapesTemp[] = `listRelatives -ni -shapes $attach` ; connectAttr -f ($creator+".showRestMovers") ($shapesTemp[0]+".v") ; connectAttr -f ($creator+".showSquashMovers") ($attachSq+".v") ; connectAttr -f ($creator+".showStretchMovers") ($attachSt+".v") ; setAttr -lock 0 -k 0 ($attachSq+".v") ; setAttr -lock 0 -k 0 ($attachSt+".v") ; // Parent parent $ctrl $ctrlAUTO ; parent $ctrlAUTO $ctrlZERO ; parent $ctrlZERO $grpCTRLs ; parent $linearZERO $grpATTACHs ; parent $linearAUTO $linearZERO ; parent $attach $linearAUTO ; parent $attachSq $attachSt $attach ; // Move to right spot... // float $pos[3] = cMuscle_interObjPos($fPct, $attaches) ; // xform -ws -a -t $pos[0] $pos[1] $pos[2] $attach ; // string $aCons[] = `aimConstraint -w 1 -aim 0 1 0 -wut "object" -u 1 0 0 -wuo $attaches[1] $attaches[2] $attaches[3] $attach` ; // delete $aCons ; // if ($fPct <= 0.5 && $attachStart != "") // parent $attach $attachStart ; // else if ($fPct > 0.5 && $attachEnd != "") // parent $attach $attachEnd ; // Set up Attrs addAttr -ln "uValue" -sn "uval" -dv $fPct -min 0.0 -max 1.0 -k 1 $linearZERO ; addAttr -ln "gravity" -sn "grav" -dv $fPctHalfSmooth -min 0.0 -k 1 $attach ; addAttr -ln "JIGGLE" -at "enum" -en "-" -k 1 $ctrl ; setAttr -l true ($ctrl+".JIGGLE") ; addAttr -ln "jiggle" -sn "jig" -dv $fPctHalfSmooth -k 1 $ctrl ; addAttr -ln "jiggleX" -sn "jigx" -dv 1.0 -k 1 $ctrl ; addAttr -ln "jiggleY" -sn "jigy" -dv 0.25 -k 1 $ctrl ; addAttr -ln "jiggleZ" -sn "jigz" -dv 1.0 -k 1 $ctrl ; addAttr -ln "jiggleImpact" -sn "jigimp" -dv (0.5) -k 1 $ctrl ; addAttr -ln "jiggleImpactStart" -sn "jigimpst" -dv 1000 -k 1 $ctrl ; addAttr -ln "jiggleImpactStop" -sn "jigimpsp" -dv 0.001 -k 1 $ctrl ; addAttr -ln "cycle" -sn "cyc" -min 1.0 -dv 12.0 -k 1 $ctrl ; addAttr -ln "rest" -sn "rst" -min 1.0 -dv 24.0 -k 1 $ctrl ; setAttr -l 1 -k 0 ($ctrl+".sx") ; setAttr -l 1 -k 0 ($ctrl+".sy") ; setAttr -l 1 -k 0 ($ctrl+".sz") ; connectAttr -f ($creator+".showControls") ($ctrl+".v") ; setAttr -l 0 -k 0 ($ctrl+".v") ; connectAttr -f ($linearZERO+".worldMatrix") ($creator+".linearData["+$m+"].linearMatrix") ; connectAttr -f ($linearZERO+".uValue") ($creator+".linearData["+$m+"].uValue") ; connectAttr -f ($attach+".worldMatrix") ($creator+".attachData["+$m+"].attachMatrix") ; connectAttr -f ($attachSq+".worldMatrix") ($creator+".attachData["+$m+"].attachMatrixSq") ; connectAttr -f ($attachSt+".worldMatrix") ($creator+".attachData["+$m+"].attachMatrixSt") ; connectAttr -f ($attach+".gravity") ($creator+".attachData["+$m+"].gravityMult") ; connectAttr -f ($creator+".outLinearData["+$m+"].outLinearTranslate") ($linearAUTO+".translate") ; connectAttr -f ($creator+".outLinearData["+$m+"].outLinearRotate") ($linearAUTO+".rotate") ; connectAttr -f ($creator+".outAttachData["+$m+"].outAttachTranslate") ($ctrlAUTO+".translate") ; connectAttr -f ($creator+".outAttachData["+$m+"].outAttachRotate") ($ctrlAUTO+".rotate") ; connectAttr -f ($creator+".userScale") ($ctrlAUTO+".scaleX") ; connectAttr -f ($creator+".userScale") ($ctrlAUTO+".scaleY") ; connectAttr -f ($creator+".userScale") ($ctrlAUTO+".scaleZ") ; connectAttr -f ($ctrl+".worldMatrix") ($creator+".controlData["+$cIdx+"].insertMatrix") ; connectAttr -f ($ctrl+".jiggle") ($creator+".controlData["+$cIdx+"].jiggle") ; connectAttr -f ($ctrl+".cycle") ($creator+".controlData["+$cIdx+"].cycle") ; connectAttr -f ($ctrl+".rest") ($creator+".controlData["+$cIdx+"].rest") ; connectAttr -f ($ctrl+".jiggleX") ($creator+".controlData["+$cIdx+"].jiggleX") ; connectAttr -f ($ctrl+".jiggleY") ($creator+".controlData["+$cIdx+"].jiggleY") ; connectAttr -f ($ctrl+".jiggleZ") ($creator+".controlData["+$cIdx+"].jiggleZ") ; connectAttr -f ($ctrl+".jiggleImpact") ($creator+".controlData["+$cIdx+"].jiggleImpact") ; connectAttr -f ($ctrl+".jiggleImpactStart") ($creator+".controlData["+$cIdx+"].jiggleImpactStart") ; connectAttr -f ($ctrl+".jiggleImpactStop") ($creator+".controlData["+$cIdx+"].jiggleImpactStop") ; // Now create the sub sq/st controls... // string $parent = $ctrl ; string $rests[] = `circle -c 0 0 0 -nr 0 1 0 -sw 360 -r $fRadCur -d 3 -ut 0 -tol 0.01 -s $nAround -ch 1 -n ($parent+"_crossSectionREST")` ; string $rest = $rests[0] ; string $restShapes[] = `listRelatives -ni -shapes $rest` ; string $sqs[] = `circle -c 0 0 0 -nr 0 1 0 -sw 360 -r (1.5*$fRadCur) -d 3 -ut 0 -tol 0.01 -s $nAround -ch 1 -n ($parent+"_crossSectionSQUASH")` ; string $sq = $sqs[0] ; string $sqShapes[] = `listRelatives -ni -shapes $sq` ; string $sts[] = `circle -c 0 0 0 -nr 0 1 0 -sw 360 -r (0.6*$fRadCur) -d 3 -ut 0 -tol 0.01 -s $nAround -ch 1 -n ($parent+"_crossSectionSTRETCH")` ; string $st = $sts[0] ; string $stShapes[] = `listRelatives -ni -shapes $st` ; parent $rest $sq $st $parent ; cMuscle_snap($parent, $rest) ; cMuscle_snap($parent, $sq) ; cMuscle_snap($parent, $st) ; setAttr ($rest+".overrideEnabled") 1; // on setAttr ($rest+".overrideColor") 9 ; // magenta connectAttr -f ($creator+".showRestMovers") ($rest+".v") ; setAttr ($sq+".overrideEnabled") 1; // on setAttr ($sq+".overrideColor") 18 ; // cyan connectAttr -f ($creator+".showSquashMovers") ($sq+".v") ; setAttr ($st+".overrideEnabled") 1; // on setAttr ($st+".overrideColor") 6 ; // blue connectAttr -f ($creator+".showStretchMovers") ($st+".v") ; setAttr -lock 1 -k 1 ($rest+".tx") ; setAttr -lock 1 -k 1 ($rest+".ty") ; setAttr -lock 1 -k 1 ($rest+".tz") ; setAttr -lock 1 -k 1 ($rest+".rx") ; setAttr -lock 1 -k 1 ($rest+".ry") ; setAttr -lock 1 -k 1 ($rest+".rz") ; setAttr -lock 1 -k 1 ($rest+".sx") ; setAttr -lock 1 -k 1 ($rest+".sy") ; setAttr -lock 1 -k 1 ($rest+".sz") ; setAttr -lock 0 -k 0 ($rest+".v") ; setAttr -lock 1 -k 1 ($sq+".tx") ; setAttr -lock 1 -k 1 ($sq+".ty") ; setAttr -lock 1 -k 1 ($sq+".tz") ; setAttr -lock 1 -k 1 ($sq+".rx") ; setAttr -lock 1 -k 1 ($sq+".ry") ; setAttr -lock 1 -k 1 ($sq+".rz") ; setAttr -lock 1 -k 1 ($sq+".sx") ; setAttr -lock 1 -k 1 ($sq+".sy") ; setAttr -lock 1 -k 1 ($sq+".sz") ; setAttr -lock 0 -k 0 ($sq+".v") ; setAttr -lock 1 -k 1 ($st+".tx") ; setAttr -lock 1 -k 1 ($st+".ty") ; setAttr -lock 1 -k 1 ($st+".tz") ; setAttr -lock 1 -k 1 ($st+".rx") ; setAttr -lock 1 -k 1 ($st+".ry") ; setAttr -lock 1 -k 1 ($st+".rz") ; setAttr -lock 1 -k 1 ($st+".sx") ; setAttr -lock 1 -k 1 ($st+".sy") ; setAttr -lock 1 -k 1 ($st+".sz") ; setAttr -lock 0 -k 0 ($st+".v") ; connectAttr -f ($restShapes[0]+".worldSpace") ($creator+".controlData["+$cIdx+"].curveRest") ; connectAttr -f ($sqShapes[0]+".worldSpace") ($creator+".controlData["+$cIdx+"].curveSq") ; connectAttr -f ($stShapes[0]+".worldSpace") ($creator+".controlData["+$cIdx+"].curveSt") ; } // Create the animCurve stuff for Sq/St curve mode... // Sq string $animCurveSq = `createNode animCurveUU -n ("animCurveUU_Sq_"+$creator)` ; setKeyframe -f 0.0 -v 0.0 -itt "flat" -ott "flat" $animCurveSq; setKeyframe -f 0.25 -v 0.15 -itt "spline" -ott "spline" $animCurveSq; setKeyframe -f 0.75 -v 0.85 -itt "spline" -ott "spline" $animCurveSq; setKeyframe -f 1.0 -v 1.0 -itt "flat" -ott "flat" $animCurveSq; connectAttr -f ($animCurveSq+".message") ($creator+".msgAnimCurveSq") ; connectAttr -f ($animCurveSq+".output") ($creator+".animCurveOutputSq") ; // St string $animCurveSt = `createNode animCurveUU -n ("animCurveUU_St_"+$creator)` ; setKeyframe -f 0.0 -v 0.0 -itt "flat" -ott "flat" $animCurveSt; setKeyframe -f 0.25 -v 0.15 -itt "spline" -ott "spline" $animCurveSt; setKeyframe -f 0.75 -v 0.85 -itt "spline" -ott "spline" $animCurveSt; setKeyframe -f 1.0 -v 1.0 -itt "flat" -ott "flat" $animCurveSt; connectAttr -f ($animCurveSt+".message") ($creator+".msgAnimCurveSt") ; connectAttr -f ($animCurveSt+".output") ($creator+".animCurveOutputSt") ; // Connect stuff up! connectAttr -f ("time1.outTime") ($creator+".inTime") ; connectAttr -f ($attaches[0]+".worldMatrix") ($creator+".startPointA") ; connectAttr -f ($attaches[1]+".worldMatrix") ($creator+".startPointB") ; connectAttr -f ($attaches[2]+".worldMatrix") ($creator+".endPointA") ; connectAttr -f ($attaches[3]+".worldMatrix") ($creator+".endPointB") ; // Fake start/end control data too...internally this get done right, but we need to grow array and such here // connectAttr -f ($attaches[0]+".worldMatrix") ($creator+".controlData[0].insertMatrix") ; // connectAttr -f ($attaches[2]+".worldMatrix") ($creator+".controlData["+($nMidControls+1)+"].insertMatrix") ; connectAttr -f ($startParent+".worldMatrix") ($creator+".controlData[0].insertMatrix") ; connectAttr -f ($endParent+".worldMatrix") ($creator+".controlData["+($nMidControls+1)+"].insertMatrix") ; connectAttr -f ($startParent+".worldMatrix") ($creator+".startParent") ; connectAttr -f ($endParent+".worldMatrix") ($creator+".endParent") ; connectAttr -f ($creator+".outNurbs") ($surf+".create") ; // Set attrs nice setAttr -l 1 ($creator+".MODEL") ; setAttr -l 1 ($creator+".SQUASH_STRETCH") ; setAttr -l 1 ($creator+".JIGGLE") ; float $defLen = `getAttr ($creator+".outLength")` ; setAttr ($creator+".lenDefault") $defLen ; setAttr ($creator+".lenSquash") (0.5*$defLen) ; setAttr ($creator+".lenStretch") (2.0*$defLen) ; setAttr ($creator+".crossSections") ( 2 * $nMidControls ) ; setAttr ($creator+".sides") ( $nAround ) ; // Material time! cMuscle_makeMuscleMaterial() ; // Make material if it doesn't exist. // Apply material select -r $surf ; sets -e -forceElement ("matMuscleCreatorSG"); // Make it have a Red wireframe color. setAttr ($surf+".overrideEnabled") 1 ; setAttr ($surf+".overrideColor") 13 ; // Now set it up as a cMuscleObject shape too if desired... if ($bMakeMO) { select -r $xform ; string $mOs[] = cMuscle_makeMuscle(0) ; } select -r $xform $creator ; return {$creator, $xform, $surf} ; } // -------------------------------------------------------------------------- /* * cMuscle_makeMuscleMaterial() - Makes a nice muscle material */ global proc cMuscle_makeMuscleMaterial() { // If material doesn't exist...make one. // if (objExists("matMuscleCreator") != true) { string $mat = `shadingNode -asShader blinn`; $mat = `rename $mat ("matMuscleCreator")`; sets -renderable true -noSurfaceShader true -empty -name ($mat+"SG") ; connectAttr -f ($mat+".outColor") ($mat+"SG.surfaceShader") ; setAttr ($mat+".color") -type double3 0.82 0.20 0.0 ; setAttr ($mat+".specularColor") -type double3 0.35 0.1 0.2 ; setAttr ($mat+".reflectivity") 0.0 ; setAttr ($mat+".specularRollOff") 0.25 ; setAttr ($mat+".eccentricity") 0.60 ; // Now make the Ramp... string $ramp = `createNode "ramp" -n ("rampMuscleCreator")` ; // Blow away extra entries so we can make new ones. removeMultiInstance -break true ($ramp+".colorEntryList[2]") ; removeMultiInstance -break true ($ramp+".colorEntryList[1]") ; // 0 start setAttr ($ramp+".colorEntryList[1].position") 0; setAttr ($ramp+".colorEntryList[0].color") -type double3 1.0 1.0 1.0 ; // 1 end setAttr ($ramp+".colorEntryList[1].position") 1.0; setAttr ($ramp+".colorEntryList[1].color") -type double3 1.0 1.0 1.0 ; // 2 midstart setAttr ($ramp+".colorEntryList[2].position") 0.333 ; setAttr ($ramp+".colorEntryList[2].color") -type double3 0.65 0.15 0.15 ; // 3 midend setAttr ($ramp+".colorEntryList[3].position") 0.666 ; setAttr ($ramp+".colorEntryList[3].color") -type double3 0.65 0.15 0.15 ; connectAttr -f ($ramp+".outColor") ($mat+".color") ; setAttr ($ramp+".defaultColor") -type double3 0.65 0.15 0.15 ; setAttr ($ramp+".interpolation") 6 ; // spike // Now make the red fractal noise string $frac = `createNode "fractal" -n ("fractalMuscleCreator")` ; setAttr ($frac+".defaultColor") -type double3 0.65 0.15 0.15 ; setAttr ($frac+".colorGain") -type double3 0.65 0.15 0.15 ; setAttr ($frac+".colorOffset") -type double3 0.3 0.07 0.07 ; connectAttr -f ($frac+".outColor") ($ramp+".colorEntryList[2].color") ; connectAttr -f ($frac+".outColor") ($ramp+".colorEntryList[3].color") ; // Maka the placer string $place = `createNode "place2dTexture" -n ("place2dTextureMuscleCreator")` ; connectAttr -f ($place+".outUV") ($frac+".uvCoord") ; connectAttr -f ($place+".outUvFilterSize") ($frac+".uvFilterSize") ; setAttr ($place+".repeatU") 2.0 ; setAttr ($place+".repeatV") 0.1 ; } } // -------------------------------------------------------------------------- /* * cMuscle_interObjPos() - */ global proc float[] cMuscle_interObjPos(float $pct, string $attaches[] ) { float $pos1[3] = `xform -q -rp -ws $attaches[0]` ; float $pos1b[3] = `xform -q -rp -ws $attaches[1]` ; float $pos2[3] = `xform -q -rp -ws $attaches[2]` ; float $pos2b[3] = `xform -q -rp -ws $attaches[3]` ; $pos1[0] = ($pos1[0] + $pos1b[0]) / 2.0 ; $pos1[1] = ($pos1[1] + $pos1b[1]) / 2.0 ; $pos1[2] = ($pos1[2] + $pos1b[2]) / 2.0 ; $pos2[0] = ($pos2[0] + $pos2b[0]) / 2.0 ; $pos2[1] = ($pos2[1] + $pos2b[1]) / 2.0 ; $pos2[2] = ($pos2[2] + $pos2b[2]) / 2.0 ; float $pos[3] ; $pos[0] = ((1.0-$pct) * $pos1[0]) + ($pct * $pos2[0] ) ; $pos[1] = ((1.0-$pct) * $pos1[1]) + ($pct * $pos2[1] ) ; $pos[2] = ((1.0-$pct) * $pos1[2]) + ($pct * $pos2[2] ) ; return $pos ; } // -------------------------------------------------------------------------- /* * cMCUI_setCreatorDistanceAsDefault() */ global proc cMCUI_setCreatorDistanceAsDefault() { // Get the list of creators ... string $creators[] = cMCUI_getCreatorsFromList() ; for ($creator in $creators) { string $startLocs[] = cMCUI_getMuscleItems({$creator}, "startLocs") ; string $endLocs[] = cMCUI_getMuscleItems({$creator}, "endLocs") ; // Now look at dist the start and end locators are apart float $fWidthStart = cMuscle_objDist($startLocs[1], $startLocs[2]) ; float $fWidthEnd = cMuscle_objDist($endLocs[1], $endLocs[2]) ; // And set that on the node as the default. setAttr ($creator+".defWidthStart") ( $fWidthStart ) ; setAttr ($creator+".defWidthEnd") ( $fWidthEnd ) ; } } // -------------------------------------------------------------------------- global proc cMCUI_showHideControls(string $type, int $bShowHide) { // Get the list of creators ... string $creators[] = cMCUI_getCreatorsFromList() ; for ($creator in $creators) { if ($type == "controls") setAttr ($creator+".showControls") $bShowHide ; else if ($type == "rest") setAttr ($creator+".showRestMovers") $bShowHide ; else if ($type == "sq") setAttr ($creator+".showSquashMovers") $bShowHide ; else if ($type == "st") setAttr ($creator+".showStretchMovers") $bShowHide ; else if ($type == "locs") { string $startLocs[] = cMCUI_getMuscleItems({$creator}, "startLocs") ; string $endLocs[] = cMCUI_getMuscleItems({$creator}, "endLocs") ; setAttr ($startLocs[0]+".v") $bShowHide ; setAttr ($startLocs[1]+".v") $bShowHide ; setAttr ($startLocs[2]+".v") $bShowHide ; setAttr ($endLocs[0]+".v") $bShowHide ; setAttr ($endLocs[1]+".v") $bShowHide ; setAttr ($endLocs[2]+".v") $bShowHide ; } } } // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- // Pose Procs // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- /* * cMuscle_storePoseState() - Stores the given state for the creator provided. * $type must be "Default", "Squash" or "Stretch" * */ global proc cMuscle_storePoseState(string $type, string $creator) { string $sel[] = `ls -sl` ; string $cons[] ; clear $cons ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".startParent")` ; string $startParent = $cons[0] ; clear $cons ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".endParent")` ; string $endParent = $cons[0] ; // See if a target group exists already... clear $cons ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".pose"+$type)` ; string $poseTarget = $cons[0] ; // And delete if so... if ($poseTarget != "" && objExists($poseTarget)) catch(`delete $poseTarget`) ; // And if not..create a new one... $poseTarget = `group -em -w -n ("pose"+$type+"Target_"+$creator)`; // Parent the target to the right place...aka to the startParent... parent $poseTarget $startParent ; // Now snap the target to the endParent...which is the pose cMuscle_snap($endParent, $poseTarget) ; // Finally connect this into the creator... and set it as used. connectAttr -f ($poseTarget+".worldMatrix") ($creator+".pose"+$type) ; setAttr ($creator+".pose"+$type+"Stored") true ; // Bring back orig sel. select -cl ; if (size($sel) > 0) select -r $sel ; } // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- // Sculpt Adjust Procs // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- global float $gSculptValue = 0.0 ; global int $gSculptActive = 0 ; /* * sculptDragCB() */ global proc sculptDragCB() { global float $gSculptValue ; global int $gSculptActive ; float $adjustAt = `floatSliderGrp -q -v fsgLocation` ; // Where from 0 to 1 down length are we adjusting? float $spread = `floatSliderGrp -q -v fsgFalloff` ; // How much falloff? if ($spread <= 0) $spread = 0.0001 ; float $str = `floatSliderGrp -q -v fsgStr` ; int $mx = `iconTextCheckBox -q -v itcbX` ; int $my = `iconTextCheckBox -q -v itcbY` ; int $mz = `iconTextCheckBox -q -v itcbZ` ; int $doRest = `iconTextCheckBox -q -v itcbRest` ; int $doSq = `iconTextCheckBox -q -v itcbSq` ; int $doSt = `iconTextCheckBox -q -v itcbSt` ; // Get current values float $delta = ($str * `floatSliderGrp -q -v fsgSculpt`) - $gSculptValue ; // Now get selected cv's string $verts[] = `filterExpand -ex true -sm 28` ; // Get selected CV's // Assume if we have verts selected we want to only sculpt those...otherwise do the entire creators... if (size($verts) > 0) { string $v ; for ($v in $verts) { // Attempt to find master xform and shape from the selected vert... string $masterObj = "" ; string $parts[] ; tokenize($v, ".", $parts) ; $masterObj = $parts[0] ; string $shapes[] = `listRelatives -ni -shapes $masterObj` ; string $masterShape = $shapes[0] ; // Now see if the shape is connected to a creator node... string $cons[] ; $cons = `listConnections -s 0 -d 1 -p 0 -scn 1 -type "cMuscleCreator" ($masterShape+".worldSpace")` ; string $creator = $cons[0] ; if ($creator == "") continue ; // Now we have the creator...so we determine how many controls there are so we can determine the pct down the length this vert it... // ie: which csec it is. int $nCtrl = `getAttr -size ($creator+".controlData")` ; // and which one are we connected to...? Now get with the plug...! $cons = `listConnections -s 0 -d 1 -p 1 -scn 1 -type "cMuscleCreator" ($masterShape+".worldSpace")` ; tokenize($cons[0], "[]", $parts) ; // cMuscleCreatorMusA.controlData[4].curveRest for example... int $idx = (int)$parts[1] ; // Get the part in the [ ] brackets float $fPct = $idx / ($nCtrl - 1.0) ; // Calc amount based on where we are... float $fAmt = 0.0 ; if ($fPct <= $adjustAt - $spread) $fAmt = 0.0 ; else if ($fPct >= $adjustAt + $spread) $fAmt = 0.0 ; else $fAmt = 1.0 - ( abs($fPct - $adjustAt) / $spread ) ; $fAmt = ($fAmt * $fAmt) * (3.0 - (2.0 * $fAmt)) ; float $amt = 1.0 + ($fAmt * $delta) ; float $amtX=1.0, $amtY=1.0, $amtZ=1.0 ; if ($mx) $amtX = $amt ; if ($my) $amtY = $amt ; if ($mz) $amtZ = $amt ; scale -r $amtX $amtY $amtZ $v ; } } else { // Get the list of creators ... string $creators[] = cMCUI_getCreatorsFromList() ; if ($gSculptActive == 0) { // Init $gSculptActive = 1 ; $gSculptValue = 0.0 ; undoInfo -openChunk; } string $creator ; for ($creator in $creators) { int $nCtrl = `getAttr -size ($creator+".controlData")` ; int $c ; for ($c=1; $c < $nCtrl-1; ++$c) { float $fPct = $c / ($nCtrl - 1.0) ; string $crvRests[] = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".controlData["+$c+"].curveRest")` ; string $crvRest = $crvRests[0] ; string $crvSqs[] = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".controlData["+$c+"].curveSq")` ; string $crvSq = $crvSqs[0] ; string $crvSts[] = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".controlData["+$c+"].curveSt")` ; string $crvSt = $crvSts[0] ; string $vertsRest[] = `ls ($crvRest+".cv[*]")` ; string $vertsSq[] = `ls ($crvSq+".cv[*]")` ; string $vertsSt[] = `ls ($crvSt+".cv[*]")` ; // Calc amount based on where we are... float $fAmt = 0.0 ; if ($fPct <= $adjustAt - $spread) $fAmt = 0.0 ; else if ($fPct >= $adjustAt + $spread) $fAmt = 0.0 ; else $fAmt = 1.0 - ( abs($fPct - $adjustAt) / $spread ) ; $fAmt = ($fAmt * $fAmt) * (3.0 - (2.0 * $fAmt)) ; float $amt = 1.0 + ($fAmt * $delta) ; float $amtX=1.0, $amtY=1.0, $amtZ=1.0 ; if ($mx) $amtX = $amt ; if ($my) $amtY = $amt ; if ($mz) $amtZ = $amt ; if ($doRest) scale -r $amtX $amtY $amtZ $vertsRest ; if ($doSq) scale -r $amtX $amtY $amtZ $vertsSq ; if ($doSt) scale -r $amtX $amtY $amtZ $vertsSt ; } // end of each control } // end of each creator } // end of if doing creator not verts // Store for next loop $gSculptValue += $delta ; } // -------------------------------------------------------------------------- /* * sculptChangeCB() */ global proc sculptChangeCB() { global float $gSculptValue ; global int $gSculptActive ; $gSculptValue = 0.0 ; $gSculptActive = 0 ; undoInfo -closeChunk; floatSliderGrp -e -v 0.0 fsgSculpt ; } // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- // Grow Procs // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- /* * cMCUI_guessTipBone() - When the user picks a main bone, this attempts to guess and * fill in the child bone tip for it. */ global proc cMCUI_guessTipBone() { string $mainBone = `textField -q -tx tfMainBone` ; string $mainBoneTip = "" ; if ($mainBone != "" && objExists($mainBone)) { string $childBones[] = `listRelatives -children -type "joint" $mainBone` ; $mainBoneTip = $childBones[0] ; } textField -e -tx $mainBoneTip tfMainBoneTip ; } // -------------------------------------------------------------------------- /* * cMCUI_getMuscleItems() - Given a cMuscleCreator node(s), get the items for it * * $item can be: controls, CSectRest, CSectSq, CSectSt, attachRest, attachSq, attachSt, startLocs, endLocs, surf */ global proc string[] cMCUI_getMuscleItems(string $creators[], string $item) { string $items[] ; if (size($creators) <= 0) { return $items ; } string $list = "" ; for ($creator in $creators) { if ($item == "controls" || $item == "CSectRest" || $item == "CSectSq" || $item == "CSectSt") { int $nCtrls = `getAttr -size ($creator+".controlData")` ; int $c ; for ($c=1; $c < $nCtrls-1; ++$c) { string $cons[] ; if ($item == "controls") { $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".controlData["+$c+"].insertMatrix")` ; for ($con in $cons) $items[ size($items) ] = $con ; } if ($item == "CSectRest") { $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".controlData["+$c+"].curveRest")` ; for ($con in $cons) $items[ size($items) ] = $con ; } if ($item == "CSectSq") { $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".controlData["+$c+"].curveSq")` ; for ($con in $cons) $items[ size($items) ] = $con ; } if ($item == "CSectSt") { $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".controlData["+$c+"].curveSt")` ; for ($con in $cons) $items[ size($items) ] = $con ; } } } if ($item == "attachRest" || $item == "attachSq" || $item == "attachSt") { int $nAttach = `getAttr -size ($creator+".attachData")` ; int $a ; for ($a=0; $a < $nAttach; ++$a) { string $cons[] ; if ($item == "attachRest") { $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".attachData["+$a+"].attachMatrix")` ; for ($con in $cons) $items[ size($items) ] = $con ; } if ($item == "attachSq") { $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".attachData["+$a+"].attachMatrixSq")` ; for ($con in $cons) $items[ size($items) ] = $con ; } if ($item == "attachSt") { $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".attachData["+$a+"].attachMatrixSt")` ; for ($con in $cons) $items[ size($items) ] = $con ; } } } if ($item == "startLocs") { string $cons[] ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".startParent")` ; $items[ size($items) ] = $cons[0] ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".startPointA")` ; $items[ size($items) ] = $cons[0] ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".startPointB")` ; $items[ size($items) ] = $cons[0] ; } if ($item == "endLocs") { string $cons[] ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".endParent")` ; $items[ size($items) ] = $cons[0] ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".endPointA")` ; $items[ size($items) ] = $cons[0] ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creator+".endPointB")` ; $items[ size($items) ] = $cons[0] ; } if ($item == "surf") // Get nurbs surface and parent xform, and also MO if it has one { string $cons[] ; // We use -p 1 to get true surface, not xform..then split on the . $cons = `listConnections -s 0 -d 1 -p 1 -scn 1 ($creator+".outNurbs")` ; string $parts[] ; tokenize($cons[0], ".", $parts) ; $items[ size($items) ] = $parts[0] ; string $parents[] = `listRelatives -ni -parent $parts[0]` ; $items[ size($items) ] = $parents[0] ; string $mOs[] = `listRelatives -ni -shapes -type "cMuscleObject" $parents[0]` ; $items[ size($items) ] = $mOs[0] ; } } return $items ; } // -------------------------------------------------------------------------- /* * cMuscle_growMuscle() */ global proc cMuscle_growMuscle() { // Get the list of creators ... string $creators[] = cMCUI_getCreatorsFromList() ; string $creator ; string $surfTxt = `textField -q -tx tfGrowSurf` ; string $surfs[] ; tokenize($surfTxt, $surfs) ; float $fat = `floatSliderGrp -q -v fsgFat` ; float $pctRest = `floatSliderGrp -q -v fsgPctRest` / 100.0 ; float $pctSq = `floatSliderGrp -q -v fsgPctSq` / 100.0 ; float $pctSt = `floatSliderGrp -q -v fsgPctSt` / 100.0 ; string $mainBone = `textField -q -tx tfMainBone` ; string $mainBoneTip = `textField -q -tx tfMainBoneTip` ; float $boneAngle = `floatSliderGrp -q -v fsgBoneAngle` ; float $posMainBone[3] = {0,0,0} ; float $posMainBoneTip[3] = {0,0,0} ; if ($mainBone != "" && $mainBoneTip != "") { $posMainBone = `xform -q -ws -rp $mainBone` ; $posMainBoneTip = `xform -q -ws -rp $mainBoneTip` ; } else { $boneAngle = -1 ; } waitCursor -state on ; // Now from the creators, get the curves we need. string $CSectRests[] = cMCUI_getMuscleItems( $creators, "CSectRest") ; string $CSectSq[] = cMCUI_getMuscleItems( $creators, "CSectSq") ; string $CSectSt[] = cMCUI_getMuscleItems( $creators, "CSectSt") ; // Now go thru each curve and grow... string $crv ; for ($crv in $CSectRests) { string $verts[] = `ls -fl ($crv+".cv[*]")` ; float $ptCenter[3] = `xform -q -ws -t $crv` ; // Grow from center of curve which is immovable and is same as attach node. string $v ; for ($v in $verts) { float $ptV[3] = `xform -q -ws -t $v` ; // Get vertex position float $ptGrow[4] = `cMuscleRayIntersect -offset $fat -mult $pctRest -point1 $ptCenter[0] $ptCenter[1] $ptCenter[2] -point2 $ptV[0] $ptV[1] $ptV[2] -bonepoint1 $posMainBone[0] $posMainBone[1] $posMainBone[2] -bonepoint2 $posMainBoneTip[0] $posMainBoneTip[1] $posMainBoneTip[2] -boneangle $boneAngle $surfs` ; // Now move the point if ($ptGrow[3]) xform -a -ws -t $ptGrow[0] $ptGrow[1] $ptGrow[2] $v ; } } for ($crv in $CSectSq) { string $verts[] = `ls -fl ($crv+".cv[*]")` ; float $ptCenter[3] = `xform -q -ws -t $crv` ; // Grow from center of curve which is immovable and is same as attach node. string $v ; for ($v in $verts) { float $ptV[3] = `xform -q -ws -t $v` ; // Get vertex position float $ptGrow[4] = `cMuscleRayIntersect -offset $fat -mult $pctSq -point1 $ptCenter[0] $ptCenter[1] $ptCenter[2] -point2 $ptV[0] $ptV[1] $ptV[2] -bonepoint1 $posMainBone[0] $posMainBone[1] $posMainBone[2] -bonepoint2 $posMainBoneTip[0] $posMainBoneTip[1] $posMainBoneTip[2] -boneangle $boneAngle $surfs` ; // Now move the point if ($ptGrow[3]) xform -a -ws -t $ptGrow[0] $ptGrow[1] $ptGrow[2] $v ; } } for ($crv in $CSectSt) { string $verts[] = `ls -fl ($crv+".cv[*]")` ; float $ptCenter[3] = `xform -q -ws -t $crv` ; // Grow from center of curve which is immovable and is same as attach node. string $v ; for ($v in $verts) { float $ptV[3] = `xform -q -ws -t $v` ; // Get vertex position float $ptGrow[4] = `cMuscleRayIntersect -offset $fat -mult $pctSt -point1 $ptCenter[0] $ptCenter[1] $ptCenter[2] -point2 $ptV[0] $ptV[1] $ptV[2] -bonepoint1 $posMainBone[0] $posMainBone[1] $posMainBone[2] -bonepoint2 $posMainBoneTip[0] $posMainBoneTip[1] $posMainBoneTip[2] -boneangle $boneAngle $surfs` ; // Now move the point if ($ptGrow[3]) xform -a -ws -t $ptGrow[0] $ptGrow[1] $ptGrow[2] $v ; } } waitCursor -state off ; } // -------------------------------------------------------------------------- /* * cMuscle_growSelPts() */ global proc cMuscle_growSelPts() { // Get the list of creators ... string $creators[] = cMCUI_getCreatorsFromList() ; string $creator ; string $surfTxt = `textField -q -tx tfGrowSurf` ; string $surfs[] ; tokenize($surfTxt, $surfs) ; float $fat = `floatSliderGrp -q -v fsgFat` ; float $pctRest = `floatSliderGrp -q -v fsgPctRest` / 100.0 ; float $pctSq = `floatSliderGrp -q -v fsgPctSq` / 100.0 ; float $pctSt = `floatSliderGrp -q -v fsgPctSt` / 100.0 ; string $mainBone = `textField -q -tx tfMainBone` ; string $mainBoneTip = `textField -q -tx tfMainBoneTip` ; float $boneAngle = `floatSliderGrp -q -v fsgBoneAngle` ; float $posMainBone[3] = {0,0,0} ; float $posMainBoneTip[3] = {0,0,0} ; if ($mainBone != "" && $mainBoneTip != "") { $posMainBone = `xform -q -ws -rp $mainBone` ; $posMainBoneTip = `xform -q -ws -rp $mainBoneTip` ; } else { $boneAngle = -1 ; } waitCursor -state on ; // Now get selected cv's string $verts[] = `filterExpand -ex true -sm 28` ; // Get selected CV's // Now go thru each vert and grow... string $pt ; for ($v in $verts) { // Find which master curve object this vert is a part of string $masterObj ; string $parts[] ; tokenize($v, ".", $parts) ; // Break on . for something like iControlMidMusTest51_crossSectionSQUASH.cv[0] $masterObj = $parts[0] ; if ($masterObj == "") continue ; float $ptCenter[3] = `xform -q -ws -t $masterObj` ; // Grow from center of curve which is immovable and is same as attach node. float $ptV[3] = `xform -q -ws -t $v` ; // Get vertex position // Try to guess which mult to use... float $mult = $pctRest ; if (gmatch($masterObj , "*SQUASH*") == 1) $mult = $pctSq ; else if (gmatch($masterObj , "*STRETCH*") == 1) $mult = $pctSt ; float $ptGrow[4] = `cMuscleRayIntersect -offset $fat -mult $mult -point1 $ptCenter[0] $ptCenter[1] $ptCenter[2] -point2 $ptV[0] $ptV[1] $ptV[2] -bonepoint1 $posMainBone[0] $posMainBone[1] $posMainBone[2] -bonepoint2 $posMainBoneTip[0] $posMainBoneTip[1] $posMainBoneTip[2] -boneangle $boneAngle $surfs` ; // Now move the point if ($ptGrow[3]) xform -a -ws -t $ptGrow[0] $ptGrow[1] $ptGrow[2] $v ; } waitCursor -state off ; } // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- /* * cMuscle_resetToCyl() - Reset muscle to a simple cylindrical shape... */ global proc cMuscle_resetToCyl() { // Get the list of creators ... string $creators[] = cMCUI_getCreatorsFromList() ; string $creator ; float $pctRest = `floatSliderGrp -q -v fsgPctRest` / 100.0 ; float $pctSq = `floatSliderGrp -q -v fsgPctSq` / 100.0 ; float $pctSt = `floatSliderGrp -q -v fsgPctSt` / 100.0 ; waitCursor -state on ; // Now from the creators, get the curves we need. string $CSectRests[] = cMCUI_getMuscleItems( $creators, "CSectRest") ; string $CSectSq[] = cMCUI_getMuscleItems( $creators, "CSectSq") ; string $CSectSt[] = cMCUI_getMuscleItems( $creators, "CSectSt") ; string $startLocs[] = cMCUI_getMuscleItems($creators, "startLocs") ; string $endLocs[] = cMCUI_getMuscleItems($creators, "endLocs") ; // Now get avg distance of start/end locs float $radius = 0.25 * 0.5 * (cMuscle_objDist($startLocs[1], $startLocs[2]) + cMuscle_objDist($endLocs[1], $endLocs[2])) / 2.0 ; // Now go thru each curve and reset to cyl... string $crv ; for ($crv in $CSectRests) { string $verts[] = `ls -fl ($crv+".cv[*]")` ; float $ptCenter[3] = `xform -q -ws -t $crv` ; // Grow from center of curve which is immovable and is same as attach node. int $nVerts = size($verts) ; float $pctDelta = 1.0 / ($nVerts) ; float $pct = $pctDelta ; // right starting offset so no twist... int $i ; float $twoPi = 2 * 3.14159 ; for ($i=0; $i < $nVerts; ++$i) { string $v = $verts[$i] ; float $x = $radius * $pctRest * cos( $twoPi * $pct ) ; float $z = $radius * $pctRest * sin( $twoPi * $pct ) ; // Now move the point xform -a -os -t $x 0.0 $z $v ; $pct += $pctDelta ; } } for ($crv in $CSectSq) { string $verts[] = `ls -fl ($crv+".cv[*]")` ; float $ptCenter[3] = `xform -q -ws -t $crv` ; // Grow from center of curve which is immovable and is same as attach node. int $nVerts = size($verts) ; float $pctDelta = 1.0 / ($nVerts) ; float $pct = $pctDelta ; // right starting offset so no twist... int $i ; float $twoPi = 2 * 3.14159 ; for ($i=0; $i < $nVerts; ++$i) { string $v = $verts[$i] ; float $x = $radius * $pctSq * cos( $twoPi * $pct ) ; float $z = $radius * $pctSq * sin( $twoPi * $pct ) ; // Now move the point xform -a -os -t $x 0.0 $z $v ; $pct += $pctDelta ; } } for ($crv in $CSectSt) { string $verts[] = `ls -fl ($crv+".cv[*]")` ; float $ptCenter[3] = `xform -q -ws -t $crv` ; // Grow from center of curve which is immovable and is same as attach node. int $nVerts = size($verts) ; float $pctDelta = 1.0 / ($nVerts) ; float $pct = $pctDelta ; // right starting offset so no twist... int $i ; float $twoPi = 2 * 3.14159 ; for ($i=0; $i < $nVerts; ++$i) { string $v = $verts[$i] ; float $x = $radius * $pctSt * cos( $twoPi * $pct ) ; float $z = $radius * $pctSt * sin( $twoPi * $pct ) ; // Now move the point xform -a -os -t $x 0.0 $z $v ; $pct += $pctDelta ; } } waitCursor -state off ; } // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- // Mirroring and Copy/Paste Procs // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- /* * cMCUI_createMirror() */ global proc cMCUI_createMirror() { string $search = `textField -q -tx tfCMCUISearch` ; string $replace = `textField -q -tx tfCMCUIReplace` ; int $nAxis = `radioButtonGrp -q -sl rbgMirrorAxis` - 1 ; if($search == "") { error((uiRes("m_cMuscleCreatorUI.kMirroringEmptySearchString"))); return; } if($replace == "") { error((uiRes("m_cMuscleCreatorUI.kMirroringEmptyReplaceString"))); return; } string $creators[] = cMuscle_getSelectedDeformers("cMuscleCreator") ; string $creator ; for ($creator in $creators) { int $nMidControls = `getAttr ($creator+".nMidControls")` ; int $nAround = `getAttr ($creator+".nAround")` ; // We start by just mirroring the attach start/end points...then we "create" the muscle normally... // This way we get the same results as a normal build...but attached to what we want...then we do hand mirroring // of all the shapes/poses/attributes after... string $startLocs[] = cMCUI_getMuscleItems({$creator}, "startLocs") ; string $endLocs[] = cMCUI_getMuscleItems({$creator}, "endLocs") ; string $searchStrNotFoundMsg = (uiRes("m_cMuscleCreatorUI.kMirroringSearchStringNotFound")); if(`match $search $startLocs[1]` == "") { string $msg = `format -stringArg $search -stringArg $startLocs[1] $searchStrNotFoundMsg`; error($msg); continue; } if(`match $search $startLocs[2]` == "") { string $msg = `format -stringArg $search -stringArg $startLocs[2] $searchStrNotFoundMsg`; error($msg); continue; } if(`match $search $endLocs[1]` == "") { string $msg = `format -stringArg $search -stringArg $endLocs[1] $searchStrNotFoundMsg`; error($msg); continue; } if(`match $search $endLocs[2]` == "") { string $msg = `format -stringArg $search -stringArg $endLocs[2] $searchStrNotFoundMsg`; error($msg); continue; } string $startLocA = cMuscle_duplicateObject($startLocs[1], $search, $replace, 1) ; string $startLocB = cMuscle_duplicateObject($startLocs[2], $search, $replace, 1) ; string $endLocA = cMuscle_duplicateObject($endLocs[1], $search, $replace, 1) ; string $endLocB = cMuscle_duplicateObject($endLocs[2], $search, $replace, 1) ; cMuscle_mirrorObject($startLocA, $nAxis ) ; cMuscle_mirrorObject($startLocB, $nAxis ) ; cMuscle_mirrorObject($endLocA, $nAxis ) ; cMuscle_mirrorObject($endLocB, $nAxis ) ; // Figure out proper basename by searching/replacing the main name of the creator they all have, as well as the # at the end... // And then finally searching/replacing for side... string $baseName = cMuscle_strSearchReplace($creator, "cMuscleCreator", "") ; string $endNumber = match("[0-9]+$", $creator) ; $baseName = cMuscle_strSearchReplace($baseName, $endNumber, "") ; $baseName = cMuscle_strSearchReplace($baseName, $search, $replace) ; string $msg = (uiRes("m_cMuscleCreatorUI.kMirroringCreator")); $msg = `format -stringArg $creator -stringArg $baseName $msg`; print ($msg) ; // Guess the attach parents..which should now be correct since we mirrored... string $parents[] ; $parents = `listRelatives -ni -parent $startLocA` ; string $attachStart = $parents[0] ; $parents = `listRelatives -ni -parent $endLocA` ; string $attachEnd = $parents[0] ; // See if this muscle has a cMuscleObject on it.... string $surfData[] = cMCUI_getMuscleItems({$creator}, "surf") ; string $mO = $surfData[2] ; $bHasMO = $mO != "" ? true : false ; // Now do the regular build.... // select -r $startLocA $startLocB $endLocA $endLocB ; string $creatorData[] = cMuscle_createCreatorMuscleFromSel( $baseName, $nMidControls, $nAround, $attachStart, $attachEnd, $bHasMO ) ; string $creatorNew = $creatorData[0] ; // Whee..ok now the muscle is made...etc.. .but we need to do the copy/pasting of all the stuff... cMCUI_copyPasteMuscle( $creator, $creatorNew, true, $nAxis, $search, $replace ) ; } } // -------------------------------------------------------------------------- /* * cMuscle_copyPasteUI() - Copy first selected muscle to others */ global proc cMuscle_copyPasteUI() { string $creators[] = cMuscle_getSelectedDeformers("cMuscleCreator") ; int $nC = size($creators) ; int $i ; for ($i=1; $i < $nC; ++$i) { cMCUI_copyPasteMuscle( $creators[0], $creators[$i], false, 0, "", "" ) ; } print (uiRes("m_cMuscleCreatorUI.kCopyPasteDone")) ; } // -------------------------------------------------------------------------- /* * cMCUI_copyPasteMuscle() - Copy values/setup info from one muscle to the other... * * This will either paste or do a paste mirrored as needed */ global proc cMCUI_copyPasteMuscle(string $creatorSrc, string $creatorDest, int $bMirror, int $nAxis, string $search, string $replace) { // First we snap the locs... string $startLocsSrc[] = cMCUI_getMuscleItems({$creatorSrc}, "startLocs") ; string $endLocsSrc[] = cMCUI_getMuscleItems({$creatorSrc}, "endLocs") ; string $startLocsDest[] = cMCUI_getMuscleItems({$creatorDest}, "startLocs") ; string $endLocsDest[] = cMCUI_getMuscleItems({$creatorDest}, "endLocs") ; // Snap the pose locs if (!$bMirror) { } else { string $grpTEMP = `group -em -w -n "grpTEMPPASTE"` ; cMuscle_snap($startLocsSrc[0], $grpTEMP) ; cMuscle_mirrorObject($grpTEMP, $nAxis ) ; cMuscle_snap($grpTEMP, $startLocsDest[0]) ; cMuscle_snap($endLocsSrc[0], $grpTEMP) ; cMuscle_mirrorObject($grpTEMP, $nAxis ) ; cMuscle_snap($grpTEMP, $endLocsDest[0]) ; } // Copy all the unlocked settable attrs on the creator... // string $attrs[] = `listAttr -k -u -se -s $creatorDest` ; string $attr ; for ($attr in $attrs) { setAttr ($creatorDest+"."+$attr) (`getAttr ($creatorSrc+"."+$attr)`); } // Now we copy the values for all the attach points int $i ; string $attachSrc[] = cMCUI_getMuscleItems({$creatorSrc}, "attachRest") ; string $attachDest[] = cMCUI_getMuscleItems({$creatorDest}, "attachRest") ; for ($i=0; $i < size($attachDest); ++$i) { if (!$bMirror) { setAttr ($attachDest[$i]+".translateX") (`getAttr ($attachSrc[$i]+".translateX")`); setAttr ($attachDest[$i]+".translateY") (`getAttr ($attachSrc[$i]+".translateY")`); setAttr ($attachDest[$i]+".translateZ") (`getAttr ($attachSrc[$i]+".translateZ")`); setAttr ($attachDest[$i]+".rotateX") (`getAttr ($attachSrc[$i]+".rotateX")`); setAttr ($attachDest[$i]+".rotateY") (`getAttr ($attachSrc[$i]+".rotateY")`); setAttr ($attachDest[$i]+".rotateZ") (`getAttr ($attachSrc[$i]+".rotateZ")`); setAttr ($attachDest[$i]+".scaleX") (`getAttr ($attachSrc[$i]+".scaleX")`); setAttr ($attachDest[$i]+".scaleY") (`getAttr ($attachSrc[$i]+".scaleY")`); setAttr ($attachDest[$i]+".scaleZ") (`getAttr ($attachSrc[$i]+".scaleZ")`); setAttr ($attachDest[$i]+".visibility") (`getAttr ($attachSrc[$i]+".visibility")`); setAttr ($attachDest[$i]+".gravity") (`getAttr ($attachSrc[$i]+".gravity")`); } else { cMuscle_mirrorObjectProvided($attachSrc[$i], $attachDest[$i], $nAxis) ; setAttr ($attachDest[$i]+".visibility") (`getAttr ($attachSrc[$i]+".visibility")`); setAttr ($attachDest[$i]+".gravity") (`getAttr ($attachSrc[$i]+".gravity")`); } } string $attachSqSrc[] = cMCUI_getMuscleItems({$creatorSrc}, "attachSq") ; string $attachSqDest[] = cMCUI_getMuscleItems({$creatorDest}, "attachSq") ; for ($i=0; $i < size($attachSqDest); ++$i) { if (!$bMirror) { setAttr ($attachSqDest[$i]+".translateX") (`getAttr ($attachSqSrc[$i]+".translateX")`); setAttr ($attachSqDest[$i]+".translateY") (`getAttr ($attachSqSrc[$i]+".translateY")`); setAttr ($attachSqDest[$i]+".translateZ") (`getAttr ($attachSqSrc[$i]+".translateZ")`); setAttr ($attachSqDest[$i]+".rotateX") (`getAttr ($attachSqSrc[$i]+".rotateX")`); setAttr ($attachSqDest[$i]+".rotateY") (`getAttr ($attachSqSrc[$i]+".rotateY")`); setAttr ($attachSqDest[$i]+".rotateZ") (`getAttr ($attachSqSrc[$i]+".rotateZ")`); setAttr ($attachSqDest[$i]+".scaleX") (`getAttr ($attachSqSrc[$i]+".scaleX")`); setAttr ($attachSqDest[$i]+".scaleY") (`getAttr ($attachSqSrc[$i]+".scaleY")`); setAttr ($attachSqDest[$i]+".scaleZ") (`getAttr ($attachSqSrc[$i]+".scaleZ")`); } else { cMuscle_mirrorObjectProvided($attachSqSrc[$i], $attachSqDest[$i], $nAxis) ; } } string $attachStSrc[] = cMCUI_getMuscleItems({$creatorSrc}, "attachSt") ; string $attachStDest[] = cMCUI_getMuscleItems({$creatorDest}, "attachSt") ; for ($i=0; $i < size($attachStDest); ++$i) { if (!$bMirror) { setAttr ($attachStDest[$i]+".translateX") (`getAttr ($attachStSrc[$i]+".translateX")`); setAttr ($attachStDest[$i]+".translateY") (`getAttr ($attachStSrc[$i]+".translateY")`); setAttr ($attachStDest[$i]+".translateZ") (`getAttr ($attachStSrc[$i]+".translateZ")`); setAttr ($attachStDest[$i]+".rotateX") (`getAttr ($attachStSrc[$i]+".rotateX")`); setAttr ($attachStDest[$i]+".rotateY") (`getAttr ($attachStSrc[$i]+".rotateY")`); setAttr ($attachStDest[$i]+".rotateZ") (`getAttr ($attachStSrc[$i]+".rotateZ")`); setAttr ($attachStDest[$i]+".scaleX") (`getAttr ($attachStSrc[$i]+".scaleX")`); setAttr ($attachStDest[$i]+".scaleY") (`getAttr ($attachStSrc[$i]+".scaleY")`); setAttr ($attachStDest[$i]+".scaleZ") (`getAttr ($attachStSrc[$i]+".scaleZ")`); } else { cMuscle_mirrorObjectProvided($attachStSrc[$i], $attachStDest[$i], $nAxis) ; } } string $controlsSrc[] = cMCUI_getMuscleItems({$creatorSrc}, "controls") ; string $controlsDest[] = cMCUI_getMuscleItems({$creatorDest}, "controls") ; for ($i=0; $i < size($controlsDest); ++$i) { setAttr ($controlsDest[$i]+".jiggle") (`getAttr ($controlsSrc[$i]+".jiggle")`); setAttr ($controlsDest[$i]+".jiggleX") (`getAttr ($controlsSrc[$i]+".jiggleX")`); setAttr ($controlsDest[$i]+".jiggleY") (`getAttr ($controlsSrc[$i]+".jiggleY")`); setAttr ($controlsDest[$i]+".jiggleZ") (`getAttr ($controlsSrc[$i]+".jiggleZ")`); setAttr ($controlsDest[$i]+".jiggleImpact") (`getAttr ($controlsSrc[$i]+".jiggleImpact")`); setAttr ($controlsDest[$i]+".jiggleImpactStart") (`getAttr ($controlsSrc[$i]+".jiggleImpactStart")`); setAttr ($controlsDest[$i]+".jiggleImpactStop") (`getAttr ($controlsSrc[$i]+".jiggleImpactStop")`); setAttr ($controlsDest[$i]+".cycle") (`getAttr ($controlsSrc[$i]+".cycle")`); setAttr ($controlsDest[$i]+".rest") (`getAttr ($controlsSrc[$i]+".rest")`); } string $csectRestSrc[] = cMCUI_getMuscleItems({$creatorSrc}, "CSectRest") ; string $csectRestDest[] = cMCUI_getMuscleItems({$creatorDest}, "CSectRest") ; string $csectSquashSrc[] = cMCUI_getMuscleItems({$creatorSrc}, "CSectSq") ; string $csectSquashDest[] = cMCUI_getMuscleItems({$creatorDest}, "CSectSq") ; string $csectStretchSrc[] = cMCUI_getMuscleItems({$creatorSrc}, "CSectSt") ; string $csectStretchDest[] = cMCUI_getMuscleItems({$creatorDest}, "CSectSt") ; for ($i=0; $i < size($csectRestDest); ++$i) { string $vertsSrc[] = `ls -fl ($csectRestSrc[$i]+".cv[*]")` ; string $vertsDest[] = `ls -fl ($csectRestDest[$i]+".cv[*]")` ; int $nVerts = size($vertsDest) ; for ($v=0; $v < $nVerts; ++$v) { float $pos[3] = `xform -q -os -t $vertsSrc[$v]` ; xform -a -os -t $pos[0] $pos[1] $pos[2] $vertsDest[$v] ; } if ($bMirror) { xform -r -os -ro 0 -180 180 $vertsDest ; } $vertsSrc = `ls -fl ($csectSquashSrc[$i]+".cv[*]")` ; $vertsDest = `ls -fl ($csectSquashDest[$i]+".cv[*]")` ; $nVerts = size($vertsDest) ; for ($v=0; $v < $nVerts; ++$v) { float $pos[3] = `xform -q -os -t $vertsSrc[$v]` ; xform -a -os -t $pos[0] $pos[1] $pos[2] $vertsDest[$v] ; } if ($bMirror) { xform -r -os -ro 0 -180 180 $vertsDest ; } $vertsSrc = `ls -fl ($csectStretchSrc[$i]+".cv[*]")` ; $vertsDest = `ls -fl ($csectStretchDest[$i]+".cv[*]")` ; $nVerts = size($vertsDest) ; for ($v=0; $v < $nVerts; ++$v) { float $pos[3] = `xform -q -os -t $vertsSrc[$v]` ; xform -a -os -t $pos[0] $pos[1] $pos[2] $vertsDest[$v] ; } if ($bMirror) { xform -r -os -ro 0 -180 180 $vertsDest ; } } // do pose stuff // if (!$bMirror) { } else { string $cons[] ; $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creatorSrc+".poseState.poseDefault")` ; if (size($cons) > 0) { // Dup and parent to mirror on opposite side string $grpPose = cMuscle_duplicateObject($cons[0], $search, $replace, 1) ; cMuscle_mirrorObject($grpPose, $nAxis ) ; connectAttr -f ($grpPose+".worldMatrix") ($creatorDest+".poseState.poseDefault") ; } $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creatorSrc+".poseState.poseSquash")` ; if (size($cons) > 0) { // Dup and parent to mirror on opposite side string $grpPose = cMuscle_duplicateObject($cons[0], $search, $replace, 1) ; cMuscle_mirrorObject($grpPose, $nAxis ) ; connectAttr -f ($grpPose+".worldMatrix") ($creatorDest+".poseState.poseSquash") ; } $cons = `listConnections -s 1 -d 0 -p 0 -scn 1 ($creatorSrc+".poseState.poseStretch")` ; if (size($cons) > 0) { // Dup and parent to mirror on opposite side string $grpPose = cMuscle_duplicateObject($cons[0], $search, $replace, 1) ; cMuscle_mirrorObject($grpPose, $nAxis ) ; connectAttr -f ($grpPose+".worldMatrix") ($creatorDest+".poseState.poseStretch") ; } setAttr ($creatorDest+".poseState.poseDefaultStored") (`getAttr ($creatorSrc+".poseState.poseDefaultStored")`); setAttr ($creatorDest+".poseState.poseSquashStored") (`getAttr ($creatorSrc+".poseState.poseSquashStored")`); setAttr ($creatorDest+".poseState.poseStretchStored") (`getAttr ($creatorSrc+".poseState.poseStretchStored")`); } } // --------------------------------------------------------------------------