// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // Creation Date: Mar. 14, 1997 // // Description: // The nurbsToPolyPreset() procedure tesselates each // selected object. // global proc nurbsToPolyPreset( int $doHistory, int $format, int $merge, int $mrt, int $type, int $count, float $chr, float $ft, float $mel, float $d, int $ut, int $un, int $vt, int $vn, int $uch, int $ucr, float $cht, int $es ) { // Get a list of surfaces to tesselate and execute the cmd on each. // global int $gSelectNurbsSurfacesBit; string $surfaces[] = `filterExpand -ex true -sm $gSelectNurbsSurfacesBit`; if( size($surfaces) > 0 ) { // merge results into a single mesh or not // int $doMerge = ((size($surfaces)>1) && $merge == 1); string $cmd = ($doMerge) ? "makeSingleSurface" : "nurbsToPoly"; // Piece together the appropriate tesselate command // $cmd = $cmd + " -mnd 1 " + " -ch " + $doHistory + " -f " + $format + " -pt " + $type + " -pc " + $count + " -chr " + $chr + " -ft " + $ft + " -mel " + $mel + " -d " + $d + " -ut " + $ut + " -un " + $un + " -vt " + $vt + " -vn " + $vn + " -uch " + $uch + " -ucr " + $ucr + " -cht " + $cht + " -es " + $es ; // Add the flag that will properly map texture space on // tesselated trimmed surfaces. // $cmd = $cmd + " -ntr "; $cmd = $cmd + "0"; string $results[]; // single or multiple output surfaces if($doMerge) { // Need to get the tolerance if we are merging meshes. float $mergeTol = `nurbsToPolygonsPref -q -mergeTolerance`; $cmd += (" -stitchTolerance " + $mergeTol); int $nsrf = size($surfaces); int $i; for($i=0; $i<$nsrf; $i++) { $cmd += " " + $surfaces[$i]; } $results = evalEcho( $cmd ); } else { // match render tessellation only applies if not merging surfaces $cmd = $cmd + " -mrt " + $mrt; // add use the existing surface shader flag. // $cmd = $cmd + " -uss " ; $cmd = $cmd + "1" ; $cmd = $cmd + " %s"; $results = executeForEachObject( $surfaces, $cmd ); } if( (size($results)) == 0 ) { error (uiRes("m_nurbsToPolyPreset.kFailedOnSelection")); } else { if($doMerge) { // If we merged the polys and the poly has a nonzero // faceEdge count (ie it is there) then layout the uv's in // an appropriate manner. if (size(`polyInfo -fe $results[0]`) > 0) { polyLayoutUV -layout 2 -scale 1 -separate 1 -rotateForBestFit 0 -flipReversed 1 -percentageSpace 0.2 -ch 1 $results[0]; } else { error (uiRes("m_nurbsToPolyPreset.kFailedTesselation")); } } // Select all the results with one select command. Note that only // resulting meshes are selected, not dependency nodes. // string $selectString; $selectString = "select "; int $i; int $numResults = size($results); for( $i = 0; $i < $numResults; $i ++ ) { $selectString += $results[$i]; $selectString += " "; } $selectString += ";"; select -cl; eval($selectString); } } else { error (uiRes("m_nurbsToPolyPreset.kInvalidSelection")); } }