// =========================================================================== // 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: Oct 12, 1998 // // Description: // This script sets up the Create Wrap dialog box // // Input Arguments: // None. // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { // Auto weight threshold. On by default. // if ( $forceFactorySettings || !`optionVar -exists autoWeightThreshold`) { optionVar -intValue autoWeightThreshold 1; } // UseMaxDistance is set to true by default for performance // if ( $forceFactorySettings || !`optionVar -exists limitWrapInfluence`) { optionVar -intValue limitWrapInfluence 1; optionVar -remove limitInfluence; } // Weight threshold // if ( $forceFactorySettings || !`optionVar -exists weightThreshold` ) { optionVar -floatValue weightThreshold 0.0; } // Max Distance // if ( $forceFactorySettings || !`optionVar -exists maxDistance` ) { optionVar -floatValue maxDistance 1.0; } // Influence type: points or face // if ( $forceFactorySettings || !`optionVar -exists wrapInflType` ) { optionVar -intValue wrapInflType 2; } // Exclusive bind // if ( $forceFactorySettings || !`optionVar -exists exclusiveBind`) { optionVar -intValue exclusiveBind 0; } // Render influence objects. Off by default // if ( $forceFactorySettings || !`optionVar -exists renderInfl`) { optionVar -intValue renderInfl 0; } // Distance mode: volume or surface // if ( $forceFactorySettings || !`optionVar -exists falloffMode`) { optionVar -stringValue falloffMode "volume"; } } // // Procedure Name: // createWrapSetup // // 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 createWrapSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars( $forceFactorySettings ); setParent $parent; // Exclusive bind // int $exclusiveBind = `optionVar -query exclusiveBind`; checkBoxGrp -e -value1 $exclusiveBind ebWidget; // Auto max distance // int $autoWeightThreshold = `optionVar -query autoWeightThreshold`; checkBoxGrp -e -value1 $autoWeightThreshold awtWidget; // Query the optionVar's and set the values into the controls // int $limitWrapInfluence = `optionVar -query limitWrapInfluence`; checkBoxGrp -e -value1 $limitWrapInfluence liWidget; if (! $autoWeightThreshold) checkBoxGrp -e -enable 1 liWidget; else checkBoxGrp -e -enable 0 liWidget; // Weight threshold // if (`floatSliderGrp -exists wtWidget`){ floatSliderGrp -edit -value `optionVar -query weightThreshold` wtWidget; if ($exclusiveBind || $autoWeightThreshold) floatSliderGrp -e -enable 0 wtWidget; else floatSliderGrp -e -enable 1 wtWidget; } // max distance // if (`floatSliderGrp -exists mdWidget`){ floatSliderGrp -edit -value `optionVar -query maxDistance` mdWidget; if ($limitWrapInfluence && ! $autoWeightThreshold) floatSliderGrp -e -enable 1 mdWidget; else floatSliderGrp -e -enable 0 mdWidget; } // Render influence object(s) // int $renderInfl = `optionVar -query renderInfl`; checkBoxGrp -e -value1 $renderInfl riWidget; // Falloff // string $falloffMode = `optionVar -query falloffMode`; if(`optionMenuGrp -exists wfWidget`) { if($falloffMode == "volume") { optionMenuGrp -edit -select 1 wfWidget; } else { optionMenuGrp -edit -select 2 wfWidget; } } } // // Procedure Name: // createWrapCallback // // 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 createWrapCallback (string $parent, int $doIt) { setParent $parent; optionVar -intValue limitWrapInfluence `checkBoxGrp -q -value1 liWidget`; optionVar -intValue exclusiveBind `checkBoxGrp -q -value1 ebWidget`; optionVar -intValue autoWeightThreshold `checkBoxGrp -q -value1 awtWidget`; // Weight threshold // if (`floatSliderGrp -exists wtWidget`) { optionVar -floatValue weightThreshold `floatSliderGrp -query -value wtWidget`; } // Max distance // if (`floatSliderGrp -exists mdWidget`) { optionVar -floatValue maxDistance `floatSliderGrp -query -value mdWidget`; } optionVar -intValue renderInfl `checkBoxGrp -q -value1 riWidget`; // Falloff // string $falloffMode = "volume"; if(`optionMenuGrp -q -select wfWidget` == 1) { $falloffMode = "volume"; } else { $falloffMode = "surface"; } optionVar -stringValue falloffMode $falloffMode; if ($doIt) { performCreateWrap false; addToRecentCommandQueue "performCreateWrap false" "CreateWrap"; } } global proc createWrapOptions () { // Name of the command for this option box // string $commandName = "createWrap"; // Build the option box "methods" // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // STEP 1: 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; // STEP 2: Pass the command name to the option box. // ================================================= // // Any default option box behaviour based on the command name is set // up with this call. For example, updating the 'Help' menu item with // the name of the command. // // setOptionBoxCommandName("performWrap"); // STEP 3: Activate the default UI template. // ========================================== // // Activate the default UI template so that the layout of this // option box is consistent with the layout of the rest of the // application. // setUITemplate -pushTemplate DefaultTemplate; // STEP 4: Create option box contents. // =================================== // // This, of course, will vary from option box to option box. // Turn on the wait cursor. // waitCursor -state 1; tabLayout -tabsVisible 0 -scrollable 1; string $parent = `columnLayout -adjustableColumn 1`; checkBoxGrp -label (uiRes("m_performCreateWrap.kExclusiveBind")) -numberOfCheckBoxes 1 -on1 "floatSliderGrp -e -enable 0 wtWidget; checkBoxGrp -e -enable 0 awtWidget" -of1 "floatSliderGrp -e -enable 1 wtWidget; checkBoxGrp -e -enable 1 awtWidget" ebWidget; checkBoxGrp -label (uiRes("m_performCreateWrap.kAutoWeightThreshold")) -numberOfCheckBoxes 1 -on1 "floatSliderGrp -e -enable 0 wtWidget; floatSliderGrp -e -enable 0 mdWidget; checkBoxGrp -e -enable 0 liWidget" -of1 "floatSliderGrp -e -enable 1 wtWidget; floatSliderGrp -e -enable 1 mdWidget; checkBoxGrp -e -enable 1 liWidget" awtWidget; floatSliderGrp -label (uiRes("m_performCreateWrap.kWeightThreshold")) -minValue 0 -maxValue 1.0 -pre 2 wtWidget ; checkBoxGrp -label (uiRes("m_performCreateWrap.kUseMaxDistance")) -annotation (uiRes("m_performCreateWrap.kLimitInfluenceAreaAnnot")) -numberOfCheckBoxes 1 -on1 "floatSliderGrp -e -enable 1 mdWidget" -of1 "floatSliderGrp -e -enable 0 mdWidget" liWidget; floatSliderGrp -label (uiRes("m_performCreateWrap.kMaxDistance")) -minValue 0.01 -maxValue 50.0 -fieldMaxValue 1000.0 -enable (`checkBoxGrp -q -v1 liWidget`) -pre 2 mdWidget; checkBoxGrp -label (uiRes("m_performCreateWrap.kRenderInfluence")) -numberOfCheckBoxes 1 riWidget; optionMenuGrp -label (uiRes("m_performCreateWrap.kFalloffMode")) wfWidget; menuItem -label (uiRes("m_performCreateWrap.kVolume")) wfWidgetPos1; menuItem -label (uiRes("m_performCreateWrap.kSurface")) wfWidgetPos2; // Turn off the wait cursor. // waitCursor -state 0; // Step 5: Deactivate the default UI template. // =========================================== // setUITemplate -popTemplate; // Step 6: Customize the buttons. // ============================== // // Provide more descriptive labels for the buttons. This is not // necessary, but in some cases, for example, a button labelled // 'Create' may be more meaningful to the user than one labelled // 'Apply'. // // Disable those buttons that are not applicable to the option box. // // Attach actions to those buttons that are applicable to the option // box. Note that the 'Close' button has a default action attached // to it that will hide the window. If a a custom action is // attached to the 'Close' button then be sure to call the 'hide the // option box' procedure within the custom action so that the option // box is hidden properly. // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performCreateWrap.kCreate")) -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; // Step 7: Set the option box title. // ================================= // setOptionBoxTitle (uiRes("m_performCreateWrap.kCreateWrapOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "CreateWrap" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); } proc string assembleCmd () { string $cmd; setOptionVars( false ); $cmd = "doWrapArgList \"7\" { \"1\","; float $thresh = `optionVar -query weightThreshold`; $cmd = $cmd + "\"" + $thresh + "\","; int $limitInfl = `optionVar -q limitWrapInfluence`; if ($limitInfl == 1) $cmd = $cmd + "\"" + `optionVar -query maxDistance` + "\""; else $cmd = $cmd + "\"0.0\""; int $inflType = `optionVar -q wrapInflType`; $cmd += (", \""+$inflType+"\""); int $exclusiveBind = `optionVar -q exclusiveBind`; $cmd += (", \""+$exclusiveBind+"\""); int $autoWeightThreshold = `optionVar -q autoWeightThreshold`; $cmd += (", \""+$autoWeightThreshold+"\""); int $renderInfl = `optionVar -q renderInfl`; $cmd += (", \""+$renderInfl+"\""); string $falloffMode = `optionVar -q falloffMode`; int $falloff = 0; if($falloffMode == "surface") $falloff = 1; $cmd += (", \""+$falloff+"\""); $cmd = $cmd + " }"; return $cmd; } global proc string performCreateWrap (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 eval($cmd); break; case 1: // Do the option box createWrapOptions; break; case 2: // Return the drag string // Retrieve the option settings // setOptionVars (false); // Get the command $cmd = `assembleCmd`; break; } return $cmd; }