// $Id: createRenderPipeCommonGlobalsTab.mel,v 1.2 2003/07/25 07:14:32 ajh Exp $ // // RenderPipe for Maya // Common Render Globals Tab for Maya 5 // // Copyright (C) 1999-2003 ART VPS Ltd. // Portions copyright (C) 1997-2003 Alias|Wavefront, used under license // // Derived mainly from createMayaSoftwareCommonGlobalsTab.mel // // Globals: // adjustRenderPipeDeviceAspect(string $nodeName) // adjustRenderPipePixelAspect(string $nodeName) // changeRenderPipeAspectLockHeight() // changeRenderPipeAspectLockWidth() // changeRenderPipeCamera() // changeRenderPipeFileNameFormat() // changeRenderPipeFileNamePrefix() // changeRenderPipeImageFormat() // changeRenderPipeResolution() // changeRenderPipeUseCustomExtension() // checkRenderPipeAspectLock(string $nodeName) // checkRenderPipeAspectLockHeight(string $nodeName) // checkRenderPipeAspectLockWidth(string $nodeName) // createRenderPipeCommonGlobalsTab() // createRenderPipeCommonResolution() // updateRenderPipeCameraControl() // updateRenderPipeCommonGlobalsTab() // updateRenderPipeCustomExtensionControl() // updateRenderPipeDeviceAspectRatio() // updateRenderPipeFileNameFormatControl() // updateRenderPipeFileNamePrefixControl() // updateRenderPipeFrameNumberControls() // updateRenderPipeImageFormatControl() // updateRenderPipeResolution() // updateRenderPipeTargetFilePreview() // updateRenderPipeUseCustomExtensionControl() // proc setParentToCommonTab() { setParent `rendererTabLayoutName("RenderPipe")`; setParent commonTabColumn; } // ---------------------------------------------------------------------------- // Code to create and update the file name preview area // proc createTargetFilePreview() { string $oldParent = `setParent -query`; columnLayout -adjustableColumn true rpTargetFilePreview; text -align "left" -font "boldLabelFont" -label "Path" rpFilePath; text -align "left" -font "boldLabelFont" -label "File Name" rpStartFileName; text -align "left" -font "boldLabelFont" -label "To" rpEndFileName; setParent $oldParent; // This target file preview is affected by a number of attributes. // If any of those attributes change, this preview needs to be updated. // // Here we fill an array with the names of all of the current renderer's // attributes which affect the naming of the target file. // string $attrArray[]; $attrArray[size($attrArray)] = "defaultRenderGlobals.imageFilePrefix"; $attrArray[size($attrArray)] = "defaultRenderGlobals.outFormatControl"; $attrArray[size($attrArray)] = "defaultRenderGlobals.imageFormat"; $attrArray[size($attrArray)] = "defaultRenderGlobals.outFormatExt"; $attrArray[size($attrArray)] = "defaultRenderGlobals.animation"; $attrArray[size($attrArray)] = "defaultRenderGlobals.imageFormat"; $attrArray[size($attrArray)] = "defaultRenderGlobals.byFrameStep"; $attrArray[size($attrArray)] = "defaultRenderGlobals.extensionPadding"; $attrArray[size($attrArray)] = "defaultRenderGlobals.startFrame"; $attrArray[size($attrArray)] = "defaultRenderGlobals.endFrame"; $attrArray[size($attrArray)] = "defaultRenderGlobals.modifyExtension"; $attrArray[size($attrArray)] = "defaultRenderGlobals.startExtension"; $attrArray[size($attrArray)] = "defaultRenderGlobals.byExtension"; $attrArray[size($attrArray)] = "defaultRenderGlobals.periodInExt"; $attrArray[size($attrArray)] = "defaultResolution.fields"; $attrArray[size($attrArray)] = "defaultRenderGlobals.fieldExtControl"; $attrArray[size($attrArray)] = "defaultRenderGlobals.oddFieldExt"; $attrArray[size($attrArray)] = "defaultRenderGlobals.evenFieldExt"; $attrArray[size($attrArray)] = "defaultRenderGlobals.putFrameBeforeExt"; // Now we establish scriptJobs to invoke the procedure which updates the // target file preview when any of the above attributes change. // int $i; for ($i = 0; $i < size($attrArray); $i++) { scriptJob -attributeChange $attrArray[$i] "updateRenderPipeTargetFilePreview" -parent rpTargetFilePreview; } scriptJob -parent rpTargetFilePreview -event workspaceChanged "updateRenderPipeTargetFilePreview"; } proc int isMultiframeFormat(string $format) { if (getApplicationVersionAsFloat() >= 5.01) { return multiframeFormat ($format); } else { return UNIFIED_multiframeFormat ($format); } } global proc updateRenderPipeTargetFilePreview() { // // Description: // This procedure is called any time an attribute change occurs which // would affect the name(s) of the file(s) that would be created when the // user performs a render. // This procedure updates the lines of text in the General tab that allow // the user to see what files are going to be created when they render. // string $oldParent = `setParent -query`; string $renderer = "RenderPipe"; string $tabLayout = rendererTabLayoutName($renderer); setParent $tabLayout; // // Update the Path portion of the preview. // // relative path, get the project's image directory // string $fileRules[] = `workspace -q -rt`; int $i; string $imageDir = ""; // default for ($i = 0; $i < size($fileRules); $i += 2) { if ($fileRules[$i] == "images") { $imageDir = "/" + $fileRules[$i+1]; break; } } $path = " Path: "+(`workspace -q -fn` + $imageDir + "/"); text -edit -label $path rpFilePath; // // Update the File Name portion of the preview. // string $title1 = " File Name: "; string $title2 = " To: "; string $prefix = `getAttr defaultRenderGlobals.imageFilePrefix`; if ($prefix == "") { string $sceneName = `file -q -sn`; if (size($sceneName) == 0) { $prefix = "untitled"; } else { string $buffer[]; tokenize $sceneName "/\\" $buffer; string $tail = $buffer[size($buffer) - 1]; tokenize $tail "." $buffer; $tail = $buffer[0]; $prefix = $tail; } } // Image extension string $imageType; int $imageUse = `getAttr "defaultRenderGlobals.outFormatControl"`; if ($imageUse == 1) { // Don't use extension $imageType = ""; } else if ($imageUse == 0) { // Show the extension global string $imgExt[]; // This is the actual file extension global int $imgExtNum[]; // This is the corresponding internal value int $imageNum = `getAttr "defaultRenderGlobals.imageFormat"`; for ($i=0; $i < size($imgExtNum); ++$i) { if ($imageNum == $imgExtNum[$i]) { $imageType = $imgExt[$i]; break; } } } else if ($imageUse == 2) { // User specified $imageType = `getAttr "defaultRenderGlobals.outFormatExt"` ; } // Frames number extension string $frame1 = ""; string $frame2 = ""; int $useAnim = `getAttr "defaultRenderGlobals.animation"`; // If we have an animation file format, then we do not need frame number. // if ($useAnim) { if (isMultiframeFormat($imageType)) { $useAnim = 0; } } // Put the dot in front of the image type if the image type is not an // empty string. // if ($imageType != "") { $imageType = "." + $imageType; } if ($useAnim) { // if useAnim, make sure it's not a movie format, or else // bad extension names will be printed out to the window. int $imgFormat = `getAttr "defaultRenderGlobals.imageFormat"`; if ($imgFormat == 21 || $imgFormat == 22 || $imgFormat == 23) $useAnim = 0; } if ($useAnim) { float $byf = `getAttr defaultRenderGlobals.byFrameStep`; if ($byf == 0.0) $byf = 0.00001; int $pad = `getAttr "defaultRenderGlobals.extensionPadding"`; int $f1 = `getAttr "defaultRenderGlobals.startFrame"`; int $f2 = `getAttr "defaultRenderGlobals.endFrame"`; int $numFrames = ($f2 - $f1) / $byf; // Check to see if the numbers are being modified if (`getAttr "defaultRenderGlobals.modifyExtension"`) { $f1 = `getAttr defaultRenderGlobals.startExtension`; $f2 = $f1 + ($numFrames * `getAttr defaultRenderGlobals.byExtension`); } // Convert to strings $frame1 = $f1; $frame2 = $f2; // Pad the numbers for ($i=size($frame1); $i<$pad; $i++) { $frame1 = "0"+$frame1; } if (`getAttr "defaultRenderGlobals.periodInExt"`) { $frame1 = "."+$frame1; } for ($i=size($frame2); $i<$pad; $i++) { $frame2 = "0"+$frame2; } if (`getAttr "defaultRenderGlobals.periodInExt"`) { $frame2 = "."+$frame2; } } // Check for fields string $fieldExt = ""; int $whichFields = `getAttr defaultResolution.fields`; int $useFields = ($whichFields != 0); int $useFieldExt = (`getAttr "defaultRenderGlobals.fieldExtControl"` != 1); int $defFieldExt = (`getAttr "defaultRenderGlobals.fieldExtControl"` == 0); int $useCustom = (`getAttr "defaultRenderGlobals.fieldExtControl"` == 2); // Note that I am not using a "." in front of these. // That's the way the code works now. // I think that there should be a "." // if ($useFields && $useFieldExt) { // Add fields to the file name if ($defFieldExt) { if ($whichFields == 1) $fieldExt = "o"; if ($whichFields == 2) $fieldExt = "e"; if ($whichFields == 3 || $whichFields == 4) $fieldExt = "e (o)"; } else if ($useCustom) { if ($whichFields == 1) { $fieldExt = `getAttr "defaultRenderGlobals.oddFieldExt"`; } if ($whichFields == 2) { $fieldExt = `getAttr "defaultRenderGlobals.evenFieldExt"`; } if ($whichFields == 3 || $whichFields == 4) { $fieldExt = `getAttr "defaultRenderGlobals.oddFieldExt"` + " (" + `getAttr "defaultRenderGlobals.evenFieldExt"` + ")"; } } } // Now put them all together to show what is going to happen int $frameBeforeExt = `getAttr "defaultRenderGlobals.putFrameBeforeExt"`; // 0=ext.frame, 1=frame.ext if ($frameBeforeExt == 0) { text -edit -label ($title1+$prefix+$imageType+$frame1+$fieldExt) rpStartFileName; if ($useAnim) { text -edit -label ($title2+$prefix+$imageType+$frame2+$fieldExt) rpEndFileName; } else { text -edit -label "" rpEndFileName; } } else { text -edit -label ($title1+$prefix+$frame1+$fieldExt+$imageType) rpStartFileName; if ($useAnim) { text -edit -label ($title2+$prefix+$frame2+$fieldExt+$imageType) rpEndFileName; } else { text -edit -label "" rpEndFileName; } } setParent $oldParent; } // ---------------------------------------------------------------------------- // Code to create and update the Image File Output frame // proc createFileNamePrefixControl() { // Create the control // textFieldGrp -label "File Name Prefix" -changeCommand ("changeRenderPipeFileNamePrefix") RenderPipeFileName; // Create a scriptJob which will update the control when the value of the // attribute it represents is changed. // scriptJob -parent RenderPipeFileName -attributeChange "defaultRenderGlobals.imageFilePrefix" "updateRenderPipeFileNamePrefixControl"; } global proc changeRenderPipeFileNamePrefix() { setParentToCommonTab(); string $prefix = `textFieldGrp -query -text RenderPipeFileName`; string $prefixAttr = "defaultRenderGlobals.imageFilePrefix"; if ( $prefix != "(not set; using filename)" && isValidFileNamePrefix($prefix)) { // The user has set the prefix to something, and it is a valid name, so // we will set the value of the corresponding attribute. // setAttr $prefixAttr -type "string" $prefix; } else { // The user has set the prefix to an invalid value. We will refresh the // UI to show the current value, which has not been changed. // updateRenderPipeFileNamePrefixControl(); } } global proc updateRenderPipeFileNamePrefixControl() // // Procedure Name: // changeFileName // // Description: // This procedure is called when the user changes the file // prefix. It sets the internal representation of the prefix // and then updates the example to show the changes. // { string $oldParent = `setParent -query`; setParentToCommonTab(); string $prefixAttr = "defaultRenderGlobals.imageFilePrefix"; string $prefix = `getAttr $prefixAttr`; if (size($prefix) > 0) { textFieldGrp -edit -text $prefix RenderPipeFileName; } else { textFieldGrp -edit -text "(not set; using filename)" RenderPipeFileName; } setParent $oldParent; } proc createFileNameFormatControl() { optionMenuGrp -label "Frame/Animation Ext" -changeCommand ("changeRenderPipeFileNameFormat") rpExtMenu; menuItem -label "name (Single Frame)"; menuItem -label "name.ext (Single Frame)"; menuItem -label "name.#.ext" renderPipeNameDotFrameDotExtension; menuItem -label "name.ext.#" renderPipeNameDotExtensionDotFrame; menuItem -label "name.#" renderPipeNameDotFrame; menuItem -label "name#.ext" renderPipeFrameDotExtension; // New for Maya 5.0.1 if (getApplicationVersionAsFloat() >= 5.01) { menuItem -label "name (Multi Frame)" renderPipeMultiFrame; menuItem -label "name.ext (Multi Frame)" renderPipeMultiFrameDotExtension; } string $attrArray[]; $attrArray[size($attrArray)] = "defaultRenderGlobals.outFormatControl"; $attrArray[size($attrArray)] = "defaultRenderGlobals.animation"; $attrArray[size($attrArray)] = "defaultRenderGlobals.periodInExt"; $attrArray[size($attrArray)] = "defaultRenderGlobals.putFrameBeforeExt"; $attrArray[size($attrArray)] = "defaultRenderGlobals.imageFormat"; // Now we establish scriptJobs to invoke the procedure which updates the // file name format control when any of the above attributes change. // int $i; for ($i = 0; $i < size($attrArray); $i++) { scriptJob -attributeChange $attrArray[$i] "updateRenderPipeFileNameFormatControl" -parent rpExtMenu; } } global proc changeRenderPipeFileNameFormat() // // Procedure Name: // changeExtension // // Description: // This procedure is called when the user changes the format // of the file extension. It sets the internal representation // and then updates the example to show the changes. // // Note: // Although the user sees only one control to change the // extension, it actually affects more than one value. // { setParentToCommonTab(); global string $imgExt[]; // This is the actual file extension global int $imgExtNum[]; // This is the corresponding internal value int $item = `optionMenuGrp -q -sl rpExtMenu`; int $imageFormatNum = `getAttr defaultRenderGlobals.imageFormat`; int $multiframe = isMultiframeFormat(extOfImageFormat($imageFormatNum)); // print ("changeExtension to " // + $ext // + " " // + $imgExt[$ext] // + "\nmultiframe " // + $multiframe + "\n"); if ($item == 1) // "name" { // Animation off // setAttr defaultRenderGlobals.animation 0; // No image file format type // setAttr defaultRenderGlobals.outFormatControl 1; setAttr "defaultRenderGlobals.periodInExt" 1; } else if ($item == 2) // "name.ext" { // Animation off // setAttr defaultRenderGlobals.animation 0; if (`checkBoxGrp -q -v1 rpUseCustomExtensionCtrl`) { // Override image file format type // setAttr defaultRenderGlobals.outFormatControl 2; } else { // Standard image file format type // setAttr defaultRenderGlobals.outFormatControl 0; } setAttr "defaultRenderGlobals.periodInExt" 1; } else if ($item == 3) // "name.#.ext" { // Animation on // setAttr defaultRenderGlobals.animation 1; if (`checkBoxGrp -q -v1 rpUseCustomExtensionCtrl`) { // Override image file format type // setAttr defaultRenderGlobals.outFormatControl 2; } else { // Standard image file format type // setAttr defaultRenderGlobals.outFormatControl 0; } setAttr "defaultRenderGlobals.putFrameBeforeExt" 1; setAttr "defaultRenderGlobals.periodInExt" 1; } else if ($item == 4) // "name.ext.#" { // Animation on // setAttr defaultRenderGlobals.animation 1; if (`checkBoxGrp -q -v1 rpUseCustomExtensionCtrl`) { // Override image file format type // setAttr defaultRenderGlobals.outFormatControl 2; } else { // Standard image file format type // setAttr defaultRenderGlobals.outFormatControl 0; } setAttr "defaultRenderGlobals.putFrameBeforeExt" 0; setAttr "defaultRenderGlobals.periodInExt" 1; } else if ($item == 5) // "name.#" { // Animation on // setAttr defaultRenderGlobals.animation 1; // No image file format type // setAttr defaultRenderGlobals.outFormatControl 1; setAttr "defaultRenderGlobals.periodInExt" 1; } else if ($item == 6) // "name#.ext" { // Animation on // setAttr defaultRenderGlobals.animation 1; if (`checkBoxGrp -q -v1 rpUseCustomExtensionCtrl`) { // Override image file format type // setAttr defaultRenderGlobals.outFormatControl 2; } else { // Standard image file format type // setAttr defaultRenderGlobals.outFormatControl 0; } setAttr "defaultRenderGlobals.putFrameBeforeExt" 1; setAttr "defaultRenderGlobals.periodInExt" 0; } else if ($item == 7) // "name (Multi Frame)" { // Animation on // setAttr defaultRenderGlobals.animation 1; // No image file format type // setAttr defaultRenderGlobals.outFormatControl 1; setAttr "defaultRenderGlobals.periodInExt" 1; } else if ($item == 8) // "name.ext (Multi Frame)" { // Animation on // setAttr defaultRenderGlobals.animation 1; if (`checkBoxGrp -q -v1 useCustomExtensionCtrl`) { // Override image file format type // setAttr defaultRenderGlobals.outFormatControl 2; } else { // Standard image file format type // setAttr defaultRenderGlobals.outFormatControl 0; } setAttr "defaultRenderGlobals.periodInExt" 1; } // Update the batch render window if it exists // if (`exists updateBatchRenderWindowTitle`) { updateBatchRenderWindowTitle(); } } global proc updateRenderPipeFileNameFormatControl() { string $oldParent = `setParent -query`; setParentToCommonTab(); int $frameBeforeExt = `getAttr "defaultRenderGlobals.putFrameBeforeExt"`; int $useAnim = `getAttr "defaultRenderGlobals.animation"`; int $imageUse = `getAttr "defaultRenderGlobals.outFormatControl"`; int $period = `getAttr "defaultRenderGlobals.periodInExt"`; int $imageFormatNum = `getAttr "defaultRenderGlobals.imageFormat"`; int $multiframe = isMultiframeFormat(extOfImageFormat($imageFormatNum)); int $activeMenuItem = 0; if (getApplicationVersionAsFloat() >= 5.01) { // Update Frame/Animation Ext menuItems and enable only the relevant ones. // menuItem -edit -enable (!$multiframe) renderPipeNameDotFrameDotExtension; menuItem -edit -enable (!$multiframe) renderPipeNameDotExtensionDotFrame; menuItem -edit -enable (!$multiframe) renderPipeNameDotFrame; menuItem -edit -enable (!$multiframe) renderPipeFrameDotExtension; menuItem -edit -enable $multiframe renderPipeMultiFrame; menuItem -edit -enable $multiframe renderPipeMultiFrameDotExtension; } if ($multiframe) { if ($useAnim && getApplicationVersionAsFloat() >= 5.01) { if ($imageUse == 1) // no extension { $activeMenuItem = 7; } else { $activeMenuItem = 8; } } else { if ($imageUse == 1) // no extension { $activeMenuItem = 1; } else { $activeMenuItem = 2; } } } else { if ($useAnim) { if ($imageUse == 1) { $activeMenuItem = 5; } else { if ($frameBeforeExt == 0) { $activeMenuItem = 4; } else { if ($period == 0) { $activeMenuItem = 6; } else { $activeMenuItem = 3; } } } } else { if ($imageUse == 1) { $activeMenuItem = 1; } else { $activeMenuItem = 2; } } } optionMenuGrp -edit -sl $activeMenuItem rpExtMenu; // Also update the frame number controls to enable/disable them according // to whether or not they are being used. // updateRenderPipeFrameNumberControls(); setParent $oldParent; } proc createUseCustomExtensionControl() { checkBoxGrp -numberOfCheckBoxes 1 -label "" -label1 "Use Custom Extension:" -changeCommand "changeRenderPipeUseCustomExtension" rpUseCustomExtensionCtrl; scriptJob -parent rpUseCustomExtensionCtrl -attributeChange "defaultRenderGlobals.outFormatControl" "updateRenderPipeUseCustomExtensionControl"; } global proc updateRenderPipeUseCustomExtensionControl() { string $oldParent = `setParent -query`; setParentToCommonTab(); int $useImage = (`getAttr "defaultRenderGlobals.outFormatControl"` != 1); checkBoxGrp -edit -value1 (`getAttr "defaultRenderGlobals.outFormatControl"` == 2) -enable $useImage rpUseCustomExtensionCtrl; setParent $oldParent; } global proc changeRenderPipeUseCustomExtension() { // TODO: Update docs // // Procedure Name: // changeCustomExtensionCheck // // Description: // This procedure is called when the user turns the custom // extension on or off. It sets the internal representation // and then updates the example to show the changes. // setParentToCommonTab(); int $isOn = `checkBoxGrp -query -value1 rpUseCustomExtensionCtrl`; if ($isOn) { setAttr defaultRenderGlobals.outFormatControl 2; } else { // We have to figure out if there should be an extension // at all or not. // int $item = `optionMenuGrp -query -select rpExtMenu`; if ($item == 1 || $item == 5) { setAttr defaultRenderGlobals.outFormatControl 1; } else { setAttr defaultRenderGlobals.outFormatControl 0; } } } proc createCustomExtensionControl() { attrControlGrp -label "" -attribute defaultRenderGlobals.outFormatExt rpUserExt; scriptJob -parent rpUserExt -attributeChange "defaultRenderGlobals.outFormatControl" "updateRenderPipeCustomExtensionControl"; } global proc updateRenderPipeCustomExtensionControl() { string $oldParent = `setParent -query`; setParentToCommonTab(); // TODO: Find a better name for value1 int $useImage = (`getAttr "defaultRenderGlobals.outFormatControl"` != 1); int $value1 = (`getAttr "defaultRenderGlobals.outFormatControl"` == 2); int $useExt = $useImage && $value1; attrControlGrp -edit -enable $useExt rpUserExt; setParent $oldParent; } proc createCompressorControlForMac(int $item) { global string $imgExt[]; rowLayout -adjustableColumn true -nc 4 ; text -l ""; button -l "Compression..." -width 80 -enable false -c "movieCompressor -softwareOptions" renderGlobalsCompression; text -l ""; text -l ""; setParent ..; if($imgExt[$item] == "qt"){ button -e -enable true renderGlobalsCompression; } } proc enableMacCompressorbutton(int $item) { global int $imgExtNum[]; if(`about -mac`){ if($imgExtNum[$item] == 22){ button -e -enable true renderGlobalsCompression; }else{ button -e -enable false renderGlobalsCompression; } } } proc createImageFormatControl() { string $parent = `setParent -query`; // These tables translate between the internal representation of the // image formats and the UI that is presented to the user. // // Fill up the below tables alphabetically. // NOTE !!!! WARNING !!!! NOTE !!!! WARNING !!!! NOTE !!!! WARNING !!!! // If you are changing one of the menuItem fields below or adding new ones // or whatever, be certain to also update the fields in the // 'createImageFormats()' procedure of createImageFormats.mel // // TODO: There has got to be a better way of implementing this mechanism. optionMenuGrp -label "Image Format" -changeCommand "changeRenderPipeImageFormat" rpImageMenu; if (`about -nt`) { menuItem -label "Alias PIX (als)"; // $imgExt[0] = "als"; $imgExtNum[0] = 6; menuItem -label "AVI (avi)"; // $imgExt[1] = "avi"; $imgExtNum[1] = 23; menuItem -label "Cineon (cin)"; // $imgExt[2] = "cin"; $imgExtNum[2] = 11; menuItem -label "EPS (eps)"; // $imgExt[3] = "eps"; $imgExtNum[3] = 9; menuItem -label "GIF (gif)"; // $imgExt[4] = "gif"; $imgExtNum[4] = 0; menuItem -label "JPEG (jpeg)"; // $imgExt[5] = "jpeg"; $imgExtNum[5] = 8; menuItem -label "Maya IFF (iff)"; // $imgExt[6] = "iff"; $imgExtNum[6] = 7; menuItem -label "Maya16 IFF (iff)"; // $imgExt[7] = "iff"; $imgExtNum[7] = 10; menuItem -label "Quantel (yuv)"; // $imgExt[8] = "yuv"; $imgExtNum[8] = 12; menuItem -label "RLA (rla)"; // $imgExt[9] = "rla"; $imgExtNum[9] = 2; menuItem -label "SGI (sgi)"; // $imgExt[10] = "sgi"; $imgExtNum[10] = 5; menuItem -label "SGI16 (sgi)"; // $imgExt[11] = "sgi"; $imgExtNum[11] = 13; menuItem -label "SoftImage (pic)"; // $imgExt[12] = "pic"; $imgExtNum[12] = 1; menuItem -label "Targa (tga)"; // $imgExt[13] = "tga"; $imgExtNum[13] = 19; menuItem -label "Tiff (tif)"; // $imgExt[14] = "tif"; $imgExtNum[14] = 3; menuItem -label "Tiff16 (tif)"; // $imgExt[15] = "tif"; $imgExtNum[15] = 4; menuItem -label "Windows Bitmap (bmp)"; // $imgExt[16] = "bmp"; $imgExtNum[16] = 20; } else if (`about -irix`) { menuItem -label "Alias PIX (als)"; // $imgExt[0] = "als"; $imgExtNum[0] = 6; menuItem -label "AVI (avi)"; // $imgExt[1] = "avi"; $imgExtNum[1] = 23; menuItem -label "Cineon (cin)"; // $imgExt[2] = "cin"; $imgExtNum[2] = 11; menuItem -label "EPS (eps)"; // $imgExt[3] = "eps"; $imgExtNum[3] = 9; menuItem -label "GIF (gif)"; // $imgExt[4] = "gif"; $imgExtNum[4] = 0; menuItem -label "JPEG (jpeg)"; // $imgExt[5] = "jpeg"; $imgExtNum[5] = 8; menuItem -label "Maya IFF (iff)"; // $imgExt[6] = "iff"; $imgExtNum[6] = 7; menuItem -label "Maya16 IFF (iff)"; // $imgExt[7] = "iff"; $imgExtNum[7] = 10; menuItem -label "Quantel (yuv)"; // $imgExt[8] = "yuv"; $imgExtNum[8] = 12; menuItem -label "Quicktime (qt)"; // $imgExt[9] = "qt"; $imgExtNum[9] = 22; menuItem -label "RLA (rla)"; // $imgExt[10] = "rla"; $imgExtNum[10] = 2; menuItem -label "SGI (sgi)"; // $imgExt[11] = "sgi"; $imgExtNum[11] = 5; menuItem -label "SGI16 (sgi)"; // $imgExt[12] = "sgi"; $imgExtNum[12] = 13; menuItem -label "SGI Movie (mv)"; // $imgExt[13] = "mv"; $imgExtNum[13] = 21; menuItem -label "SoftImage (pic)"; // $imgExt[14] = "pic"; $imgExtNum[14] = 1; menuItem -label "Targa (tga)"; // $imgExt[15] = "tga"; $imgExtNum[15] = 19; menuItem -label "Tiff (tif)"; // $imgExt[16] = "tif"; $imgExtNum[16] = 3; menuItem -label "Tiff16 (tif)"; // $imgExt[17] = "tif"; $imgExtNum[17] = 4; menuItem -label "Windows Bitmap (bmp)"; // $imgExt[18] = "bmp"; $imgExtNum[18] = 20; } else if (`about -linux`) { menuItem -label "Alias PIX (als)"; // $imgExt[0] = "als"; $imgExtNum[0] = 6; menuItem -label "Cineon (cin)"; // $imgExt[1] = "cin"; $imgExtNum[1] = 11; menuItem -label "EPS (eps)"; // $imgExt[2] = "eps"; $imgExtNum[2] = 9; menuItem -label "GIF (gif)"; // $imgExt[3] = "gif"; $imgExtNum[3] = 0; menuItem -label "JPEG (jpeg)"; // $imgExt[4] = "jpeg"; $imgExtNum[4] = 8; menuItem -label "Maya IFF (iff)"; // $imgExt[5] = "iff"; $imgExtNum[5] = 7; menuItem -label "Maya16 IFF (iff)"; // $imgExt[6] = "iff"; $imgExtNum[6] = 10; menuItem -label "Quantel (yuv)"; // $imgExt[7] = "yuv"; $imgExtNum[7] = 12; menuItem -label "RLA (rla)"; // $imgExt[8] = "rla"; $imgExtNum[8] = 2; menuItem -label "SGI (sgi)"; // $imgExt[9] = "sgi"; $imgExtNum[9] = 5; menuItem -label "SGI16 (sgi)"; // $imgExt[10] = "sgi"; $imgExtNum[10] = 13; menuItem -label "SoftImage (pic)"; // $imgExt[11] = "pic"; $imgExtNum[11] = 1; menuItem -label "Targa (tga)"; // $imgExt[12] = "tga"; $imgExtNum[12] = 19; menuItem -label "Tiff (tif)"; // $imgExt[13] = "tif"; $imgExtNum[13] = 3; menuItem -label "Tiff16 (tif)"; // $imgExt[14] = "tif"; $imgExtNum[14] = 4; menuItem -label "Windows Bitmap (bmp)"; // $imgExt[15] = "bmp"; $imgExtNum[15] = 20; } else if (`about -mac`) { menuItem -label "JPEG (jpeg)"; // $imgExt[0] = "jpeg"; $imgExtNum[0] = 8; menuItem -label "Maya IFF (iff)"; // $imgExt[1] = "iff"; $imgExtNum[1] = 7; menuItem -label "Maya16 IFF (iff)"; // $imgExt[2] = "iff"; $imgExtNum[2] = 10; menuItem -label "MacPaint (pntg)"; // $imgExt[3] = "pntg"; $imgExtNum[3] = 30; menuItem -label "Photoshop (ps)"; // $imgExt[4] = "ps"; $imgExtNum[4] = 31; menuItem -label "PNG (png)"; // $imgExt[5] = "png"; $imgExtNum[5] = 32; menuItem -label "QuickDraw (pict)"; // $imgExt[6] = "pict"; $imgExtNum[6] = 33; menuItem -label "Quicktime Movie (qt)"; // $imgExt[7] = "qt"; $imgExtNum[7] = 22; menuItem -label "Quicktime Image (qtif)";// $imgExt[8] = "qtif"; $imgExtNum[8] = 34; menuItem -label "Silicon Graphics (sgi)";// $imgExt[9] = "sgi"; $imgExtNum[9] = 5; menuItem -label "Targa (tga)"; // $imgExt[10] = "tga"; $imgExtNum[10] = 19; menuItem -label "Tiff (tif)"; // $imgExt[11] = "tif"; $imgExtNum[11] = 3; menuItem -label "Windows Bitmap (bmp)"; // $imgExt[12] = "bmp"; $imgExtNum[12] = 20; } else { warning "Unsupported platform in unifiedRenderGlobalsWindow.mel"; } scriptJob -parent $parent -attributeChange "defaultRenderGlobals.imageFormat" "updateRenderPipeImageFormatControl"; } global proc updateRenderPipeImageFormatControl() { string $oldParent = `setParent -query`; global string $imgExt[]; // This is the actual file extension global int $imgExtNum[]; // This is the corresponding internal value int $imageNum = `getAttr "defaultRenderGlobals.imageFormat"`; for ($i=0; $i < size($imgExtNum); ++$i) { if ($imageNum == $imgExtNum[$i]) { optionMenuGrp -edit -sl ($i+1) rpImageMenu; enableMacCompressorbutton($i); break; } } setParent $oldParent; } global proc changeRenderPipeImageFormat() { // // Procedure Name: // changeImageFormat // // Description: // This procedure is called when the user changes the type of // image that will be written out. It sets the internal // representation and then updates the example to show the changes. // setParentToCommonTab(); global string $imgExt[]; // This is the actual file extension global int $imgExtNum[]; // This is the corresponding internal value int $item = `optionMenuGrp -q -sl rpImageMenu` - 1; setAttr defaultRenderGlobals.imageFormat $imgExtNum[$item]; enableMacCompressorbutton($item); // Check if the image format is IFF. // // Note: there are two IFF image types. One for 8 bit images // and one for 16 bit images. They both have an imgExt of iff. if ($imgExt[$item] != "iff") { int $useBlur = `getAttr defaultRenderGlobals.motionBlur`; int $blur2d = (`getAttr defaultRenderGlobals.motionBlurType` == 0); int $keepMotionVector = (`getAttr defaultRenderGlobals.keepMotionVector` == 1); if ($useBlur && $blur2d && $keepMotionVector) { warning ("Non-IFF image formats are not supported when writing"+ " 2D motion vectors; setting image format to IFF"); // Set globals imageFormat to Maya IFF setAttr defaultRenderGlobals.imageFormat 7; } } $item = `optionMenuGrp -q -sl rpImageMenu` - 1; int $multiframe = isMultiframeFormat($imgExt[$item]); if ($multiframe) { setAttr defaultRenderGlobals.animation 1; } // Update the batch render window if it exists. if (`exists updateBatchRenderWindowTitle`) { updateBatchRenderWindowTitle(); } } proc createCameraControl() { //Note: not updating if changed elsewhere // optionMenuGrp -label "Camera" -changeCommand changeRenderPipeCamera RenderPipeCameraMenu; } global proc updateRenderPipeCameraControl() { string $oldParent = `setParent -query`; setParentToCommonTab(); // This is a fix to get around the optionMenuGrp bug (#81337) string $fullName = `setParent "RenderPipeCameraMenu"`; string $menuName = ($fullName+"|OptionMenu"); setParent -m $menuName; string $allCameras[] = `ls -cameras`; string $parents[]; int $i; int $numRenderable = 0; string $cmd; // // First remove any existing menuItems; we're gonna rebuild the menu // from scratch each time. int $numOldMenuItems = `optionMenuGrp -q -ni RenderPipeCameraMenu`; string $oldMenuItems[] = `optionMenuGrp -q -ill RenderPipeCameraMenu`; for ($i = 0; $i < $numOldMenuItems; $i++) { deleteUI $oldMenuItems[$i]; } // Run through the list of all of the cameras and build a // optionMenu of them that the user uses to select the // renderable camera. // // First count how many renderable cameras exist // for ($i = 0; $i < size($allCameras); $i++) { if (`getAttr ($allCameras[$i] + ".renderable")`) { $numRenderable++; } } int $firstRenderable = 0; for ($i = 0; $i < size($allCameras); $i++) { $parents = `listRelatives -p $allCameras[$i]`; string $menuItem = `menuItem -label $parents[0]`; // Use the first renderable camera if (`getAttr ($allCameras[$i] + ".renderable")`) { $firstRenderable++; if ($firstRenderable == 1) { // Selected Camera ----------------------------------------- optionMenuGrp -edit -sl ($i+1) RenderPipeCameraMenu; } if ($numRenderable > 1) { string $camLabel = $parents[0] + " (Renderable)"; menuItem -edit -label $camLabel $menuItem; } } } setParent $oldParent; } global proc changeRenderPipeCamera() { // // Procedure Name: // changeRenderPipeCamera // // Description: // This procedure is called when the user changes the camera // that will be rendered. // It updates the controls for the new camera // setParentToCommonTab(); // // First count how many renderable cameras exist // string $allCameras[] = `ls -cameras`; int $numRenderable = 0; for ($i = 0; $i < size($allCameras); $i++) { if (`getAttr ($allCameras[$i] + ".renderable")`) { $numRenderable++; } } int $camIndex = `optionMenuGrp -query -select RenderPipeCameraMenu` - 1; if ($numRenderable < 2) { for ($i = 0; $i < size($allCameras); $i++) { if ($i == $camIndex) { setAttr ($allCameras[$i] + ".renderable") 1; } else { setAttr ($allCameras[$i] + ".renderable") 0; } } } // Connect the channel controls to the new camera. // string $whichCamera = $allCameras[$camIndex]; attrControlGrp -edit -attribute ($whichCamera + ".image") rpRgbChannel; attrControlGrp -edit -attribute ($whichCamera + ".mask") rpAlphaChannel; attrControlGrp -edit -attribute ($whichCamera + ".depth") rpDepthChannel; // Fix for 160069. The mental ray renderer and the Maya renderer // use the same renderable camera, so the mental ray render globals and // the Maya render globals must be kept in sync when the renderable camera // changes. The following code causes the attribute editor to be // refreshed, just in case it contains the mental ray render globals. // global string $gAEFocusNode; updateAE($gAEFocusNode); } global proc updateRenderPipeFrameNumberControls() { int $useAnim = `getAttr "defaultRenderGlobals.animation"`; int $useCustomExt = `getAttr "defaultRenderGlobals.modifyExtension"`; int $imageFormatNum = `getAttr "defaultRenderGlobals.imageFormat"`; int $multiframe = isMultiframeFormat(extOfImageFormat($imageFormatNum)); attrControlGrp -edit -enable $useAnim rpStartFrameCtrl; attrControlGrp -edit -enable $useAnim rpEndFrameCtrl; attrControlGrp -edit -enable $useAnim rpByFrameStepCtrl; attrControlGrp -edit -enable ($useAnim && !$multiframe) rpExtensionPaddingCtrl; attrControlGrp -edit -enable ($useAnim && !$multiframe) rpModifyExtensionCtrl; attrControlGrp -edit -enable ($useAnim && $useCustomExt && !$multiframe) rpStartExtensionCtrl; attrControlGrp -edit -enable ($useAnim && $useCustomExt && !$multiframe) rpByExtensionCtrl; } proc createCommonImageFile() // // Procedure Name: // createCommonImageFile // // Description: // Creates the UI in the "Image File Output" expand/collapse section. // This section is always created so is treated differently // then the sections created when the tab is expanded. // { string $parent = `setParent -query`; setUITemplate -pushTemplate attributeEditorTemplate; global string $imgExt[]; if (size($imgExt) == 0) { // If the file format array has not been initialized yet, do so. // This routine may be called in dynPaintMenus.mel during the // file save for PFX canvas images. createImageFormats(); } columnLayout -adjustableColumn true; createFileNamePrefixControl(); createFileNameFormatControl(); createImageFormatControl(); if(`about -mac`){ int $item = `optionMenuGrp -q -sl rpImageMenu` - 1; createCompressorControlForMac($item); } separator; // Frame numbers ------------------------------------------------ attrControlGrp -attribute defaultRenderGlobals.startFrame -label "Start Frame" rpStartFrameCtrl; attrControlGrp -attribute defaultRenderGlobals.endFrame -label "End Frame" rpEndFrameCtrl; attrControlGrp -attribute defaultRenderGlobals.byFrameStep -label "By Frame" rpByFrameStepCtrl; attrControlGrp -attribute defaultRenderGlobals.extensionPadding -label "Frame Padding" rpExtensionPaddingCtrl; separator; // Renderable Objects ------------------------------------------------ attrEnumOptionMenuGrp -label "Renderable Objects" -attribute "defaultRenderGlobals.renderAll" -enumeratedItem 1 "Render All" -enumeratedItem 0 "Render Active"; // Cameras ------------------------------------------------ createCameraControl(); updateRenderPipeCameraControl(); // Channels ------------------------------------------------ // string $currentCamera = `optionMenuGrp -q -v RenderPipeCameraMenu`; // Remove the substring " (Renderable)" from the string // $currentCamera if there is any. // $currentCamera = `substitute " .*" $currentCamera ""`; string $camShapes[] = `listRelatives -path -shapes $currentCamera`; $currentCamera = $camShapes[0]; attrControlGrp -label "RGB Channel (Color)" -attribute ($currentCamera + ".image") rpRgbChannel; attrControlGrp -label "Alpha Channel (Mask)" -attribute ($currentCamera + ".mask") rpAlphaChannel; attrControlGrp -label "Depth Channel (Z Depth)" -attribute ($currentCamera + ".depth") rpDepthChannel; // Custom Extension ---------------------------------------- frameLayout -label "Custom Extension" -collapsable true -collapse true; columnLayout; createUseCustomExtensionControl(); createCustomExtensionControl(); setParent ..; setParent ..; // Renumber ------------------------------------------------ frameLayout -label "Renumber Frames" -collapsable true -collapse true; columnLayout; attrControlGrp -attribute defaultRenderGlobals.modifyExtension -changeCommand "updateRenderPipeFrameNumberControls" -label "Renumber Frames Using:" rpModifyExtensionCtrl; attrControlGrp -attribute defaultRenderGlobals.startExtension -enable (`getAttr defaultRenderGlobals.modifyExtension`) -label "Start Number" rpStartExtensionCtrl; attrControlGrp -attribute defaultRenderGlobals.byExtension -enable (`getAttr defaultRenderGlobals.modifyExtension`) -label "By Frame" rpByExtensionCtrl; setParent ..; setParent ..; setParent $parent; setUITemplate -popTemplate; // Perform an initial update of the UI created above, so that controls // which are not directly connected to attributes are properly initialized. // updateRenderPipeFileNamePrefixControl(); updateRenderPipeFileNameFormatControl(); updateRenderPipeImageFormatControl(); updateRenderPipeUseCustomExtensionControl(); updateRenderPipeCustomExtensionControl(); } // ---------------------------------------------------------------------------- // Code to create and update the Resolution frame // global proc createRenderPipeCommonResolution() // // Procedure Name: // createRenderPipeCommonResolution // // Description: // Creates the UI in the "Resolution" expand/collapse section. // { // // Make sure the list of predefined resolutions has been read in. // global string $gImageFormatData[]; global string $gUserImageFormatData[]; if (size($gImageFormatData) == 0) { eval("source imageFormats"); } int $isMayaEvalVersion = `about -ev`; global string $gPLEImageFormatData[]; if ($isMayaEvalVersion) { $gImageFormatData = $gPLEImageFormatData; } if (exists("userImageFormats.mel") && size($gUserImageFormatData) == 0) { // Yes, we need the eval here, to avoid doing the source // until we know whether the file actually exists eval("source userImageFormats"); } setUITemplate -pushTemplate attributeEditorTemplate; // If the UI is created already then just update the attribute values. if (`columnLayout -exists rpResolutionLayout`) { updateRenderPipeResolution(); return; } columnLayout -adjustableColumn true rpResolutionLayout; int $resItem; int $numResolutionPresets = size($gImageFormatData); int $numUserResolutionPresets = size($gUserImageFormatData); string $allResNodes[] = `ls -type resolution`; int $numResolutionNodePresets = size($allResNodes) - 1; int $numTokens; string $tokens[]; string $niceName; optionMenuGrp -label "Presets" -changeCommand "changeRenderPipeResolution()" rpResolutionMenu; menuItem -label "Custom"; for ($resItem = 0; $resItem < $numResolutionPresets; $resItem++) { string $item = $gImageFormatData[$resItem]; $numTokens = tokenize($item, $tokens); // Change any underscore into a space; // some names may have up to 2 underscores in them, // so we do this twice. // $niceName = `substitute "_" $tokens[0] " "`; $niceName = `substitute "_" $niceName " "`; menuItem -label $niceName; } for ($resItem = 0; $resItem < $numUserResolutionPresets; $resItem++) { string $item = $gUserImageFormatData[$resItem]; $numTokens = tokenize($item, $tokens); // Change any underscore into a space; // some names may have up to 2 underscores in them, // so we do this twice. // $niceName = `substitute "_" $tokens[0] " "`; $niceName = `substitute "_" $niceName " "`; menuItem -label $niceName; } for ($resItem = 0; $resItem < $numResolutionNodePresets; $resItem++) { menuItem -label $allResNodes[$resItem + 1]; } separator; checkBoxGrp -numberOfCheckBoxes 1 -label1 "Maintain Width/Height Ratio" -changeCommand ("setAttr defaultResolution.aspectLock #1;" + "checkRenderPipeAspectLock \"defaultResolution\";" + "updateRenderPipeResolution") aspectLockCheck; intFieldGrp -label "Width" -changeCommand "changeRenderPipeAspectLockWidth" renderPipeResWidth; intFieldGrp -label "Height" -changeCommand "changeRenderPipeAspectLockHeight" renderPipeResHeight; separator; checkBoxGrp -numberOfCheckBoxes 1 -label1 "Lock Device Aspect Ratio" -changeCommand ("setAttr defaultResolution.lockDeviceAspectRatio #1;" + "changeRenderPipeAspectLockWidth") rpRatioLockCheck; floatFieldGrp -label "Device Aspect Ratio" -changeCommand "updateRenderPipeDeviceAspectRatio" rpResRatio; floatFieldGrp -label "Pixel Aspect Ratio" -changeCommand "adjustRenderPipeDeviceAspect \"defaultResolution\"" rpPixRatio; setParent ..; setUITemplate -popTemplate; // Make sure the values are right updateRenderPipeResolution(); } global proc updateRenderPipeResolution() // // Procedure Name: // updateResolution // // Description: // Gets the real values from the nodes and sets the UI based // on these values. This procedure updates all of the resolution // values. // { setParentToCommonTab(); int $width = `getAttr defaultResolution.width`; int $height = `getAttr defaultResolution.height`; float $aspect = `getAttr defaultResolution.deviceAspectRatio`; int $resItem; int $whichRes = 1; // use "Custom" if no match is found string $allResNodes[] = `ls -type resolution`; global string $gImageFormatData[]; global string $gUserImageFormatData[]; int $numResolutionPresets = size($gImageFormatData); int $numUserResolutionPresets = size($gUserImageFormatData); int $numResolutionNodePresets = size($allResNodes) - 1; int $resWidth; int $resHeight; float $resAspect; int $numTokens; string $tokens[]; for ($resItem = 0; $resItem < $numResolutionPresets; $resItem++) { string $item = $gImageFormatData[$resItem]; $numTokens = tokenize($item, $tokens); if ($numTokens == 4) { $resWidth = $tokens[1]; $resHeight = $tokens[2]; $resAspect = $tokens[3]; if ($width == $resWidth && $height == $resHeight && abs($aspect - $resAspect) < 0.001) { // We add _2_ to $resItem below: 1 because we're // skipping the first item (Custom) in the list, and 1 // because the optionMenu items are numbered starting at 1, // but our list in $gImageFormatData is indexed starting at 0. $whichRes = $resItem + 2; break; } } else { warning( "Found invalid image format description: \"" + $item + "\" in imageFormats.mel"); } } // If no match was found in the built-in resolutions, // check out the user-defined ones // if ($whichRes == 1) { for ($resItem = 0; $resItem < $numUserResolutionPresets; $resItem++) { string $item = $gUserImageFormatData[$resItem]; $numTokens = tokenize($item, $tokens); if ($numTokens == 4) { $resWidth = $tokens[1]; $resHeight = $tokens[2]; $resAspect = $tokens[3]; if ($width == $resWidth && $height == $resHeight && abs($aspect - $resAspect) < 0.001) { $whichRes = $numResolutionPresets + $resItem + 2; break; } } else { warning( "Found invalid image format description: \"" + $item + "\" in userImageFormats.mel"); } } } // If no match was found in the user-defined resolutions, // see if there are any 'extra' resolution nodes in the scene. // if ($whichRes == 1) { for ($resItem = 0; $resItem < $numResolutionNodePresets; $resItem++) { // We assume the 0th item in the list of resolution nodes is // the default one, which is created implicitly... // string $resNodeName = $allResNodes[$resItem + 1]; $resWidth = `getAttr ($resNodeName + ".width")`; $resHeight = `getAttr ($resNodeName + ".height")`; $resAspect = `getAttr ($resNodeName + ".deviceAspectRatio")`; if ($width == $resWidth && $height == $resHeight && abs($aspect - $resAspect) < 0.001) { // We add _2_ to $resItem below: 1 because we're // skipping the first item (Custom) in the list, and 1 // because the optionMenu items are numbered starting at 1, // but our list in $gImageFormatData is indexed starting at 0. // $whichRes = $numResolutionPresets + $numUserResolutionPresets + $resItem + 2; break; } } } optionMenuGrp -edit -sl $whichRes rpResolutionMenu; checkBoxGrp -edit -v1 `getAttr defaultResolution.aspectLock` aspectLockCheck; intFieldGrp -edit -v1 $width renderPipeResWidth; intFieldGrp -edit -v1 $height renderPipeResHeight; floatFieldGrp -edit -v1 $aspect rpResRatio; adjustRenderPipePixelAspect "defaultResolution"; checkBoxGrp -edit -v1 `getAttr defaultResolution.lockDeviceAspectRatio` rpRatioLockCheck; } global proc changeRenderPipeResolution() // // Procedure Name: // changeResolution // // Description: // This procedure is called when the user selects a different // resolution. It sets the internal representation // and then updates the example to show the changes. // { setParentToCommonTab(); global string $gImageFormatData[]; global string $gUserImageFormatData[]; int $numResolutionPresets = size($gImageFormatData); int $numUserResolutionPresets = size($gUserImageFormatData); string $allResNodes[] = `ls -type resolution`; int $numResolutionNodePresets = size($allResNodes) - 1; string $tokens[]; int $resItem = `optionMenuGrp -q -sl rpResolutionMenu`; int $resWidth; int $resHeight; float $resAspect; string $item; // Item #1 is Custom, which doesn't change the fields // We subtract _2_ from $resItem below: 1 because we're // skipping the first item (Custom) in the list, and 1 // because the optionMenu items are numbered starting at 1, // but our list in $gImageFormatData is indexed starting at 0. // if ($resItem > 1) { if ($resItem > ($numResolutionPresets + 1)) { if ($resItem > ($numResolutionPresets + $numUserResolutionPresets + 1)) { // It's one of the user-defined resolution nodes' presets string $resNodeName = $allResNodes[$resItem - $numResolutionPresets - $numUserResolutionPresets - 1]; $resWidth = `getAttr ($resNodeName + ".width")`; $resHeight = `getAttr ($resNodeName + ".height")`; $resAspect = `getAttr ($resNodeName + ".deviceAspectRatio")`; } else { // It's one of the user-defined resolution presets $item = $gUserImageFormatData[$resItem - $numResolutionPresets - 2]; int $numTokens = tokenize($item, $tokens); $resWidth = $tokens[1]; $resHeight = $tokens[2]; $resAspect = $tokens[3]; } } else { // It's one of the built-in resolution presets $item = $gImageFormatData[$resItem - 2]; int $numTokens = tokenize($item, $tokens); $resWidth = $tokens[1]; $resHeight = $tokens[2]; $resAspect = $tokens[3]; } setAttr "defaultResolution.width" $resWidth; setAttr "defaultResolution.height" $resHeight; setAttr "defaultResolution.deviceAspectRatio" $resAspect; setAttr "defaultResolution.lockDeviceAspectRatio" 1; // Set the proper field ordering if PAL or NTSC. if (`getAttr defaultResolution.height` == 576) // PAL { setAttr "defaultResolution.oddFieldFirst" 0; if (`columnLayout -exists rgFieldLayout`) { if (`exists updateFieldOptions`) { updateFieldOptions(); } } } else if (`getAttr defaultResolution.height` == 486) // NTSC { setAttr "defaultResolution.oddFieldFirst" 1; if (`columnLayout -exists rgFieldLayout`) { if (`exists updateFieldOptions`) { updateFieldOptions(); } } } } updateRenderPipeResolution(); } global proc checkRenderPipeAspectLockWidth(string $nodeName) { float $deviceAspect; if (`getAttr ($nodeName + ".aspectLock")`) { int $value = `getAttr ($nodeName + ".width")`; float $aspect = `getAttr ($nodeName + ".pixelAspect")`; if ($aspect > 0.0) { int $rez = $aspect * $value; int $oldrez = `getAttr ($nodeName + ".height")`; if ($rez - $oldrez > 1 || $oldrez - $rez > 1) { setAttr ($nodeName + ".height") $rez; } } else { checkRenderPipeAspectLock $nodeName; } } if (`getAttr ($nodeName + ".lockDeviceAspectRatio")` == 0) { $deviceAspect = `getAttr ($nodeName + ".width")`; $deviceAspect = $deviceAspect / `getAttr ($nodeName + ".height")`; setAttr ($nodeName + ".deviceAspectRatio") $deviceAspect; } } global proc checkRenderPipeAspectLockHeight(string $nodeName) { float $deviceAspect; if (`getAttr ($nodeName + ".aspectLock")`) { int $value = `getAttr ($nodeName + ".height")`; float $aspect = `getAttr ($nodeName + ".pixelAspect")`; if ($aspect > 0.0) { int $rez = $value / $aspect; int $oldrez = `getAttr ($nodeName + ".width")`; if ($rez - $oldrez > 1 || $oldrez - $rez > 1) { setAttr ($nodeName + ".width") $rez; } } else { checkRenderPipeAspectLock $nodeName; } } if (`getAttr ($nodeName + ".lockDeviceAspectRatio")` == 0) { $deviceAspect = `getAttr ($nodeName + ".width")`; $deviceAspect = $deviceAspect / `getAttr ($nodeName + ".height")`; setAttr ($nodeName + ".deviceAspectRatio") $deviceAspect; } } global proc checkRenderPipeAspectLock(string $nodeName) { int $lockOn = `getAttr ($nodeName + ".aspectLock")`; if ($lockOn) { float $h = `getAttr ($nodeName + ".height")`; float $w = `getAttr ($nodeName + ".width")`; float $aspect = $h / $w; setAttr ($nodeName + ".pixelAspect") $aspect; } else { setAttr ($nodeName + ".pixelAspect") 0.0; } } global proc changeRenderPipeAspectLockWidth() // // Procedure Name: // changeAspectLockWidth // // Description: // This procedure is called when the user changes the // resolution width. It sets the internal representation // then looks at the ratio lock etc and changes any other // values that rely on it. // { setParentToCommonTab(); int $requestedWidth = `intFieldGrp -q -v1 renderPipeResWidth`; int $isMayaEvalVersion = `about -ev`; int $kPLEMaxX = 1024; int $kPLEMaxY = 768; if ($isMayaEvalVersion) { if ($requestedWidth > $kPLEMaxX) { warning("Image resolution is limited to "+$kPLEMaxX+"x"+$kPLEMaxY+" pixels for the Maya Personal Learning Edition"); $requestedWidth = $kPLEMaxX; } if (`getAttr defaultResolution.aspectLock`) { float $aspect = `getAttr defaultResolution.pixelAspect`; if ($aspect > 0.0) { int $rez = $aspect * $requestedWidth; int $oldrez = `getAttr defaultResolution.height`; if ($rez <= $kPLEMaxY) { if ($rez - $oldrez > 1 || $oldrez - $rez > 1) { setAttr defaultResolution.height $rez; } } else { intFieldGrp -e -v1 $kPLEMaxY renderPipeResHeight; changeRenderPipeAspectLockHeight; return; } } } } if ($requestedWidth < 2) { warning "Width must be at least 2 pixels"; $requestedWidth = 2; } setAttr defaultResolution.width $requestedWidth; optionMenuGrp -edit -sl 1 rpResolutionMenu; checkRenderPipeAspectLockWidth "defaultResolution"; // Update the values updateRenderPipeResolution(); } global proc changeRenderPipeAspectLockHeight() // // Procedure Name: // changeAspectLockHeight // // Description: // This procedure is called when the user changes the // resolution width. It sets the internal representation // then looks at the ratio lock etc and changes any other // values that rely on it. // { setParentToCommonTab(); int $requestedHeight = `intFieldGrp -q -v1 renderPipeResHeight`; int $isMayaEvalVersion = `about -ev`; int $kPLEMaxX = 1024; int $kPLEMaxY = 768; if ($isMayaEvalVersion) { if ($requestedHeight > $kPLEMaxY) { warning("Image resolution is limited to "+$kPLEMaxX+"x"+$kPLEMaxY+" pixels for the Maya Personal Learning Edition"); $requestedHeight = $kPLEMaxY; } if (`getAttr defaultResolution.aspectLock`) { float $aspect = `getAttr defaultResolution.pixelAspect`; if ($aspect > 0.0) { int $rez = $requestedHeight / $aspect; int $oldrez = `getAttr defaultResolution.width`; if ($rez <= $kPLEMaxX) { if ($rez - $oldrez > 1 || $oldrez - $rez > 1) { setAttr defaultResolution.width $rez; } } else { intFieldGrp -e -v1 $kPLEMaxX renderPipeResWidth; changeRenderPipeAspectLockWidth; return; } } } } if ($requestedHeight < 2) { warning "Height must be at least 2 pixels"; $requestedHeight = 2; } setAttr defaultResolution.height $requestedHeight; optionMenuGrp -edit -sl 1 rpResolutionMenu; checkRenderPipeAspectLockHeight "defaultResolution"; // Set the proper field ordering if PAL or NTSC. if (`getAttr defaultResolution.height` == 576) // PAL { setAttr "defaultResolution.oddFieldFirst" 0; if (`columnLayout -exists rgFieldLayout`) { if (`exists updateFieldOptions`) { updateFieldOptions(); } } } else if (`getAttr defaultResolution.height` == 486) // NTSC { setAttr "defaultResolution.oddFieldFirst" 1; if (`columnLayout -exists rgFieldLayout`) { if (`exists updateFieldOptions`) { updateFieldOptions(); } } } // Update the values updateRenderPipeResolution(); } global proc adjustRenderPipePixelAspect(string $nodeName) { setParentToCommonTab(); string $aspectAttr = $nodeName + ".deviceAspectRatio"; string $widthAttr = $nodeName + ".width"; string $heightAttr = $nodeName + ".height"; float $pixelAspect = (float) `getAttr $widthAttr` / (float) `getAttr $heightAttr`; $pixelAspect = `getAttr $aspectAttr` / $pixelAspect; floatFieldGrp -e -v1 $pixelAspect rpPixRatio; } global proc adjustRenderPipeDeviceAspect(string $nodeName) { setParentToCommonTab(); string $devAspectAttr = $nodeName + ".deviceAspectRatio"; string $widthAttr = $nodeName + ".width"; string $heightAttr = $nodeName + ".height"; float $pixelAspect = `floatFieldGrp -q -v1 rpPixRatio`; float $aspect = (float) `getAttr $widthAttr` / (float) `getAttr $heightAttr`; $aspect = $pixelAspect * $aspect; setAttr $devAspectAttr $aspect; floatFieldGrp -edit -v1 $aspect rpResRatio; } global proc updateRenderPipeDeviceAspectRatio() { setParentToCommonTab(); setAttr defaultResolution.deviceAspectRatio `floatFieldGrp -q -v1 rpResRatio`; adjustRenderPipePixelAspect "defaultResolution"; updateRenderPipeResolution(); } // ---------------------------------------------------------------------------- // Code to create and update the Render Options frame // proc createCommonRenderOptions() { string $parent = `setParent -query`; setUITemplate -pushTemplate attributeEditorTemplate; columnLayout -adjustableColumn true; attrControlGrp -attribute "defaultRenderGlobals.enableDefaultLight"; textFieldGrp // defaultRenderGlobals.pluginFormat -label "Plug-in Format" -tx "Not available for this renderer" -enable false; attrControlGrp -attribute defaultRenderGlobals.preRenderMel -label "Pre Frame Render MEL"; attrControlGrp -attribute defaultRenderGlobals.postRenderMel -label "Post Frame Render MEL"; setParent $parent; setUITemplate -popTemplate; } //================================================================== // Common Tab //================================================================== global proc updateRenderPipeCommonGlobalsTab() { // // Description: // This procedure is called when the current renderer changes to be the // RenderPipe Renderer. // This procedure updates controls in the Common tab of the RenderPipe // renderer to reflect values which may have been copied from the previous // current renderer. // updateRenderPipeFileNamePrefixControl(); updateRenderPipeFileNameFormatControl(); updateRenderPipeImageFormatControl(); updateRenderPipeUseCustomExtensionControl(); updateRenderPipeCustomExtensionControl(); updateRenderPipeCameraControl(); updateRenderPipeResolution(); } global proc createRenderPipeCommonGlobalsTab() { // // Description: // This procedure is called when building the render globals tabs for the // RenderPipe renderer. // This procedure builds the "General" tab for the RenderPipe renderer. // string $renderer = "RenderPipe"; string $parentForm = `setParent -query`; createTargetFilePreview(); setParent $parentForm; scrollLayout -horizontalScrollBarThickness 0 scrollLayout; columnLayout -adjustableColumn true commonTabColumn; // Image File Name // frameLayout -label "Image File Output" -collapsable true -collapse false rpImageFileFrame; createCommonImageFile(); setParent commonTabColumn; // Resolution Section // frameLayout -label "Resolution" -collapsable true -collapse false rpResolutionFrame; createRenderPipeCommonResolution(); setParent commonTabColumn; // Render Options // frameLayout -label "Render Options" -collapsable true -collapse false RenderPipeOptionFrame; createCommonRenderOptions(); setParent commonTabColumn; setParent $parentForm; formLayout -edit -af rpTargetFilePreview "top" 5 -an rpTargetFilePreview "bottom" -af rpTargetFilePreview "left" 0 -af rpTargetFilePreview "right" 0 -ac scrollLayout "top" 5 rpTargetFilePreview -af scrollLayout "bottom" 0 -af scrollLayout "left" 0 -af scrollLayout "right" 0 $parentForm; // Update the target file preview. // updateRenderPipeTargetFilePreview; }