// =========================================================================== // 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: 5 June, 1997 // // Description: // This script is a template script for option box dialogs. // // Input Arguments: // None. // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { if( $forceFactorySettings || !`optionVar -exists lambertRed` ) { optionVar -floatValue lambertRed 0.5; } if( $forceFactorySettings || !`optionVar -exists lambertGreen` ) { optionVar -floatValue lambertGreen 0.5; } if( $forceFactorySettings || !`optionVar -exists lambertBlue` ) { optionVar -floatValue lambertBlue 0.5; } if( $forceFactorySettings || !`optionVar -exists lambertTransRed` ) { optionVar -floatValue lambertTransRed 0.0; } if( $forceFactorySettings || !`optionVar -exists lambertTransGreen` ) { optionVar -floatValue lambertTransGreen 0.0; } if( $forceFactorySettings || !`optionVar -exists lambertTransBlue` ) { optionVar -floatValue lambertTransBlue 0.0; } if( $forceFactorySettings || !`optionVar -exists lambertAmbientRed` ) { optionVar -floatValue lambertAmbientRed 0.0; } if( $forceFactorySettings || !`optionVar -exists lambertAmbientGreen` ) { optionVar -floatValue lambertAmbientGreen 0.0; } if( $forceFactorySettings || !`optionVar -exists lambertAmbientBlue` ) { optionVar -floatValue lambertAmbientBlue 0.0; } if( $forceFactorySettings || !`optionVar -exists lambertIncandRed` ) { optionVar -floatValue lambertIncandRed 0.0; } if( $forceFactorySettings || !`optionVar -exists lambertIncandGreen` ) { optionVar -floatValue lambertIncandGreen 0.0; } if( $forceFactorySettings || !`optionVar -exists lambertIncandBlue` ) { optionVar -floatValue lambertIncandBlue 0.0; } } global proc createLambertSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars( $forceFactorySettings ); setParent $parent; // Query the optionVar's and set the values into the controls // float $red = `optionVar -query lambertRed`; float $green = `optionVar -query lambertGreen`; float $blue = `optionVar -query lambertBlue`; colorSliderGrp -e -rgb $red $green $blue lambertRGB; $red = `optionVar -query lambertTransRed`; $green = `optionVar -query lambertTransGreen`; $blue = `optionVar -query lambertTransBlue`; colorSliderGrp -e -rgb $red $green $blue lambertTransRGB; $red = `optionVar -query lambertAmbientRed`; $green = `optionVar -query lambertAmbientGreen`; $blue = `optionVar -query lambertAmbientBlue`; colorSliderGrp -e -rgb $red $green $blue lambertAmbientRGB; $red = `optionVar -query lambertIncandRed`; $green = `optionVar -query lambertIncandGreen`; $blue = `optionVar -query lambertIncandBlue`; colorSliderGrp -e -rgb $red $green $blue lambertIncandRGB; } global proc createLambertCallback (string $parent, int $doIt) // // Description: // Set the optionVar's from the control values, and then perform // the command // { setParent $parent; float $rgb[] = `colorSliderGrp -q -rgb lambertRGB`; optionVar -floatValue lambertRed $rgb[0]; optionVar -floatValue lambertGreen $rgb[1]; optionVar -floatValue lambertBlue $rgb[2]; $rgb = `colorSliderGrp -q -rgb lambertTransRGB`; optionVar -floatValue lambertTransRed $rgb[0]; optionVar -floatValue lambertTransGreen $rgb[1]; optionVar -floatValue lambertTransBlue $rgb[2]; $rgb = `colorSliderGrp -q -rgb lambertAmbientRGB`; optionVar -floatValue lambertAmbientRed $rgb[0]; optionVar -floatValue lambertAmbientGreen $rgb[1]; optionVar -floatValue lambertAmbientBlue $rgb[2]; $rgb = `colorSliderGrp -q -rgb lambertIncandRGB`; optionVar -floatValue lambertIncandRed $rgb[0]; optionVar -floatValue lambertIncandGreen $rgb[1]; optionVar -floatValue lambertIncandBlue $rgb[2]; if( $doIt ) { performCreateLambert 0; } } global proc enableCreateLambertOptions( ) // // No dynamic UI changing necessary - stubbed out { } global proc createLambertOptions () { // Name of the command for this option box // string $commandName = "createLambert"; // 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($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 -scr true -tv false; string $parent = `columnLayout -adjustableColumn 1`; // Create the widgets for this option box // separator -style "none" -h 5; colorSliderGrp -h 25 -label (uiRes("m_performCreateLambert.kColor")) -rgb 0.5 0.5 0.5 lambertRGB; colorSliderGrp -h 25 -label (uiRes("m_performCreateLambert.kTransparency")) -rgb 0 0 0 lambertTransRGB; colorSliderGrp -h 25 -label (uiRes("m_performCreateLambert.kAmbientColor")) -rgb 0 0 0 lambertAmbientRGB; colorSliderGrp -h 25 -label (uiRes("m_performCreateLambert.kIncandescence")) -rgb 0 0 0 lambertIncandRGB; // 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_performCreateLambert.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_performCreateLambert.kOptions"))); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); } proc string getCmd() { string $cmd; setOptionVars( false ); float $red = `optionVar -query lambertRed`; float $green = `optionVar -query lambertGreen`; float $blue = `optionVar -query lambertBlue`; float $transR = `optionVar -query lambertTransRed`; float $transG = `optionVar -query lambertTransGreen`; float $transB = `optionVar -query lambertTransBlue`; float $ambR = `optionVar -query lambertAmbientRed`; float $ambG = `optionVar -query lambertAmbientGreen`; float $ambB = `optionVar -query lambertAmbientBlue`; float $incandR = `optionVar -query lambertIncandRed`; float $incandG = `optionVar -query lambertIncandGreen`; float $incandB = `optionVar -query lambertIncandBlue`; $cmd = "{string $result;"; $cmd = $cmd + ( "$result = `shadingNode -asShader lambert`;" ); $cmd = $cmd + "string $SEName = `sets -renderable true -name ($result+\"Grp\") -empty`;"; $cmd = $cmd + "connectAttr -f ( $result + \".outColor\") ( $SEName + \".surfaceShader\" );"; // $cmd = ( "shadingNode -asShader lambert" ); // $result = eval( $cmd ); // string $SEName = `sets -renderable true -name ($result+"Group") -empty`; // connectAttr -f ( $result+".outColor" ) ( $SEName+".surfaceShader" ); // Set the attributes the from the optionVars set // in the optionBox // $cmd = $cmd + "setAttr ( $result+\".colorR\" ) " + $red + ";"; $cmd = $cmd + "setAttr ( $result+\".colorG\" ) " + $green + ";"; $cmd = $cmd + "setAttr ( $result+\".colorB\" ) " + $blue + ";"; $cmd = $cmd + "setAttr ( $result+\".transparencyR\" ) " + $transR + ";"; $cmd = $cmd + "setAttr ( $result+\".transparencyG\" ) " + $transG + ";"; $cmd = $cmd + "setAttr ( $result+\".transparencyB\" ) " + $transB + ";"; $cmd = $cmd + "setAttr ( $result+\".ambientColorR\" ) " + $ambR + ";"; $cmd = $cmd + "setAttr ( $result+\".ambientColorG\" ) " + $ambG + ";"; $cmd = $cmd + "setAttr ( $result+\".ambientColorB\" ) " + $ambB + ";"; $cmd = $cmd + "setAttr ( $result+\".incandescenceR\" ) " + $incandR + ";"; $cmd = $cmd + "setAttr ( $result+\".incandescenceG\" ) " + $incandG + ";"; $cmd = $cmd + "setAttr ( $result+\".incandescenceB\" ) " + $incandB + ";"; $cmd = $cmd + "}"; return $cmd; } global proc string performCreateLambert (int $showOptionBox) { string $cmd; if ($showOptionBox == 0) { $cmd = `getCmd`; eval($cmd); } else if( $showOptionBox == 1) { createLambertOptions; } else { $cmd = `getCmd`; } return $cmd; }