ReturnAverageRGBThruPath MEL

From scripting
Revision as of 19:53, 24 April 2017 by Nickpisca (talk | contribs) (Created page with " global proc float ReturnAverageRGBThruPath(float $U1, float $V1, float $U2, float $V2, int $Interval, string $FileName) { //0001D LLC 2015 Nick Pisca //float $U1 = 0.896;...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
global proc float ReturnAverageRGBThruPath(float $U1, float $V1, float $U2, float $V2, int $Interval, string $FileName) {
	//0001D LLC 2015 Nick Pisca
	//float $U1 = 0.896; float $V1 = 0.428; float $U2 = 0.926; float $V2 = 0.485; int $Interval = 10; string $FileName = "file1";
	float $UDiff = $U2 - $U1;
	float $VDiff = $V2 - $V1;
	float $UInt = $UDiff / float($Interval);
	float $VInt = $VDiff / float($Interval);
	float $RGBTotal = 0.0;
	for ($x=1;$x<=$Interval;$x++) {
		float $UNew = $U1 + ($x * $UInt);
		float $VNew = $V1 + ($x * $VInt);
		float $rdb[] = `colorAtPoint -u $UNew -v $VNew $FileName`;
		//PlaceLocatorOnPlane $UNew $VNew "nurbsPlane1";
		$RGBTotal = $RGBTotal + $rdb[0];
	}
	return ($RGBTotal / $Interval);   //print($RGBTotal);  print($RGBTotal / $Interval);
}


More information on vectors and arrays, read pages 12-16 in YSYT.