Hey guys, I'm having some trouble with this.
Suppose I have selected a face (or faces) on a model. I need (in Mel) to get the U and V values for each vertex on that face, but since each vertex can have multiple UV coordinates (and many of them will), they have to be the UVs that control the texture position of just that face, not any adjacent faces. But in all cases, the UVs will be an entire shell. Does that make sense?
Or alternately, I guess, can I select a face and convert that to a particular UV shell? And then get the U and V values for each vertex in that shell?
The reason I need this is because I had a texture atlas that I have used on close to 200 models. I then changed the texture atlas (it uses all the same subtextures, but in different places and in some cases different sizes), so now all my models are mis-UVed. So the idea is to write a script where I select the faces I want to fix, hit a button, and it adjusts the UV coordinates to their new position.
I can map the old UV coords to what they need to be changed to fit the new atlas (in fact, I already have the equations for this all written down). But first I need to get those old values, and I'm having a hard time of it figuring out how to grab them.
EDIT: I've gotten as far as "polySelectBorderShell 0;", which seems to do what I want in terms of selecting the UV shell for any given select face. Now I need the U and V values for all vertices on that shell...
EDIT2: This is what I have so far, which is getting pretty close, I have access to the individual components now. The UVs are not necessarily in the range of 0->1, so they have to first be normalized. The problem with this script is the U is being normalized, but the V is not, and I have no clue why. Anyone see what I'm doing wrong here?
string $select[] = `ls -sl`;
//convert any selected meshes to faces
PolySelectConvert 1;
//grab a list of the faces
string $faceList[] = `filterExpand -sm 34`;
//grab a list of the faces
for ($i=0; $i<size($faceList); $i++)
{
select $faceList[$i];
polySelectBorderShell 0;
ConvertSelectionToUVs;
string $UVList[] = `filterExpand -sm 35`;
for ($j=0; $j<size($UVList); $j++)
{
select $UVList[$j];
float $pos[] = `polyEditUV -q -u`;
while ($pos[0] < 0)
{
polyEditUV -u 1.0;
$pos = `polyEditUV -q -u`;
}
while ($pos[0] > 1)
{
polyEditUV -u -1.0;
$pos = `polyEditUV -q -u`;
}
$pos = `polyEditUV -q -v`;
while ($pos[0] < 0)
{
polyEditUV -v 1.0;
$pos = `polyEditUV -q -v`;
}
while ($pos[0] > 1)
{
polyEditUV -v -1.0;
$pos = `polyEditUV -q -v`;
}
}
};