//----------------------------------------------------
// getVertexRGB
//----------------------------------------------------
// This returns the rgb values of the vertices of a mesh
global proc getVertexRGB (string $tnode, vector $rgbs[], string $colorInputNode)
{
int     $count = size($rgbs);
int     $num[] = `polyEvaluate -v $tnode`;
string     $shp[] = `listRelatives -shapes $tnode`;
string     $shape = $shp[0];
  
// We step over the list of "maps", get each uv and
// then use colorAtPoint to build a list of rgb values
for ($n = 0; $n < $num[0]; $n++) {
    $vert = $shape + ".vtx[" + $n + "]";
    $comps = `polyListComponentConversion -fv -toUV $vert`;
    $uv = `polyEditUV -q $comps[0]`;
    
    float  $color[];
    if(size($colorInputNode) > 0)
        $color = `colorAtPoint -o RGB -u $uv[0] -v $uv[1] $colorInputNode`;
    else
        $color[0] = $color[1] = $color[2] = 1.0;
        
    $rgbs[$count] = <<$color[0], $color[1], $color[2]>>;
    $count++;
    }
}