// =========================================================================== // 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: 2003 // // Description: // Option box for createHair menu. // // Procedure Name: // setOptionVars // // Description: // Initialize the option values. // // Input Arguments: // Whether to set the options to default values. // // proc setOptionVars(int $forceFactorySettings) { if($forceFactorySettings || !`optionVar -exists createHairUCount`) { optionVar -intValue createHairUCount 8; } if($forceFactorySettings || !`optionVar -exists createHairVCount`) { optionVar -intValue createHairVCount 8; } if($forceFactorySettings || !`optionVar -exists createHairPointsPerHair`) { optionVar -intValue createHairPointsPerHair 10; } if($forceFactorySettings || !`optionVar -exists createHairCreateRestCurves`) { optionVar -intValue createHairCreateRestCurves 0; } if($forceFactorySettings || !`optionVar -exists createHairEdgeBounded`) { optionVar -intValue createHairEdgeBounded 0; } if($forceFactorySettings || !`optionVar -exists createHairEqualize`) { optionVar -intValue createHairCreateEqualize 1; } if($forceFactorySettings || !`optionVar -exists createHairPassiveFill`) { optionVar -intValue createHairPassiveFill 0; } if($forceFactorySettings || !`optionVar -exists createHairSimulationType`) { optionVar -intValue createHairSimulationType 1; } if($forceFactorySettings || !`optionVar -exists createHairGridPoints`) { optionVar -intValue createHairGridPoints 1; } if($forceFactorySettings || !`optionVar -exists createHairLength`) { optionVar -floatValue createHairLength 5.0; } if($forceFactorySettings || !`optionVar -exists createHairRandomization`) { optionVar -floatValue createHairRandomization 0.0; } if($forceFactorySettings || !`optionVar -exists createHairHairsPerClump`) { optionVar -intValue createHairHairsPerClump 10; } // This optionVar is shared with the paint hair tool if($forceFactorySettings || !`optionVar -exists createHairOutput`) { optionVar -intValue createHairOutput 1; } if($forceFactorySettings || !`optionVar -exists createHairCollideWithMesh`) { optionVar -intValue createHairCollideWithMesh 0; } } // // Procedure Name: // performCreateHairSetup // // 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 performCreateHairSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; intSliderGrp -edit -v `optionVar -query createHairUCount` createHairUCount; intSliderGrp -edit -v `optionVar -query createHairVCount` createHairVCount; intSliderGrp -edit -v `optionVar -query createHairPointsPerHair` createHairPointsPerHair; checkBoxGrp -edit -value1 `optionVar -q createHairCreateRestCurves` createHairCreateRestCurves; checkBoxGrp -edit -value1 `optionVar -q createHairEdgeBounded` createHairEdgeBounded; checkBoxGrp -edit -value1 `optionVar -q createHairEqualize` createHairEqualize; intSliderGrp -edit -v `optionVar -query createHairPassiveFill` createHairPassiveFill; radioButtonGrp -edit -sl `optionVar -query createHairSimulationType` createHairSimulationType; radioButtonGrp -edit -sl `optionVar -query createHairGridPoints` createHairGridPoints ; floatSliderGrp -edit -v `optionVar -query createHairLength` createHairLength; floatSliderGrp -edit -v `optionVar -query createHairRandomization` createHairRandomization; intSliderGrp -edit -v `optionVar -query createHairHairsPerClump` createHairHairsPerClump; optionMenuGrp -edit -sl `optionVar -query createHairOutput` createHairOutput; checkBoxGrp -edit -value1 `optionVar -q createHairCollideWithMesh` createHairCollideWithMesh; createHairOptionsDimControl; } // // Procedure Name: // performCreateHairCallback // // 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 performCreateHairCallback(string $parent, int $doIt) { setParent $parent; optionVar -intValue createHairUCount `intSliderGrp -query -v createHairUCount`; optionVar -intValue createHairVCount `intSliderGrp -query -v createHairVCount`; optionVar -intValue createHairPointsPerHair `intSliderGrp -query -v createHairPointsPerHair`; optionVar -intValue createHairCreateRestCurves `checkBoxGrp -query -value1 createHairCreateRestCurves`; optionVar -intValue createHairEdgeBounded `checkBoxGrp -query -value1 createHairEdgeBounded`; optionVar -intValue createHairEqualize `checkBoxGrp -query -value1 createHairEqualize`; optionVar -intValue createHairGridPoints `radioButtonGrp -query -sl createHairGridPoints`; optionVar -intValue createHairSimulationType `radioButtonGrp -query -sl createHairSimulationType`; optionVar -intValue createHairPassiveFill `intSliderGrp -query -v createHairPassiveFill`; optionVar -floatValue createHairLength `floatSliderGrp -query -v createHairLength`; optionVar -floatValue createHairRandomization `floatSliderGrp -query -v createHairRandomization`; optionVar -intValue createHairHairsPerClump `intSliderGrp -query -v createHairHairsPerClump`; optionVar -intValue createHairOutput `optionMenuGrp -query -sl createHairOutput`; optionVar -intValue createHairCollideWithMesh `checkBoxGrp -query -value1 createHairCollideWithMesh`; if( $doIt ) { performCreateHair 0; } createHairOptionsDimControl; } // // Procedure Name: // createHairOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc createHairOptions() { // Name of the command for this option box. // string $commandName = "performCreateHair"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); string $layout = getOptionBox(); setParent $layout; setUITemplate -pushTemplate DefaultTemplate; tabLayout -tv false -scr true; string $parent = `columnLayout -adjustableColumn 1`; optionMenuGrp -label (uiRes("m_performCreateHair.kOutput")) -cw 2 243 createHairOutput; menuItem -label (uiRes("m_performCreateHair.kPaintEffects")); menuItem -label (uiRes("m_performCreateHair.kNURBSCurves")); menuItem -label (uiRes("m_performCreateHair.kPaintAndNURBS")); optionMenuGrp -edit -cc "createHairOutputDimControl" createHairOutput; checkBoxGrp -ncb 1 -label1 (uiRes("m_performCreateHair.kCreateRestCurves")) createHairCreateRestCurves; checkBoxGrp -ncb 1 -label1 (uiRes("m_performCreateHair.kCollideWithMesh")) createHairCollideWithMesh; string $grid = (uiRes("m_performCreateHair.kGrid")); string $selectedPointsFaces = (uiRes("m_performCreateHair.kSelectedPointsFaces")); radioButtonGrp -numberOfRadioButtons 2 -cw3 170 90 200 -labelArray2 $grid $selectedPointsFaces -cc "createHairOptionsDimControl" createHairGridPoints; separator; intSliderGrp -label (uiRes("m_performCreateHair.kUCount")) -field 1 -min 1 -max 100 -fieldMinValue 0 -fieldMaxValue 100000 createHairUCount; intSliderGrp -label (uiRes("m_performCreateHair.kVCount")) -field 1 -min 1 -max 100 -fieldMinValue 0 -fieldMaxValue 100000 createHairVCount; intSliderGrp -label (uiRes("m_performCreateHair.kPassiveFill")) -field 1 -min 0 -max 20 -fieldMinValue 0 -fieldMaxValue 100000 createHairPassiveFill; floatSliderGrp -label (uiRes("m_performCreateHair.kRandomization")) -min 0.0 -max 1.0 -fieldMinValue 0.0 -fieldMaxValue 2.0 createHairRandomization; intSliderGrp -label (uiRes("m_performCreateHair.kHairsPerClump")) -min 1 -max 50 -fieldMinValue 0 -fieldMaxValue 2000 createHairHairsPerClump; checkBoxGrp -ncb 1 -label1 (uiRes("m_performCreateHair.kEdgeBounded")) createHairEdgeBounded; checkBoxGrp -ncb 1 -label1 (uiRes("m_performCreateHair.kEqualize")) createHairEqualize; separator; string $dynamic = (uiRes("m_performCreateHair.kDynamic")); string $static = (uiRes("m_performCreateHair.kStatic")); radioButtonGrp -numberOfRadioButtons 2 -cw3 170 90 200 -labelArray2 $dynamic $static -cc simulationTypeDimControl createHairSimulationType; intSliderGrp -label (uiRes("m_performCreateHair.kPointsPerHair")) -field 1 -min 2 -max 100 -fieldMinValue 2 -fieldMaxValue 100000 createHairPointsPerHair; floatSliderGrp -label (uiRes("m_performCreateHair.kLength")) -min 0.0 -max 20.0 -fieldMinValue 0.0 -fieldMaxValue 100000.0 createHairLength; optionMenuGrp -label (uiRes("m_performCreateHair.kPlaceHairsInto")) hsPlaceMenu; menuItem -label (uiRes("m_performCreateHair.kNewHairSystem")); // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performCreateHair.kCreateHairs")) -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_performCreateHair.kCreateHairOptions")); setOptionBoxCommandName($commandName); setOptionBoxHelpTag( "CreateHair" ); // Pop the UI template // setUITemplate -popTemplate; // Set the current values of the option box. // eval( $setup + " " + $parent + " " + 0 ); updateHSPlaceMenu( true ); scriptJob -p hsPlaceMenu -e "SelectionChanged" ("updateHSPlaceMenu false"); // Show the option box. // showOptionBox(); } // // Procedure Name: // createHairOutputDimControl // // Description: // Disable/enable createHair option box controls depending on if paint effects or curve output global proc createHairOutputDimControl( ) { int $hairOutput = `optionMenuGrp -query -sl createHairOutput`; intSliderGrp -edit -enable ($hairOutput != 2) createHairHairsPerClump; } // // Procedure Name: // createHairOptionsDimControl // // Description: // Disable/enable createHair option box controls depending on // (i) Simulation type (Static/Dynamic) // (ii)Hair creation type (Grid/At Selected point) // // Input Arguments: // None. // // Return Value: // None. // global proc createHairOptionsDimControl( ) { if(`radioButtonGrp -q -sl createHairGridPoints`== 2) { intSliderGrp -edit -enable false createHairUCount; intSliderGrp -edit -enable false createHairVCount; intSliderGrp -edit -enable false createHairPassiveFill; floatSliderGrp -edit -enable false createHairRandomization; checkBoxGrp -edit -enable false createHairEdgeBounded; checkBoxGrp -edit -enable false createHairEqualize; } else { intSliderGrp -edit -enable true createHairUCount; intSliderGrp -edit -enable true createHairVCount; intSliderGrp -edit -enable true createHairPassiveFill; floatSliderGrp -edit -enable true createHairRandomization; checkBoxGrp -edit -enable true createHairEdgeBounded; checkBoxGrp -edit -enable true createHairEqualize; } simulationTypeDimControl(); } // // Procedure Name: // simulationTypeDimControl // // Description: // Disable/enable passive fill menu depending on simulation type (Static/Dynamic) // // Input Arguments: // None. // // Return Value: // None. // global proc simulationTypeDimControl() { if(`radioButtonGrp -q -sl createHairGridPoints`== 2) { intSliderGrp -edit -enable false createHairPassiveFill; } else if(`radioButtonGrp -q -sl createHairSimulationType`== 2) { intSliderGrp -edit -value 0 createHairPassiveFill; intSliderGrp -edit -enable false createHairPassiveFill; } else { intSliderGrp -edit -enable true createHairPassiveFill; } } // // Procedure Name: // updateHSPlaceMenu // // Description: // Update `hsPlace` menu depending on the selection list // // Input Arguments: // None. // // Return Value: // None. // global proc updateHSPlaceMenu( int $check) { // Add any existing hair system to the place into menu // int $placeItems = `optionMenuGrp -q -ni hsPlaceMenu`; int $selectIndex = `optionMenuGrp -q -sl hsPlaceMenu`; string $placeMenuItemName="placeMenuItem"; string $placeItemSelected; int $i; string $hairSystems[] = `ls -sl -dag -ni -type hairSystem`; string $hsys; if( size( $hairSystems ) > 0 ){ $hsys = $hairSystems[0]; } if($hsys != "") $placeItemSelected = $hsys; else $placeItemSelected = `optionMenuGrp -q -v hsPlaceMenu`; // Get rid of any that are there for ( $i = 1; $i < $placeItems; $i++ ) { deleteUI ($placeMenuItemName+$i); } // Add all existing hair system $selectIndex = 1; $hairSystems = `ls -dag -ni -type hairSystem`; if ( size( $hairSystems ) > 0 ) { string $savedParent = `setParent -q`; string $fullName = `setParent hsPlaceMenu`; setParent -menu ($fullName + "|OptionMenu"); $i = 1; for ( $hs in $hairSystems ) { if ( $hs == $placeItemSelected ) { $selectIndex = $i + 1; } menuItem -l $hs ($placeMenuItemName+$i); $i++; } setParent $savedParent; if ( $selectIndex == 1 && $i == 2 && $check) { $selectIndex = 2; } // The following if-else is a workaround for a refresh problem // that occurred with the option menu // if ( $selectIndex > 1 ) { optionMenuGrp -e -sl ($selectIndex - 1) hsPlaceMenu; } else { optionMenuGrp -e -sl ($selectIndex + 1) hsPlaceMenu; } optionMenuGrp -e -sl $selectIndex hsPlaceMenu; } } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // // Return Value: // None. // proc string assembleCmd() { setOptionVars(false); string $cmd = ("doCreateHair " + `optionVar -query createHairUCount` + " " + `optionVar -query createHairVCount` + " " + `optionVar -query createHairPointsPerHair` + " " + `optionVar -query createHairCreateRestCurves` + " " + `optionVar -query createHairPassiveFill` + " " + `optionVar -query createHairEdgeBounded` + " " + `optionVar -query createHairEqualize` + " " + `optionVar -query createHairLength` + " " + `optionVar -query createHairRandomization` + " " + `optionVar -query createHairOutput` + " " + `optionVar -query createHairSimulationType` + " " + `optionVar -query createHairGridPoints` ); return $cmd; } // // Procedure Name: // performCreateHair // // Description: // Perform the 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 command 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 performCreateHair(int $action) { string $cmd = ""; switch ($action) { // Execute the command from option settings. // case 0: setOptionVars(false); $cmd = `assembleCmd`; evalNoSelectNotify($cmd); break; // Show the option box. // case 1: createHairOptions(); break; // Return the command string. // case 2: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }