// =========================================================================== // 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: June 1, 2009 // // Description: // This script is the replayblast shot option box dialogs. // // Input Arguments: // None. // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { // Start Frame // if ($forceFactorySettings || !`optionVar -exists replayblastShotStartFrame`) { optionVar -floatValue replayblastShotStartFrame 1.0; } // End Frame // if ($forceFactorySettings || !`optionVar -exists replayblastShotEndFrame`) { optionVar -floatValue replayblastShotEndFrame 10.0; } // Audio Only // if ($forceFactorySettings || !`optionVar -exists replayblastShotAudioOnly`) { optionVar -intValue replayblastShotAudioOnly 0; } // Format // Note: the follow option vars are shared with shot and other playblast UI. // if ($forceFactorySettings || !`optionVar -exists playblastFormat`) { if ( `about -nt` ) { optionVar -stringValue playblastFormat "avi"; } else if ( `about -mac`) { optionVar -stringValue playblastFormat "avfoundation "; } else { optionVar -stringValue playblastFormat "qt"; } } // Compression if ($forceFactorySettings || !`optionVar -exists playblastCompression`) { // on mac we want user use jpeg as default if ( `about -mac` ) { optionVar -stringValue playblastCompression "jpeg"; } else { optionVar -stringValue playblastCompression "none"; } } // Quality if ($forceFactorySettings || !`optionVar -exists playblastQuality`) { optionVar -intValue playblastQuality 70; } // Offscreen if ($forceFactorySettings || !`optionVar -exists playblastSequenceOffscreen`) { optionVar -intValue playblastSequenceOffscreen 1; } } // // Procedure Name: // replayblastShotSetup // // 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 replayblastShotSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings. setOptionVars( $forceFactorySettings ); setParent $parent; // Audio Only int $audioOnly = `optionVar -query replayblastShotAudioOnly`; checkBoxGrp -edit -v1 $audioOnly replayblastShotAudioOnlyWidget; // Start Frame float $startFrame = `optionVar -query replayblastShotStartFrame`; floatFieldGrp -edit -v1 $startFrame -enable (!$audioOnly) replayblastShotStartFrameWidget; // End Frame float $endFrame = `optionVar -query replayblastShotEndFrame`; floatFieldGrp -edit -v1 $endFrame -enable (!$audioOnly) replayblastShotEndFrameWidget; // Encoding and Format string $format = `optionVar -query playblastFormat`; if( !catchQuiet( `optionMenuGrp -edit -value $format playblastFormatWidget` ) ) { changeReplayblastSequenceFormat( $parent ); // Manually trigger a refresh of the compression list } // Quality int $quality = `optionVar -query playblastQuality`; intSliderGrp -edit -value $quality playblastQualityWidget; // Offscreen int $offscreen = `optionVar -query playblastSequenceOffscreen`; checkBoxGrp -edit -value1 $offscreen playblastOffscreenWidget; } // // Procedure Name: // replayblastShotCallback // // 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 replayblastShotCallback (string $parent, int $doIt, string $shot ) { setParent $parent; // Start Frame // optionVar -floatValue replayblastShotStartFrame `floatFieldGrp -query -v1 replayblastShotStartFrameWidget`; // End Frame // optionVar -floatValue replayblastShotEndFrame `floatFieldGrp -query -v1 replayblastShotEndFrameWidget`; // Audio Only // optionVar -intValue replayblastShotAudioOnly `checkBoxGrp -query -v1 replayblastShotAudioOnlyWidget`; // Format optionVar -stringValue playblastFormat `optionMenuGrp -query -value playblastFormatWidget`; // Compression optionVar -stringValue playblastCompression `optionMenuGrp -query -value playblastCompressionWidget`; // Quality optionVar -intValue playblastQuality `intSliderGrp -query -value playblastQualityWidget`; // Offscreen int $offscreen = `checkBoxGrp -query -value1 playblastOffscreenWidget`; optionVar -intValue playblastSequenceOffscreen $offscreen; if ($doIt) { performReplayblastShot 0 ("\"" + $shot + "\""); } } global proc changeReplayblastSequenceEncoding (string $parent) { setParent $parent; string $selectedFormat = `optionMenuGrp -q -value playblastFormatWidget`; string $encodingFormat = `optionMenuGrp -q -value playblastCompressionWidget`; int $enableQuality = 1; if ( $selectedFormat == "image" || ($selectedFormat == "avfoundation" && $encodingFormat == "H.264") ) { $enableQuality = 0; } intSliderGrp -edit -enable $enableQuality playblastQualityWidget; } global proc changeReplayblastSequenceFormat( string $parent) { setParent $parent; string $selectedFormat = `optionMenuGrp -q -value playblastFormatWidget`; string $lEncodings[] = `playblast -format $selectedFormat -q -compression`; string $lMenus[] = `optionMenuGrp -q -ils playblastCompressionWidget`; for( $menu in $lMenus ) { deleteUI -menuItem $menu; } // make sure that this a "none" to work with. iff will not return anything currently if (size($lEncodings) == 0) { $lEncodings[0] = "none"; } // add new menuItem into optionMenuGrp string $menuPath = `optionMenuGrp -q -fullPathName playblastCompressionWidget` + "|OptionMenu"; for( $encoding in $lEncodings ) { menuItem -parent $menuPath -label $encoding; } // try the current compression type or set a default value // string $compression = `optionVar -query playblastCompression`; if( $compression != "" ) { string $newMenu[] = `optionMenuGrp -q -ils playblastCompressionWidget`; for ($menu in $newMenu) { string $label = `menuItem -q -label $menu`; if ($label == $compression) { // found it, so set it. optionMenuGrp -edit -value $compression playblastCompressionWidget; changeReplayblastSequenceEncoding($parent); return; } } // set a default value if ($selectedFormat == "qt") { if(`about -linux`){ catchQuiet( `optionMenuGrp -edit -value "png" playblastCompressionWidget`); } else { catchQuiet( `optionMenuGrp -edit -value "PNG" playblastCompressionWidget`); } } else { catchQuiet( `optionMenuGrp -edit -value "none" playblastCompressionWidget`); } } changeReplayblastSequenceEncoding($parent); } global proc replayblastUpdateStartEnd () { int $audioOnly = `checkBoxGrp -query -v1 replayblastShotAudioOnlyWidget`; // Start Frame floatFieldGrp -edit -enable (!$audioOnly) replayblastShotStartFrameWidget; floatFieldGrp -edit -enable (!$audioOnly) replayblastShotEndFrameWidget; } proc string replayblastShotWidgets( string $parent ) { setParent $parent; string $tabForm = `columnLayout -adjustableColumn true`; // Audio Only checkBoxGrp -label (uiRes("m_performReplayblastShot.kReShotAudioOnly")) -numberOfCheckBoxes 1 -cc1 "replayblastUpdateStartEnd" replayblastShotAudioOnlyWidget; // Start/End frames floatFieldGrp -label (uiRes("m_performReplayblastShot.kReShotStartFrame")) -numberOfFields 1 replayblastShotStartFrameWidget; floatFieldGrp -label (uiRes("m_performReplayblastShot.kReShotEndFrame")) -numberOfFields 1 replayblastShotEndFrameWidget; separator; // Offscreen rendering. checkBoxGrp -label (uiRes("m_performReplayblastShot.kView")) -ncb 1 -value1 on -label1 "" playblastOffscreenWidget; // Format and Compression optionMenuGrp -label (uiRes("m_performReplayblastShot.kPlayblastFormat")) -changeCommand ( "changeReplayblastSequenceFormat "+$parent ) playblastFormatWidget; string $lFormats[] = `playblast -q -format`; for( $format in $lFormats ) { menuItem -label $format; } optionMenuGrp -label (uiRes("m_performReplayblastShot.kPlayblastCompression")) -changeCommand ( "changeReplayblastSequenceEncoding "+$parent ) playblastCompressionWidget; intSliderGrp -field true -label (uiRes("m_performReplayblastShot.kPlayblastQuality")) -min 0 -max 100 - step 20 playblastQualityWidget; return $tabForm; } global proc replayblastShotOptions ( string $shot ) { string $commandName = "replayblastShot"; // Build the option box "methods" // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // Get the option box. // // The value returned is the name of the layout to be used as // the parent for the option box UI. // string $layout = getOptionBox(); setParent $layout; setOptionBoxCommandName("replayblastShot"); setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -scrollable true -tabsVisible false; // To get the scroll bars string $parent = `columnLayout -adjustableColumn 1`; replayblastShotWidgets $parent; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performReplayblastShot.kReplayblastShot")) -command ($callback + " " + $parent + " " + 1 + " " + $shot ) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + " " + $shot + "; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Set the option box title. // setOptionBoxTitle((uiRes("m_performReplayblastShot.kReplayblastShotOptions"))); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "ReplayblastShot" ); // 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( string $shot ) { string $cmd; setOptionVars(false); // Start Frame float $startFrame = 2.0; if (`optionVar -exists replayblastShotStartFrame`) { $startFrame = `optionVar -query replayblastShotStartFrame`; } // End Frame float $endFrame = 10.0; if (`optionVar -exists replayblastShotEndFrame`) { $endFrame = `optionVar -query replayblastShotEndFrame`; } // Audio Only int $audioOnly = 0; if (`optionVar -exists replayblastShotAudioOnly`) { $audioOnly = `optionVar -query replayblastShotAudioOnly`; } // Format string $format = "qt"; if (`optionVar -exists playblastFormat`) { $format = `optionVar -query playblastFormat`; } // Compression string $compression = ""; if (`optionVar -exists playblastCompression`) { $compression = `optionVar -query playblastCompression`; } // Quality int $quality = 50; if (`optionVar -exists playblastQuality`) { $quality = `optionVar -query playblastQuality`; } // Offscreen control int $offscreen = 1; if (`optionVar -exists playblastSequenceOffscreen`) { $offscreen = `optionVar -query playblastSequenceOffscreen`; } // Go! $cmd = "doReplayblastShotArgList 3 { " + "\"" + $startFrame + "\"" + ",\"" + $endFrame + "\"" + ",\"" + $audioOnly + "\"" + ",\"" + $format + "\"" + ",\"" + $compression + "\"" + ",\"" + $quality + "\"" + ",\"" + $offscreen + "\"" + " } " + $shot; return $cmd; } // // Procedure Name: // performReplayblastShot // // Description: // Replayblast a shot and add the animatable attributes from the // selected nodes. This procedure will also show the option box // window if necessary as well as construct the command string // that will replayblast a shot 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 performReplayblastShot (int $action, string $shot) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Retrieve the option settings // setOptionVars(false); // Get the command. // $cmd = assembleCmd ($shot); // Execute the command with the option settings. // eval($cmd); break; // Show the option box. // case 1: replayblastShotOptions ($shot); break; // Return the command string. // case 2: // Retrieve the option settings. // setOptionVars (false); // Get the command. // $cmd = assembleCmd ($shot); break; } return $cmd; }