// EJL_maya2008_activeSmooth proc EJL_maya2008_activeSmooth(int $blinn) { global string $smoothed[]; global string $sg; global string $startup; global int $wosstate; global int $typeresult; int $CSL[]; int $size = `size($smoothed)`; float $spec = 0.15702; /* // turn edges back normal displayColor -active "lead" 19; displayColor -dormant "polyEdge" 22; // exit uber snap tool if (`objExists "EJL_ubersnaptool_geo"`) { delete EJL_ubersnaptool_geo; } */ // go to object mode toggleSelMode; toggleSelMode; selectMode -object; // get info string $sel[] = `ls -sl`; int $size2 = `size($sel)`; // check to ensure something was selected if ($size == 0) { if ($size2 == 0) { error "EJL Says: Nothing selected, and nothing currently smoothed. Select something first!\n"; } } // has the script been used during this maya session? If not, delete any un-used shaders to prevent errors if ($startup != 1) { hyperShadePanelMenuCommand("hyperShadePanel1", "deleteUnusedNodes"); } // since the script is currently being executed, set startup variable to one so it will be detected next time. $startup = 1; // if user has toggled blinn mode on... if ($blinn == 1) { // create shader for object being manipulated if ( !`objExists "EJL_blinn"`) { string $shader = `shadingNode -asShader -n EJL_blinn blinn` ; $sg = `sets -renderable true -noSurfaceShader true -empty -name EJL_blinnSG`; connectAttr -f ($shader + ".outColor") ($sg + ".surfaceShader"); setAttr "EJL_blinn.specularColor" -type double3 $spec $spec $spec ; } } ///////////////////////////////////////////////////////////////////////////////////////////////// // if item is smoothed... if ($size != 0) { // find out what the user has selected, object or components, and record! /* $typeresult = 0; string $objresult[]; //is selection poly objects? $objresult = `filterExpand -sm 12`; if (size($objresult)) { $typeresult = 1; } //is selection verticies? $objresult = `filterExpand -sm 31`; if (size($objresult)) { $typeresult = 2; } //is selection edges? $objresult = `filterExpand -sm 32`; if (size($objresult)) { $typeresult = 3; } //is selection faces? $objresult = `filterExpand -sm 34`; if (size($objresult)) { $typeresult = 4; } //is selection uvs? $objresult = `filterExpand -sm 35`; if (size($objresult)) { $typeresult = 5; } */ for ($y in $smoothed) { select -r $y; string $polytest[]; string $nurbstest[]; int $polyresult = 0; int $nurbsresult = 0; int $addition = 0; //is selection poly objects? $polytest = `filterExpand -sm 12`; if (size($polytest)) { $polyresult = 1; } //is selection nurbs objects? $nurbstest = `filterExpand -sm 12`; if (size($nurbstest)) { $nurbsresult = 1; } $addition = ($polyresult + $nurbsresult); if ($addition != 0){ if ( `objExists $y`) { select -r $y; displaySmoothness -divisionsU 0 -divisionsV 0 -pointsWire 4 -pointsShaded 1 -polygonObject 1; setDisplaySmoothness 0; if ($blinn == 1) { sets -e -forceElement initialShadingGroup; } else { clear($smoothed); } } } else { // item is not a polygon or nurbs geo, skip! } // end loop } // re-validate list of smoothed items to prune deleted objects. string $newsmoothed[]; int $newsize = 0; for ($z in $smoothed) { if ( `objExists $z`) { $newsmoothed[$newsize] = $z; $newsize = ($newsize + 1); } } select -r $newsmoothed; clear($smoothed); // check to see if WOS was on before smoothing, if so, return to that state if ($wosstate == 1){ string $currentPanel = `getPanel -withFocus`; modelEditor -edit -wos 1 $currentPanel; modelEditor -e -smoothWireframe 1 $currentPanel; } } //////////////////////////////////////////////////////////////////////////////////////////// // if item is NOT smoothed... if ($size2 != 0) { for ($x in $sel) { select -r $x; string $polytest[]; string $nurbstest[]; int $polyresult = 0; int $nurbsresult = 0; int $addition = 0; //is selection poly objects? $polytest = `filterExpand -sm 12`; if (size($polytest)) { $polyresult = 1; } //is selection nurbs objects? $nurbstest = `filterExpand -sm 12`; if (size($nurbstest)) { $nurbsresult = 1; } $addition = ($polyresult + $nurbsresult); if ($addition != 0){ $CSL = `displaySmoothness -q -polygonObject $x`; if ($CSL[0] != 3) { $smoothed = $sel; select -r $x; displaySmoothness -divisionsU 2 -divisionsV 2 -pointsWire 16 -pointsShaded 4 -polygonObject 2; setDisplaySmoothness 3; if ($blinn == 1) { select -r $x; sets -e -forceElement $sg $x; } } } else { // skip this object, it is not a polygon or nurbs object! } // end for loop } // record WOS state, and set WOS to off string $currentPanel = `getPanel -withFocus`; int $state = `modelEditor -q -wos $currentPanel`; if ($state == 1){ modelEditor -edit -wos 0 $currentPanel; modelEditor -e -smoothWireframe 1 $currentPanel; // remember that WOS was on before smoothing $wosstate = 1; } else{ // already smoothed! } // go to object mode toggleSelMode; toggleSelMode; selectMode -object; select -cl; // end of 'if items is not smoothed...' } } EJL_maya2008_activeSmooth 1 ;