Maya mel语初解之二-多边型建模

http://tech.ddvip.com   2007年08月14日    社区交流

内容摘要:Maya mel语初解

  也可以这样写:string $faces[] = getSelFaces();

  return为返回的意思,proc后面的字代表返回值的类型,return后面的字(变量或表达式)代表返回值,也就是函数的输出值。

  对初学者来说,看到"-sm 34"后,总是很难联想到多边形的面。当然你可以用maya的全局变量$gSelectMeshFaces来替代34,不过这样做有些麻烦。我们编一个新的函数来做与上面代码同样的事情。

  proc string[] getSelFaces()
  {
  return `filterExpand -ex true -sm 34`;
  }
  // [注] Sel为Selected的缩写

  有了这个函数,我们以后再获取多边形的面时,就可以这样写:string $faces[] = `getSelFaces`;

  也可以这样写:string $faces[] = getSelFaces();

  return为返回的意思,proc后面的字代表返回值的类型,return后面的字(变量或表达式)代表返回值,也就是函数的输出值。

  再看一个例子:

  proc string[] getPolySel(string $type)
  {
  if ($type == "vert")
  return `filterExpand -ex true -sm 31`;
  if ($type == "edge")
  return `filterExpand -ex true -sm 32`;
  if ($type == "face")
  return `filterExpand -ex true -sm 34`;
  // 假如输入参数是非预期的,就返回一个空数组
  string $null[];
  return $null;
  }

  想要获取多边形的面时,可以这样写: string $faces[] = getSelFaces("face");

  或: string $faces[] = `getPolySel "face"`;

  这回用到了函数的输入参数(string $type),根据输入参数的不同,产成不同的返回值。

责编:豆豆技术应用

正在加载评论...