//author: Edward Kim //Title: Look AWAY!!! //Desc: re-orients face normal away from sun angle //Date: March 11, 2008 //Contributors: Nick Pisca //Revision: //Compatibility: 'REQUIRES TRIANGULATED POLYGON GEOMETRY' int $STOP = 0; do{ int $timer = `currentTime -query`; int $faceCounter = 0; int $numFaces[] = `polyEvaluate -f pPlane1`; //determines total #faces in the geometry string $array[]; do { select -r pPlane1.f[$faceCounter]; string $faceInfo[] = `polyInfo -fv`; //gets name of vetices associated with the face $array = stringToStringArray($faceInfo[0], " "); //puts returned value (string) into array float $A = $array[2]; //re-inputs above data into float for vector calculation float $B = $array[3]; float $C = $array[4]; //find position of each vertex in world space float $VTX1[] = `pointPosition pPlane1.vtx[$A]`; float $VTX2[] = `pointPosition pPlane1.vtx[$B]`; float $VTX3[] = `pointPosition pPlane1.vtx[$C]`; //print $VTX2[1] to test for values //normal Vector of face calculation float $Qx = $VTX2[0]-$VTX1[0]; float $Qy = $VTX2[1]-$VTX1[1]; float $Qz = $VTX2[2]-$VTX1[2]; float $Px = $VTX3[0]-$VTX1[0]; float $Py = $VTX3[1]-$VTX2[1]; float $Pz = $VTX3[2]-$VTX1[2]; float $NormalX = $Py*$Qz - $Pz*$Qy; float $NormalY = $Pz*$Qx - $Px*$Qz; float $NormalZ = $Px*$Qy - $Py*$Qx; vector $panelAngle = <<$NormalX,$NormalY,$NormalZ>>; //get vector from line-light float $CV0[] = `pointPosition curve1.cv[0]`; float $CV1[] = `pointPosition curve1.cv[1]`; float $Line[] = {$CV0[0]-$CV1[0], $CV0[1]-$CV1[1], $CV0[2]-$CV1[2]}; vector $Light = <<$Line[0], $Line[1], $Line[2]>>; //angle of rotation depending on existing deviation (rotation deminish as found angle is increases) float $angle = rad_to_deg(`angle $panelAngle $Light`); print ($angle + "\n"); if ($angle < 180 && $angle >= 170) {rotate -r -xyz 5;} else if ($angle < 170 && $angle >= 160) {rotate -r -xyz 2;} else if ($angle < 160 && $angle >= 150) {rotate -r -xyz 4;} else if ($angle < 150 && $angle >= 140) {rotate -r -xyz 6;} else if ($angle < 140 && $angle >= 130) {rotate -r -xyz 8;} else if ($angle < 130 && $angle >= 120) {rotate -r -xyz 10;} else if ($angle < 120 && $angle >= 110) {rotate -r -xyz 12;} else if ($angle < 110 && $angle >= 100) {rotate -r -xyz 14;} else if ($angle < 100 && $angle >= 90) {rotate -r -xyz 16;} else if ($angle < 90 && $angle >= 80) {rotate -r -xyz 18;} else if ($angle < 70 && $angle >= 60) {rotate -r -xyz 20;} else if ($angle < 50 && $angle >= 40) {rotate -r -xyz 22;} else if ($angle < 40 && $angle >= 35) {rotate -r -xyz 24;} else if ($angle < 35 && $angle >= 30) {rotate -r -xyz 26;} else if ($angle < 30 && $angle >= 20) {rotate -r -xyz 28;} else if ($angle < 20 && $angle >= 10) {rotate -r -xyz 30;} $faceCounter++; currentTime $timer; $timer ++; //advances the frame forward int $count[] = `polyEvaluate -f pPlane1`; setKeyframe ("pPlane1.f[0:" + ($count[0] -1) + "]"); }while ($faceCounter <= $numFaces[0]); int $timer = `currentTime -query`; //keeps the last frame so that next loop can continue from that frame $STOP ++; }while ($STOP <= 25 )