/* jooCCRequestedCam2SteroCam.mel 0.11
Authors: Janne 'Joojaa' Ojala
Testing: if it works after a suitably long time without
much problems let me know. Report any problems.
License: Creative Commons, Attribution, Share Alike
Request by: John
About:
A simple script that will replace a standard camera with a stereo
camera rig while trying to keep the cameras place in any existing
rig/scene intact.
Install Instructions:
place this text in a file named: jooCCRequestedCam2SteroCam.mel
that resides in your personal Maya script directory.
Usage:
jooCCRequestedCam2SteroCam cameraName
from a command line. Alternatively run, or put in shelf
executeForEachObject(ls -sl
,"jooCCRequestedCam2SteroCam %s")
Changelist:
11.10.2009 - Original file
11.10.2009 - v0.11 I overlooked one thing causes crash fixed
*****************************************************************/
global proc jooCCRequestedCam2SteroCam(string $camera){
string $shapes[],$cam[],$camShapes[];
$shapes=ls -dag -shapes $camera
;
if (size($shapes)==0){
warning ($camera+" not found, bailing out.");
return;
}
python("from maya.app.stereo import stereoCameraRig");
$cam=python("stereoCameraRig.createStereoCameraRig(rigName='StereoCamera')");
$camShapes=ls -dag -shapes $cam[0]
;
nodeCast -sv 1 $camShapes[0] $shapes[0];
nodeCast -sv 1 $cam[0] $camera;
parent -add -shape $camShapes[1] $cam[0];
parent $cam[1] $cam[0];
parent $cam[2] $cam[0];
delete $camera;
// while nodecast does most of the job we
// need to reconnect the old rig
$attribs={".farClipPlane",".nearClipPlane",".displayResolution",
".displayFilmGate",".filmFit",".cameraPrecompTemplate",
".shutterAngle",".focusDistance",".fStop",".lensSqueezeRatio",
".cameraAperture.verticalFilmAperture",
".horizontalFilmAperture",".focalLength"};
for ($attrib in $attribs){
connectAttr ($camShapes[0]+$attrib) ($camShapes[2]+$attrib);
connectAttr ($camShapes[0]+$attrib) ($camShapes[3]+$attrib);
}
connectAttr -f ($camShapes[0]+".message") ($cam[0]+".centerCam");
}