Weird problem: UV coord order expertise needed

Hi

Ok...I got a prob that makes my head spinn...

I retreive UV coords from faces by this:


select -r eyeL_hi.f[0];
select polyListComponentConversion -ff -tv -tuv;
polyEditUV -q;
// Result: 0.140006 0.281843 0.218835 0.310023 0.175482 0.26398 0.217163 0.332342 //

Which UV Coord belongs to which vertice in that face?

If I look in the *.ma file, at the current face info...I
get the same UV Coords, but in a different order.
So the texturing becomes a sad sight in my program,
I presumed this from the result.....

vertice 0: 0.140006 0.281843
vertice 1: 0.218835 0.310023
vertice 2: 0.175482 0.26398
vertice 3: 0.217163 0.332342

But following the correct order in the *.ma file, it would
be like this:

vertice 0: 0.217163 0.332342
vertice 1: 0.140006 0.281843
vertice 2: 0.175482 0.26398
vertice 3: 0.218835 0.310023

Id like to have it in the right order out from my MEL script, even if I can compensate for it in my program...

pls help

/Sumo

use polyInfo instead, it'll return the vertices in face order.

eg:
polyInfo -fv pCube1.f[0];
// Result: FACE 0: 0 1 3 2
the verts of f[0] are 0,1,3,2 in counter-clockwise order.

Hi...thx for your reply!!

I use polyInfo -fv shape.f[x]; to get the vertices. So I think that ccw order is correct. I can render shapes correct in wireframe, differnet shadings etc. The problem is the textures..and probably because of the uvcoords...

I wish there was a way to do the following.

polyInfo -fv shape.f[0];
-> FACE 0: 1 2 3 4
polyInfo -fuv shape.f[0];
-> Face 0: 0.11 0.12 0.22 0.23 0.32 0.33 0.44 0.45

and from that Id know the uvs for each vertice on that face....ex:
vertice 0: (0.11 0.12)
vertice 2: (0.22 0.23)
...
etc

But this cant be done, seems to be no flag for getting the uvcoords with polyInfo. The only way I know is

select shape.f[0];
select polyListComponentConversion -ff -tuv;
float $uvCoords[] = polyEditUV -query;

But Im not sure of the order here, all I know is that my textures looks crappy...like looking through a shower.
There seems to be a mismatch between the uvcoords and the vertices....different orders or something, compared with the *.ma file.

You can get the verts in order, and you can convert face to vert and face to uv, and you can query the uv's of a vert. All you have to do is find the uv associated with the vert that is also part of the same face.

something like this...

proc int[] getUVIndiciesForFace(string $faceStr) {
string $longUVlist[], $tokens[], $uv;
int $numTokens, $numUVs, $result[];

$numUVs = 0;

$longUVlist = polyListComponentConversion -fromFace -toUV $faceStr;

for ($uv in $longUVlist) {
$numtokens = tokenize $uv "[:]" $tokens;
$numTokens = size($tokens);
// check for just a single uv number
if ($numTokens == 2) {
$result[$numUVs] = $tokens[1];
$numUVs++;
} else if ($numTokens == 3) {
int $from, $to;
$from = $tokens[1];
$to = $tokens[2];
for ($vert = $to; $vert >= $from; $vert--) {
$result[$numUVs] = $vert;
$numUVs++;
}
}
}
return $result;
}

Hi & many thx..

It seems like you get the same order as I did, which isn't the same compared to the original *.ma file...

ex:

for a face in the model:
$result is [3 49 48 52]

for the same face in the *.ma file
$order is [52 3 49 48]


f 4 4 5 6 7
mu 0 4 52 3 49 48


I was wondering how to get indexkeys instead of 2 float values...so this still helps a lot....maybe its possible to fprint a UVCoord list that corresponds to the order I get with the script in $result....

ex uvcoord nr 3 in the new list has the same u,v values as uvcoord nr 52 in the old list....or something..dunno how to proceed on that right now....

/Sumo

Hello
this is a short script that checks what uv-cord correlates to what vertex, I've put in a check if theres more UV-cords per vertex.
Hopefully this will be to some help

string $fSelec[]=filterExpand -sm 34; //names of selected verts
string $uvTemp[];
string $uvVertex[];
for ($zi=0; $zi < (size ($fSelec)); ++$zi) {
select $fSelec[$zi];
PolySelectConvert 4; //converts to UV-cords
string $uvSelec[]=filterExpand -sm 35;
PolySelectConvert 3;//converts to vertex
string $vxSelect[]=filterExpand -sm 31;

int $num=size ($vxSelect);
for ($i=0; $i < ($num); ++$i) {
	select $vxSelect[$i];
	PolySelectConvert 4;
	string $uvTemp[]=`filterExpand -sm 35`;

	$uNum=size ($uvTemp);
	for ($xi=0; $xi < ($uNum); ++$xi) {
		if ($uvSelec[$i]==$uvTemp[$xi])$uvVertex[$i]=$uvTemp[$xi];
		}
	}

//this part just prints out face, vertex and its uv cord
print ("nFace:"+$fSelec[$zi]+"n");
for ($i=0; $i < ($num); ++$i) {
print ("Vertex: "+$vxSelect[$i]+" UV:"+$uvVertex[$i]+"n");
}
}