Cameras in maya are stored as MFn::kCamera
nodes. In the hypergraph view above, the transform is "persp"
and the camera itself is "perspShape". In order
to access the Camera information, we can use the MFnCamera function
set.
In maya you can have one of two camera
types, an orthographic camera or a perspective camera.
Finding all Cameras
in
a Scene
To iterate through all of the cameras within a scene you can
simply use an MItDependencyNode to iterate through the MFn::kCamera
nodes in the scene.
// create an iterator to go through all
curves MItDag it(MFn::kCamera);
while(!it.isDone())
{
// attach
the function set to the object
MFnCamera fn(it.item());
// print camera name
cout<<"Camera
"<< fn.name().asChar()
<<endl;
// get next curve
it.next();
}
Camera Data
The MFnCamera function set provides you with
access to all of the cameras attributes. The function listed
here extracts common camera attributes for a perspective camera.
It is possible to extract orthographic cameras
as well if you wish (possibly useful for user interfaces); However
i will leave that as an excersice for the reader ;)