KeepInsideBox

From scripting
Revision as of 07:07, 22 April 2017 by Nickpisca (talk | contribs) (Created page with " global proc string KeepInsideBox(string $ObjName, float $BBMin[], float $BBMax[]) { //Author Nick Pisca 0001d 2010 //string $ObjName = "nurbsSphere1"; float $BBMax[] = {1...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
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.