一半君的总结纸

听话只听一半君

#19 How can I determine if a camera other than the default cameras has been created if I don’t know the name of the new camera?

By default Maya creates four cameras for a scene:

persp
front
side
top

The first camera, ‘persp’ is non-orthographic, the remaining three are orthographic.

It is not possible (without effort) to rename or delete these default cameras as they are flagged as read-only. You can determine if a camera is read-only — or rather if it’s flagged as one of the default startup cameras — by querying the ‘−startupCamera’ flag using the ‘camera’ command:

camera -q -startupCamera persp;
// Result: 1 //

Knowing this, it is possible to get a list of all cameras, query each for the ‘−startupCamera’ flag, and mark any others as a camera that the user has added.

proc string[] getExtraCameras()
{
  string $extraCameras[];
  int $numExtraCameras = 0;

  string $cameras[] = `ls -cameras`;

  for ( $camera in $cameras )
  {
    // If this camera is not a startupCamera, add it to the array
    if ( !`camera -q -startupCamera $camera` )
      $extraCameras[$numExtraCameras++] = $camera;
  }

  return $extraCameras;
}

// Get a list of all non-startup cameras
string $extraCameras[] = getExtraCameras();

if ( size( $extraCameras ) )
{
  print ( "The following cameras have been added to the scene:\n" );
  print $extraCameras;
}
else
  print ( "No extra cameras added to the scene.\n" );
Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: