Difference between revisions of "KeepInsideBox"

From scripting
Jump to: navigation, search
(Created page with " global proc string KeepInsideBox(string $ObjName, float $BBMin[], float $BBMax[]) { //Author Nick Pisca 0001d 2010 //string $ObjName = "nurbsSphere1"; float $BBMax[] = {1...")
 
(No difference)

Latest revision as of 07:07, 22 April 2017

global proc string KeepInsideBox(string $ObjName, float $BBMin[], float $BBMax[]) {
	//Author Nick Pisca 0001d 2010
	//string $ObjName = "nurbsSphere1"; float $BBMax[] = {10,10,5}; float $BBMin[] = {0,0,0};
	float $OL[] = `pointPosition($ObjName+".cv[0][0]")`;
	float $FixL[2];
	clear $FixL;
	for ($x=0;$x<=2;$x++) {
		if ($OL[$x] < $BBMin[$x]) {
			$FixL[$x] = $BBMin[$x] - $OL[$x];
		}
	}

	for ($x=0;$x<=2;$x++) {
		if ($OL[$x] > $BBMax[$x]) {
			$FixL[$x] = $BBMax[$x] - $OL[$x];
		}
	}
	
	move -r ($FixL[0]) ($FixL[1]) ($FixL[2]) $ObjName;
	return $ObjName;
}


More information on translate transformations, read pages 55-67 in YSYT.

See also RandomMoveArrayOfObjects.