// =========================================================================== // 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 mirror skin weight option box dialogs. // // Input Arguments: // None. // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { if ($forceFactorySettings || !`optionVar -exists mirrorSkinAxis`) { optionVar -stringValue mirrorSkinAxis "YZ"; } if ($forceFactorySettings || !`optionVar -exists mirrorInverse`) { optionVar -intValue mirrorInverse 1; } if ( $forceFactorySettings || !`optionVar -exists mirrorSkinWeightsSurfaceAssociationOption` ) optionVar -intValue mirrorSkinWeightsSurfaceAssociationOption 1; if ( $forceFactorySettings || !`optionVar -exists mirrorSkinWeightsInfluenceAssociationOption1` ) optionVar -intValue mirrorSkinWeightsInfluenceAssociationOption1 1; if ( $forceFactorySettings || !`optionVar -exists mirrorSkinWeightsInfluenceAssociationOption2` ) optionVar -intValue mirrorSkinWeightsInfluenceAssociationOption2 1; if ( $forceFactorySettings || !`optionVar -exists mirrorSkinWeightsInfluenceAssociationOption3` ) optionVar -intValue mirrorSkinWeightsInfluenceAssociationOption3 1; if ($forceFactorySettings || !`optionVar -exists mirrorSkinNormalize`) { optionVar -intValue mirrorSkinNormalize 0; // off by default } } // // Procedure Name: // mirrorSkinWeightsSetup // // 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 mirrorSkinWeightsSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars( $forceFactorySettings ); setParent $parent; string $mode = `optionVar -query mirrorSkinAxis`; if ($mode == "XY") { radioButtonGrp -edit -select 1 mirrorSkinAxisWidget; checkBoxGrp -e -label1 (uiRes("m_performMirrorSkinWeights.kPositivetoNegativeZ")) mirrorInverseWidget; } else if ($mode == "YZ") { radioButtonGrp -edit -select 2 mirrorSkinAxisWidget; checkBoxGrp -e -label1 (uiRes("m_performMirrorSkinWeights.kPositivetoNegativeX")) mirrorInverseWidget; } else { radioButtonGrp -edit -select 3 mirrorSkinAxisWidget; checkBoxGrp -e -label1 (uiRes("m_performMirrorSkinWeights.kPositivetoNegativeY")) mirrorInverseWidget; } int $objectCentered = `optionVar -query mirrorInverse`; checkBoxGrp -edit -value1 $objectCentered mirrorInverseWidget; int $value; // Set the state of the check box to that of the variable smoothCopyWeights // if (`radioButtonGrp -exists mirrorSkinWeightsSurfaceAssociationMenu1`) { int $value = `optionVar -q mirrorSkinWeightsSurfaceAssociationOption`; if( $value > 0) radioButtonGrp -e -select 1 ("mirrorSkinWeightsSurfaceAssociationMenu" + $value); optionMenuGrp -e -select `optionVar -q mirrorSkinWeightsInfluenceAssociationOption1` mirrorSkinWeightsInfluenceAssociationMenu1; optionMenuGrp -e -select `optionVar -q mirrorSkinWeightsInfluenceAssociationOption2` mirrorSkinWeightsInfluenceAssociationMenu2; } // normalize int $objectNormalize = `optionVar -query mirrorSkinNormalize`; checkBoxGrp -edit -value1 $objectNormalize mirrorNormalizeWidget; } // // Procedure Name: // mirrorSkinWeightsCallback // // 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 mirrorSkinWeightsCallback (string $parent, int $doIt) { setParent $parent; string $mode; if (`radioButtonGrp -query -select mirrorSkinAxisWidget` == 1) { $mode = "XY"; } else if (`radioButtonGrp -query -select mirrorSkinAxisWidget` == 2) { $mode = "YZ"; } else { $mode = "XZ"; } optionVar -stringValue mirrorSkinAxis $mode; // inverse int $invertIt = `checkBoxGrp -query -value1 mirrorInverseWidget`; optionVar -intValue mirrorInverse $invertIt; // Remember the values of the surface/influence associations // $value = 1; for( $i = 1; $i < 4; $i++) if( `radioButtonGrp -q -select ("mirrorSkinWeightsSurfaceAssociationMenu" + $i)`) $value = $i; optionVar -intValue mirrorSkinWeightsSurfaceAssociationOption $value; $value = `optionMenuGrp -q -select mirrorSkinWeightsInfluenceAssociationMenu1`; optionVar -intValue mirrorSkinWeightsInfluenceAssociationOption1 $value; $value = `optionMenuGrp -q -select mirrorSkinWeightsInfluenceAssociationMenu2`; optionVar -intValue mirrorSkinWeightsInfluenceAssociationOption2 $value; // normalize int $normalizeIt = `checkBoxGrp -query -value1 mirrorNormalizeWidget`; optionVar -intValue mirrorSkinNormalize $normalizeIt; if ($doIt) { performMirrorSkinWeights false; addToRecentCommandQueue "performMirrorSkinWeights false" "MirrorSkinWeights"; } } 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_performMirrorSkinWeights.kNone")); menuItem -label (uiRes("m_performMirrorSkinWeights.kClosestJoint")); menuItem -label (uiRes("m_performMirrorSkinWeights.kOneToOne")); menuItem -label (uiRes("m_performMirrorSkinWeights.kLabel")); optionMenuGrp -e -enable true -select 1 -width 100 $menuName; } proc string mirrorSkinWeightsWidgets( string $parent ) { setParent $parent; string $tabForm = `columnLayout -adjustableColumn true`; // Mode string $strValZ = uiRes("m_performMirrorSkinWeights.kPositivetoNegativeZ"); string $strValX = uiRes("m_performMirrorSkinWeights.kPositivetoNegativeX"); string $strValY = uiRes("m_performMirrorSkinWeights.kPositivetoNegativeY"); string $cc1 = "checkBoxGrp -e -label1 \"" + $strValZ + "\" mirrorInverseWidget"; string $cc2 = "checkBoxGrp -e -label1 \"" + $strValX + "\" mirrorInverseWidget"; string $cc3 = "checkBoxGrp -e -label1 \"" + $strValY + "\" mirrorInverseWidget"; radioButtonGrp -label (uiRes("m_performMirrorSkinWeights.kMirrorAcross")) -numberOfRadioButtons 3 -label1 (uiRes("m_performMirrorSkinWeights.kXY")) -label2 (uiRes("m_performMirrorSkinWeights.kYZ")) -label3 (uiRes("m_performMirrorSkinWeights.kXZ")) -cc1 $cc1 -cc2 $cc2 -cc3 $cc3 mirrorSkinAxisWidget; // Invert checkBoxGrp -label (uiRes("m_performMirrorSkinWeights.kDirection")) -label1 (uiRes("m_performMirrorSkinWeights.kPositivetoNegative")) -numberOfCheckBoxes 1 mirrorInverseWidget; separator; radioButtonGrp -numberOfRadioButtons 1 -label (uiRes("m_performMirrorSkinWeights.kSurfaceAssociation")) -label1 (uiRes("m_performMirrorSkinWeights.kClosestPoint")) -select 1 mirrorSkinWeightsSurfaceAssociationMenu1; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performMirrorSkinWeights.kRayCast")) -shareCollection mirrorSkinWeightsSurfaceAssociationMenu1 mirrorSkinWeightsSurfaceAssociationMenu2; radioButtonGrp -numberOfRadioButtons 1 -label1 (uiRes("m_performMirrorSkinWeights.kClosestComponent")) -shareCollection mirrorSkinWeightsSurfaceAssociationMenu1 mirrorSkinWeightsSurfaceAssociationMenu3; separator; createInfluenceAssociationMenu( "mirrorSkinWeightsInfluenceAssociationMenu1", (uiRes("m_performMirrorSkinWeights.kInfluenceAssociation1")), false); createInfluenceAssociationMenu( "mirrorSkinWeightsInfluenceAssociationMenu2", (uiRes("m_performMirrorSkinWeights.kInfluenceAssociation2")), true); separator; // Normalize checkBoxGrp -label "" -label1 (uiRes("m_performMirrorSkinWeights.kNormalize")) -numberOfCheckBoxes 1 mirrorNormalizeWidget; return $tabForm; } global proc mirrorSkinWeightsOptions () { string $commandName = "mirrorSkinWeights"; // 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("mirrorSkinWeights"); setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -scr true -tv false; // To get the scroll bars string $parent = `columnLayout -adjustableColumn 1`; mirrorSkinWeightsWidgets $parent; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performMirrorSkinWeights.kMirror")) -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_performMirrorSkinWeights.kMirrorSkinWeightsOptions")); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "MirrorSkinWeights" ); // 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; setOptionVars(false); // Setup the arguments for our mirror command // string $args = " -mirrorMode " + `optionVar -query mirrorSkinAxis`; if( !`optionVar -query mirrorInverse`) $args = $args + " -mirrorInverse"; int $surfaceAssociationMode = `optionVar -query mirrorSkinWeightsSurfaceAssociationOption`; string $surfaceAssociationModes[] = { "closestPoint", "rayCast", "closestComponent"}; $args = $args + " -surfaceAssociation " + $surfaceAssociationModes[ $surfaceAssociationMode - 1]; int $influenceAssociationMode = `optionVar -query mirrorSkinWeightsInfluenceAssociationOption1`; string $influenceAssociationModes[] = { "closestJoint", "oneToOne", "label", "name"}; if( $influenceAssociationMode > 0) $args = $args + " -influenceAssociation " + $influenceAssociationModes[ $influenceAssociationMode - 1]; $influenceAssociationMode = `optionVar -query mirrorSkinWeightsInfluenceAssociationOption2`; if( $influenceAssociationMode > 1) $args = $args + " -influenceAssociation " + $influenceAssociationModes[ $influenceAssociationMode - 2]; // Normalize if( `optionVar -query mirrorSkinNormalize`) $args = $args + " -normalize"; // Now pass them over // $cmd = "doMirrorSkinWeightsArgList( 2, { \"" + $args + "\" } );"; return $cmd; } // // Procedure Name: // performMirrorSkinWeights // // 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 performMirrorSkinWeights (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. // evalEcho($cmd); break; // Show the option box. // case 1: mirrorSkinWeightsOptions; break; case 2: // Get the command. // $cmd = `assembleCmd`; } return $cmd; }