Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- @file xyMatchCameraFilmGate.mel
- @version 0.1
- @date 2007-01-21
- @author Imre Tuske
- <br> mail: imre.tuske@gmail.com
- \brief Modify camera film gate to match the resolution gate.
- \section qcmd Quick commands:
- - <a href="mel:xyMatchCameraFilmGate({})">Match Film Gate of selected camera(s)</a> -- Select camera(s)
- - <a href="mel:xyMatchCameraFilmGate(`ls -type camera`)">Match Film Gate of all cameras</a>
- \section desc Description:
- Maya cameras have many attributes that allow sophistical view setups, but it is also
- a tedium for the regular user to make sure they are set up properly.
- <br><br>
- The camera Film Gate describes the width/height of the camera view plane. In an ideal
- default case, the camera Film Gate should have the same proportions as the output
- resolution (the actual rendered frame).
- <br><br>
- This script modifies the camera film gate to have the same proportions as the output
- resolution. This modification doesn't modify the current camera view (if it is, it's
- a script bug :)).
- <br><br>
- Why Is It Important To Match The Film Gate:
- <br><br>
- The 'FilmFit' camera attribute determines how would Maya fit the camera view (Film Gate)
- to the output frame (Resolution Gate). However it also affects how the view is shown
- in the viewports. (Fill, Horizontal, Vertical, Overscan).
- Artists often change this attribute to have a better view in the viewport display,
- and this can result in problems such as mismatched renders. If the Film Gate and
- Resolution Gate is properly matched, such trouble can be avoided.
- <br><br>
- <small>
- \section hist History:
- \par 2001-10-27 [0.1]
- First version.
- <br><br>
- \section todoo Todo:
- - none
- </small>
- */
- proc match_film_gate( string $c )
- {
- string $os[]={ "Fill", "Horizontal", "Vertical", "Overscan" };
- string $dr="defaultResolution";
- if (size(`ls -type camera $c`) && !getAttr($c+".orthographic"))
- {
- float $iw=getAttr($dr+".width"), $ih=getAttr($dr+".height"); // current resolution and aspect
- float $r=getAttr($dr+".deviceAspectRatio");
- $r=($ih/$iw)*$r; // convert to pixel aspect ratio
- $iw*=$r; // and apply ratio to resolution
- float $iR=$ih/$iw; // image ratio (aspect-corrected)
- float $aw=getAttr($c+".hfa"), $ah=getAttr($c+".vfa"); // current film gate
- int $m=getAttr($c+".filmFit");
- float $aR=$ah/$aw;
- // determine actual film fit of camera
- // (1=horizontal, 2=vertical)
- if ($m==0) $m=( $aR<$iR ? 2 : 1 );
- else if ($m==3) $m=( $aR<$iR ? 1 : 2 );
- print("- "+$c+": current fit type "+$os[$m]+"; changing aperture from "+$aw+"/"+$ah);
- switch($m) // calculate new aperture
- {
- case 1: // horizontal: modify vertical aperture
- $ah=$aw*$iR;
- break;
- case 2: // vertical: modify horizontal aperture
- $aw=$ah/$iR;
- break;
- }
- print(" to "+$aw+"/"+$ah+"\n");
- // set new overscan value
- catch(`setAttr ($c+".hfa") $aw`);
- catch(`setAttr ($c+".vfa") $ah`);
- }
- }
- global proc xyMatchCameraFilmGate( string $sel[] )
- {
- string $sl[]=`ls $sel`, $s;
- if (!size($sl)) $sl=`ls -sl`;
- $sl=`ls -dag -lf -ni -type camera $sl`;
- for($s in $sl)
- match_film_gate($s);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement