// Created by Alex Hogan, Turbine Entertainment Software // This script takes the selected vertexFaces (or the vertex faces asssociated with // a selected edge, face, or vertex) and sets either the x, y, or z component to zero, // and a few other useful functions. // Note: This script works best if you select the vertex faces themselves. // Also, sometimes non-selected normals will move arbitrarily because of Maya's shared // normal system. Locking all of the normals on the mesh you are working on before running // flattenNormal will prevent this. // use as flattenNormal x; flattenNormal y; or flattenNormal z; // // updated on December 10, 2002 by Alex - // added posx, negx, posy, negy, posz, negz arguments, which set all the selected components' // vertex faces to be completely positive or negative in that direction. proc flattenNormalWork ( string $vtxFace, string $axis ) { float $vtxNormals[3] = `polyNormalPerVertex -q -xyz $vtxFace`; // gets the current vertex normal switch ( $axis ) //sets the new one, setting the specified axis to zero { case "x": polyNormalPerVertex -xyz 0 $vtxNormals[1] $vtxNormals[2] $vtxFace; //sets the specified axis to zero break; case "posx": polyNormalPerVertex -xyz 1 0 0 $vtxFace; break; case "negx": polyNormalPerVertex -xyz -1 0 0 $vtxFace; break; case "y": polyNormalPerVertex -xyz $vtxNormals[0] 0 $vtxNormals[2] $vtxFace; //on the current vertex-face break; case "posy": polyNormalPerVertex -xyz 0 1 0 $vtxFace; break; case "negy": polyNormalPerVertex -xyz 0 -1 0 $vtxFace; break; case "z": polyNormalPerVertex -xyz $vtxNormals[0] $vtxNormals[1] 0 $vtxFace; break; case "posz": polyNormalPerVertex -xyz 0 0 1 $vtxFace; break; case "negz": polyNormalPerVertex -xyz 0 0 -1 $vtxFace; break; default: print "Erur - No case switch found, m'lord.\n"; break; } } global proc flattenNormal ( string $axis ) { int $erur = 0; switch ( $axis ) //check to make sure there is a proper axis specidied { case "x": break; case "posx": break; case "negx": break; case "y": break; case "posy": break; case "negy": break; case "z": break; case "posz": break; case "negz": break; default: $erur = 1; break; } if ( $erur == 0 ) { $selectionList = `ls -sl`; //get selection list string $vertexFaceList[] = `polyListComponentConversion -toVertexFace $selectionList`; // 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 for ($node in $vertexFaceList) { flattenNormalWork( $node, $axis); } //refresh; //string $didit = `polyAverageNormal -prenormalize 1 -allowZeroNormal 0 -postnormalize 0 -distance 0.1 -replaceNormalXYZ 1 0 0 $selectionList`; } else { print "\nSyntax error: You must specify either the x, y, or z axis to flatten."; print "\nCorrect usage for x axis is 'flattenNormal x'\n"; } return; }