Script : Harden edges of all UV borders

Here's a MEL Script to harden the edges that are attached to UV borders. When baking Normal maps you generally put your UV seams in areas that require hard edges. This script automates the hardening of the edges prior to baking. Super useful.

string $objList[] = `ls -sl -o`;
string $uvBorder[];
string $edgeUVs[];
string $finalBorder[];

for ($subObj in $objList) {
select -r $subObj;
polyNormalPerVertex -ufn true;
polySoftEdge -a 180 -ch 1 $subObj;
select -r $subObj.map["*"];

polySelectBorderShell 1;

$uvBorder = `polyListComponentConversion -te -in`;
$uvBorder = `ls -fl $uvBorder`;

clear( $finalBorder );

for( $curEdge in $uvBorder ) {
$edgeUVs = `polyListComponentConversion -tuv $curEdge`;
$edgeUVs = `ls -fl $edgeUVs`;

if( size( $edgeUVs ) > 2 ) {
$finalBorder[ size( $finalBorder ) ] = $curEdge;
}
}

polySoftEdge -a 0 -ch 1 $finalBorder;
}

select -r $objList;

No comments:

About Me

My photo
I am a video game artist at Dovetail games, working on Train Simulator 2014, 2015 and an unannounced title. I also graduated from the CG Arts course at UCA in 2010 with a First Class. www.jonstewart.co.uk