// =========================================================================== // 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: 24 January 2006 // // Description: // This is a helper script to perform the "cacheFile -append" command // using the corresponding option box values. // // // 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) { // Time range // if($forceFactorySettings || !`optionVar -exists appendFluidCacheTimeRange`) { optionVar -intValue appendFluidCacheTimeRange 2; } // startTime // if ($forceFactorySettings || !`optionVar -exists appendFluidCacheStartTime`) { optionVar -floatValue appendFluidCacheStartTime 1.0; } // endTime // if ($forceFactorySettings || !`optionVar -exists appendFluidCacheEndTime`) { optionVar -floatValue appendFluidCacheEndTime 10.0; } // simulation rate // if ($forceFactorySettings || !`optionVar -exists appendFluidCacheSimulationRate`) { optionVar -floatValue appendFluidCacheSimulationRate 1; } // sampling rate // if( $forceFactorySettings ||! `optionVar -exists appendFluidCacheSampleMultiplier` ) { optionVar -intValue appendFluidCacheSampleMultiplier 1; } } // // Procedure Name: // appendFluidCacheEnabling // // Description: // Set the enable state of start and end time fields. // // Input Arguments: // parent - Top level parent layout of the option box UI. // Required so that object names of the fields can be // successfully resolved. // // state - Enable state of the fields. // // Return Value: // None. // global proc appendFluidCacheEnabling() { int $start = ( `radioButtonGrp -q -sl appendFluidCacheTimeRange6` == 1 ); int $end = $start || (`radioButtonGrp -q -sl appendFluidCacheTimeRange5` == 1); floatFieldGrp -edit -enable $start appendFluidCacheStartTime; floatFieldGrp -edit -enable $end appendFluidCacheEndTime; } // // Procedure Name: // appendFluidCacheSetup // // 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 appendFluidCacheSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Range start // int $rangeStart = `optionVar -query appendFluidCacheTimeRange`; eval( "radioButtonGrp -e -select 1 appendFluidCacheTimeRange"+$rangeStart); // Start/End // float $startTime = `optionVar -query appendFluidCacheStartTime`; float $endTime = `optionVar -query appendFluidCacheEndTime`; floatFieldGrp -edit -value1 $startTime appendFluidCacheStartTime; floatFieldGrp -edit -value1 $endTime appendFluidCacheEndTime; // Sampling information // float $simulation = `optionVar -q appendFluidCacheSimulationRate` ; floatFieldGrp -e -v1 $simulation appendFluidCacheSimulationRate ; int $samplingRate = `optionVar -q appendFluidCacheSampleMultiplier` ; intFieldGrp -edit -v1 $samplingRate appendFluidCacheSampleMultiplier ; appendFluidCacheEnabling(); } // // Procedure Name: // appendFluidCacheCallback // // 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 appendFluidCacheCallback(string $parent, int $doIt) { setParent $parent; // start/end range // int $timeRangeMode = 2; if( `radioButtonGrp -q -sl appendFluidCacheTimeRange1` ) { $timeRangeMode = 1; } else if( `radioButtonGrp -q -sl appendFluidCacheTimeRange2` ) { $timeRangeMode = 2; } else if( `radioButtonGrp -q -sl appendFluidCacheTimeRange3` ) { $timeRangeMode = 3; } else if( `radioButtonGrp -q -sl appendFluidCacheTimeRange4` ) { $timeRangeMode = 4; } else if( `radioButtonGrp -q -sl appendFluidCacheTimeRange5` ) { $timeRangeMode = 5; } else if( `radioButtonGrp -q -sl appendFluidCacheTimeRange6` ) { $timeRangeMode = 6; } optionVar -intValue appendFluidCacheTimeRange $timeRangeMode; // start/end Time // optionVar -floatValue appendFluidCacheStartTime `floatFieldGrp -query -value1 appendFluidCacheStartTime`; optionVar -floatValue appendFluidCacheEndTime `floatFieldGrp -query -value1 appendFluidCacheEndTime`; // simulation rate // optionVar -floatValue appendFluidCacheSimulationRate `floatFieldGrp -query -v1 appendFluidCacheSimulationRate`; // sampling rate // optionVar -intValue appendFluidCacheSampleMultiplier `intFieldGrp -query -v1 appendFluidCacheSampleMultiplier`; if( $doIt ) { performAppendFluidCache 0; } } // // Procedure Name: // appendFluidCacheOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc appendFluidCacheOptions() { // Name of the command for this option box. // string $commandName = "appendFluidCache"; // 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`; radioButtonGrp -label (uiRes("m_performAppendFluidCache.kFluidAppendTimeRange")) -nrb 1 -l1 (uiRes("m_performAppendFluidCache.kFluidCurrentTime")) -cc "appendFluidCacheEnabling" appendFluidCacheTimeRange1; radioButtonGrp -label "" -nrb 1 -scl appendFluidCacheTimeRange1 -l1 (uiRes("m_performAppendFluidCache.kFluidCurrentTimeToSliderEnd")) -cc "appendFluidCacheEnabling" appendFluidCacheTimeRange2; radioButtonGrp -label "" -nrb 1 -scl appendFluidCacheTimeRange1 -l1 (uiRes("m_performAppendFluidCache.kFluidTimeSlider")) -cc "appendFluidCacheEnabling" appendFluidCacheTimeRange3; radioButtonGrp -label "" -nrb 1 -scl appendFluidCacheTimeRange1 -l1 (uiRes("m_performAppendFluidCache.kFluidCacheEndToTimeSlider")) -cc "appendFluidCacheEnabling" appendFluidCacheTimeRange4; radioButtonGrp -label "" -nrb 1 -scl appendFluidCacheTimeRange1 -l1 (uiRes("m_performAppendFluidCache.kFluidCacheEndToEnd")) -cc "appendFluidCacheEnabling" appendFluidCacheTimeRange5; radioButtonGrp -label "" -nrb 1 -scl appendFluidCacheTimeRange1 -l1 (uiRes("m_performAppendFluidCache.kFluidStartEnd")) -cc "appendFluidCacheEnabling" appendFluidCacheTimeRange6; floatFieldGrp -nf 1 -label (uiRes("m_performAppendFluidCache.kFluidStart")) appendFluidCacheStartTime; floatFieldGrp -nf 1 -label (uiRes("m_performAppendFluidCache.kFluidEnd")) appendFluidCacheEndTime; separator -h 5 -style "none"; floatFieldGrp -label (uiRes("m_performAppendFluidCache.kFluidSimulationRate")) -extraLabel (uiRes("m_performAppendFluidCache.kFluidSimulationRateEnd")) -nf 1 appendFluidCacheSimulationRate; intFieldGrp -label (uiRes("m_performAppendFluidCache.kFluidSampleMultiplier")) -extraLabel (uiRes("m_performAppendFluidCache.kFluidSampleMultiplierEnd")) -nf 1 appendFluidCacheSampleMultiplier; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performAppendFluidCache.kFluidAppend")) -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_performAppendFluidCache.kFluidAppendOptions")) ); setOptionBoxCommandName($commandName); setOptionBoxHelpTag( "AppendToFluidCache" ); // 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() { setOptionVars(false); string $obj; float $startTime, $endTime; string $cmd = "cacheFile -refresh -appendFrame "; string $objects[] = getFluidObjectsToCache(1); for( $obj in $objects ) { $cmd += (" -cnd " + $obj); } int $timeMode = `optionVar -query appendFluidCacheTimeRange`; float $cacheEnd = 0.0; if( $timeMode == 4 || $timeMode == 5 ) { $cacheEnd = getCacheEndTime( getGeometriesToCache() ); } switch( $timeMode ) { case 1: $startTime = `currentTime -q`; $endTime = `currentTime -q`; break; case 2: $startTime = `currentTime -q`; $endTime = `playbackOptions -q -max`; break; case 3: $startTime = `playbackOptions -q -min`; $endTime = `playbackOptions -q -max`; break; case 4: $startTime = $cacheEnd; $endTime = `playbackOptions -q -max`; break; case 5: $startTime = $cacheEnd; $endTime = `optionVar -query appendFluidCacheEndTime`; break; case 6: default: $startTime = `optionVar -query appendFluidCacheStartTime`; $endTime = `optionVar -query appendFluidCacheEndTime`; break; } float $simRate = `optionVar -query appendFluidCacheSimulationRate`; int $sampleMult = `optionVar -query appendFluidCacheSampleMultiplier`; $cmd += (" -startTime " + $startTime ); $cmd += (" -endTime " + $endTime ); $cmd += (" -simulationRate " + $simRate ); $cmd += (" -sampleMultiplier " + $sampleMult ); $cmd += (" -noBackup" ); return $cmd; } // // Procedure Name: // performAppendFluidCache // // 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 performAppendFluidCache(int $action) { string $cmd = ""; switch ($action) { // Execute the command from option settings. // case 0: setOptionVars(false); $cmd = `assembleCmd`; evalEcho($cmd); break; // Show the option box. // case 1: appendFluidCacheOptions(); break; // Return the command string. // case 2: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }