Home Technical Talk

maya move uv shells into 0-1 from relative position.

polycount sponsor
Offline / Send Message
malcolm polycount sponsor
Does anyone know of a tool that will take uv shells and move them into the 0-1 uv range without changing their relative positions in the uv editor. I'm cleaning up some messy props and artists have their shells scattered randomly sometimes 100 tiles away from zero, I'd like to click a magic button and get these back in 0-1 without having to fix any uv's after the fact.

Replies

  • bugo
    Options
    Offline / Send Message
    bugo polycounter lvl 17
    Let's say you want to move the menu to the right, just make the code below:

    polyEditUV -u 1 -v 0 ;

    Left

    polyEditUV -u -1 -v 0 ;

    and etc..
  • MoP
    Options
    Offline / Send Message
    MoP polycounter lvl 18
    Well, bugo, that moves it by exactly one unit, which isn't exactly what he's after, and it'd mean changing the number for every different amount you need to move each piece.

    He wants a one-click solution for pieces of UV anywhere outside the 0-1 range.
    To do this you'd need to query the selection, find how far outside the 0-1 range they are, and offset them back by the opposite amount.

    Sounds like a fairly straightforward script, I might take a quick look now...
  • MoP
    Options
    Offline / Send Message
    MoP polycounter lvl 18
    malcolm: Try this... I just threw it together in 20 minutes now but it seems to work fairly well on the stuff I tried it out on. It may be a bit slower on objects with tens of thousands of UVs... it will work on any selection, but it'll be fastest if you manually select the parts you want to move into the 0-1 range first.

    mopGatherUVs

    Just copy this .mel file into your My Documents/maya/scripts/ folder, type rehash; into the MEL command line to refresh your script folder so that it picks it up (otherwise restart Maya).

    Then make a selection and type mopGatherUVs; into the command line. You could create a shelf button for this command.

    Let me know how it goes.

    Obviously this is used at your discretion, I accept no responsibility for any loss of work as a result of using this script (although I can't imagine anything would break that much, and you probably saved recently anyway, right? :) ).
  • malcolm
    Options
    Offline / Send Message
    malcolm polycount sponsor
    Hey that is fucking awesome. You are quite the fancy pants scripter these days thanks a lot!
  • bugo
    Options
    Offline / Send Message
    bugo polycounter lvl 17
    ahh, read wrong...
  • MoP
    Options
    Offline / Send Message
    MoP polycounter lvl 18
    So it worked ok?
  • Whargoul
    Options
    Offline / Send Message
    Whargoul polycounter lvl 18
    Hey Malcolm if you still have my toolset, it's called "normalize UVs" under the UV tab.
  • malcolm
    Options
    Offline / Send Message
    malcolm polycount sponsor
    Mop yeah it worked on a really fucked up object.

    Cody I never had your toolset I just had random one off buttons you ripped out for me.
  • ajr2764
    Options
    Offline / Send Message
    ajr2764 polycounter lvl 10
    Well that was interesting, I downloaded that script and tried it out also. That may be handy somtime in the future. Does anyone know of a simlar script that would pack all the uvs in 0 to 1 space tight and equally spaced like in headus uv layout you can choose pack uvs.
  • dproeder
    Options
    Offline / Send Message
    dproeder polycounter lvl 5
    bugo wrote: »
    Let's say you want to move the menu to the right, just make the code below:

    polyEditUV -u 1 -v 0 ;

    Left

    polyEditUV -u -1 -v 0 ;

    and etc..


    Haha this is actually what I was looking for. Thanks!
  • bugo
    Options
    Offline / Send Message
    bugo polycounter lvl 17
    no problem, lol
  • lod3
    Options
    Offline / Send Message
    Hi,

    Arriving late to the party, but, does anyone still have the MopGatherUV script? The link's 404, and I've been looking for something like this for days now.

    Thank you.
  • melxmel
    Options
    Offline / Send Message
    Hello everyone,

    lod3, have you found it ? I'm looking for this script as well :). Somebody please help :) !

    Thank you !
  • athyri
    Options
    Offline / Send Message
    hi there, i found the script via google, but it doesn't work for me. :/
    http://www.ldaustinart.com/paul//scripts/mopGatherUVs.mel
    i select the shells i want to move and type in mopGatherUVs;
    for a second a small window pops up, but the uvs stay exactly where they are and nothing else happens... :(
  • athyri
    Options
    Offline / Send Message
    with some small changes it works for me now. thanks alot MoP!

    // Procedure to automatically put UVs back inside the 0-1 range.

    mopGatherUVs;

    global proc mopGatherUVs()
    {
    // Check selection.
    string $uvSel[] = `polyListComponentConversion -tuv`;
    if ( !`size $uvSel` )
    {
    error "Please make a UV selection to gather into the 0-1 range.";
    }

    // Flatten component selection.
    $uvSel = `ls -fl $uvSel`;

    // Show progress.
    progressWindow
    -title "mopGatherUVs"
    -status "Gathering UVs..."
    -max `size $uvSel`
    -min 0
    -isInterruptable 1;

    for ( $uv in $uvSel )
    {
    // Check for user cancel request.
    if ( `progressWindow -q -isCancelled` )
    {
    break;
    }
    float $pos[] = `polyEditUV -q $uv`;
    float $offsetU = 0;
    float $offsetV = 0;
    int $move = 0;

    // Find U offset.
    if ( $pos[ 0 ] < 0 )
    {
    $offsetU = 1 - trunc( $pos[ 0 ] );
    $move = 1;
    }
    else if ( $pos[ 0 ] > 1 )
    {
    $offsetU = 0 - trunc( $pos[ 0 ] );
    $move = 1;
    }

    // Find V offset.
    if ( $pos[ 1 ] < 0 )
    {
    $offsetV = 1 - trunc( $pos[ 1 ] );
    $move = 1;
    }
    else if ( $pos[ 1 ] > 1 )
    {
    $offsetV = 0 - trunc( $pos[ 1 ] );
    $move = 1;
    }
    if ( $move )
    {
    select -r $uv;
    polyEditUVShell -r 1 -u $offsetU -v $offsetV;
    }
    progressWindow -e -s 1;
    }

    // Finish progress.
    progressWindow -ep;
    }
  • Jegge
    Options
    Offline / Send Message
    Hi

    I have a problem with some models for a game, in the previous version I hat no problems with my models, but in the latest realese of the game I keep getting this error message on my models "Error: UVs out of range [-8,8]".

    Question is, can I use this same procedure as "athyri" posted, or would this not work to correct these errors im getting ?

    greets
    Jegge
  • passerby
    Options
    Offline / Send Message
    passerby polycounter lvl 12
    your not giveing us much info to go on, and also giveing us a error from a game engine you never told us about dosnt help much either since we dont know the requirements of that engine.
  • tristamus
  • malcolm
    Options
    Offline / Send Message
    malcolm polycount sponsor
    Sorry to dig up an old thread, but mop's tool no longer works in newer versions of Maya. Mop care to update your script?
  • passerby
    Options
    Offline / Send Message
    passerby polycounter lvl 12
    just use nightshade uv editor or uv delux they add this feature + many more. what feature of it do you need? it also wouldn't take long to get any of this features working on python for newer mayas as well
  • Bartalon
    Options
    Offline / Send Message
    Bartalon polycounter lvl 12
    If you don't want to deal with MEL script or special plugins just for moving shells around, you can just use the input line at the top of the window.

    xyz.png

    Just make sure it's set to Relative and X/Y will control up/down/left/right shell positioning. Moving it by 1 will shift everything 1 full tile.
  • bugo
    Options
    Offline / Send Message
    bugo polycounter lvl 17
    nightshade and deluxe uv works like charm. Go get it! Passerby is right
Sign In or Register to comment.