Hi everyone, I'm looking for a rock solid way to take an arbitrary UV shell and rotate it so it always faces the same way in the UV editor, V being Y-up basically. I've tried a number of solutions, but I can't seem to find a reliable way to calculate this. If it helps the UV shell will always be a perfect right angle alignment to start, but it needs to work on arbitrary models with arbitrary shapes and normal angles. Does anyone know a method of doing this? Image attached.
Hi everyone, I'm looking for a rock solid way to take an arbitrary UV shell and rotate it so it always faces the same way in the UV editor, V being Y-up basically. I've tried a number of solutions, but I can't seem to find a reliable way to calculate this. If it helps the UV shell will always be a perfect right angle alignment to start, but it needs to work on arbitrary models with arbitrary shapes and normal angles. Does anyone know a method of doing this? Image attached.
Have you considered using "colorAtPoint" to sample the color value at each corner to determine which rotate action is required to orient the UVs?
Have you considered using "colorAtPoint" to sample the color value at each corner to determine which rotate action is required to orient the UVs?
I have not, and I've never heard of colorAtPoint, please explain further? How does it work there aren't any vertex colours on these objects.
I have not, and I've never heard of colorAtPoint, please explain further? How does it work there aren't any vertex colours on these objects.
Since you are using the same image, you can sample the image with `colorAtPoint -output RGB -u 0 -v 0 texturefile`. Then sample at u=0:v=1 and if that's not enough, then another sample at u=1:v=0 and u=1:v=1. Depending on the results, you can figure out whether to rotate you're uv shell, + or -.
Since you are using the same image, you can sample the image with `colorAtPoint -output RGB -u 0 -v 0 texturefile`. Then sample at u=0:v=1 and if that's not enough, then another sample at u=1:v=0 and u=1:v=1. Depending on the results, you can figure out whether to rotate you're uv shell, + or -.
Oh that's really interesting, let me look into this further and see if I can make it work.
Oh that's really interesting, let me look into this further and see if I can make it work.
So I looked into colorAtPoint and I'm not sure how this command could be helpful, unless I'm missing something it just returns the colour of the texture at the point you specify, it doesn't have any relation to the mesh UVs so the colours it returns are always the same no matter what UVs you give it. Any other suggestions, this may have worked if it used the mesh UVs.
So I looked into colorAtPoint and I'm not sure how this command could be helpful, unless I'm missing something it just returns the colour of the texture at the point you specify, it doesn't have any relation to the mesh UVs so the colours it returns are always the same no matter what UVs you give it. Any other suggestions, this may have worked if it used the mesh UVs.
Give this a try:
// SELECT THE FIRST VERTEX OF EACH MESH
string $sel[] = `ls -sl`;
string $map = stringArrayToString( ls("-flatten", `polyListComponentConversion -fv -tuv $sel[0]`), " ");
float $uvc[] = `polyEditUV -q $map`;
string $map1 = stringArrayToString( ls("-flatten", `polyListComponentConversion -fv -tuv $sel[1]`), " ");
float $uvc1[] = `polyEditUV -q $map1`;
string $parts[];
tokenize($sel[1], ".", $parts);
string $maps[] = `ls -flatten ($parts[0]+".map[*]")`;
if($uvc[0] < $uvc1[0])
polyEditUV -pu .5 -pv .5 -angle -90 $maps;
else if($uvc[1] < $uvc1[1])
polyEditUV -pu .5 -pv .5 -angle 90 $maps;
Give this a try:
// SELECT THE FIRST VERTEX OF EACH MESH
string $sel[] = `ls -sl`;
string $map = stringArrayToString( ls("-flatten", `polyListComponentConversion -fv -tuv $sel[0]`), " ");
float $uvc[] = `polyEditUV -q $map`;
string $map1 = stringArrayToString( ls("-flatten", `polyListComponentConversion -fv -tuv $sel[1]`), " ");
float $uvc1[] = `polyEditUV -q $map1`;
string $parts[];
tokenize($sel[1], ".", $parts);
string $maps[] = `ls -flatten ($parts[0]+".map[*]")`;
if($uvc[0] < $uvc1[0])
polyEditUV -pu .5 -pv .5 -angle -90 $maps;
else if($uvc[1] < $uvc1[1])
polyEditUV -pu .5 -pv .5 -angle 90 $maps;
That code doens't work for me for whatever reason, it looks like there's a formatting errror so maybe something else was lost when it was pasted as text rather than code into this forum.
Also I should've mentioned my model consists of mutliple faces not just a single quad and each face is unitized. I'm basically trying to figure out how to get Maya's unitize command to return UVs that are all rotated the same way.
That code doens't work for me for whatever reason, it looks like there's a formatting errror so maybe something else was lost when it was pasted as text rather than code into this forum.
Also I should've mentioned my model consists of mutliple faces not just a single quad and each face is unitized. I'm basically trying to figure out how to get Maya's unitize command to return UVs that are all rotated the same way.
Are you getting errors?
Are you getting errors?
Yeah looks like it is erroring out here
string $map1 = stringArrayToString( ls("-flatten", `polyListComponentConversion -fv -tuv $sel[1]`), " ");
// Error: line 1: No object matches name: //
// Error: line 1: Error evaluating argument at position 1 in procedure "stringArrayToString". //
Yeah looks like it is erroring out here
string $map1 = stringArrayToString( ls("-flatten", `polyListComponentConversion -fv -tuv $sel[1]`), " ");
// Error: line 1: No object matches name: //
// Error: line 1: Error evaluating argument at position 1 in procedure "stringArrayToString". //
I did not, I selected only one mesh so I guess that was my problem sorry. The result was unfortunately undesireable after selecting two meshes, and vertex[0] on both though, it rotated the second mesh UVs the wrong way and left the first mesh UVs the way they were. I also don't have multiple meshes so it's not entirely clear if this method could solve my problem because I'm trying to figure out how to rotate one UV shell or a bunch of UV shells to all face the same way in UV space on a single mesh. Positive or negative doesn't matter though, I just want the arrows to face up or down and never sideways. Perhaps my initial diagram was confusing heres another image if helps, I would always like the UVs to face world space Y up.
I did not, I selected only one mesh so I guess that was my problem sorry. The result was unfortunately undesireable after selecting two meshes, and vertex[0] on both though, it rotated the second mesh UVs the wrong way and left the first mesh UVs the way they were. I also don't have multiple meshes so it's not entirely clear if this method could solve my problem because I'm trying to figure out how to rotate one UV shell or a bunch of UV shells to all face the same way in UV space on a single mesh. Positive or negative doesn't matter though, I just want the arrows to face up or down and never sideways. Perhaps my initial diagram was confusing heres another image if helps, I would always like the UVs to face world space Y up.
After much searching a found a semi-reliable way to achieve this with some built in Maya commands.
//Rotate shell so Yup is V in UV space
u3dLayout -res 256 -rot 4 -box 0 1 0 1 -ls 1;
//Select shell border and orient to fix rotation bug from above tool not aligning correctly
ConvertSelectionToEdges;
ConvertSelectionToShellBorder;
texOrientEdge;
After much searching a found a semi-reliable way to achieve this with some built in Maya commands.
//Rotate shell so Yup is V in UV space
u3dLayout -res 256 -rot 4 -box 0 1 0 1 -ls 1;
//Select shell border and orient to fix rotation bug from above tool not aligning correctly
ConvertSelectionToEdges;
ConvertSelectionToShellBorder;
texOrientEdge;
looking for the exact same feature. Sadly your latest solution didn't worked for me. Any hints? I mean it runs the "Orient to Edge" command, but it still not correctly rotated. Makes me a bit crazy 🙂
looking for the exact same feature. Sadly your latest solution didn't worked for me. Any hints? I mean it runs the "Orient to Edge" command, but it still not correctly rotated. Makes me a bit crazy 🙂
I found a solution to my problem that didn't need shell rotation so I stopped working on this issue. That said, the closest I got was getting the shells to orient Y up, but sometimes they would be Y+ and Y- and the layout command wouldn't work because you have to select between two modes, orient Y straight and orient Y angled. I guess Maya has two different commands if the geometry is right angled or if it's diagonal and you have to choose which command to use for the appropriate shape. Also that won't help with figuring out how to get the sell Y+ it will just randomly make the shell Y aligned.
Here are the commands if you want to research further
//Orient Y
u3dLayout -res 64 -rot 4 -trs 1 -spc 0.0078125 -mar 0.00390625 -box 0 1 0 1 -ls 1;
//Orient V
u3dLayout -res 64 -rot 2 -trs 1 -spc 0.0078125 -mar 0.00390625 -box 0 1 0 1 -ls 1;
I found a solution to my problem that didn't need shell rotation so I stopped working on this issue. That said, the closest I got was getting the shells to orient Y up, but sometimes they would be Y+ and Y- and the layout command wouldn't work because you have to select between two modes, orient Y straight and orient Y angled. I guess Maya has two different commands if the geometry is right angled or if it's diagonal and you have to choose which command to use for the appropriate shape. Also that won't help with figuring out how to get the sell Y+ it will just randomly make the shell Y aligned.
Here are the commands if you want to research further
//Orient Y
u3dLayout -res 64 -rot 4 -trs 1 -spc 0.0078125 -mar 0.00390625 -box 0 1 0 1 -ls 1;
//Orient V
u3dLayout -res 64 -rot 2 -trs 1 -spc 0.0078125 -mar 0.00390625 -box 0 1 0 1 -ls 1;
Hey,
thanks for your quick answer. I also kept up looking for a solution meanwhile. So was also looking for tools out there and found "Polyraven UV tools". There is a function inside, that does exactly what we want. I work mostly with Z up and works really well for me. The price was at least worth avoided headache the rest of the day, week or whatever :).
I mean not the best solution, but at least it helped me.
Hey,
thanks for your quick answer. I also kept up looking for a solution meanwhile. So was also looking for tools out there and found "Polyraven UV tools". There is a function inside, that does exactly what we want. I work mostly with Z up and works really well for me. The price was at least worth avoided headache the rest of the day, week or whatever :).
I mean not the best solution, but at least it helped me.
Oh interesting, but does it always work even on geometry that is diagonal. I had already added orient X, Y, Z and horizontal, vertical to my UV tool a while back. I'm wondering if the polyRaven is any better in that respect? You can check out my tool here https://youtu.be/exrJNgaqb20?list=PLAUgGUDpaMENfz8Nd7Zw-LxDK_v5ZflY6&t=104
Oh interesting, but does it always work even on geometry that is diagonal. I had already added orient X, Y, Z and horizontal, vertical to my UV tool a while back. I'm wondering if the polyRaven is any better in that respect? You can check out my tool here https://youtu.be/exrJNgaqb20?list=PLAUgGUDpaMENfz8Nd7Zw-LxDK_v5ZflY6&t=104
about diagonal. That is a good question. So if i understood you correct, yes it works. See screenshot.
Edit: other side of the mesh looks similar. If you have more questions, let me know.
about diagonal. That is a good question. So if i understood you correct, yes it works. See screenshot.
Edit: other side of the mesh looks similar. If you have more questions, let me know.
Could you try making a rectangle geometry in the front view and duplicate and rotate it 20 degrees so it's on an angle, then freeze transforms on both and planar from the front view. Then try the polyRaven button and see if it makes both shapes align correctly.
Could you try making a rectangle geometry in the front view and duplicate and rotate it 20 degrees so it's on an angle, then freeze transforms on both and planar from the front view. Then try the polyRaven button and see if it makes both shapes align correctly.
If i did it correct, it worked yes.This are the following steps i did:
1. create both cube (both 1m)
2. rotate left one by 20 degrees
3. Freeze Transformations on both
4. Auto Mapping so each face is single
5. stack sheels (not needed)
6. used the tool exacttly like in my first screenshot in my post above. (UV Space: Auto and World Space Z).
On a car i worked on today, i had the situation where i not worked on the first time. i switched to Hor. instead of auto, clicked, switched back to auto, clicked again and then it worked.
let me know if you have more questions. i hope i don't celebrate to early for you, but for me it works like i want. 🙂
Greets Spaehling
If i did it correct, it worked yes.This are the following steps i did:
1. create both cube (both 1m)
2. rotate left one by 20 degrees
3. Freeze Transformations on both
4. Auto Mapping so each face is single
5. stack sheels (not needed)
6. used the tool exacttly like in my first screenshot in my post above. (UV Space: Auto and World Space Z).
On a car i worked on today, i had the situation where i not worked on the first time. i switched to Hor. instead of auto, clicked, switched back to auto, clicked again and then it worked.
let me know if you have more questions. i hope i don't celebrate to early for you, but for me it works like i want. 🙂
Greets Spaehling
Can't find what you're looking for? Ask the community or share your knowledge.