// // // Creates a duplicate version of the selected camera, and allows you to change the // aperture size on the new camera without affecting the horizontal field of view. // It does this by modifying the focal length. // // Simple but does the job. // // To install, copy this script to your maya scripts directory. // To run, source the script, select a camera and execute the command jpCreateLockedFOVCamera // // (PLEASE CONTACT ME IF YOU PLAN TO MODIFY THIS SCRIPT FOR RE-DISTRIBUTION) // // jeremy pronk 2004 // webmaster@thereisnoluck.com global proc jpCreateLockedFOVCamera() { string $oldCam[] = `ls -sl`; string $newCam[] = `duplicate -rr $oldCam[0]`; string $oldCamShape[] = `listRelatives -c -type "camera" $oldCam[0]`; string $newCamShape[] = `listRelatives -c -type "camera" $newCam[0]`; addAttr -ln baseFocalLength -at double $newCamShape[0]; setAttr -e -keyable true ($newCamShape[0]+".baseFocalLength"); addAttr -ln baseHorizontalFilmAperture -at double $newCamShape[0]; setAttr -e -keyable true ($newCamShape[0]+".baseHorizontalFilmAperture"); connectAttr -f ( $oldCamShape[0]+".focalLength" ) ( $newCamShape[0]+".baseFocalLength" ); connectAttr -f ( $oldCamShape[0]+".horizontalFilmAperture" ) ( $newCamShape[0]+".baseHorizontalFilmAperture" ); string $flExp; $flExp += "float $baseFilmbackWidthMM = baseHorizontalFilmAperture * 2.54;\n"; $flExp += "float $newFilmbackWidth = horizontalFilmAperture * 2.54;\n\n"; $flExp += "float $hfov = 2 * ( atan( $baseFilmbackWidthMM / 2.0 / baseFocalLength ) );\n"; $flExp += "focalLength = $newFilmbackWidth / 2.0 / tan( $hfov / 2.0 );\n"; expression -s $flExp -o $newCamShape -ae 1 -uc all; }