一半君的总结纸

听话只听一半君

#19 如何知道场景里有哪些新建的camera(除了默认的以外)?

Maya 会自动创建4个默认cameras:

persp
front
side
top

第一个 camera, ‘persp’ 是非正交视图(non-orthographic)的带透视的camera, 其余4个是正交视图的.

这4个默认cemera“正常情况下”是无法删除或重命名的,因为他们被标记为只读了. 你可以通过用‘camera’ command 加上‘−startupCamera’ flag来查询一个camera是不是只读的,或者说他是不是被标记为默认的 startup cameras了:

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

知道了这个, 我们就可以首先得到所有的camera, 然后逐个查询他们的 ‘−startupCamera’ flag, 那其他的camera就可以认为是用户自己添加的了.

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

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

  for ( $camera in $cameras )
  {
    // 如果这个camera不是 startupCamera, 把他添加到 array
    if ( !`camera -q -startupCamera $camera` )
      $extraCameras[$numExtraCameras++] = $camera;
  }

  return $extraCameras;
}

// 得到所有的 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 博主赞过: