// =========================================================================== // 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: Nov 24, 19987 // // Description: // This script is use to display and update the lattice deformer options. // // Input Arguments: // None. // // Return Value: // None. // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // proc string assembleCmd() { string $cmd; setToolTo texLatticeDeformSuperContext; string $context = "texLatticeDeformCtx"; int $row = `intSliderGrp -query -value texLatticeDeformRows`; int $col = `intSliderGrp -query -value texLatticeDeformColumns`; float $env = `floatSliderGrp -query -value texLatticeDeformEnvelope`; int $ub = `checkBoxGrp -query -value1 texLatticeDeformUseBoundRect`; $cmd = "texLatticeDeformContext -edit"; $cmd += " -latticeRows " + $row; $cmd += " -latticeColumns " + $col; $cmd += " -envelope " + $env; $cmd += " -ubr " + $ub; $cmd += " " + $context; return $cmd; } global proc tvLatticeToolCallback(string $parent, int $doIt) { if ($doIt ) { // Execute the command with the option settings. $cmd = `assembleCmd`; eval($cmd); } else { tvLatticeToolRefresh $parent; } } global proc tvLatticeToolRefresh(string $parent ) { setToolTo texLatticeDeformSuperContext; string $context = "texLatticeDeformCtx"; setParent $parent; int $rows = `texLatticeDeformContext -query -latticeRows $context`; int $col = `texLatticeDeformContext -query -latticeColumns $context`; float $env = `texLatticeDeformContext -query -envelope $context`; int $br = `texLatticeDeformContext -query -ubr $context`; intSliderGrp -edit -value $rows -min 2 -max 8 texLatticeDeformRows; intSliderGrp -edit -min 2 -max 8 -value $col texLatticeDeformColumns; floatSliderGrp -edit -value $env texLatticeDeformEnvelope; checkBoxGrp -edit -v1 $br texLatticeDeformUseBoundRect; int $snapMode = `texLatticeDeformContext -q -snapPixelMode $context`; // Recast the values to the selected items switch ($snapMode) { case 1: radioButtonGrp -e -sl 1 texLatSnapMode; break; case 0: radioButtonGrp -e -sl 2 texLatSnapMode; break; } // setup the commands radioButtonGrp -e -on1 ("texLatticeDeformContext -e -snapPixelMode 0 " + $context) -on2 ("texLatticeDeformContext -e -snapPixelMode 1 " + $context) texLatSnapMode; } global proc tvLatticeToolSetup(string $parent, int $doIt) { setParent $parent; setUITemplate -pushTemplate OptionsTemplate; if ($doIt == false) { columnLayout textureLatticeDeform; frameLayout -collapsable true -collapse false -label (uiRes("m_performTextureLatticeOptions.kLatticeSettings")) textureLatticeDeformFrame; columnLayout textureLatticeDeformOptions; separator -style "none"; intSliderGrp -label (uiRes("m_performTextureLatticeOptions.kColumns")) -field true -minValue 2 -maxValue 20 -fieldMinValue 2 -fieldMaxValue 20 texLatticeDeformColumns; intSliderGrp -label (uiRes("m_performTextureLatticeOptions.kRows")) -field true -minValue 2 -maxValue 20 -fieldMinValue 2 -fieldMaxValue 20 texLatticeDeformRows; floatSliderGrp -label (uiRes("m_performTextureLatticeOptions.kFalloff")) -field true -minValue 0.0 -maxValue 1.0 -fieldMinValue 0.0 -fieldMaxValue 1.0 texLatticeDeformEnvelope; checkBoxGrp -label1 (uiRes("m_performTextureLatticeOptions.kUseBoundingRectangle")) -label "" texLatticeDeformUseBoundRect; setParent ..; setParent ..; frameLayout -collapsable true -collapse false -label (uiRes("m_performTextureLatticeOptions.kSnapSettings")) texLatSnapFrame; columnLayout texLatSnapOptions; separator -style "none"; radioButtonGrp -nrb 2 -label (uiRes("m_performTextureLatticeOptions.kPlacement")) -sl 1 -label1 (uiRes("m_performTextureLatticeOptions.kSanpCorner")) -label2 (uiRes("m_performTextureLatticeOptions.kSanpCenter")) texLatSnapMode; setParent ..; setParent ..; setParent ..; setUITemplate -popTemplate; } tvLatticeToolCallback($parent, false); } // // Procedure Name: // tvLatticeToolOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc tvLatticeToolOptions() { // Name of the command for this option box. // string $commandName = "tvLatticeTool"; // Build the option box actions. // 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($commandName); // 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`; // optionMenuGrp -l "Baked Texture Resolution" // -cc ("tvBakeTextureCheckResolution") // resolutionMenuPopup; // 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 -command ($callback + " " + $parent + " " + 1) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 1 + "; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Step 7: Set the option box title. // ================================= // setOptionBoxTitle (uiRes("m_performTextureLatticeOptions.kUVLatticeToolOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "UVTextureEditorLatticeTool" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // performTextureLatticeOptions // // Description: // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // global proc string performTextureLatticeOptions(int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Get the command. // $cmd = `assembleCmd`; // Execute the command with the option settings. // eval($cmd); break; // Show the option box. // case 1: tvLatticeToolOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }