Mel Script - Camera Data [API]





There are two types of camera available within Maya, perspective and orthographic. The camera itself is a simple object parented underneath a transform node. When we animate a camera, we are in effect animating it's trasnform (see sampling animation data or animation curves for more info)





Finding All Cameras in a Scene

To find all of the camera nodes, we can simply use ls.



		// get a list of all cameras in the scene
		$cameras = `ls -type "camera"`;

		// loop through each camera
		for( $cam in $cameras )
			// print the name of the camera node
			print( $cam + "\n" );




Creating a Camera

we can declare our own lights fairly simply as shown in the example below.



			// create a perspective camera
			camera -centerOfInterest 5 
			       -focalLength 35 
				   -lensSqueezeRatio 1 
				   -cameraScale 1 
				   -horizontalFilmAperture 1.4173 
				   -horizontalFilmOffset 0 
				   -verticalFilmAperture 0.9449 
				   -verticalFilmOffset 0 
				   -filmFit Horizontal 
				   -overscan 1 
				   -motionBlur 0 
				   -shutterAngle 144 
				   -nearClipPlane 0.01 
				   -farClipPlane 1000 
				   -orthographic 0     // change to 1 for orthographic
				   -orthographicWidth 30;