// =========================================================================== // 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: 3 June 1997 // // Description: // Script to create the option dialog for convert solid texture. // // // Procedure Name: // setOptionVars // // Description: // Initialize the option values. // // Input Arguments: // Whether to set the options to default values. // // Return Value: // None. // proc setOptionVars(int $forceFactorySettings) { // AntiAlias. // if ($forceFactorySettings || !`optionVar -exists convertSolidTxAntiA`) { optionVar -intValue convertSolidTxAntiA false; } // BackgroundMode if ($forceFactorySettings || !`optionVar -exists convertSolidBckMode`) { optionVar -intValue convertSolidBckMode 1; } // Background Color if ($forceFactorySettings || !`optionVar -exists convertSolidBckColor`) { optionVar -fv convertSolidBckColor 0 -fva convertSolidBckColor 0 -fva convertSolidBckColor 0 ; } // Fill Texture Seams. // if ($forceFactorySettings || !`optionVar -exists convertSolidTxFillTextureSeams`) { optionVar -intValue convertSolidTxFillTextureSeams true; } // bakeLt. // if ($forceFactorySettings || !`optionVar -exists convertSolidTxBakeLt`) { optionVar -intValue convertSolidTxBakeLt false; } // samplePlane // if ($forceFactorySettings || !`optionVar -exists convertSolidTxSamplePlane`) { optionVar -intValue convertSolidTxSamplePlane false; } // bakeShadow. // if ($forceFactorySettings || !`optionVar -exists convertSolidTxBakeShadow`) { optionVar -intValue convertSolidTxBakeShadow false; } // bakeAlpha if ($forceFactorySettings || !`optionVar -exists convertSolidTxBakeAlpha`) { optionVar -intValue convertSolidTxBakeAlpha false; } // doubleSided if ($forceFactorySettings || !`optionVar -exists convertSolidTxDoubleSided`) { optionVar -intValue convertSolidTxDoubleSided false; } // component range if ($forceFactorySettings || !`optionVar -exists convertSolidTxCompRange`) { optionVar -intValue convertSolidTxCompRange false; } // uv range if ($forceFactorySettings || !`optionVar -exists convertSolidTxUvRange`) { optionVar -intValue convertSolidTxUvRange 0; } if ($forceFactorySettings || !`optionVar -exists convertSolidTxUMin`) { optionVar -floatValue convertSolidTxUMin 0.0; } if ($forceFactorySettings || !`optionVar -exists convertSolidTxVMin`) { optionVar -floatValue convertSolidTxVMin 0.0; } if ($forceFactorySettings || !`optionVar -exists convertSolidTxUMax`) { optionVar -floatValue convertSolidTxUMax 1.0; } if ($forceFactorySettings || !`optionVar -exists convertSolidTxVMax`) { optionVar -floatValue convertSolidTxVMax 1.0; } // ResolutionX. // if ($forceFactorySettings || !`optionVar -exists convertSolidTxResX`) { optionVar -intValue convertSolidTxResX 256; } // ResolutionY. // if ($forceFactorySettings || !`optionVar -exists convertSolidTxResY`) { optionVar -intValue convertSolidTxResY 256; } // File Format. if ($forceFactorySettings || !`optionVar -exists convertSolidTxFileFormat`) { optionVar -stringValue convertSolidTxFileFormat "iff"; } } // // Procedure Name: // performConvertSolidBackModeCB // // Description: // Toggles the dimming of controls when background mode is changed // // Return Value: // None. // global proc performConvertSolidBackModeCB() { int $isBackColor = `optionMenuGrp -q -sl convertSolidBckMode`; disable -v ($isBackColor != 2) convertSolidBckColor; } // // Procedure Name: // performConvertSolidTxBakeLtCB // // Description: // Toggles the dimming of controls when bake lighting is changed. // // Return Value: // None. // global proc performConvertSolidTxBakeLtCB() { int $isBakeLighting = `checkBoxGrp -query -value1 convertSolidTxBakeLt`; checkBoxGrp -edit -enable $isBakeLighting convertSolidTxBakeShadow; // Turn the Bake Shadow box off if the Bake Lighting box is off if (! $isBakeLighting) { checkBoxGrp -edit -value1 off convertSolidTxBakeShadow; } } // // Procedure Name: // performConvertSolidTxUvRangeCB // // Description: // Toggles the dimming of the UV Range Controls // // Return Value: // None. // global proc performConvertSolidTxUvRangeCB() { int $setRange = `radioButtonGrp -q -select setRangeRadio`; floatSliderGrp -edit -enable ($setRange == 1) convertSolidTxUMin; floatSliderGrp -edit -enable ($setRange == 1) convertSolidTxVMin; floatSliderGrp -edit -enable ($setRange == 1) convertSolidTxUMax; floatSliderGrp -edit -enable ($setRange == 1) convertSolidTxVMax; } // // Procedure Name: // convertSolidTxSetup // // 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 convertSolidTxSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Query the optionVar's and set the values into the controls. // AntiAlias. // checkBoxGrp -edit -value1 `optionVar -query convertSolidTxAntiA` convertSolidTxAntiA; // Background Mode optionMenuGrp -e -sl `optionVar -q convertSolidBckMode` convertSolidBckMode; // Background Color float $a[] = `optionVar -q convertSolidBckColor`; colorSliderGrp -e -rgb $a[0] $a[1] $a[2] convertSolidBckColor; // FillTextureSeams. // checkBoxGrp -edit -value1 `optionVar -query convertSolidTxFillTextureSeams` convertSolidTxFillTextureSeams; // BakeLighting. // checkBoxGrp -edit -value1 `optionVar -query convertSolidTxBakeLt` convertSolidTxBakeLt; // SamplePlane. // checkBoxGrp -edit -value1 `optionVar -query convertSolidTxSamplePlane` convertSolidTxSamplePlane; // BakeShadow. // checkBoxGrp -edit -value1 `optionVar -query convertSolidTxBakeShadow` -enable `checkBoxGrp -query -value1 convertSolidTxBakeLt` convertSolidTxBakeShadow; // bakeAlpha checkBoxGrp -edit -value1 `optionVar -query convertSolidTxBakeAlpha` convertSolidTxBakeAlpha; // doubleSided checkBoxGrp -edit -value1 `optionVar -query convertSolidTxDoubleSided` convertSolidTxDoubleSided; // component range //checkBoxGrp -edit // -value1 `optionVar -query convertSolidTxCompRange` // convertSolidTxCompRange; int $rangeOption = `optionVar -query convertSolidTxUvRange`; if ($rangeOption == 0) { radioButtonGrp -e -select 1 unitRangeRadio; } else if ($rangeOption == 1) { radioButtonGrp -e -select 1 fullRangeRadio; } else if ($rangeOption == 2) { radioButtonGrp -e -select 1 setRangeRadio; } // uv range floatSliderGrp -edit -value `optionVar -query convertSolidTxUMin` -enable ($rangeOption == 2) convertSolidTxUMin; floatSliderGrp -edit -value `optionVar -query convertSolidTxVMin` -enable ($rangeOption == 2) convertSolidTxVMin; floatSliderGrp -edit -value `optionVar -query convertSolidTxUMax` -enable ($rangeOption == 2) convertSolidTxUMax; floatSliderGrp -edit -value `optionVar -query convertSolidTxVMax` -enable ($rangeOption == 2) convertSolidTxVMax; // ResolutionX. // intSliderGrp -edit -value `optionVar -query convertSolidTxResX` convertSolidTxResX; // ResolutionY. // intSliderGrp -edit -value `optionVar -query convertSolidTxResY` convertSolidTxResY; // File Format. string $format = `optionVar -query convertSolidTxFileFormat`; // The file format options have changed; if the user's option is // not in the menu, we default to IFF (BUG 163640). imageFormatsMenuSelectImfKey("convertSolidTxFileFormat", $format); performConvertSolidBackModeCB; } // // Procedure Name: // convertSolidTxCallback // // 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 convertSolidTxCallback( string $parent, int $doIt) { setParent $parent; // Set the optionVar's from the control values, and then // perform the command. // AntiAlias // optionVar -intValue convertSolidTxAntiA `checkBoxGrp -query -value1 convertSolidTxAntiA`; // Background Mode optionVar -intValue convertSolidBckMode `optionMenuGrp -q -sl convertSolidBckMode`; // Background Color float $a[] = `colorSliderGrp -q -rgb convertSolidBckColor`; optionVar -fv convertSolidBckColor $a[0] -fva convertSolidBckColor $a[1] -fva convertSolidBckColor $a[2]; // Fill Texture Seams optionVar -intValue convertSolidTxFillTextureSeams `checkBoxGrp -query -value1 convertSolidTxFillTextureSeams`; // BakeLight // optionVar -intValue convertSolidTxBakeLt `checkBoxGrp -query -value1 convertSolidTxBakeLt`; // SamplePlane // optionVar -intValue convertSolidTxSamplePlane `checkBoxGrp -query -value1 convertSolidTxSamplePlane`; // BakeShadow // optionVar -intValue convertSolidTxBakeShadow `checkBoxGrp -query -value1 convertSolidTxBakeShadow`; // bakeAlpha optionVar -intValue convertSolidTxBakeAlpha `checkBoxGrp -query -value1 convertSolidTxBakeAlpha`; // doubleSided optionVar -intValue convertSolidTxDoubleSided `checkBoxGrp -query -value1 convertSolidTxDoubleSided`; // component range //optionVar -intValue convertSolidTxCompRange // `checkBoxGrp -query -value1 convertSolidTxCompRange`; if (`radioButtonGrp -q -select unitRangeRadio`) { optionVar -intValue convertSolidTxUvRange 0; } else if (`radioButtonGrp -q -select fullRangeRadio`) { optionVar -intValue convertSolidTxUvRange 1; } else if (`radioButtonGrp -q -select setRangeRadio`) { optionVar -intValue convertSolidTxUvRange 2; } // uv range optionVar -floatValue convertSolidTxUMin `floatSliderGrp -query -value convertSolidTxUMin`; optionVar -floatValue convertSolidTxVMin `floatSliderGrp -query -value convertSolidTxVMin`; optionVar -floatValue convertSolidTxUMax `floatSliderGrp -query -value convertSolidTxUMax`; optionVar -floatValue convertSolidTxVMax `floatSliderGrp -query -value convertSolidTxVMax`; // ResolutionX. // optionVar -intValue convertSolidTxResX `intSliderGrp -query -value convertSolidTxResX`; // ResolutionY. // optionVar -intValue convertSolidTxResY `intSliderGrp -query -value convertSolidTxResY`; // File Format. optionVar -stringValue convertSolidTxFileFormat `imageFormatsMenuImfKey("convertSolidTxFileFormat")`; if ($doIt) { performConvertSolidTx 0; string $tmpCmd = "performConvertSolidTx 0 "; addToRecentCommandQueue $tmpCmd "Convert to File Texture"; } } // // Procedure Name: // convertSolidTxOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc convertSolidTxOptions() { // Name of the command for this option box. // string $commandName = "convertSolidTx"; // 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; // RECOMMENDATION: Place the UI in a 'scrollable' layout. A // scrollable layout ensures that if the option box window is ever // resized such that it's entire contents is not visible then the // scroll bars provided by the scrollable layout will allow the user // to access the hidden UI. Two layouts currently supporting // scrollable behaviour are the 'scrollLayout' and the 'tabLayout'. // // scrollLayout; // // or... // tabLayout -tabsVisible 0 -scrollable 1; string $parent = `columnLayout -adjustableColumn 1`; // RECOMMENDATION: Use the 'Grp' commands where possible because // they obey the formatting specified in the default template. // This will result in a more consistent look throughout the // application. // separator -height 10 -style "none"; checkBoxGrp -label "" -label1 (uiRes("m_performConvertSolidTx.kAntialias")) -numberOfCheckBoxes 1 -value1 off convertSolidTxAntiA; optionMenuGrp -label (uiRes("m_performConvertSolidTx.kBackgroundMode")) -cc "performConvertSolidBackModeCB" convertSolidBckMode; menuItem -label (uiRes("m_performConvertSolidTx.kShaderDefault")) ; menuItem -label (uiRes("m_performConvertSolidTx.kCustomColor")) ; menuItem -label (uiRes("m_performConvertSolidTx.kExtendEdgeColor")) ; colorSliderGrp -label (uiRes("m_performConvertSolidTx.kBackgroundColor")) -rgb 0 0 0 convertSolidBckColor; separator -height 15; checkBoxGrp -label "" -label1 (uiRes("m_performConvertSolidTx.kFillTextureSeams")) -numberOfCheckBoxes 1 -value1 on convertSolidTxFillTextureSeams; checkBoxGrp -label "" -label1 (uiRes("m_performConvertSolidTx.kBakeShadingGroupLighting")) -numberOfCheckBoxes 1 -value1 off -changeCommand "performConvertSolidTxBakeLtCB" convertSolidTxBakeLt; checkBoxGrp -label "" -label1 (uiRes("m_performConvertSolidTx.kBakeUsingVirtualPlane")) -numberOfCheckBoxes 1 -value1 off convertSolidTxSamplePlane; checkBoxGrp -label "" -label1 (uiRes("m_performConvertSolidTx.kBakeShadows")) -numberOfCheckBoxes 1 -value1 off -enable `checkBoxGrp -query -value1 convertSolidTxBakeLt` convertSolidTxBakeShadow; checkBoxGrp -label "" -label1 (uiRes("m_performConvertSolidTx.kBakeTransparency")) -numberOfCheckBoxes 1 -value1 off convertSolidTxBakeAlpha; checkBoxGrp -label "" -label1 (uiRes("m_performConvertSolidTx.kDoubleSided")) -annotation (uiRes("m_performConvertSolidTx.kUsedToLightBothSidesAnnot")) -numberOfCheckBoxes 1 -value1 off convertSolidTxDoubleSided; separator -height 15; radioButtonGrp -numberOfRadioButtons 1 -label (uiRes("m_performConvertSolidTx.kUVRange")) -label1 (uiRes("m_performConvertSolidTx.kDefault")) -changeCommand "performConvertSolidTxUvRangeCB" -annotation (uiRes("m_performConvertSolidTx.kDefaultAnnot")) unitRangeRadio; radioButtonGrp -numberOfRadioButtons 1 -label "" -label1 (uiRes("m_performConvertSolidTx.kEntireRange")) -changeCommand "performConvertSolidTxUvRangeCB" -annotation (uiRes("m_performConvertSolidTx.kEntireRangeAnnot")) -shareCollection unitRangeRadio fullRangeRadio; radioButtonGrp -numberOfRadioButtons 1 -label "" -label1 (uiRes("m_performConvertSolidTx.kUserSpecified")) -changeCommand "performConvertSolidTxUvRangeCB" -shareCollection unitRangeRadio setRangeRadio; separator -style "none" -height 5; floatSliderGrp -field on -label (uiRes("m_performConvertSolidTx.kUMin")) -minValue -10000.0 -maxValue 10000.0 -value 0.0 convertSolidTxUMin; floatSliderGrp -field on -label (uiRes("m_performConvertSolidTx.kVMin")) -value 0.0 -minValue -10000.0 -maxValue 10000.0 convertSolidTxVMin; floatSliderGrp -field on -label (uiRes("m_performConvertSolidTx.kUMax")) -minValue -10000.0 -maxValue 10000.0 -value 1.0 convertSolidTxUMax; floatSliderGrp -field on -label (uiRes("m_performConvertSolidTx.kVMax")) -value 1.0 -minValue -10000.0 -maxValue 10000.0 convertSolidTxVMax; separator -height 15; intSliderGrp -field on -label (uiRes("m_performConvertSolidTx.kXResolution")) -minValue 1 -maxValue 512 -fieldMinValue 1 -fieldMaxValue 4096 -value 256 convertSolidTxResX; intSliderGrp -field on -label (uiRes("m_performConvertSolidTx.kYResolution")) -minValue 1 -maxValue 512 -fieldMinValue 1 -fieldMaxValue 4096 -value 256 convertSolidTxResY; optionMenuGrp -label (uiRes("m_performConvertSolidTx.kFileFormat")) convertSolidTxFileFormat; buildImageFormatsMenu(0, 0, 0, 0, 0); // 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_performConvertSolidTx.kConvert")) -command ( $callback + " " + $parent + " " + 1 + " " ) $applyBtn; string $applyAndCloseBtn = getOptionBoxApplyAndCloseBtn(); button -edit -label (uiRes("m_performConvertSolidTx.kConvertandClose")) $applyAndCloseBtn; // '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_performConvertSolidTx.kConvertFileTextureOptions")); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "ConvertFileText" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // convertSolidTxHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string convertSolidTxHelp() { // ******** Example // " Command: Extrude - create a surface using extrusion.\n" + // "Selection: curves and isoparms." return " Command: convertSolidTx - convert a texture to a file texture.\n" + "Selection: surface or texture.\n" + "Highlight: surface or texture."; } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // proc string assembleCmd() { string $cmd = "copyConvertSolidTx"; setOptionVars(false); float $color[] = `optionVar -query convertSolidBckColor`; $cmd = ($cmd + " " + `optionVar -query convertSolidTxAntiA` + " " + `optionVar -query convertSolidBckMode` + " " + ($color[0]*255) + " " + ($color[1]*255) + " " + ($color[2]*255) + " " + `optionVar -query convertSolidTxFillTextureSeams` + " " + `optionVar -query convertSolidTxBakeLt` + " " + `optionVar -query convertSolidTxSamplePlane` + " " + `optionVar -query convertSolidTxBakeShadow` + " " + `optionVar -query convertSolidTxBakeAlpha` + " " + `optionVar -query convertSolidTxDoubleSided` + " " + `optionVar -query convertSolidTxCompRange` + " " + `optionVar -query convertSolidTxUvRange` + " " + `optionVar -query convertSolidTxUMin` + " " + `optionVar -query convertSolidTxVMin` + " " + `optionVar -query convertSolidTxUMax` + " " + `optionVar -query convertSolidTxVMax` + " " + `optionVar -query convertSolidTxResX` + " " + `optionVar -query convertSolidTxResY` + " \"\"" + " " + `optionVar -query convertSolidTxFileFormat` ); return $cmd; } // // Procedure Name: // performConvertSolidTx // // Description: // Perform the convertSolidTx command using the corresponding // option values. This procedure will also show the option box // window if necessary as well as construct the command string // that will invoke the optionBoxExample1 command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // global proc string performConvertSolidTx( 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: convertSolidTxOptions; break; // Return the command string. // case 2: // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }