GetRGBGrid MEL
From scripting
global proc string[] GetRGBGrid(string $FileName, int $xMax, int $yMax ) { //0001D LLC 2015 Nick Pisca //int $xMax = 5; int $yMax = 6; string $FileName = "file1"; //eval("matrix $Acc["+$xMax+"]["+$yMax+"]"); string $wstr[] ; for ($x=0;$x<=$xMax;$x++) { float $xf = float($x)/float($xMax); print ("Collecting RGB's " + $x + " of " + $xMax + ".\n"); string $wsub = ""; for ($y=0;$y<=$yMax;$y++) { float $yf = float($y)/float($yMax); //select -r ("nurbsPlane1.uv["+($xf)+"]["+($yf)+"]"); float $rdb[] = `colorAtPoint -u $xf -v $yf $FileName`; if (($rdb[0] > 0.5) && ($rdb[0] < 0.9)) { float $RRand = rand(0.0,0.999); if ($RRand > 0.90) { float $FRand = $rdb[0]/2.0; //rand(0.5,0.999); $wsub = $wsub + $FRand + ","; } else { $wsub = $wsub + $rdb[0] + ","; } } else { $wsub = $wsub + $rdb[0] + ","; } //$Acc[$x][$y] = $rdb[0]; } $wstr[$x] = $wsub; } return $wstr; }
Second Version:
global proc string[] GetRGBGrid(string $FileName, int $xMax, int $yMax ) { //0001D LLC 2015 Nick Pisca //int $xMax = 5; int $yMax = 6; string $FileName = "file1"; //eval("matrix $Acc["+$xMax+"]["+$yMax+"]"); string $wstr[] ; for ($x=0;$x<=$xMax;$x++) { float $xf = float($x)/float($xMax); print ("Collecting RGB's " + $x + " of " + $xMax + ".\n"); string $wsub = ""; for ($y=0;$y<=$yMax;$y++) { float $yf = float($y)/float($yMax); //select -r ("nurbsPlane1.uv["+($xf)+"]["+($yf)+"]"); float $rdb[] = `colorAtPoint -u $xf -v $yf $FileName`; vector $xyz = `pointPosition ("nurbsPlane1.uv["+($xf)+"]["+($yf)+"]")`; //if (($rdb[0] > 0.5) && ($rdb[0] < 0.9)) { if (($rdb[0] > 0.00) && ($rdb[0] < 0.99)) { float $RRand = rand(0.00,0.99); if ($RRand < (1.000 - $rdb[0])) { $wsub = $wsub + $rdb[0] + ","; //sphere -r 0.01 -p ($xyz.x) ($xyz.y) ($xyz.z) ; spaceLocator -p ($xyz.x) ($xyz.y) ($xyz.z); scale -cp 0.05 0.05 0.05; } else { $wsub = $wsub + 0.999 + ","; } //float $RRand = rand(0.0,0.999); //if ($RRand > 0.90) { // float $FRand = $rdb[0]/2.0; //rand(0.5,0.999); // $wsub = $wsub + $FRand + ","; //} else { // $wsub = $wsub + $rdb[0] + ","; //} } else { $wsub = $wsub + $rdb[0] + ","; } //$Acc[$x][$y] = $rdb[0]; } $wstr[$x] = $wsub; } return $wstr; }
More information on applying materials, read pages 128-133 in YSYT.