// =========================================================================== // 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 appendGeometryCacheTimeRange`) { optionVar -intValue appendGeometryCacheTimeRange 2; } // startTime // if ($forceFactorySettings || !`optionVar -exists appendGeometryCacheStartTime`) { optionVar -floatValue appendnClothCacheStartTime 1.0; } // endTime // if ($forceFactorySettings || !`optionVar -exists appendGeometryCacheEndTime`) { optionVar -floatValue appendGeometryCacheEndTime 10.0; } // simulation rate // if ($forceFactorySettings || !`optionVar -exists appendGeometryCacheSimulationRate`) { optionVar -floatValue appendGeometryCacheSimulationRate 1; } // sampling rate // if( $forceFactorySettings ||! `optionVar -exists appendGeometryCacheSampleMultiplier` ) { optionVar -intValue appendGeometryCacheSampleMultiplier 1; } } // // Procedure Name: // appendGeometryCacheEnabling // // 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 appendGeometryCacheEnabling() { int $start = ( `radioButtonGrp -q -sl appendGeometryCacheTimeRange6` == 1 ); int $end = $start || (`radioButtonGrp -q -sl appendGeometryCacheTimeRange5` == 1); floatFieldGrp -edit -enable $start appendGeometryCacheStartTime; floatFieldGrp -edit -enable $end appendGeometryCacheEndTime; } // // Procedure Name: // appendGeometryCacheSetup // // 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 appendGeometryCacheSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars($forceFactorySettings); setParent $parent; // Range start // int $rangeStart = `optionVar -query appendGeometryCacheTimeRange`; eval( "radioButtonGrp -e -select 1 appendGeometryCacheTimeRange"+$rangeStart); // Start/End // float $startTime = `optionVar -query appendGeometryCacheStartTime`; float $endTime = `optionVar -query appendGeometryCacheEndTime`; floatFieldGrp -edit -value1 $startTime appendGeometryCacheStartTime; floatFieldGrp -edit -value1 $endTime appendGeometryCacheEndTime; // Sampling information // float $simulation = `optionVar -q appendGeometryCacheSimulationRate` ; floatFieldGrp -e -v1 $simulation appendGeometryCacheSimulationRate ; int $samplingRate = `optionVar -q appendGeometryCacheSampleMultiplier` ; intFieldGrp -edit -v1 $samplingRate appendGeometryCacheSampleMultiplier ; appendGeometryCacheEnabling(); } // // Procedure Name: // appendGeometryCacheCallback // // 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 appendGeometryCacheCallback(string $parent, int $doIt) { setParent $parent; // start/end range // int $timeRangeMode = 2; if( `radioButtonGrp -q -sl appendGeometryCacheTimeRange1` ) { $timeRangeMode = 1; } else if( `radioButtonGrp -q -sl appendGeometryCacheTimeRange2` ) { $timeRangeMode = 2; } else if( `radioButtonGrp -q -sl appendGeometryCacheTimeRange3` ) { $timeRangeMode = 3; } else if( `radioButtonGrp -q -sl appendGeometryCacheTimeRange4` ) { $timeRangeMode = 4; } else if( `radioButtonGrp -q -sl appendGeometryCacheTimeRange5` ) { $timeRangeMode = 5; } else if( `radioButtonGrp -q -sl appendGeometryCacheTimeRange6` ) { $timeRangeMode = 6; } optionVar -intValue appendGeometryCacheTimeRange $timeRangeMode; // start/end Time // optionVar -floatValue appendGeometryCacheStartTime `floatFieldGrp -query -value1 appendGeometryCacheStartTime`; optionVar -floatValue appendGeometryCacheEndTime `floatFieldGrp -query -value1 appendGeometryCacheEndTime`; // simulation rate // optionVar -floatValue appendGeometryCacheSimulationRate `floatFieldGrp -query -v1 appendGeometryCacheSimulationRate`; // sampling rate // optionVar -intValue appendGeometryCacheSampleMultiplier `intFieldGrp -query -v1 appendGeometryCacheSampleMultiplier`; if( $doIt ) { performAppendGeometryCache 0; } } // // Procedure Name: // appendGeometryCacheOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc appendGeometryCacheOptions() { // Name of the command for this option box. // string $commandName = "appendGeometryCache"; // 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_performAppendGeometryCache.kAppendTimeRange")) -nrb 1 -l1 (uiRes("m_performAppendGeometryCache.kCurrentTime")) -cc "appendGeometryCacheEnabling" appendGeometryCacheTimeRange1; radioButtonGrp -label "" -nrb 1 -scl appendGeometryCacheTimeRange1 -l1 (uiRes("m_performAppendGeometryCache.kCurrentTimeToSliderEnd")) -cc "appendGeometryCacheEnabling" appendGeometryCacheTimeRange2; radioButtonGrp -label "" -nrb 1 -scl appendGeometryCacheTimeRange1 -l1 (localizedUIComponentLabel("Time Slider")) -cc "appendGeometryCacheEnabling" appendGeometryCacheTimeRange3; radioButtonGrp -label "" -nrb 1 -scl appendGeometryCacheTimeRange1 -l1 (uiRes("m_performAppendGeometryCache.kCacheEndToTimeSlider")) -cc "appendGeometryCacheEnabling" appendGeometryCacheTimeRange4; radioButtonGrp -label "" -nrb 1 -scl appendGeometryCacheTimeRange1 -l1 (uiRes("m_performAppendGeometryCache.kCacheEndToEnd")) -cc "appendGeometryCacheEnabling" appendGeometryCacheTimeRange5; radioButtonGrp -label "" -nrb 1 -scl appendGeometryCacheTimeRange1 -l1 (uiRes("m_performAppendGeometryCache.kStartEnd")) -cc "appendGeometryCacheEnabling" appendGeometryCacheTimeRange6; floatFieldGrp -nf 1 -label (uiRes("m_performAppendGeometryCache.kStart")) appendGeometryCacheStartTime; floatFieldGrp -nf 1 -label (uiRes("m_performAppendGeometryCache.kEnd")) appendGeometryCacheEndTime; separator -h 5 -style "none"; floatFieldGrp -label (uiRes("m_performAppendGeometryCache.kSimulationRate")) -extraLabel (uiRes("m_performAppendGeometryCache.kSimulationRateEnd")) -nf 1 appendGeometryCacheSimulationRate; intFieldGrp -label (uiRes("m_performAppendGeometryCache.kSampleMultiplier")) -extraLabel (uiRes("m_performAppendGeometryCache.kSampleMultiplierEnd")) -nf 1 appendGeometryCacheSampleMultiplier; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performAppendGeometryCache.kAppend")) -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_performAppendGeometryCache.kAppendOptions")) ); setOptionBoxCommandName($commandName); setOptionBoxHelpTag( "AppendToGeometryCache" ); // 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[] = getGeometriesToCache(); for( $obj in $objects ) { $cmd += (" -points " + $obj); } int $timeMode = `optionVar -query appendGeometryCacheTimeRange`; float $cacheEnd = 0.0; if( $timeMode == 4 || $timeMode == 5) { $cacheEnd = getCacheEndTime( $objects ); } 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 appendGeometryCacheEndTime`; break; case 6: default: $startTime = `optionVar -query appendGeometryCacheStartTime`; $endTime = `optionVar -query appendGeometryCacheEndTime`; break; } float $simRate = `optionVar -query appendGeometryCacheSimulationRate`; int $sampleMult = `optionVar -query appendGeometryCacheSampleMultiplier`; $cmd += (" -startTime " + $startTime ); $cmd += (" -endTime " + $endTime ); $cmd += (" -simulationRate " + $simRate ); $cmd += (" -sampleMultiplier " + $sampleMult ); $cmd += (" -noBackup"); return $cmd; } // // Procedure Name: // performAppendGeometryCache // // 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 performAppendGeometryCache(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: appendGeometryCacheOptions(); break; // Return the command string. // case 2: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }