// aimNormal takes all the selected vertexFaces (or the vertexFaces associated with // selected faces, edges, or vertexes, and point their normals toward the last selected // object. proc aimNormalWork ( string $currentObject, string $targetObject ) { /* This procedure should handle the main work of grabbing the vector from each polygon vertexFace to the target object and setting the normal of the vertexFace to the normalized vector */ string $vertexFaceList[] = `polyListComponentConversion -toVertexFace $currentObject`; // convert and faces, edges, or normal vertex to their vertexFace equivalent $vertexFaceList = `filterExpand -sm 70 -ex true $vertexFaceList`; // expand the vertex face list into individual names, instead of Maya's default compressed format string $vtxFace; for ($vtxFace in $vertexFaceList) { float $vtx[3] = `xform -ws -q -t $vtxFace`; // gets the worldspace location of the vertexface in vector style form (i don't like Maya vectors, so it's an array) float $targetVect[3] = `xform -ws -q -t $targetObject`; // gets worldspace location of target object float $vectVal[3]; $vectVal[0] = $targetVect[0] - $vtx[0]; $vectVal[1] = $targetVect[1] - $vtx[1]; $vectVal[2] = $targetVect[2] - $vtx[2]; // this gives you $vectVal, which is the vector from the vtxFace to the target object //normalize da vector! warning, inefficient code ahead //also, I know there is a normalize command, but it doesn't work like I want it to. float $highestVal = $vectVal[0]; if ( abs($vectVal[1]) > abs($highestVal) ) $highestVal = $vectVal[1]; if ( abs($vectVal[2]) > abs($highestVal) ) $highestVal = $vectVal[2]; // gets the highest value of the 3 $vectVal[0] = $vectVal[0] / abs($highestVal); $vectVal[1] = $vectVal[1] / abs($highestVal); $vectVal[2] = $vectVal[2] / abs($highestVal); // normalizes the three numbers, keeping their relative values the same, ratio wise polyNormalPerVertex -xyz $vectVal[0] $vectVal[1] $vectVal[2] $vtxFace; //(normalized vector Should work damnit!) // (Might not work, since you may be doing shared normals one at a time, and // the could move each other as you do them) // could also try selecting groups of normals in the same affected family, and setting their // normals all at once } } global proc aimNormal () { $selectionList = `ls -sl`; //get selection list //check last object, if it it a vertex or vertex face, perform the actin anyway, but pop // up a warnign explaining that all normals end up pointing at the last selected object, // except the last object (if it is a vtx or vtxFace) // Later: Ok, how about just get last object for now? Cool string $lastObject = $selectionList[ size( $selectionList ) - 1 ]; //get object //$selectionList[size( $selectionList )] = " "; //clear target object from selection list for ($node in $selectionList) { aimNormalWork( $node, $lastObject); } return; }