// =========================================================================== // 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: August 14, 1996 // // // Description: // This is a helper script to perform the bakeResults command // using the various options that have been set // // Input Arguments: // int action 0 - just execute the command // 1 - show the option box dialog // 2 - return the drag command // // Return Value: // None. // proc setOptionVars( int $forceFactorySettings ) { // use startTime/endTime // if ($forceFactorySettings || !`optionVar -exists bakeResultsUseStartEnd`) { optionVar -intValue bakeResultsUseStartEnd 0; } // startTime // if ($forceFactorySettings || !`optionVar -exists bakeResultsStartTime`) { optionVar -floatValue bakeResultsStartTime 0.0; } // endTime // if ($forceFactorySettings || !`optionVar -exists bakeResultsEndTime`) { optionVar -floatValue bakeResultsEndTime 24.0; } // sampleBy // if ($forceFactorySettings || !`optionVar -exists bakeResultsSampleBy`) { optionVar -floatValue bakeResultsSampleBy 1.0; } // Oversampling Rate // if ($forceFactorySettings || !`optionVar -exists bakeResultsOversamplingRate`) { optionVar -intValue bakeResultsOversamplingRate 1; } // Preserve keys outside the bake range // if ($forceFactorySettings || !`optionVar -exists bakeResultsPreserveKeys`) { optionVar -intValue bakeResultsPreserveKeys 1; } // Bake anim curves sparsely // if ($forceFactorySettings || !`optionVar -exists bakeResultsSparseAnimCurve`) { optionVar -intValue bakeResultsSparseAnimCurve 0; } } global proc bakeResultsSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars ($forceFactorySettings); setParent $parent; // -startTime/-endTime // int $useRange = `optionVar -query bakeResultsUseStartEnd`; radioButtonGrp -e -select ($useRange + 1) timeRange; if( $useRange ) { frameLayout -e -enable true startEndFrame; } else { frameLayout -e -enable false startEndFrame; } float $startTime = `optionVar -query bakeResultsStartTime`; float $endTime = `optionVar -query bakeResultsEndTime`; floatFieldGrp -edit -value1 $startTime frameStart; floatFieldGrp -edit -value1 $endTime frameEnd; // -sampleBy // float $sampleBy = `optionVar -query bakeResultsSampleBy`; floatFieldGrp -edit -value1 $sampleBy sampleBy; // Oversampling Rate // intField -edit -value `optionVar -q bakeResultsOversamplingRate` oversamplingRate; // Preserve keys outside bake range // checkBoxGrp -edit -value1 `optionVar -q bakeResultsPreserveKeys` preserveKeys; // Bake anim curves sparsely // checkBoxGrp -edit -value1 `optionVar -q bakeResultsSparseAnimCurve` sparseAnimCurves; } global proc bakeResultsCallback( string $parent, int $doIt, string $commandOptions, int $performAction ) { setParent $parent; int $useRange = (`radioButtonGrp -query -select timeRange` - 1); optionVar -intValue bakeResultsUseStartEnd $useRange; // -startTime/-endTime // float $startTime = `floatFieldGrp -query -value1 frameStart`; float $endTime = `floatFieldGrp -query -value1 frameEnd`; optionVar -floatValue bakeResultsStartTime $startTime; optionVar -floatValue bakeResultsEndTime $endTime; // -sampleBy // float $sampleBy = `floatFieldGrp -query -value1 sampleBy`; optionVar -floatValue bakeResultsSampleBy $sampleBy; // Oversampling Rate // optionVar -intValue bakeResultsOversamplingRate `intField -query -value oversamplingRate`; // Preserve keys outside bake range // optionVar -intValue bakeResultsPreserveKeys `checkBoxGrp -query -value1 preserveKeys`; // Bake anim curves sparsely // optionVar -intValue bakeResultsSparseAnimCurve `checkBoxGrp -query -value1 sparseAnimCurves`; if ($doIt) { performBakeResults ($performAction, $commandOptions); string $tmpCmd = "performBakeResults \"" + $performAction + "\" \"" + $commandOptions + "\""; addToRecentCommandQueue $tmpCmd "Bake Animation"; } } proc string bakeResultsWidgets( string $tabLayout ) { setParent $tabLayout; string $tabForm = `columnLayout -adjustableColumn true`; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performBakeResults.kTimeRange")) -label1 (localizedUIComponentLabel("Time Slider")) -cc1 "frameLayout -e -enable false startEndFrame;" -label2 (uiRes("m_performBakeResults.kStartEnd")) -cc2 "frameLayout -e -enable true startEndFrame;" timeRange; frameLayout -bv no -lv no -collapsable no startEndFrame; columnLayout -adjustableColumn true; floatFieldGrp -label (uiRes("m_performBakeResults.kStartTime")) -value1 0.0 frameStart; floatFieldGrp -label (uiRes("m_performBakeResults.kEndTime")) -value1 10.0 frameEnd; setParent ..; setParent ..; separator; floatFieldGrp -label (uiRes("m_performBakeResults.kSampleBy")) -value1 1.0 sampleBy; rowLayout -nc 3 -adj 3 oversamplingRateGrp; text -label (uiRes("m_performBakeResults.kOversamplingRate")); intField -v 1 -min 1 oversamplingRate; text -label ""; setParent ..; checkBoxGrp -label "" -label1 (uiRes("m_performBakeResults.kKeepUnbakedKeys")) -ncb 1 preserveKeys; checkBoxGrp -label "" -label1 (uiRes("m_performBakeResults.kSparseCurveBake")) -ncb 1 sparseAnimCurves; setParent ..; return $tabForm; } global proc bakeResultsDoSelectionChanged() // // Description: // Since timeRange is irrelevant when there are // picked keyframes, collapse the timeRange // when there are. (This is hooked in to a SelectionChanged // trigger.) // { string $list[] = `ls -sl`; int $keys; if(( size( $list ) == 0 ) || ( catch( $keys = `keyframe -an keys -q -kc` ) )) { $keys = 0; } int $isStartEnd = (`radioButtonGrp -q -select timeRange` == 2 ); radioButtonGrp -e -enable ($keys == 0) timeRange; frameLayout -e -enable (($keys == 0) && $isStartEnd) startEndFrame; } proc bakeResultsOptions( string $commandOptions, int $performAction ) { // Customisation options // // Name of the command for this option box (think of it as the base class) string $commandName = "bakeResults"; // Title for the option box window string $optionBoxTitle = (uiRes("m_performBakeResults.kBakeChannelOptions")); // Title for the apply button string $applyTitle = (uiRes("m_performBakeResults.kBake")); // Build the option box "methods" // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // Build the window, with a tab layout // string $widgetList[] = `getStandardWindow $optionBoxTitle 0 "noOptions"`; setUITemplate -pushTemplate DefaultTemplate; // Make the form invisible while we create the widgets in the window // formLayout -edit -vis false $widgetList[1]; // Attach each tab // bakeResultsWidgets $widgetList[2]; // Attach the standard buttons // string $buttonList[] = `addStandardButtons $commandName $applyTitle $widgetList[1] $widgetList[2] "noOptions"`; // attach commands to the standard buttons // button -edit -command ($callback + " " + $widgetList[0] + " " + false + " " + $commandOptions + " " + $performAction + "; hideOptionBox()") $buttonList[3]; button -edit -command hideOptionBox $buttonList[2]; button -edit -command ($setup + " " + $widgetList[0] + " true") $buttonList[1]; button -edit -command ($callback + " " + $widgetList[0] + " " + true + " " + $commandOptions + " " + $performAction) $buttonList[0]; // Make the form layout visible so we can see what we built, and // reset the template // formLayout -edit -vis true $widgetList[1]; setUITemplate -popTemplate; // Customize the 'Help' menu item text. // This is called from 2 different places but there is no way // to figure out which one so use the graph editor. // setOptionBoxHelpTag( "GraphBakeChannel" ); // setOptionBoxHelpTag( "DopeBakeChannel" ); // Can't differentiate. Can't Use // Call the setup "method" to fill in the current settings // eval (($setup + " " + $widgetList[0] + " false")); showOptionBox(); showWindow $widgetList[0]; bakeResultsDoSelectionChanged(); scriptJob -protected -event "SelectionChanged" bakeResultsDoSelectionChanged -parent $widgetList[2]; } proc string assembleCmd( string $selectionConnection, string $options ) { // Retrieve the option settings // setOptionVars (false); string $cmd = "doBakeResultsArgList 2 { " + "\"" + `optionVar -query bakeResultsUseStartEnd` + "\"" + ",\"" + `optionVar -query bakeResultsStartTime` + "\"" + ",\"" + `optionVar -query bakeResultsEndTime` + "\"" + ",\"" + `optionVar -query bakeResultsSampleBy` + "\"" + ",\"" + `optionVar -query bakeResultsPreserveKeys` + "\"" + ",\"" + $selectionConnection + "\"" + ",\"" + $options + "\"" + ",\"" + `optionVar -query bakeResultsSparseAnimCurve` + "\"" + ",\"" + `optionVar -query bakeResultsOversamplingRate` + "\"" + " };"; return $cmd; } // The action variable means // 0 - do the command // 1 - show the option box // 2 - return the drag command // 3 - do the command (bufferCurve version) // 4 - show the option box (bufferCurve version) // 5 - return the drag command (bufferCurve version) global proc string performBakeResults( int $action, string $commandOptions ) { string $cmd = ""; switch ($action) { case 0: // execute the command $cmd = assembleCmd ($commandOptions, "noOptions"); eval ($cmd); break; case 1: // show the option box bakeResultsOptions ($commandOptions, 0); break; case 2: // return the drag string $cmd = assembleCmd ($commandOptions, "noOptions"); break; case 3: // execute the command $cmd = assembleCmd ($commandOptions, "bufferCurve"); eval ($cmd); break; case 4: // show the option box bakeResultsOptions ($commandOptions, 3); break; case 5: // return the drag string $cmd = assembleCmd ($commandOptions, "bufferCurve"); break; } return ($cmd); }