Home Technical Talk

Option to select only UV islands within the 1-1 space?? Script help.

polycounter lvl 14
Offline / Send Message
nrek polycounter lvl 14
So I am working on hacking my way through my first MaxScript and I have run into a road block that I thought some of you guys may be able to help me with. I am trying to create a script that will take my UVs and scale then reposition them into a defined section of the UV layout.

For example, as I am making my modular pieces I pack the UVs so that they take up the full UV space so I can bake out my textures and everything within a full 512 or 256 etc. But once I finish creating all my textures and it comes time to get it in-game, I want to have the uvs scale and move to a specific location so that I can create a sort of atlas with a set of modular pieces.

To achieve this I have been using a UVW_Xform to scale and position each part. This works great until I come across a mesh with UVs that have been offset to avoid stacking. Using the UVW_Xform will lead to the offset UVs being scaled correctly but now sitting within the 1-1 space of the UV window.

So to make this work I need to see if there is a way to isolate only the shells within the 1-1 space so the UVW_Xform can be applied separately to each set of uvs. If anyone has any thoughts on a way to achieve this I would appreciate some tips.

Replies

  • renderhjs
    Options
    Offline / Send Message
    renderhjs sublime tool
    I think I would have the knowledge on how to script it but I don't understand fully what you want.
    Once you isolated (I assume through selection) only the shells that are within the 1-1 area - what are you going to do then? Looping through the UV shells and determining if their bounds are within 1-1 is easy - but I don't know or worry about what comes ofter that?
  • nrek
    Options
    Offline / Send Message
    nrek polycounter lvl 14
    Glad you saw this renderhjs, hopefully this image will help explain my script a bit better.

    scriptinfog.jpg

    So right now what happens is I select a mesh, then set the "Game" or "working" box and press a button that relates to a specific section of my texture atlas. The script then applies a UVW_Xform which scales and offsets ALL of the UVs and leaves them in the desired texture region. However if a mesh has offset UVs those will no longer line up since they were scaled at the same time as the rest of the UVs (image 2). So if I could have the script first identify and select only the UVs in the 1-1 space then run the UVW_Xform and then run the same UVW_Xform on the remaining UVs, it should end with properly offset UVs (image 3)
Sign In or Register to comment.