I'm wondering if anyone knows if there is a 3ds max script to do this.
Basically, the problem I have is I have this super complicated mesh that has uvs off the 1to1 space. There is like 12x12 tiles off uv space so all 100 and some spaces have there own textures.
I don't have the original files and it would take forever to try and select the mesh via the uv roll out colapse and apply the textures manually.
So I'm wondering if there is a script to do this... Every part of the mesh that is in its own 1to1 space on the uvs gets detached as its own object.
This would allow me to hide stuff and apply the materials 1 by 1. Currently, the mesh is so complicated just opening a uvw modifier practically crashes max. So I really don't know any other solution other than getting a script that does something like I just mentioned.
Replies
Got interested with this question. How did it go? Did you ask on script spot?
I wouldn't mind giving this a try, currently swamped in an utterly complicated script that might prove to not be useful... a break from it will be nice.
If you have more information on:
- All the faces are in their own [0,1] space right? so for example a group of faces that are in say [1,2] range will never have vertices that get on another tile.
- Do you need the detached objects to return the uv tile to the [0,1] range?
How is it currently textured? You say there are currently 12x12 tiles, and some tiles have their own texture? Does it have a multimaterial or something?
If you have a 'test' model, like a 3x3 uv tiles example and a brief explanation of how it should end up?
https://www.dropbox.com/s/qt5t4qao43vj7uk/AM-DetachFacesByUVQuadrant.ms
(Save to some place, drag and drop over your scene).
I think it probably does already the basics.
It still has some grayed out options that could be added as needed.
Hope it suits you well.
amartinez: I really appreciate you taking the time to help!
I probably didn't describe my problem well enough, but simply put I need a solution for applying all these diffuse textures to a single mesh, where I really don't know anything about what faces they should be applied other than the uv layout.
Here is the uv layout currently...
See how I selected the first 1x1 space? What I want to do, is use a script to jump from each 1x1 space and detach those faces as its own seperate object. Counting the spaces, I guess there is 107 different 1x1 uv squares. So after running the script I would have 107 individual meshes, that I could manage much easier (hide in viewport and what not). And, I could apply a material to each object as a whole without any issues.
This is a project I am doing at work, and its an actual source model from a movie. Obviously I can't say much about it, but a lot of the textures look the same actually, so it wouldn't be that hard to apply them one by one, but if you can think of a solution for this too that would be awesome.
Anyway, this is the only practical solution I can think of, because just opening the uv rollout selecting the faces and detaching them manually 107 times would take forever.
Here is a print screen of my attempt to run the script. It just gets stuck there, but you can see from the viewport the mesh has over 1.5 million tris (and its already been decimated as far as I can go).
Just to clarify, each one of those 107 1x1 uv spots has its own texture that goes with it. I need to apply each texture accordingly.
http://www.neilblevins.com/cg_education/multiple_uv_tiles/multiple_uvs_tiles.htm
Thanks for the links Eric.
@Brad: It's probably the size of the mesh. I didn't add any progress bar as of yet. No clue how much it would actually take currently, I could work on adding that tonight.
I think the script does exactly what you ask for, it's just probably not optimized enough.
Try creating a 'box', tessellate, move different faces to different quadrants, (or select from a bunch of random faces, uv detach/break and move them to a random quadrant) to use as a mesh test to see what the script will do.
@Brad: Progress bar added and minor tweaks.
https://dl.dropboxusercontent.com/u/136334834/forums_shared/AM-DetachFacesByUVQuadrant.ms
Tested on a 600k vertices box with 12 tiles and it takes less than 30s.
(Boxes as usual, is never a real test case)
Did you try the 'udim' layout explanation pointed out by Eric?
There would be a way to put the textures automatically, if the textures are conveniently named (which is probably the case) (using the udim "1001" naming conventions or if in the name there is a hint of which tile it points to).
(For both of these cases: to detach and a assign the proper texture for each tile or to automatically setup udim ready material for the whole mesh).
@Noors: Please do! Would like to see how you solved it.
I detach all shells that are in the 0-1 square.
But it looks like you made the right thing.
The only trick i use is from Jorge "Polytools" Rodriguez.
I convert uvs to a trimesh, because mesh are faster to deal with than uvs, not to mention unwrap modifier.
Also you could cache your last polyop, maybe you'll gain a bit of time.
This is a very clever way of doing things, didn't know that manipulating a mesh was faster than manipulating the UVs via polyOps.
I'm caching some of the polyOp functions to local variables and UVW Unwrap is modifier is never used. But for example, there is no convenient functions like 'getFaceCenter' that I know of, I have to get the vertices of an UV face and average it's positions.
If I understand correctly, you flatten the UVs as a physical mesh. Then somehow you have to transfer back those positions back to the real uv right?
Will give this a try. (Although for the case at hand, since there is no real "manipulation", just detecting where a face is in the quadrants, so the first read should be enough, I should do it on a trimesh though).
Thanks for the tips.
Lot to digest here since my last post, I'm gonna look everything over and see what I can come up with. I'll post an update on my progress later today. thanks again!
I don't modify the original obj in my case.
Also, face in uv and on mesh have the same index, and the same vertex index order.
Yeah it's clever, that's how i guess, he performs shells detections, open edges so quickly in polytools.
Here, i select 1 face in all faces, get its center, get its element (which is fast on mesh) and remove the element from my faces array. So I don't test every face/vert position.
But thanks again man, this is good to know!
amartinez: Hey dude, thanks again! I used the script and it worked well. I still had the issue of trying to apply the various textures and not knowing with which texture each model went. But I did some guess and check and was able to get enough of them correct for my purposes. I really appreciate the help dude!
Wonder if there is actually a way to extract some sort of texture information.
Like:
- Do the faces IDs in the original mesh object have some sort of name? (they usually are 1 - No Name, 2 - No Name, etc... but MAAAYBE this time there is something).
- Does it come with a pre-applied material? Standard? Multi-material? none at all?
Glad to hear that it was at least halfway useful .
Cheers.
amartinez: They had some numbering system, but it was def. broke. Also, I believe the model was built in another program, and all I had access to was an .obj.
But yea man, it was tedious but I was able to do it thanks to you! It would have been way more difficult without that script!
Glad to help and hear that it went well.
If at some point you need it again and have any suggestions feel free to send a message.