//--------------------------------------------------------------------- // //flatten polygon facets // //--------------------------------------------------------------------- for($i=0;$i < (($gx - 1) * ($gy - 1) ); $i++){ select -add ("HiroPoly" + $i); } string $slPolySrf[] = `ls -sl`; string $xRot[]; string $yRot[]; int $pCount = 0; for($each in $slPolySrf){ //select each polygon select -r $each; string $arrAllVertex[] = `polyListComponentConversion -tv`; //select all vertex in each polygon select -r $arrAllVertex; //put all vertex name of $each into $selectedVertex[] string $selectedVertex[]= `filterExpand -ex true -sm 31`; select -r $each; //get the 2 point locations on x direction [0] and [1] for rotation Y float $toVec0[] = `pointPosition $selectedVertex[0]`; float $toVec1[] = `pointPosition $selectedVertex[1]`; vector $unrollVec0 = <<($toVec0[0]) , ($toVec0[1]), ($toVec0[2]) >>; vector $unrollVec1 = <<($toVec1[0]) , ($toVec1[1]), ($toVec1[2]) >>; vector $resultant0 = $unrollVec0 - $unrollVec1; vector $projected0 = <<($toVec0[0]) , ($toVec0[1]), ($toVec1[2]) >>; vector $resultant1 = $projected0 - $unrollVec1; //conditions for the direction of rotation if(($toVec0[2]) > ($toVec1[2]) ){ rotate -r 0 (0 - (rad_to_deg(`angle $resultant0 $resultant1`)) ) 0; $xRot[$pCount] = (0 - (rad_to_deg(`angle $resultant0 $resultant1`)) ); } else{ rotate -r 0 (rad_to_deg(`angle $resultant0 $resultant1`)) 0; $xRot[$pCount] = (rad_to_deg(`angle $resultant0 $resultant1`)) ; } //get the 2 point locations on y direction [0] and [3] for rotation X float $toVec2[] = `pointPosition $selectedVertex[0]`;//connecting point float $toVec3[] = `pointPosition $selectedVertex[3]`; vector $unrollVec2 = <<($toVec3[0]) , ($toVec2[1]), ($toVec2[2]) >>;//connecting point vector $unrollVec3 = <<($toVec3[0]) , ($toVec3[1]), ($toVec3[2]) >>; vector $resultant2 = $unrollVec3 - $unrollVec2; vector $projected1 = <<($toVec3[0]) , ($toVec3[1]), ($toVec2[2]) >>; vector $resultant3 = $projected1 - $unrollVec2; //conditions for the direction of rotation if(($toVec2[2]) > ($toVec3[2]) ){ rotate -r (rad_to_deg(`angle $resultant2 $resultant3`)) 0 0; $yRot[$pCount] = (rad_to_deg(`angle $resultant2 $resultant3`)); } else{ rotate -r (0 - (rad_to_deg(`angle $resultant2 $resultant3`))) 0 0; $yRot[$pCount] = ( 0 -(rad_to_deg(`angle $resultant2 $resultant3`)) ); } $pCount++; currentTime $pCount; //print the x and y rotation value for flattening print ("HiroPoly" + $pCount + " yRotation = "); print ( rad_to_deg(`angle $resultant0 $resultant1`)); print ("\n"); print ("HiroPoly" + $pCount + " xRotation = "); print ( rad_to_deg(`angle $resultant2 $resultant3`)); print ("\n\n"); }