08 July 2011

Mel Scripting - Moving UVs

Here's a script I thought of when I was trying to match the UVs of 2 different objects. If you use the Smooth UV tool and are anal about your UVs then this may come in handy however most people don't even care if 2 walls have slightly off brick textures!

This script has the ability to move and scale UVs.

if (`window -exists MovingUVs`)
deleteUI MovingUVs;

textureWindowSelectConvert 4; //making sure we select UVs of the object

window -width 20 -height 20 "MovingUVs";

gridLayout
-numberOfRowsColumns 1 3
-cellWidthHeight 75 20;

text -l " "; //blank space
button -label "Up" -c "GoingUp();";
text -l " ";
button -label "Left" -c "GoingLeft();";
text -l " ";
button -label "Right" -c "GoingRight();";
text -l " ";
button -label "Down" -c "GoingDown();";
text -l " ";
button -label "Scale+" -c "ScaleUp();";
text -l " ";
text -l " ";
button -label "Scale-" -c "ScaleDown();";

setParent ..;

showWindow MovingUVs;

      //edit these values if you it to have a greater effect
global proc GoingUp()
{
       polyEditUV -u 0 -v 0.001;
}
global proc GoingDown()
{
       polyEditUV -u 0 -v -0.001;
}
global proc GoingLeft()
{
       polyEditUV -u -0.001 -v -0;
}
global proc GoingRight()
{
       polyEditUV -u 0.001 -v -0;
}
global proc ScaleUp()
{
       polyEditUV -su 1.001 -sv 1.001 ;
}
global proc ScaleDown()
{
       polyEditUV -su 0.999 -sv 0.999 ;
};

No comments:

Post a Comment