[Solved] A Script for to morph models to their UV maps :-)

Catherine3678abCatherine3678ab Posts: 7,989
edited August 2020 in Product Suggestions

Having ever tried to do this for a few items [without a script] this item I came across over at ArtStation [and it's only $2] really got my attention. Unfortunately it's for Maya which is nowhere near that price range [by a mile or 3] so ...

pretty please, could somebody write a script that would do this for Daz Studio? Thank you :-)

Can somebody make a script like this for DS.png
903 x 508 - 304K
Post edited by Catherine3678ab on
«1

Comments

  • WendyLuvsCatzWendyLuvsCatz Posts: 37,711

    Zbrush can do it

  • That's nice [says she who doesn't own Zbrush either].

    Maybe somebody with Zbrush would like to morph all the figures to their uvmaps and let loose the morphs in the freebies section?

    Think I'd still like the ability in D/S for there are lots of items it could be very useful for :-)

  • WendyLuvsCatzWendyLuvsCatz Posts: 37,711
    edited August 2020

    That's nice [says she who doesn't own Zbrush either].

    Maybe somebody with Zbrush would like to morph all the figures to their uvmaps and let loose the morphs in the freebies section?

    Think I'd still like the ability in D/S for there are lots of items it could be very useful for :-)

    does not seem to keep the vertex order sadly

    neither does Ultimate Unwrap 3D that also does it

    Post edited by WendyLuvsCatz on
  • Silent WinterSilent Winter Posts: 3,610
    edited August 2020

    Blender can do it too (and that's free so within your budget (though there's a learning curve as with everything)). I believe it's in these tools: https://blender-addons.org/textools-addon/ - one of the tools is called 'mesh texture' and creates a mesh that can morph from flat (uv-map-shaped) to shape (normal shape).

    Disclaimer: I haven't tried it.

     

    As for Daz Studio - it might be possible to script but I'm not sure if it wouldn't need more functionality within DS (you could always import the one from Blender as a morph for DS). Edit: That is unless it changes the vertex order as noted above - again, I haven't tried this). Depending on what you want to use it for, exporting both the flat and shaped versions and using one as a morph for the other might work (as the uv-mapping would be the same so it'd take the same textures in DS).

    Post edited by Silent Winter on
  • Blender can do it too (and that's free so within your budget (though there's a learning curve as with everything)). I believe it's in these tools: https://blender-addons.org/textools-addon/ - one of the tools is called 'mesh texture' and creates a mesh that can morph from flat (uv-map-shaped) to shape (normal shape).

    Disclaimer: I haven't tried it.

     

    As for Daz Studio - it might be possible to script but I'm not sure if it wouldn't need more functionality within DS (you could always import the one from Blender as a morph for DS). Edit: That is unless it changes the vertex order as noted above - again, I haven't tried this). Depending on what you want to use it for, exporting both the flat and shaped versions and using one as a morph for the other might work (as the uv-mapping would be the same so it'd take the same textures in DS).

    That looks to be very interesting, thank you :-)

  • Catherine3678abCatherine3678ab Posts: 7,989
    edited August 2020

    AWESOME! Okay, it doesn't make morphs {in D/S} either BUT the aim of the game was to get a mesh for the uvmaps to assist in painting textures on a flat surface. And at this price, this is just great. I hope those making money pay the man, this is gold.

    Silent Winter Thank you so much for bringing this to my attention :-)

    Texture Mesh via Blender.png
    700 x 700 - 96K
    Post edited by Catherine3678ab on
  • hahaha ... okay ... in order to do this task, the mesh is cut and that's why there's no morphing back to their figures. BUT there's also no uvmap on it 'as is' either. So one has to uvmap it, unfold it, align it to the desired place. Then export out their new uvmap mesh for painting in the 3D painting program(s). So it's not perfect but then what is. Looking forward to trying this out some more :-)

     

  • Silent WinterSilent Winter Posts: 3,610

    ^Hmm, ok. Why do you want it flat-packed for texturing anyway? Most uv-painting programs (like Armor-Paint, Substance Painter, etc) let you paint on either the mesh or the 2D uv-layout anyway. Most also let you hide bits to reach otherwise hard-to-get-to places.

    Blender has another addon that lets you 'explode' the different objects within a mesh (anything not welded together is separated) which might help. But I can't seem to find it (I found an 'explode' modifier but that seemed to be for making an explosion).

  • ^Hmm, ok. Why do you want it flat-packed for texturing anyway? Most uv-painting programs (like Armor-Paint, Substance Painter, etc) let you paint on either the mesh or the 2D uv-layout anyway. Most also let you hide bits to reach otherwise hard-to-get-to places.

    Blender has another addon that lets you 'explode' the different objects within a mesh (anything not welded together is separated) which might help. But I can't seem to find it (I found an 'explode' modifier but that seemed to be for making an explosion).

    Texturing Aids ... wanting the flat-packed uv mesh so the uvs match. Then I add a level or two of smoothing to it [however high Hexagon will let me do that without crashing]. Exporting out that mesh then I can paint on it in 3D Coat adding in more details than the original mesh will permit. Game plan is then to get 3D Coat to export out some nice textures [normals, etc.] which can be applied to the original mesh. Right now I'm working on something for the legacy V4.2.

    I also have an ancient copy of Blacksmith3D Paint ... and sadly no it doesn't paint 3D objects as well as some [at least me] had hoped it would. The paint will 'run' down the sides like the objects' uvmaps were never unfolded. And so I wondered what was the point of that ... but anyhow it was in using this program that I decided if I can get 'flat' models that have the same uvs as the models I wanted the textures for, life would be easier. Indeed I did make a few flat texturing aids [all new mesh] which were released some time back for those that wanted them.

    Thank you but I do have some 'exploding' morphs and know how to make more if/when I need things like that.

  • Catherine3678abCatherine3678ab Posts: 7,989
    edited August 2020

    :-) Coaxed Hexagon into getting 2 levels of smoothing :-) Was started in Blender using  https://blender-addons.org/textools-addon/

    Was thinking while matching the points in Hexagon that it would sure would be nice if the script could do all that too lol ...

     

    Promo.png
    1589 x 851 - 748K
    Post edited by Catherine3678ab on
  • richardandtracyrichardandtracy Posts: 4,979
    edited August 2020

    Catherine, I am not too sure if your problem has been solved. If not, just wondering if a separate program to do the following might meet your needs:-

    1. Read a texture mapped .obj file
    2. For each surface in the .obj file, write a new flat .obj file with extents 0-100cm in X and Z directions, and all the vertices corresponding to 100x the texture map co-ordinates for that vertex. The vertex Z directions position being defined by the texture vertex Y position. Each facet in the new model has a 1-1 correspondence with a facet in the 3D original model. The texture map co-ordinates are 0-1 in the X and Y axes. Not sure if DS keeps to the normal right handed axes for texture mapping, last time I tried mapping it seemed to be left handed, but that might be my memory playing up.
    3. Save each file.

    I could do this as a Windows 32 bit exe file - it would be a bit basic with no graphics, but should be feasible. Not quick to do, but eminently possible if that would help you.

    Regards,

    Richard.

    Post edited by richardandtracy on
  • Catherine, I am not too sure if your problem has been solved. If not, just wondering if a separate program to do the following might meet your needs:-

    1. Read a texture mapped .obj file
    2. For each surface in the .obj file, write a new flat .obj file with extents 0-100cm in X and Z directions, and all the vertices corresponding to 100x the texture map co-ordinates for that vertex. The vertex Z directions position being defined by the texture vertex Y position. Each facet in the new model has a 1-1 correspondence with a facet in the 3D original model. The texture map co-ordinates are 0-1 in the X and Y axes. Not sure if DS keeps to the normal right handed axes for texture mapping, last time I tried mapping it seemed to be left handed, but that might be my memory playing up.
    3. Save each file.

    I could do this as a Windows 32 bit exe file - it would be a bit basic with no graphics, but should be feasible. Not quick to do, but eminently possible if that would help you.

    Regards,

    Richard.

    Sounds like it's worth a try, I am on Windows! Thank you :-)

  • OK. I'll think about how to do it until tomorrow and then get started tomorrow evening. I have .obj reading code from my Finite Element modeller I can crib, also all the data structures I'll need. The output methods are available in a partially usable form. So, possibly have 10-20% of the code I need already.

    I have a few programs that may be useful already on my website http://www.chestnutpens.co.uk/misc/downloads.html that you may find useful. They cover my 3 main computing interests, cross stitch, CNC machining and 3d modelling utilities. Maybe only the 3d ones would be of interest, but it's surprising what cross-overs can sometimes trigger.

    Regards

    Richard.

  • OK. I'll think about how to do it until tomorrow and then get started tomorrow evening. I have .obj reading code from my Finite Element modeller I can crib, also all the data structures I'll need. The output methods are available in a partially usable form. So, possibly have 10-20% of the code I need already.

    I have a few programs that may be useful already on my website http://www.chestnutpens.co.uk/misc/downloads.html that you may find useful. They cover my 3 main computing interests, cross stitch, CNC machining and 3d modelling utilities. Maybe only the 3d ones would be of interest, but it's surprising what cross-overs can sometimes trigger.

    Regards

    Richard.

    Thank you. I did visit your website and snaggled a couple of items - and the instructions! And discovered a forum for pens!!! 

  • Funny how all the best people enjoy a nice fountain pen too...

    Regards,

    Richard

  • WendyLuvsCatzWendyLuvsCatz Posts: 37,711

    you have/had lovely kitties Richard and Tracy heart

  • I know. They rather rule our lives. Our current character cat is Ozzie, a 7yo Maine Coon who loves playing fetch with tinsel balls during winter and slaughtering anything ground based that moves during summer (he can't catch birds, though not for want of trying, we have had numerous occasions where we've seen him launch himself off a roof or out of a tree and try to catch a flying bird in mid fall. Never works.). We have two others, but they are less of a handful than Ozzie, the two of them together are much less of a handful than Ozzie. Now the weather has cooled a bit, Ozzie has taken to allowing us to share part of his bed at night. We always, erroneously, thought it was our bed... He's 3'7" (109cm) from tip of front paws to end of back paws when stretched out and takes up rather a lot of room. He may be a small Maine Coon, but that does not make him a small cat!

    Regards,

    Richard.

  • Small progress update: done the window and got the open method accepted by the compiler. This means no syntax errors rather than being programmatically correct. Until I have completed the conversion and save methods, can't test it yet. So far about 680 lines of code. I tend to write rather verbose programs, I know, and get things done by the brute ignorance and force method rather than by elegant coding. Should work though.

  • Okay :-) Looking forward to trying this out.

  • Further little update: Have got to the stage of writing an in-memory obj file for each surface before it's saved to the HDD. Need to remind myself of the syntax of the obj file before filling in this bit of the framework. It's syntactically correct, but untested so far.

    Also, just remembered it'd be useful to check whether the surface has actually got any facets in it - writing an empty obj file would not be very useful. Think there are now heading to 800 lines of code.

  • ... and the anticipation grows :-)

  • As usual, the 90% of a program is the programming and the other 60% is the debugging. In theory, it works. In practice, there's a little way to go. It's possible I have one level of de-referencing more than I need.

    Regards,

    Richard

  • No rush, I understand. Sounds like 'bout the same with modeling. Making the item is only part of the job, then there are the uvmaps!

  • How's the debugging going?

  • Not well. I had a look at it for around an hour this evening and I can't make head nor tail of what's happening. I have reduced the size of the test model I'm using to verify it from 8 to 3 facets so that I can work through by hand and work out where it's going wrong. I hope to be able to spend a bit of time tomorrow evening to work it through. Currently on leave and am trying to replace our garage roof and .. well, it's hard work so I am rather shattered by the evening and not entirely thinking as straight as I should. Will get it done though.

    Regards,

    Richard.

  • Roof is rather important! RL first as they say ;-)

    Sometimes the problems just just off the page when we come back to them after doing something else for a bit.

    Cheers,

    Catherine.

  • I have finally found one bug, and the program works properly with my test model. However, I'm getting an odd out of limits array error on the second surface of any real model I try. The first surface works properly and the saved obj model matches the UV template plot for that surface in DS. The fact that there are many thousands of facets means I can't single step through the program to the error, and printing info to a log file leads to vast swathes of info to wade through. Then you find crucial bits are missing... Anyway am one step closer.

    Regards

    Richard.

  • I have finally found one bug, and the program works properly with my test model. However, I'm getting an odd out of limits array error on the second surface of any real model I try. The first surface works properly and the saved obj model matches the UV template plot for that surface in DS. The fact that there are many thousands of facets means I can't single step through the program to the error, and printing info to a log file leads to vast swathes of info to wade through. Then you find crucial bits are missing... Anyway am one step closer.

    Regards

    Richard.

    What is a "second surface" of a model? Is that the uvmap part?

     

  • In a multi surface model (eg 'building.obj' with wall, door1, windowglass, windowframe surfaces) then the programme is intended to create a separate model for each surface, with names like 'building - wall.obj', 'building - door1.obj', 'building - windowglass.obj', 'building - windowframe.obj'. To create a model with all the surfaces in the same file would be simplicity, it's creating the facet/vertex referencing for each separate file that's currently where the bugs are.

    Regards,

    Richard.

  • Catherine3678abCatherine3678ab Posts: 7,989
    edited August 2020

    Glad I asked. We don't need to do multiple surfaces. Face has one surface, face. The lips I need as a separate mesh anyway so I cut that out [using Hexagon] and then it too only has the one surface, Lips.

     

    Post edited by Catherine3678ab on
Sign In or Register to comment.