// =========================================================================== // 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: // doPlayblast is the actual proc that is executed from the // Windows->Playblast option box or menu // // Input Arguments: // // Return Value: // none // // This proc will generate a confirmation box. It is used when // a playblast file is about to be overwritten. // proc string confirmPlayblastOverwrite( string $type, string $filename ) { string $message; string $showFilename; if (`about -win`) { $showFilename = unconvert($filename); } else { $showFilename = ($filename); } string $msg =(uiRes("m_doPlayblastArgList.kFilenameMessage")); $msg = `format -s $showFilename $msg`; switch ($type) { case "iff": $message = (uiRes("m_doPlayblastArgList.kCheckFileMessage")); $message = `format -s $showFilename $message`; break; default: $message = $msg; break; } string $cancel = (uiRes("m_doPlayblastArgList.kCancel")); string $result = `confirmDialog -title (uiRes("m_doPlayblastArgList.kPlayblastError")) -message $message -messageAlign center -button (uiRes("m_doPlayblastArgList.kOk")) -button $cancel -defaultButton $cancel -cancelButton $cancel -dismissString $cancel`; return $result; } proc string getModelEditor() { $thePanel = `getPanel -withFocus`; $panelType = `getPanel -typeOf $thePanel`; if ($panelType != "modelPanel") { return ""; } $modelEd = `modelPanel -query -modelEditor $thePanel`; return $modelEd; } global proc getEditorViewVars () { if (!`optionVar -query playblastOverrideViewport`) { return; } $modelEd = getModelEditor(); if ($modelEd == "") { return; } global int $gModEdControllers; global int $gModEdNurbsCurves; global int $gModEdNurbsSurfaces; global int $gModEdPolyMeshes; global int $gModEdSubDs; global int $gModEdPlanes; global int $gModEdLights; global int $gModEdCameras; global int $gModEdJoints; global int $gModEdIKHandles; global int $gModEdDeformers; global int $gModEdDynamics; global int $gModEdFluids; global int $gModEdHairSystems; global int $gModEdFollicles; global int $gModEdNCloths; global int $gModEdNParticles; global int $gModEdDynamicConstraints; global int $gModEdNRigids; global int $gModEdLocators; global int $gModEdDimensions; global int $gModEdPivots; global int $gModEdHandles; global int $gModEdTextures; global int $gModEdStrokes; global int $gModEdMotionTrails; global int $gModEdPluginShapes; global string $gModEdPluginObjects[]; global int $gModEdCVs; global int $gModEdHulls; global int $gModEdGrid; global int $gModEdHUD; global int $gModEdHoldOuts; global int $gModEdSelectionHighlighting; global int $gModEdImagePlane; global int $gModEdClipGhosts; global int $gModEdGreasePencil; global int $gModEdManips; $gModEdControllers = `modelEditor -q -controllers $modelEd`; $gModEdNurbsCurves = `modelEditor -q -nurbsCurves $modelEd`; $gModEdNurbsSurfaces = `modelEditor -q -nurbsSurfaces $modelEd`; $gModEdPolyMeshes = `modelEditor -q -polymeshes $modelEd`; $gModEdSubDs = `modelEditor -q -subdivSurfaces $modelEd`; $gModEdPlanes = `modelEditor -q -planes $modelEd`; $gModEdLights = `modelEditor -q -lights $modelEd`; $gModEdCameras = `modelEditor -q -cameras $modelEd`; $gModEdJoints = `modelEditor -q -joints $modelEd`; $gModEdIKHandles = `modelEditor -q -ikHandles $modelEd`; $gModEdDeformers = `modelEditor -q -deformers $modelEd`; $gModEdDynamics = `modelEditor -q -dynamics $modelEd`; $gModEdFluids = `modelEditor -q -fluids $modelEd`; $gModEdHairSystems = `modelEditor -q -hairSystems $modelEd`; $gModEdFollicles = `modelEditor -q -follicles $modelEd`; $gModEdNCloths = `modelEditor -q -nCloths $modelEd`; $gModEdNParticles = `modelEditor -q -nParticles $modelEd`; $gModEdNRigids = `modelEditor -q -nRigids $modelEd`; $gModEdDynamicConstraints = `modelEditor -q -dynamicConstraints $modelEd`; $gModEdLocators = `modelEditor -q -locators $modelEd`; $gModEdDimensions = `modelEditor -q -dimensions $modelEd`; $gModEdPivots = `modelEditor -q -pivots $modelEd`; $gModEdHandles = `modelEditor -q -handles $modelEd`; $gModEdTextures = `modelEditor -q -textures $modelEd`; $gModEdStrokes = `modelEditor -q -strokes $modelEd`; $gModEdMotionTrails = `modelEditor -q -motionTrails $modelEd`; $gModEdPluginShapes = `modelEditor -q -pluginShapes $modelEd`; $gModEdClipGhosts = `modelEditor -q -clipGhosts $modelEd`; $gModEdGreasePencil = `modelEditor -q -greasePencils $modelEd`; $gModEdPluginObjects = {}; string $pluginFilters[] = `pluginDisplayFilter -q -listFilters`; string $filter; for ($filter in $pluginFilters) { if (!`modelEditor -q -queryPluginObjects $filter $modelEd`) { $gModEdPluginObjects[size($gModEdPluginObjects)] = $filter; } } $gModEdCVs = `modelEditor -q -cv $modelEd`; $gModEdHulls = `modelEditor -q -hulls $modelEd`; $gModEdManips = `modelEditor -q -manipulators $modelEd`; $gModEdGrid = `modelEditor -q -grid $modelEd`; $gModEdHUD = `modelEditor -q -hud $modelEd`; $gModEdHoldOuts = `modelEditor -q -hos $modelEd`; $gModEdSelectionHighlighting = `modelEditor -q -sel $modelEd`; $gModEdImagePlane = `modelEditor -q -imagePlane $modelEd`; } global proc restoreEditorViewVars () { if (!`optionVar -query playblastOverrideViewport`) { return; } $modelEd = getModelEditor(); if ($modelEd == "") { return; } global int $gModEdControllers; global int $gModEdNurbsCurves; global int $gModEdNurbsSurfaces; global int $gModEdPolyMeshes; global int $gModEdSubDs; global int $gModEdPlanes; global int $gModEdLights; global int $gModEdCameras; global int $gModEdJoints; global int $gModEdIKHandles; global int $gModEdDeformers; global int $gModEdDynamics; global int $gModEdFluids; global int $gModEdHairSystems; global int $gModEdFollicles; global int $gModEdNCloths; global int $gModEdNParticles; global int $gModEdDynamicConstraints; global int $gModEdNRigids; global int $gModEdDynamicConstraints; global int $gModEdLocators; global int $gModEdDimensions; global int $gModEdPivots; global int $gModEdHandles; global int $gModEdTextures; global int $gModEdStrokes; global int $gModEdMotionTrails; global int $gModEdPluginShapes; global string $gModEdPluginObjects[]; global int $gModEdCVs; global int $gModEdHulls; global int $gModEdGrid; global int $gModEdHUD; global int $gModEdHoldOuts; global int $gModEdSelectionHighlighting; global int $gModEdImagePlane; global int $gModEdClipGhosts; global int $gModEdGreasePencil; global int $gModEdManips; modelEditor -e -controllers $gModEdControllers $modelEd; modelEditor -e -nurbsCurves $gModEdNurbsCurves $modelEd; modelEditor -e -nurbsSurfaces $gModEdNurbsSurfaces $modelEd; modelEditor -e -polymeshes $gModEdPolyMeshes $modelEd; modelEditor -e -subdivSurfaces $gModEdSubDs $modelEd; modelEditor -e -planes $gModEdPlanes $modelEd; modelEditor -e -lights $gModEdLights $modelEd; modelEditor -e -cameras $gModEdCameras $modelEd; modelEditor -e -joints $gModEdJoints $modelEd; modelEditor -e -ikHandles $gModEdIKHandles $modelEd; modelEditor -e -deformers $gModEdDeformers $modelEd; modelEditor -e -dynamics $gModEdDynamics $modelEd; modelEditor -e -fluids $gModEdFluids $modelEd; modelEditor -e -hairSystems $gModEdHairSystems $modelEd; modelEditor -e -follicles $gModEdFollicles $modelEd; modelEditor -e -nCloths $gModEdNCloths $modelEd; modelEditor -e -nParticles $gModEdNParticles $modelEd; modelEditor -e -nRigids $gModEdNRigids $modelEd; modelEditor -e -dynamicConstraints $gModEdDynamicConstraints $modelEd; modelEditor -e -locators $gModEdLocators $modelEd; modelEditor -e -dimensions $gModEdDimensions $modelEd; modelEditor -e -pivots $gModEdPivots $modelEd; modelEditor -e -handles $gModEdHandles $modelEd; modelEditor -e -textures $gModEdTextures $modelEd; modelEditor -e -strokes $gModEdStrokes $modelEd; modelEditor -e -motionTrails $gModEdMotionTrails $modelEd; modelEditor -e -pluginShapes $gModEdPluginShapes $modelEd; modelEditor -e -clipGhosts $gModEdClipGhosts $modelEd; modelEditor -e -greasePencils $gModEdGreasePencil $modelEd; string $pluginFilters[] = `pluginDisplayFilter -q -listFilters`; string $filter; for ($filter in $pluginFilters) { int $show = (stringArrayFind($filter, 0, $gModEdPluginObjects) == -1); modelEditor -e -pluginObjects $filter $show $modelEd; } modelEditor -e -cv $gModEdCVs $modelEd; modelEditor -e -hulls $gModEdHulls $modelEd; modelEditor -e -manipulators $gModEdManips $modelEd; modelEditor -e -grid $gModEdGrid $modelEd; modelEditor -e -hud $gModEdHUD $modelEd; modelEditor -e -hos $gModEdHoldOuts $modelEd; modelEditor -e -sel $gModEdSelectionHighlighting $modelEd; modelEditor -e -imagePlane $gModEdImagePlane $modelEd; } global proc setPlayblastViewVars () { if (!`optionVar -query playblastOverrideViewport`) { return; } $modelEd = getModelEditor(); if ($modelEd == "") { return; } modelEditor -e -controllers `optionVar -query playblastShowControllers` $modelEd ; modelEditor -e -nurbsCurves `optionVar -query playblastShowNURBSCurves` $modelEd ; modelEditor -e -nurbsSurfaces `optionVar -query playblastShowNURBSSurfaces` $modelEd ; modelEditor -e -polymeshes `optionVar -query playblastShowPolyMeshes` $modelEd ; modelEditor -e -subdivSurfaces `optionVar -query playblastShowSubdivSurfaces` $modelEd; modelEditor -e -planes `optionVar -query playblastShowPlanes` $modelEd; modelEditor -e -lights `optionVar -query playblastShowLights` $modelEd; modelEditor -e -cameras `optionVar -query playblastShowCameras` $modelEd; modelEditor -e -joints `optionVar -query playblastShowJoints` $modelEd; modelEditor -e -ikHandles `optionVar -query playblastShowIKHandles` $modelEd; modelEditor -e -deformers `optionVar -query playblastShowDeformers` $modelEd; modelEditor -e -dynamics `optionVar -query playblastShowDynamics` $modelEd; modelEditor -e -dynamics `optionVar -query playblastShowParticleInstancers` $modelEd; modelEditor -e -fluids `optionVar -query playblastShowFluids` $modelEd; modelEditor -e -hairSystems `optionVar -query playblastShowHairSystems` $modelEd; modelEditor -e -follicles `optionVar -query playblastShowFollicles` $modelEd; modelEditor -e -nCloths `optionVar -query playblastShowNCloths` $modelEd; modelEditor -e -nParticles `optionVar -query playblastShowNParticles` $modelEd; modelEditor -e -nRigids `optionVar -query playblastShowNRigids` $modelEd; modelEditor -e -dynamicConstraints `optionVar -query playblastShowDynamicConstraints` $modelEd; modelEditor -e -locators `optionVar -query playblastShowLocators` $modelEd; modelEditor -e -dimensions `optionVar -query playblastShowDimensions` $modelEd; modelEditor -e -pivots `optionVar -query playblastShowPivots` $modelEd; modelEditor -e -handles `optionVar -query playblastShowHandles` $modelEd; modelEditor -e -textures `optionVar -query playblastShowTextures` $modelEd; modelEditor -e -strokes `optionVar -query playblastShowStrokes` $modelEd; modelEditor -e -motionTrails `optionVar -query playblastShowMotionTrails` $modelEd; modelEditor -e -pluginShapes `optionVar -query playblastShowPluginShapes` $modelEd; modelEditor -e -manipulators `optionVar -query playblastShowManipulators` $modelEd; modelEditor -e -clipGhosts `optionVar -query playblastShowClipGhosts` $modelEd; modelEditor -e -greasePencils `optionVar -query playblastShowGreasePencils` $modelEd; string $pluginFilters[] = `pluginDisplayFilter -q -listFilters`; string $playblastExclude[] = {}; if (`optionVar -exists playblastShowPluginObjects`) { $playblastExclude = `optionVar -q playblastShowPluginObjects`; } string $filter; for ($filter in $pluginFilters) { int $show = (stringArrayFind($filter, 0, $playblastExclude) == -1); modelEditor -e -pluginObjects $filter $show $modelEd; } modelEditor -e -cv `optionVar -query playblastShowCVs` $modelEd; modelEditor -e -hulls `optionVar -query playblastShowHulls` $modelEd; modelEditor -e -grid `optionVar -query playblastShowGrid` $modelEd; modelEditor -e -hud `optionVar -query playblastShowHUD` $modelEd; modelEditor -e -hos `optionVar -query playblastShowHoldOuts` $modelEd; modelEditor -e -sel `optionVar -query playblastShowSelectionHighlighting` $modelEd; modelEditor -e -imagePlane `optionVar -query playblastShowImagePlane` $modelEd; } // Creation Date: 11 Nov 98 // // Description: // doPlayblastArgList allows for a variable number // or arguments to be passed in through a string array. // This is not possible through the fixed-arg proc doPlayblast // // Input Arguments: // $version: The version of this option box. Used to know how to // interpret the $args array. // "1" : $whichRange, $timeRange, $option, $hierarchy, // $doControlPoints, $doShapes, $useChannelBox, // $selectionConnection // "2" : $options // // $args // Version 1 // [0] $saveIt 0/1 // [1] $movie name of movie if $saveIt is 1 // [2] $isViewer 0/1 // [3] $format avi/qt/sgi/iff or the older image/movie // [4] $showOrnaments 0/1 // [5] $scale scale source images by this amount // [6] $compression string // [7] $displaySource what do we use to determine movie width/height // 1 : Use current view // 2 : Use Render Globals // 3 : Use values specified from option box // [8] $displayWidth requested width of movie // [9] $displayHeight requested height of movie // // Version 2 // [10] $useStartEnd 0 : Use playback range (or highlighted range) // 1 : Use user-specified start/end // [11] $startTime time to start playblast // [12] $endTime time to end playblast // // Version 3 // [13] $clearCache 0 : Leave previous temporary files // 1 : Delete temporary files from all previous // playblasts // [14] $offscreen 0 : Render onscreen -- default // 1 : Render offscreen // [15] $padding number of zeros to pad with // // Version 4 // [16] $sequenceTime 0/1 : Render from Sequencer timeline // // [17] $quality // // Version 5 // [18] $saveDepth 0 : save rgba (default) // 1 : save rgbaz // Return Value: // The number of curves from which keys were cut. // global proc doPlayblastArgList( string $versionStr, string $cameraSetups[], string $cameraIds[], string $args[]) { int $version = $versionStr; string $saveIt = $args[0]; string $movie = $args[1]; int $isViewer = $args[2]; string $format = $args[3]; int $showOrnaments = $args[4]; float $scale = $args[5]; string $compression = $args[6]; int $displaySource = $args[7]; int $displayWidth = $args[8]; int $displayHeight = $args[9]; int $useStartEnd = ($version >= 2 ? $args[10] : 0); float $startTime = ($version >= 2 ? $args[11] : 1.0); float $endTime = ($version >= 2 ? $args[12] : 10.0); int $clearCache = ($version >= 3 ? $args[13] : 1); int $offscreen = ($version >= 3 ? $args[14] : 0); int $padding = ($version >= 3 ? $args[15] : 0); int $sequenceTime = ($version >= 4 ? $args[16] : 0); int $quality = ($version >= 5 ? $args[17] : 0); int $saveDepth = ($version >= 6 ? $args[18] : 0); global string $gPlayBackSlider; string $cmd = "playblast "; // Use given start/end times // if( $useStartEnd ) { $cmd = ( $cmd+"-startTime "+$startTime+" -endTime "+$endTime + " " ); } // Time range of the blast comes from Highlight, or playback // range if no highlight. // else { if( `timeControl -q -rangeVisible $gPlayBackSlider` ) { float $range[] = `timeControl -q -rangeArray $gPlayBackSlider`; // The range query returns the max value as the right edge // of the range. This is really one frame higher than we want // to playblast. // $cmd = ( $cmd + "-startTime " + $range[0] + " -endTime " + ($range[1] - 1.0) + " " ); $startTime = $range[0]; $endTime = $range[1]; } else { $startTime = `playbackOptions -q -min`; $endTime = `playbackOptions -q -max`; } } // if the "Save to File" flag is on and the // file already exists, we need to confirm if the // user wants to overwrite it // string $forceOverwriteFlag = ""; if ($saveIt) { // If the user has specified a target filename for the playblast and // is creating quicktime or avi files, make sure the file has the proper // extension. // if ($format == "qt" || $format == "avi") { // Determine the desired extension for the file // string $desired = ($format == "qt")? ".mov" : ".avi"; // Extract the file's actual extension // string $actual = fileExtension($movie); // If there is no extension or the extension is of the wrong type, // add the correct extension. // if ((size($actual) == 0) || ($actual != $desired)) $movie = $movie + $desired; } // the $movie string can be relative or absolute; // need to resolve it here // string $path = ""; // just the directory path string $filename = ""; // just the filename if ( substring($movie,1,1) != "/" && substring($movie,1,1) != "$" && (size($movie)>1 && substring($movie,2,2) != ":")) { // relative path, get the project's image directory // string $fileRules[] = `workspace -q -fr`; string $imageDir = ""; // default if ($format == "iff") { int $i; for ( $i = 0; $i < size($fileRules); $i += 2 ) { if ( $fileRules[$i] == "images" ) { $imageDir = $fileRules[$i+1]; break; } } } // Do we want to move this to movie? if ($imageDir != "") { $path = (`workspace -q -fn` + "/" + $imageDir + "/"); } else { $path = (`workspace -q -fn` + "/"); } $filename = $movie; } else { // absolute path // int $index = 0; for( $index = size($movie); $index > 0; $index-- ) { if ( substring($movie,$index,$index) == "/" || substring($movie,$index,$index) == "$" ) { break; } } $path = substring($movie,1,$index); $filename = substring($movie,$index+1,size($movie)); } if ($format == "sgi" || $format == "avi" || $format == "qt" ) { // need to check for the ".mv" extension which // is added in the playblast code if it doesn't // already exist // string $tokens[]; tokenize($filename,".",$tokens); if ($format == "avi") { if ( $tokens[size($tokens)-1] != "avi" ) { $filename += ".avi"; } } else if ($format == "qt") { if ( $tokens[size($tokens)-1] != "mov" ) { $filename += ".mov"; } // check if the file is being created in a valid // and existant directory. // if (!`filetest -d $path`) { string $dirListing[] = `workspace -l $path`; return; } } else if ($format == "sgi") { // older linux format if ( $tokens[size($tokens)-1] != "mv" ) { $filename += ".mv"; } } // bring up a confirm dialog if the file already exists // if ( `file -q -exists ($path+$filename)` ) { string $result = `confirmPlayblastOverwrite sgi $movie`; if ( $result == (uiRes("m_doPlayblastArgList.kOk")) ){ $forceOverwriteFlag = " -forceOverwrite "; } else { return; } } } else { // need to check for files with this $movie as the // prefix and ending in ".iff" // int $i; string $regExp = ($filename+"\.*\.iff"); string $dirListing[] = `workspace -l $path`; for ( $i = 0; $i < size($dirListing); $i++ ) { if ( match($regExp,$dirListing[$i]) != "" ) { // fcheck files exists with this prefix // string $result = `confirmPlayblastOverwrite iff $movie`; if ( $result == (uiRes("m_doPlayblastArgList.kOk")) ) { $forceOverwriteFlag = " -forceOverwrite "; break; } else { return; } } } } } // Output format // $cmd = ( $cmd + " -format " + $format ); // See if there's sound in the time slider // int $isSound = `timeControl -q -ds $gPlayBackSlider`; string $sound = `timeControl -q -s $gPlayBackSlider`; if ($isSound) { // Test if it is a single trax or a trax sound if ($sound == "") { // When "Use Trax Sounds" is enabled, all audio in the scene is // considered fair game, though only one can be played by playblast. // We look for the first one that is active during this time range. // string $allSounds[] = `ls -type audio`; // single sound track if (size($allSounds) == 1) { $sound = $allSounds[0]; if ( $format != "iff" ) { $cmd = ( $cmd + " -sound \"" + $sound + "\"" ); } } else if (size($allSounds) > 1) { // useTraxSounds if ( $format != "iff" ) { $cmd = ( $cmd + " -useTraxSounds"); } } } else if ( ($format != "iff") && ($format != "image") ) { // iff and image are the same format. We don't need to specify the // sound since the code that generates the fcheck call will // search for the sound and pass it for fcheck $cmd = ( $cmd + " -sound \"" + $sound + "\"" ); } } if ($saveIt) { if( size( $movie ) > 0 ) { $cmd = ( $cmd + " -filename \"" + $movie + "\"" + $forceOverwriteFlag ); } else { // We have to catch this error; otherwise it throws // up the call stack window. // if( catch( `error((uiRes("m_doPlayblastArgList.kSaveFileError")))` ) ) { return; } } } // Use sequence time // $cmd = ($cmd + " -sequenceTime " + $sequenceTime); // Clear cache // $cmd = ($cmd + " -clearCache " + $clearCache); // Add the viewer flag // $cmd = ( $cmd + " -viewer " + $isViewer ); // Show ornaments // $cmd = ($cmd + " -showOrnaments " + $showOrnaments); // Add the offscreen toggle // if ( $offscreen ) { $cmd = ( $cmd + " -offScreen " ); } // Add the padding // $cmd = ( $cmd + " -fp " + $padding ); // Add the percentage from our scale value // $cmd = ( $cmd + " -percent " + string( int( $scale * 100 ) ) ); // Add the compression and quality // if ($compression == "") { $cmd = ( $cmd + " -compression \"none\""); } else if ($compression != "global") { // TODO internationalization this string. // global is used for get the render setting from the global render settings // this will be used if there is no compression flag set. $cmd = ( $cmd + " -compression \"" + $compression +"\"" ); $cmd = ( $cmd + " -quality " + $quality ); } // Display size // switch ($displaySource) { case 1: break; case 3: $cmd = ($cmd + " -widthHeight " + $displayWidth + " " + $displayHeight); break; default: string $warnMsg = (uiRes("m_doPlayblastArgList.kNoResolutionSpecified")); // Find the render globals // string $renderGlobals[] = `ls -type renderGlobals`; if (size ($renderGlobals) == 0) { warning ( (uiRes("m_doPlayblastArgList.kUnableToFindRenderGlobals")) ); return; } string $connections[] = `listConnections $renderGlobals[0]`; if (size ($connections) == 0) { warning ($warnMsg); return; } // Find the default resolution node // string $resolutionNode = ""; for ($i = 0; $i < size ($connections); $i++) { if (`nodeType $connections[$i]` == "resolution") { $resolutionNode = $connections[$i]; } } if (size ($resolutionNode) == 0) { warning ($warnMsg); return; } int $resDisplayWidth = `getAttr ($resolutionNode + ".width")`; int $resDisplayHeight = `getAttr ($resolutionNode + ".height")`; $cmd = ($cmd+" -widthHeight "+$resDisplayWidth+" "+$resDisplayHeight); break; } // Add camera setups + ids pairs (-cs { }, -cs { }...) if (size($cameraSetups) == size($cameraIds) && size($cameraSetups) > 0) { for ($i=0; $i