// =========================================================================== // 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. // =========================================================================== /////////////////////////////////////////////////////////////////////////////// // // Description: // This script provides an option box dialog for the // unfold command. // /////////////////////////////////////////////////////////////////////////////// proc int indexToMapSize(int $i) { int $val; switch ($i) { case 1: $val = 4096; break; case 2: $val = 2048; break; case 4: $val = 512; break; case 5: $val = 256; break; case 6: $val = 128; break; case 7: $val = 64; break; case 8: $val = 32; break; case 3: default: $val = 1024; break; } return $val; } // // // 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) { if ($forceFactorySettings || !`optionVar -exists UnfoldAlgorithm`) optionVar -intValue UnfoldAlgorithm 1; if ($forceFactorySettings || !`optionVar -exists Unfold3DIterations`) optionVar -intValue Unfold3DIterations 1; if ($forceFactorySettings || !`optionVar -exists Unfold3DPack`) optionVar -intValue Unfold3DPack 0; if ($forceFactorySettings || !`optionVar -exists Unfold3DLayout`) optionVar -intValue Unfold3DLayout 0; if ($forceFactorySettings || !`optionVar -exists Unfold3DBorderIntersect`) optionVar -intValue Unfold3DBorderIntersect 1; if ($forceFactorySettings || !`optionVar -exists Unfold3DTriFlip`) optionVar -intValue Unfold3DTriFlip 1; if ($forceFactorySettings || !`optionVar -exists Unfold3DMapSize`) optionVar -intValue Unfold3DMapSize 3; if ($forceFactorySettings || !`optionVar -exists Unfold3DRoomSpace`) optionVar -intValue Unfold3DRoomSpace 0; if ($forceFactorySettings || !`optionVar -exists Unfold3DFixNonManifoldBeforeUnfold`) optionVar -intValue Unfold3DFixNonManifoldBeforeUnfold 0; if ($forceFactorySettings || !`optionVar -exists Unfold3DAskToFixNonManifoldBeforeUnfold`) optionVar -intValue Unfold3DAskToFixNonManifoldBeforeUnfold 1; if ($forceFactorySettings || !`optionVar -exists unfoldIterations`) optionVar -intValue unfoldIterations 5000; if ($forceFactorySettings || !`optionVar -exists unfoldStopThreshold`) optionVar -floatValue unfoldStopThreshold .001; if ($forceFactorySettings || !`optionVar -exists unfoldRescale`) optionVar -intValue unfoldRescale 0; if ($forceFactorySettings || !`optionVar -exists unfoldScale`) optionVar -floatValue unfoldScale .02; if ($forceFactorySettings || !`optionVar -exists unfoldHistOn`) optionVar -intValue unfoldHistOn 0; if ($forceFactorySettings || !`optionVar -exists unfoldGlobalBlend`) optionVar -floatValue unfoldGlobalBlend 0.0; if ($forceFactorySettings || !`optionVar -exists unfoldGlobalMethodBlend`) optionVar -floatValue unfoldGlobalMethodBlend 0.5; if ($forceFactorySettings || !`optionVar -exists unfoldPinBorder`) optionVar -intValue unfoldPinBorder 0; if ($forceFactorySettings || !`optionVar -exists unfoldPinSelected`) optionVar -intValue unfoldPinSelected 0; if ($forceFactorySettings || !`optionVar -exists unfoldPinAxis`) optionVar -intValue unfoldPinAxis 1; if ($forceFactorySettings || !`optionVar -exists polyUnfoldUVs`) optionVar -intValue polyUnfoldUVs 1; } global proc unfoldAgorithmChange() { if (`radioButtonGrp -exists UnfoldAgorithm_RGB`) { int $alg = `radioButtonGrp -q -select UnfoldAgorithm_RGB`; tabLayout -e -selectTabIndex $alg unfoldAlgorithmTabs; } } // // Procedure Name: // unfoldSetup // // 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 unfoldSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings setOptionVars($forceFactorySettings); setParent $parent; int $alg = 1; int $u3DLoaded = `pluginInfo -q -loaded Unfold3D`; if ($u3DLoaded) { // Which algorithm to use. // 1: Unfold3D // 2: Legacy $alg = `optionVar -q UnfoldAlgorithm`; if ($alg < 1 || $alg > 2) $alg = 1; radioButtonGrp -e -select $alg UnfoldAgorithm_RGB; tabLayout -e -selectTabIndex $alg unfoldAlgorithmTabs; } else { $alg = 2; } // Unfolding algorithm options. // float $overall = `optionVar -q unfoldGlobalBlend`; int $quadEnable = 1; if ( $overall == 0.0 ) { $quadEnable = 0; } floatField -e -v $overall unfoldGlobalBlend; floatField -e -en $quadEnable -v `optionVar -q unfoldGlobalMethodBlend` unfoldGlobalMethodBlend; // Pinning support. // int $ival = `optionVar -q polyUnfoldUVs`; int $val; if($ival == 1) { checkBoxGrp -edit -value1 $ival polyUnfoldUVs; radioButtonGrp -edit -enable 1 polyUnfoldUVsOptions; $val = `optionVar -q unfoldPinSelected`; if($val == 1) radioButtonGrp -e -sl 1 polyUnfoldUVsOptions; else radioButtonGrp -e -sl 2 polyUnfoldUVsOptions; } $val = `optionVar -q unfoldPinAxis`; radioButtonGrp -e -sl $val unfoldPinAxis; $val = `optionVar -q unfoldPinBorder`; checkBoxGrp -e -v1 $val unfoldPinBorder; // # of iteratios and stopping threshold. // intSliderGrp -e -v `optionVar -q unfoldIterations` unfoldIterations; floatSliderGrp -e -v `optionVar -q unfoldStopThreshold` unfoldStopThreshold; // History & rescaling // $val = `optionVar -q unfoldRescale`; checkBoxGrp -e -v1 $val unfoldRescale; floatSliderGrp -e -en $val -v `optionVar -q unfoldScale` unfoldScale; checkBoxGrp -e -v1 `optionVar -q unfoldHistOn` unfoldHistOn; if ($u3DLoaded) { $iVal = `optionVar -q Unfold3DFixNonManifoldBeforeUnfold`; checkBoxGrp -edit -value1 (0 != $iVal) FixNonManifold_CBG; $iVal = `optionVar -q Unfold3DIterations`; intSliderGrp -edit -value $iVal Iterations_ISG; $iVal = `optionVar -q Unfold3DPack`; checkBoxGrp -edit -value1 (0 != $iVal) Pack_CBG; $iVal = `optionVar -q Unfold3DLayout`; checkBoxGrp -edit -value1 (0 != $iVal) Layout_CBG; $iVal = `optionVar -q Unfold3DBorderIntersect`; checkBoxGrp -edit -value1 (0 != $iVal) BorderIntersect_CBG; $iVal = `optionVar -q Unfold3DTriFlip`; checkBoxGrp -edit -value1 (0 != $iVal) TriFlip_CBG; $iVal = `optionVar -q Unfold3DMapSize`; optionMenuGrp -edit -select $iVal MapSize_OMG; $iVal = `optionVar -q Unfold3DRoomSpace`; intSliderGrp -edit -value $iVal RoomSpace_ISG; } } // // Procedure Name: // unfoldCallback // // 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 unfoldCallback(string $parent, int $doIt) { setParent $parent; // Set the optionVar's from the control values, and then // perform the command. int $alg = 1; int $u3DLoaded = `pluginInfo -q -loaded Unfold3D`; if ($u3DLoaded) { $alg = `radioButtonGrp -q -select UnfoldAgorithm_RGB`; optionVar -iv UnfoldAlgorithm $alg; } optionVar -iv unfoldIterations `intSliderGrp -q -v unfoldIterations`; optionVar -fv unfoldStopThreshold `floatSliderGrp -q -v unfoldStopThreshold`; optionVar -iv unfoldRescale `checkBoxGrp -q -v1 unfoldRescale`; optionVar -fv unfoldScale `floatSliderGrp -q -v unfoldScale`; optionVar -iv unfoldHistOn `checkBoxGrp -q -v1 unfoldHistOn`; optionVar -fv unfoldGlobalBlend `floatField -q -v unfoldGlobalBlend`; optionVar -fv unfoldGlobalMethodBlend `floatField -q -v unfoldGlobalMethodBlend`; int $ival = `checkBoxGrp -query -value1 polyUnfoldUVs`; if($ival == 1) { int $ival2 = `radioButtonGrp -q -sl polyUnfoldUVsOptions`; if($ival2 == 1) optionVar -iv unfoldPinSelected 1; else optionVar -iv unfoldPinSelected 0; } else optionVar -iv unfoldPinSelected 0; $ival = `radioButtonGrp -q -sl unfoldPinAxis`; optionVar -iv unfoldPinAxis $ival; optionVar -iv unfoldPinBorder `checkBoxGrp -q -v1 unfoldPinBorder`; if ($u3DLoaded) { $iVal = `checkBoxGrp -q -value1 FixNonManifold_CBG`; optionVar -intValue Unfold3DFixNonManifoldBeforeUnfold $iVal; $iVal = `intSliderGrp -q -value Iterations_ISG`; optionVar -intValue Unfold3DIterations $iVal; $iVal = `checkBoxGrp -q -value1 Pack_CBG`; optionVar -intValue Unfold3DPack $iVal; $iVal = `checkBoxGrp -q -value1 Layout_CBG`; optionVar -intValue Unfold3DLayout $iVal; $iVal = `checkBoxGrp -q -value1 BorderIntersect_CBG`; optionVar -intValue Unfold3DBorderIntersect $iVal; $iVal = `checkBoxGrp -q -value1 TriFlip_CBG`; optionVar -intValue Unfold3DTriFlip $iVal; $iVal = `optionMenuGrp -q -select MapSize_OMG`; optionVar -intValue Unfold3DMapSize $iVal; $iVal = `intSliderGrp -q -value RoomSpace_ISG`; optionVar -intValue Unfold3DRoomSpace $iVal; } if ($doIt) { performUnfold 0; addToRecentCommandQueue "performUnfold 0" "Unfold"; } } // // Procedure Name // unfoldOptimMethodChg // // Description: // This method is called when the user changes the overall global // consistency slider. We must disable the secondary slider, // which controls how much constribution edges and faces play // into the global consistency of the final uv layout. // global proc unfoldOverallChg( string $parent ) { string $oldParent = `setParent -q`; setParent $parent; float $overall = `floatField -q -v unfoldGlobalBlend`; int $quadEnable = 1; if ( $overall == 0.0 ) { $quadEnable = 0; } floatField -e -en $quadEnable unfoldGlobalMethodBlend; } // // Procedure Name: // unfoldOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // global proc updateSolverWeightValue(string $from) { float $val; if($from == "slider") { $val = `floatSlider -q -value unfoldGlobalBlendSlider`; floatField -e -v $val unfoldGlobalBlend; } else { $val = `floatField -q -v unfoldGlobalBlend`; floatSlider -e -value $val unfoldGlobalBlendSlider; } int $quadEnable = 1; if ( $val == 0.0 ) $quadEnable = 0; floatField -e -en $quadEnable unfoldGlobalMethodBlend; floatSlider -e -en $quadEnable unfoldGlobalMethodBlendSlider; text -e -en $quadEnable unfoldFaceArea; text -e -en $quadEnable unfoldEdgeLength; } global proc updateUnfoldMethod(string $from) { float $val; if($from == "slider") { $val = `floatSlider -q -value unfoldGlobalMethodBlendSlider`; floatField -e -v $val unfoldGlobalMethodBlend; } else { $val = `floatField -q -v unfoldGlobalMethodBlend`; floatSlider -e -value $val unfoldGlobalMethodBlendSlider; } } proc unfold3dUnfoldOptions() { string $topLevelParent = `setParent -q`; string $parent = `columnLayout`; string $settingsLabel = (uiRes("m_performUnfold.kSettingsFrame")); string $fixNonManifoldLabel = (uiRes("m_performUnfold.kFixNonManifold")); string $optsLabel = (uiRes("m_performUnfold.kUnfoldOptionsFrame")); string $iterLabel = (uiRes("m_performUnfold.kIterations")); string $packLabel = (uiRes("m_performUnfold.kPack")); string $layoutLabel = (uiRes("m_performUnfold.kLayout")); string $selfIntLabel = (uiRes("m_performUnfold.kPreventSI")); string $triFlipLabel = (uiRes("m_performUnfold.kPreventTF")); string $roomLabel = (uiRes("m_performUnfold.kRoomSpace")); string $mapSizeLabel = (uiRes("m_performUnfold.kMapSize")); string $roomSpaceLabel = (uiRes("m_performUnfold.kRoomSpaceSize")); // Setting frame string $settingsFrame = `frameLayout -label $settingsLabel`; columnLayout; checkBoxGrp -label "" -label1 $fixNonManifoldLabel -value1 false FixNonManifold_CBG; setParent ..; //columnLayout setParent $parent; // frameLayout // Solver settings frame string $optionsFrame = `frameLayout -label $optsLabel`; columnLayout; intSliderGrp -label $iterLabel -min 0 -max 10 -fieldMinValue 0 -fieldMaxValue 999 -value 1 Iterations_ISG; checkBoxGrp -label "" -label1 $packLabel -value1 false -visible false Pack_CBG; checkBoxGrp -label "" -label1 $layoutLabel -value1 false Layout_CBG; checkBoxGrp -label "" -label1 $selfIntLabel -value1 true BorderIntersect_CBG; checkBoxGrp -label "" -label1 $triFlipLabel -value1 true TriFlip_CBG; setParent ..; // columnLayout setParent $parent; // frameLayout // Room space settings string $roomFrame = `frameLayout -label $roomLabel`; columnLayout; optionMenuGrp -label $mapSizeLabel MapSize_OMG; menuItem -label "4096"; menuItem -label "2048"; menuItem -label "1024"; menuItem -label "512"; menuItem -label "256"; menuItem -label "128"; menuItem -label "64"; menuItem -label "32"; optionMenuGrp -edit -select 3 MapSize_OMG; intSliderGrp -label $roomSpaceLabel -field true -min 0 -max 10 -value 2 -fieldMinValue 0 -fieldMaxValue 999 RoomSpace_ISG; setParent ..; // columnLayout setParent $parent; // frameLayout setParent $topLevelParent; } proc legacyUnfoldOptions() { global int $gOptionBoxTemplateDescriptionMarginWidth; global int $gOptionBoxTemplateFrameSpacing; global int $gOptionBoxTemplateTextColumnWidth; global int $gOptionBoxTemplateSingleWidgetWidth; global int $gOptionBoxTemplateSliderWidgetWidth; global int $gOptionBoxTemplateOffsetText; string $topLevelParent = `setParent -q`; string $parent = `columnLayout`; // Solver settings frame string $solverSettingsFrame = `frameLayout -label (uiRes("m_performUnfold.kSolverSettingsFrame"))`; columnLayout; rowLayout -numberOfColumns 2 -columnAlign 1 "right" -columnAttach 1 "right" $gOptionBoxTemplateOffsetText -columnWidth2 $gOptionBoxTemplateTextColumnWidth $gOptionBoxTemplateSingleWidgetWidth; text -label (uiRes("m_performUnfold.kWeightSolverTowards")); floatField -min 0.0 -max 1.0 -cc ("updateSolverWeightValue " + "floatfield") unfoldGlobalBlend; setParent ..; // rowLayout rowLayout -numberOfColumns 3 -columnAttach 1 "right" $gOptionBoxTemplateOffsetText -columnAlign3 "right" "left" "left" -columnAttach3 "right" "both" "both" -columnWidth3 ($gOptionBoxTemplateTextColumnWidth + $gOptionBoxTemplateSingleWidgetWidth) $gOptionBoxTemplateSliderWidgetWidth $gOptionBoxTemplateSingleWidgetWidth; text -label (uiRes("m_performUnfold.kLocalSolver")); floatSlider -min 0.0 -max 1.0 -value 0.0 -cc ("updateSolverWeightValue " + "slider") unfoldGlobalBlendSlider; text -label (uiRes("m_performUnfold.kGlobalSolver")) -width 100; setParent ..; // rowLayout separator -style "none"; rowLayout -numberOfColumns 2 -columnAlign 1 "right" -columnAttach 1 "right" $gOptionBoxTemplateOffsetText -columnWidth2 $gOptionBoxTemplateTextColumnWidth $gOptionBoxTemplateSingleWidgetWidth; text -label (uiRes("m_performUnfold.kOptimizeToOriginal")); floatField -min 0.0 -max 1.0 -cc ("updateUnfoldMethod " + "floatfield") unfoldGlobalMethodBlend; setParent ..; // rowLayout rowLayout -numberOfColumns 3 -columnAttach 1 "right" $gOptionBoxTemplateOffsetText -columnAlign3 "right" "left" "left" -columnAttach3 "right" "both" "both" -columnWidth3 ($gOptionBoxTemplateTextColumnWidth + $gOptionBoxTemplateSingleWidgetWidth) $gOptionBoxTemplateSliderWidgetWidth $gOptionBoxTemplateSingleWidgetWidth; text -label (uiRes("m_performUnfold.kFaceArea")) unfoldFaceArea; floatSlider -min 0.0 -max 1.0 -value 0.0 -cc ("updateUnfoldMethod " + "slider") unfoldGlobalMethodBlendSlider; text -label (uiRes("m_performUnfold.kEdgeLength")) -width 75 unfoldEdgeLength; setParent ..; // rowLayout setParent ..; // columnLayout setParent $parent; // frameLayout // Pinning frame string $pinningFrame = `frameLayout -label (uiRes("m_performUnfold.kPinningFrame"))`; columnLayout; checkBoxGrp -label "" -label1 (uiRes("m_performUnfold.kPinUVBorder")) -ann (uiRes("m_performUnfold.kPinUVBorderAnnot")) unfoldPinBorder; separator -style "none"; checkBoxGrp -label1 (uiRes("m_performUnfold.kPinUVs")) -onc "radioButtonGrp -edit -en 1 polyUnfoldUVsOptions" -ofc "radioButtonGrp -edit -en 0 polyUnfoldUVsOptions" polyUnfoldUVs; radioButtonGrp -label " " -numberOfRadioButtons 2 -label1 (uiRes("m_performUnfold.kPolyUnfoldSel")) -label2 (uiRes("m_performUnfold.kPolyUnfoldUnsel")) -select 1 -vr -cat 2 "left" 20 polyUnfoldUVsOptions; radioButtonGrp -label (uiRes("m_performUnfold.kUnfoldConstraint")) -numberOfRadioButtons 3 -label1 (uiRes("m_performUnfold.kUnfoldConstraintNone")) -label2 (uiRes("m_performUnfold.kUnfoldConstraintVertical")) -label3 (uiRes("m_performUnfold.kUnfoldConstraintHorizontal")) -select 1 -vr unfoldPinAxis; setParent ..; // columnLayout setParent $parent; // frameLayout // Other settings frame string $otherSettingsFrame = `frameLayout -label (uiRes("m_performUnfold.kOtherSettingsFrame"))`; columnLayout; intSliderGrp -label (uiRes("m_performUnfold.kMaximumIter")) -ann (uiRes("m_performUnfold.kMaximumIterAnnot")) -min 1 -max 10000 unfoldIterations; floatSliderGrp -label (uiRes("m_performUnfold.kStoppingThreshold")) -ann (uiRes("m_performUnfold.kStoppingThresholdAnnot")) -min 0 -max 100 unfoldStopThreshold; separator -style "none"; string $greyCmd = "{ int $tmp = `checkBoxGrp -q -v1 unfoldRescale`;" + " floatSliderGrp -e -en $tmp unfoldScale;}"; checkBoxGrp -label1 (uiRes("m_performUnfold.kRescale")) -cc $greyCmd -ann (uiRes("m_performUnfold.kRescaleAnnot")) unfoldRescale; floatSliderGrp -label (uiRes("m_performUnfold.kScaleFactor")) -ann (uiRes("m_performUnfold.kScaleFactorAnnot")) -min 0.00001 -max 10 -fmx 10000 unfoldScale; separator -style "none"; checkBoxGrp -label1 (uiRes("m_performUnfold.kKeepHistory")) -ann (uiRes("m_performUnfold.kKeepHistoryAnnot")) unfoldHistOn; setParent..; // columnLayout setParent $parent; // frameLayout setParent $topLevelParent; } proc unfoldOptions() { // Global template variables for form and widget spacing global int $gOptionBoxTemplateDescriptionMarginWidth; global int $gOptionBoxTemplateFrameSpacing; global int $gOptionBoxTemplateTextColumnWidth; global int $gOptionBoxTemplateSingleWidgetWidth; global int $gOptionBoxTemplateSliderWidgetWidth; global int $gOptionBoxTemplateOffsetText; // Name of the command for this option box. // string $commandName = "unfold"; string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // Get the option box. // string $layout = getOptionBox(); setParent $layout; // Pass the command name to the option box. // setOptionBoxCommandName($commandName); // Activate the option box UI template. // setUITemplate -pushTemplate OptionBoxTemplate; string $parent = `scrollLayout`; // Form layout formLayout polyUnfoldOptions; if (`pluginInfo -q -loaded Unfold3D`) { string $legacyLbl = (uiRes("m_performUnfold.kLegacyLabel")); string $unfold3DLbl = (uiRes("m_performUnfold.kUnfoldLabel")); radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performUnfold.kMethodLabel")) -labelArray2 $unfold3DLbl $legacyLbl -vertical -changeCommand "unfoldAgorithmChange" UnfoldAgorithm_RGB; setParent ..; string $tabs = `tabLayout -tabsVisible false unfoldAlgorithmTabs`; unfold3dUnfoldOptions(); legacyUnfoldOptions(); setParent ..; } else { legacyUnfoldOptions(); setParent ..; } // Deactivate the default UI template. // setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -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_performUnfold.kUnfoldUVsOptions")); setOptionBoxHelpTag("UnfoldUVs"); // Set the current values of the option box. // eval (($setup + " " + $parent + " " + 0)); // Show the option box. // showOptionBox(); } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // // Return Value: // None. // proc string assembleCmd() { int $alg = 2; string $cmd; if (`pluginInfo -q -loaded Unfold3D`) { $alg = `optionVar -q UnfoldAlgorithm`; if ($alg < 1 || $alg > 2) $alg = 1; } if (2 == $alg) { if (`optionVar -q unfoldHistOn`) $cmd = "polyOptUvs"; else $cmd = "unfold"; setOptionVars(false); $cmd = ($cmd + " -i " + `optionVar -q unfoldIterations`); $cmd = ($cmd + " -ss " + `optionVar -q unfoldStopThreshold`); $cmd = ($cmd + " -gb " + `optionVar -q unfoldGlobalBlend`); $cmd = ($cmd + " -gmb " + `optionVar -q unfoldGlobalMethodBlend`); $cmd = ($cmd + " -pub " + `optionVar -q unfoldPinBorder`); $cmd = ($cmd + " -ps " + `optionVar -q unfoldPinSelected`); $cmd = ($cmd + " -oa " + (`optionVar -q unfoldPinAxis`-1)); int $rescale = `optionVar -q unfoldRescale`; if ($rescale) $cmd = ($cmd + " -us on -s " + `optionVar -q unfoldScale`); else $cmd = ($cmd + " -us off"); } else { $cmd = "u3dUnfold "; int $iVal; $iVal = `optionVar -q Unfold3DIterations`; $cmd += ("-ite " + $iVal + " "); $iVal = `optionVar -q Unfold3DPack`; $cmd += ("-p " + $iVal + " "); $iVal = `optionVar -q Unfold3DBorderIntersect`; $cmd += ("-bi " + $iVal + " "); $iVal = `optionVar -q Unfold3DTriFlip`; $cmd += ("-tf " + $iVal + " "); $iVal = `optionVar -q Unfold3DMapSize`; $iVal = indexToMapSize($iVal); $cmd += ("-ms " + $iVal + " "); $iVal = `optionVar -q Unfold3DRoomSpace`; $cmd += ("-rs " + $iVal); } return $cmd; } global proc Unfold3DFixNonManifoldBeforeUnfoldDialog() { string $commandName = "Unfold"; string $commandDisplayName = (uiRes("m_performUnfold.kUnfold")); Unfold3DFixNonManifoldDialog($commandName, $commandDisplayName); } // // Procedure Name: // performUnfold // // Description: // Perform the unfold 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 unfold 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 performUnfold(int $action) { string $cmd = ""; string $sel[]; switch ($action) { // Execute the command. // case 0: // Retrieve the option settings // setOptionVars(false); // Get the command. // $cmd = `assembleCmd`; $sel=`ls -sl`; if(size($sel) == 0) { $sel = `ls -preSelectHilite`; } string $filteredSel[]; for ($i in $sel) { string $theNodeType = `nodeType $i`; if( $theNodeType == "transform" || $theNodeType == "mesh" ) $filteredSel[size($filteredSel)]=$i; } int $index=0; string $finalSel[]; while (size($filteredSel) > $index) { string $cursel[]; $index=`polyNextSelectionBatch $filteredSel $cursel $index`; if (size($cursel) != 0) { for ($k in $cursel) { $finalSel[size($finalSel)] = $k; } } } for ($i in $finalSel) { $cmd=($cmd + " " + $i); } int $iLayout = `optionVar -q Unfold3DLayout`; if( $iLayout > 0 ) $cmd += ";performPolyLayoutUV(0);"; if (`optionVar -q unfoldHistOn`) $cmd = ("polyPerformAction \"" + $cmd + "\" \"map\" 0"); int $alg = 2; if (`pluginInfo -q -loaded Unfold3D`) { $alg = `optionVar -q UnfoldAlgorithm`; if ($alg < 1 || $alg > 2) $alg = 1; } if ($alg == 1) { // validate the mesh and clean it up string $topoValidCmd = "u3dTopoValid -type"; for ($i in $finalSel) { $topoValidCmd=($topoValidCmd + " " + $i); } string $topoErrors[] = eval($topoValidCmd); if (size($topoErrors) > 0) { int $doClean = 0; if (`optionVar -q Unfold3DFixNonManifoldBeforeUnfold`) $doClean = 1; else if (`optionVar -q Unfold3DAskToFixNonManifoldBeforeUnfold`) { string $ret = `layoutDialog -title (uiRes("m_performUnfold.kFixNonManifold")) -ui "Unfold3DFixNonManifoldBeforeUnfoldDialog"`; if($ret == "yes") $doClean = 1; } if ($doClean) Unfold3DFixNonManifold($topoErrors); } } // Execute the command with the option settings. // evalEcho($cmd); break; // Show the option box. // case 1: unfoldOptions; break; // Return the command string. // case 2: // Retrieve the option settings. // setOptionVars (false); // Get the command. // $cmd = `assembleCmd`; if (`optionVar -q unfoldHistOn`) $cmd = ("polyPerformAction \"" + $cmd + "\" \"map\" 0"); break; } return $cmd; }