// =========================================================================== // 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. // =========================================================================== proc setOptionVars (int $forceFactorySettings) { // bindTo // if ( $forceFactorySettings || !`optionVar -exists bindVolTo` ) { optionVar -intValue bindVolTo 1; } // volumeType // if ( $forceFactorySettings || !`optionVar -exists bindVolType` ) { optionVar -intValue bindVolType 1; } // bindMethod // if ( $forceFactorySettings || !`optionVar -exists bindVolMethod` ) { optionVar -intValue bindVolMethod 1; } // skinning Method // if ( $forceFactorySettings || !`optionVar -exists bindVolSkinMethod` ) { optionVar -intValue bindVolSkinMethod 1; } // Include Method // if ($forceFactorySettings || !`optionVar -exists bindVolIncludeMethod`) { optionVar -intValue bindVolIncludeMethod 1; } // Min weight // if ($forceFactorySettings || !`optionVar -exists bindVolMinWeight`) { optionVar -floatValue bindVolMinWeight .25; } // maxInfluences // if ($forceFactorySettings || !`optionVar -exists bindVolMaxInfl`) { optionVar -intValue bindVolMaxInfl 4; } if ($forceFactorySettings || !`optionVar -exists bindVolObeyMaxInfl`) { optionVar -intValue bindVolObeyMaxInfl 1; } // dropoff power // if ($forceFactorySettings || !`optionVar -exists bindVolDropoff`) { optionVar -floatValue bindVolDropoff 4.0; } // Include hidden objects during bind // if ($forceFactorySettings || !`optionVar -exists bindVolIncludeHiddenSelections`) { optionVar -intValue bindVolIncludeHiddenSelections 0; } } global proc volumeBindSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings setOptionVars( $forceFactorySettings ); setParent $parent; // Retrieve the option settings // setOptionVars( $forceFactorySettings ); setParent $parent; // Query the optionVar's and set the values into the controls // // bindTo = to selected joints or to selected skeleton // optionMenuGrp -e -sl `optionVar -query bindVolTo` bindVolTo; // volumeType // optionMenuGrp -e -sl `optionVar -query bindVolType` bindVolType; // bindMethod = closest joint or closest distance // optionMenuGrp -e -sl `optionVar -query bindVolMethod` bindVolMethod; // skinning method - linear, dual quaternion optionMenuGrp -e -sl `optionVar -query bindVolSkinMethod` bindVolSkinMethod; // Include method // int $imethod = `optionVar -query bindVolIncludeMethod`; radioButtonGrp -e -sl $imethod bindVolIncludeMethod; // Min weight // floatSliderGrp -e -value `optionVar -query bindVolMinWeight` bindVolMinWeight; floatSliderGrp -e -enable ($imethod == 2) bindVolMinWeight; // min weight method // maxInfluences // if (`intSliderGrp -exists bindVolMaxInfl`) { intSliderGrp -edit -value `optionVar -query bindVolMaxInfl` bindVolMaxInfl; } if (`checkBoxGrp -exists bindVolObeyMaxInfl`) { checkBoxGrp -edit -value1 `optionVar -query bindVolObeyMaxInfl` bindVolObeyMaxInfl; } // Include hidden objects during bind // if (`checkBoxGrp -exists bindVolIncludeHiddenSelections`) { checkBoxGrp -edit -value1 `optionVar -query bindVolIncludeHiddenSelections` bindVolIncludeHiddenSelections; } } global proc volumeBindCallback (string $parent, int $doIt) { setParent $parent; // bindTo // optionVar -intValue bindVolTo `optionMenuGrp -q -sl bindVolTo`; // bindMethod // optionVar -intValue bindVolMethod `optionMenuGrp -q -sl bindVolMethod`; // binding volume shape // optionVar -intValue bindVolType `optionMenuGrp -q -sl bindVolType`; // skining method DQ or classical // optionVar -intValue bindVolSkinMethod `optionMenuGrp -q -sl bindVolSkinMethod`; // Include method // int $imethod = `radioButtonGrp -q -sl bindVolIncludeMethod`; optionVar -intValue bindVolIncludeMethod $imethod ; // Min weight // if (`floatSliderGrp -exists bindVolMinWeight`) { optionVar -floatValue bindVolMinWeight `floatSliderGrp -query -value bindVolMinWeight`; } // MaxInfluences // if (`intSliderGrp -exists bindVolMaxInfl`) { optionVar -floatValue bindVolMaxInfl `intSliderGrp -query -value bindVolMaxInfl`; } if (`checkBoxGrp -exists bindVolObeyMaxInfl`) { optionVar -intValue bindVolObeyMaxInfl `checkBoxGrp -query -value1 bindVolObeyMaxInfl`; } // Dropoff power // if (`floatSliderGrp -exists dropoff`) { optionVar -floatValue bindVolDropoff `floatSliderGrp -query -value bindVolDropoff`; } // Set the value of the persistent variable "removeUnusedInfluences" to // that of the option box. if (`checkBoxGrp -exists removeUnusedInfluences`) { optionVar -intValue removeUnusedInfluences `checkBoxGrp -query -value1 removeUnusedInfluences`; } // Set the value of the persistent variable "bindVolIncludeHiddenSelections" to // that of the option box. // if (`checkBoxGrp -exists bindVolIncludeHiddenSelections`) { optionVar -intValue bindVolIncludeHiddenSelections `checkBoxGrp -query -value1 bindVolIncludeHiddenSelections`; } if ($doIt) { performVolumeBind false; addToRecentCommandQueue "performVolumeBind false" "Skin Cluster"; } } proc string volumeBindBasic( string $tabLayout ) { setParent $tabLayout; string $tabForm = `columnLayout -adjustableColumn true`; optionMenuGrp -annotation (uiRes("m_performVolumeBind.kBindToAllAnnot")) -label (uiRes("m_performVolumeBind.kBindTo")) bindVolTo; menuItem -label (uiRes("m_performVolumeBind.kJointHierarchy")) ; menuItem -label (uiRes("m_performVolumeBind.kSelectedJoints")) ; menuItem -label (uiRes("m_performVolumeBind.kObjectHierarchy")) ; optionMenuGrp -label (uiRes("m_performVolumeBind.kBindMethod")) -annotation (uiRes("m_performVolumeBind.kBindonDistAnnot")) bindVolMethod; menuItem -label (uiRes("m_performVolumeBind.kClosestDistance")) ; menuItem -label (uiRes("m_performVolumeBind.kClosestHierarchy")) ; // menuItem -label _L10N( kHeatMap, "Heat map" ); separator; radioButtonGrp -numberOfRadioButtons 2 -annotation (uiRes("m_performVolumeBind.kIncludeMethodAnn")) -label (uiRes("m_performVolumeBind.kIncludeMethod")) -label1 (uiRes("m_performVolumeBind.kIncludeClosest")) -label2 (uiRes("m_performVolumeBind.kInlcudeMinWeight")) -cc1 "floatSliderGrp -e -enable false bindVolMinWeight;" -cc2 "floatSliderGrp -e -enable true bindVolMinWeight;" bindVolIncludeMethod; floatSliderGrp -label (uiRes("m_performVolumeBind.kVolMinWeight")) -field true -min 0.0 -max 1.0 -step 0.01 bindVolMinWeight; optionMenuGrp -label (uiRes("m_performVolumeBind.kVolumeType")) -annotation (uiRes("m_performVolumeBind.kVolumeTypeAnnot")) bindVolType; menuItem -label (uiRes("m_performVolumeBind.kVolTypeCapsule")) ; menuItem -label (uiRes("m_performVolumeBind.kVolTypeCylinder")) ; separator; optionMenuGrp -label (uiRes("m_performVolumeBind.kSkinMethod")) -annotation (uiRes("m_performVolumeBind.kSkinMethodAnnot")) bindVolSkinMethod; menuItem -label (uiRes("m_performVolumeBind.kLinearMethod")) ; menuItem -label (uiRes("m_performVolumeBind.kDualQuaternionMethod")) ; menuItem -label (uiRes("m_performVolumeBind.kBlendedMethod")) ; intSliderGrp -label (uiRes("m_performVolumeBind.kMaxInfluences")) -annotation (uiRes("m_performVolumeBind.kMaxInfluencesAnnot")) -fieldMinValue 0 -minValue 0 -maxValue 30 bindVolMaxInfl; checkBoxGrp -ncb 1 -annotation (uiRes("m_performVolumeBind.kInfluencesEnforcedAnnot")) -label (uiRes("m_performVolumeBind.kAfterBind")) -label1 (uiRes("m_performVolumeBind.kMaintainInfluences")) bindVolObeyMaxInfl; checkBoxGrp -ncb 1 -annotation (uiRes("m_performVolumeBind.kIncludeHiddenSelAnnot")) -label1 (uiRes("m_performVolumeBind.kIncludeHiddenSelections")) bindVolIncludeHiddenSelections; setParent -m ..; // initialize optionMenuGrp -e -sl 1 bindVolTo; optionMenuGrp -e -sl 2 bindVolMethod; optionMenuGrp -e -sl 1 bindVolSkinMethod; optionMenuGrp -e -sl 1 bindVolType; setParent ..; return $tabForm; } proc string assembleCmd () { setOptionVars( false ); $cmd = "skinCluster "; int $imethod = `optionVar -query bindVolIncludeMethod`; if ($imethod == 1) { $cmd += "-volumeBind 0 "; } else { float $minWeight = `optionVar -query bindVolMinWeight`; $cmd += "-volumeBind "+ $minWeight+" "; } int $type = `optionVar -query bindVolType`; $cmd += " -volumeType " + $type + " "; int $bindTo = `optionVar -q bindVolTo`; if ($bindTo == 2) { $cmd = ( $cmd + "-toSelectedBones " ); } else if ($bindTo == 3) { $cmd = ( $cmd + "-toSkeletonAndTransforms " ); } int $bindMethod = `optionVar -q bindVolMethod`; $cmd = ( $cmd + "-bindMethod " + ( $bindMethod - 1 ) + " " ); int $skinMethod = `optionVar -q bindVolSkinMethod`; if ($skinMethod > 1) { $cmd = ( $cmd + "-skinMethod " + ($skinMethod -1) + " "); } $cmd += "-mi " + `optionVar -query bindVolMaxInfl` + " "; if (`optionVar -query bindVolObeyMaxInfl`) { $cmd += "-omi true "; } int $includeHiddenSelections = `optionVar -query bindVolIncludeHiddenSelections`; if ($includeHiddenSelections) $cmd += " -ihs "; $cmd += "-dr " + `optionVar -query bindVolDropoff`; return $cmd; } global proc volumBindOptions () { // Name of the command for this option box // string $commandName = "volumeBind"; // Build the option box "methods" // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // Get the option box. // // The value returned is the name of the layout to be used as // the parent for the option box UI. // string $layout = getOptionBox(); setParent $layout; setOptionBoxCommandName("volumeBind"); setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -scr true -tv false; string $parent = `columnLayout -adjustableColumn 1`; volumeBindBasic $parent; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performVolumeBind.kBindSkin")) -command ($callback + " " + $parent + " " + 1) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Set the option box title. // setOptionBoxTitle (uiRes("m_performVolumeBind.kSmoothBindOptions")); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "VolumeBind" ); // Set the current values of the option box. // eval (($setup + " " + $parent + " " + 0)); // Show the option box. // showOptionBox(); } global proc string performVolumeBind(int $action) // The action variable means // 0 - do the command // 1 - show the option box // 2 - return the drag command { string $cmd = ""; switch ($action) { case 0: // Execute the command // Retrieve the option settings setOptionVars (false); // Get the command and print it in the command window $cmd = assembleCmd(); // Execute the command with the option settings evalEcho($cmd); // open the skin binding tool setToolTo skinBindingContext; break; case 1: // Do the option box volumBindOptions; break; case 2: // Return the drag string // Retrieve the option settings // setOptionVars (false); // Get the command $cmd = assembleCmd(); break; } return $cmd; }