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

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

内容摘要:Maya mel语初解

// 转换当前选择为顶点,并获取这些顶点的名称
global proc string[] getVerts()
{
 select -r `polyListComponentConversion -tv`;
 string $result[]=`filterExpand -ex true -sm 31`;
 return $result;
}
// 转换当前选择为边,并获取这些点的名称
global proc string[] getEdges()
{
 select -r `polyListComponentConversion -te`;
 string $result[]=`filterExpand -ex true -sm 32`;
 return $result;
}
// 转换当前选择为面,并获取这些面的名称
global proc string[] getFaces()
{
 select -r `polyListComponentConversion -tf`;
 string $result[]=`filterExpand -ex true -sm 34`;
 return $result;
}
// 转换当前选择为UV点,并获取这些UV点的名称
global proc string[] getUVs()
{
 string $uvs[];
 $uvs=`polyListComponentConversion -tuv`;
 if (size($uvs) == 0) return $uvs;
 select -r $uvs;
 string $result[]=`filterExpand -ex true -sm 35`;
 return $result;
}
// 根据点、边、面、UV点的名称得出多边形的名称
// 例如多边形一条边的名称为"pSphere1.e[637]",则这个多边形的
// 名称为"pSphere1"
proc string getBaseName(string $item)
{
 string $buffer[];
 if ($item != "")
 {
  tokenize($item, ".", $buffer);
 }
 return $buffer[0];
}

  用法范例:

string $polyName = getBaseName("pSphere1.e[637]");
// 返回值:pSphere1
// 根据点、边、面、UV点的名称得出它们的索引号
// 例如多边形一条边的名称为"pSphere1.e[637]",则这个多边形的
// 索引号为637
proc int getIndex(string $indexString)
{
 string $buffer[];
 tokenize($indexString, "[]", $buffer);
 int $index = (int)$buffer[1];
 return $index;
}

  用法范例:

责编:豆豆技术应用

正在加载评论...