// =========================================================================== // 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. // =========================================================================== // // // Creation Date: September 16, 1999 // // Description: // This script is the copy skin weight option box dialogs. // // Input Arguments: // None. // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { if ( $forceFactorySettings || !`optionVar -exists copySkinWeightsSurfaceAssociationOption` ) optionVar -intValue copySkinWeightsSurfaceAssociationOption 1; if ( $forceFactorySettings || !`optionVar -exists copySkinWeightsInfluenceAssociationOption1` ) optionVar -intValue copySkinWeightsInfluenceAssociationOption1 1; if ( $forceFactorySettings || !`optionVar -exists copySkinWeightsInfluenceAssociationOption2` ) optionVar -intValue copySkinWeightsInfluenceAssociationOption2 1; if ( $forceFactorySettings || !`optionVar -exists copySkinWeightsInfluenceAssociationOption3` ) optionVar -intValue copySkinWeightsInfluenceAssociationOption3 1; if ($forceFactorySettings || !`optionVar -exists copySkinWeightsNormalize`) { optionVar -intValue copySkinWeightsNormalize 0; // off by default } } global proc copySkinWeightsSetOptionVarsFromUI( string $parent) // // Description: // Set the OptionVars from the UI values. // { int $value; $value = 1; for( $i = 1; $i < 5; $i++) if( `radioButtonGrp -q -select ("copySkinWeightsSurfaceAssociationMenu" + $i)`) $value = $i; optionVar -intValue copySkinWeightsSurfaceAssociationOption $value; $value = `optionMenuGrp -q -select copySkinWeightsInfluenceAssociationMenu1`; optionVar -intValue copySkinWeightsInfluenceAssociationOption1 $value; $value = `optionMenuGrp -q -select copySkinWeightsInfluenceAssociationMenu2`; optionVar -intValue copySkinWeightsInfluenceAssociationOption2 $value; $value = `optionMenuGrp -q -select copySkinWeightsInfluenceAssociationMenu3`; optionVar -intValue copySkinWeightsInfluenceAssociationOption3 $value; setParent $parent; } // // Procedure Name: // copySkinWeightsSetup // // Description: // Update the state of the option box UI to reflect the option values. // // Input Arguments: // parent - Top level parent layout of the option box UI. // Required so that UI object names can be // successfully resolved. // // forceFactorySettings - Whether the option values should be set to // default values. // // Return Value: // None. // global proc copySkinWeightsSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars( $forceFactorySettings ); // Set the state of the check box to that of the variable smoothCopyWeights // if (`radioButtonGrp -exists copySkinWeightsSurfaceAssociationMenu1`) { int $value = `optionVar -q copySkinWeightsSurfaceAssociationOption`; if( $value > 0) radioButtonGrp -e -select 1 ("copySkinWeightsSurfaceAssociationMenu" + $value); optionMenuGrp -e -select `optionVar -q copySkinWeightsInfluenceAssociationOption1` copySkinWeightsInfluenceAssociationMenu1; optionMenuGrp -e -select `optionVar -q copySkinWeightsInfluenceAssociationOption2` copySkinWeightsInfluenceAssociationMenu2; optionMenuGrp -e -select `optionVar -q copySkinWeightsInfluenceAssociationOption3` copySkinWeightsInfluenceAssociationMenu3; } // normalize int $objectNormalize = `optionVar -query copySkinWeightsNormalize`; checkBoxGrp -edit -value1 $objectNormalize copyNormalizeWidget; setParent $parent; } // // Procedure Name: // copySkinWeightsCallback // // Description: // Update the option values with the current state of the option box UI. // // Input Arguments: // parent - Top level parent layout of the option box UI. Required so // that UI object names can be successfully resolved. // // doIt - Whether the command should execute. // // Return Value: // None. // global proc copySkinWeightsCallback (string $parent, int $doIt) { setParent $parent; if (`radioButtonGrp -exists copySkinWeightsSurfaceAssociationMenu1`) { copySkinWeightsSetOptionVarsFromUI( $parent); } // normalize int $normalizeIt = `checkBoxGrp -query -value1 copyNormalizeWidget`; optionVar -intValue copySkinWeightsNormalize $normalizeIt; if ($doIt) { performCopySkinWeights false; addToRecentCommandQueue "performCopySkinWeights false" "CopySkinWeights"; } } proc createInfluenceAssociationMenu( string $menuName, string $label, int $allowNone) { optionMenuGrp -label $label -enable false $menuName; // Don't add a no-value case for the first menu if( $allowNone ) menuItem -label (uiRes("m_performCopySkinWeights.kNone")); menuItem -label (uiRes("m_performCopySkinWeights.kClosestJoint")); menuItem -label (uiRes("m_performCopySkinWeights.kClosestBone")); menuItem -label (uiRes("m_performCopySkinWeights.kOneToOne")); menuItem -label (uiRes("m_performCopySkinWeights.kLabel")); menuItem -label (uiRes("m_performCopySkinWeights.kName")); optionMenuGrp -e -enable true -select 1 -width 100 $menuName; } proc string copySkinWeightsWidgets( string $parent ) { setParent $parent; string $tabForm = `columnLayout -adjustableColumn true`; radioButtonGrp -numberOfRadioButtons 1 -label (uiRes("m_performCopySkinWeights.kSurfaceAssociation")) -label1 (uiRes("m_performCopySkinWeights.kClosestPoint")) -select 1 copySkinWeightsSurfaceAssociationMenu1; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performCopySkinWeights.kRayCast")) -shareCollection copySkinWeightsSurfaceAssociationMenu1 copySkinWeightsSurfaceAssociationMenu2; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performCopySkinWeights.kClosestComponent")) -shareCollection copySkinWeightsSurfaceAssociationMenu1 copySkinWeightsSurfaceAssociationMenu3; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performCopySkinWeights.kUVSpace")) -shareCollection copySkinWeightsSurfaceAssociationMenu1 copySkinWeightsSurfaceAssociationMenu4; separator; createInfluenceAssociationMenu( "copySkinWeightsInfluenceAssociationMenu1", (uiRes("m_performCopySkinWeights.kInfluenceAssociation1")), false); createInfluenceAssociationMenu( "copySkinWeightsInfluenceAssociationMenu2", (uiRes("m_performCopySkinWeights.kInfluenceAssociation2")), true); createInfluenceAssociationMenu( "copySkinWeightsInfluenceAssociationMenu3", (uiRes("m_performCopySkinWeights.kInfluenceAssociation3")), true); separator; // Normalize checkBoxGrp -label "" -label1 (uiRes("m_performCopySkinWeights.kNormalize")) -numberOfCheckBoxes 1 copyNormalizeWidget; return $tabForm; } global proc copySkinWeightsOptions () { string $commandName = "copySkinWeights"; // 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($commandName); setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -scr true -tv false; // To get the scroll bars string $parent = `columnLayout -adjustableColumn 1`; copySkinWeightsWidgets $parent; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performCopySkinWeights.kCopy")) -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_performCopySkinWeights.kCopySkinWeightsOptions")); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "CopySkinWeights" ); // Set the current values of the option box. // eval (($setup + " " + $parent + " " + 0)); // Show the option box. // showOptionBox(); } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // // Return Value: // None. // proc string assembleCmd() { string $cmd; string $args; setOptionVars(false); int $surfaceAssociationMode = `optionVar -query copySkinWeightsSurfaceAssociationOption`; string $surfaceAssociationModes[] = { "closestPoint", "rayCast", "closestComponent"}; if( $surfaceAssociationMode == 4) // UV space { string $uvSets[] = `polyUVSet -q -currentUVSet`; string $sourceUVSet = "map1"; string $targetUVSet = "map1"; if( size( $uvSets) > 0) { $sourceUVSet = $uvSets[0]; $targetUVSet = $uvSets[ size( $uvSets) - 1]; } $args = $args + " -surfaceAssociation " + $surfaceAssociationModes[ 0] + " -uvSpace " + $sourceUVSet + " " + $targetUVSet; } else { $args = $args + " -surfaceAssociation " + $surfaceAssociationModes[ $surfaceAssociationMode - 1]; } int $influenceAssociationMode = `optionVar -query copySkinWeightsInfluenceAssociationOption1`; string $influenceAssociationModes[] = { "closestJoint", "closestBone", "oneToOne", "label", "name"}; if( $influenceAssociationMode > 0) $args = $args + " -influenceAssociation " + $influenceAssociationModes[ $influenceAssociationMode - 1]; $influenceAssociationMode = `optionVar -query copySkinWeightsInfluenceAssociationOption2`; if( $influenceAssociationMode > 1) $args = $args + " -influenceAssociation " + $influenceAssociationModes[ $influenceAssociationMode - 2]; $influenceAssociationMode = `optionVar -query copySkinWeightsInfluenceAssociationOption3`; if( $influenceAssociationMode > 1) $args = $args + " -influenceAssociation " + $influenceAssociationModes[ $influenceAssociationMode - 2]; // Normalize if( `optionVar -query copySkinWeightsNormalize`) $args = $args + " -normalize"; $cmd = "doCopySkinWeightsArgList( 2, {\"" + $args + "\"} )"; return $cmd; } // // Procedure Name: // performCopySkinWeights // // Description: // Create a clip and add the animatable attributes from the // selected nodes. This procedure will also show the option box // window if necessary as well as construct the command string // that will create a clip with the current option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string performCopySkinWeights (int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Retrieve the option settings // setOptionVars(false); // Get the command. // $cmd = `assembleCmd`; // Execute the command with the option settings. // eval($cmd); break; // Show the option box. // case 1: copySkinWeightsOptions; break; case 2: // Get the command. // $cmd = `assembleCmd`; } return $cmd; }