/ Version 1: only works with an entire object or objects
// Version 2: we introduce the use of filterExpand() so that
// we can handle a selection of individual vertices.
global proc getVertices(string $tnode, vector $data[]) {
int $count = size($data);
// Step 1: Decide what is selected.
string $vertices[] = `filterExpand -sm 31`;
// Individual vertices have NOT been selected so we
// go ahead as usual...
if(size($vertices) == 0) {
string $shapes[] = `listRelatives -shapes $tnode`;
// here we get ALL vertices
if(size($shapes) == 1) {
int $num_vertices[] = `polyEvaluate -v $tnode`;
string $shape = $shapes[0];
float $position[];
for($n = 0; $n < $num_vertices[0]; $n++) {
$vertex_text = $shape + ".vtx[" + $n + "]";
$position = `pointPosition -local $vertex_text`;
$data[$count] = <<$position[0], $position[1], $position[2]>>;
$count++;
}
}
else // tnode is a group node
{
string $children[] = `listRelatives -children $tnode`;
for($child in $children) {
getVertices($child, $data);
}
}
}
else // here we get selected vertex positions
{
float $position[];
for($vert in $vertices) {
$position = `pointPosition -local $vert`;
$data[$count] = <<$position[0], $position[1], $position[2]>>;
$count++;
}
}
}