sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    [Proof of concept] UVunwrap

    Scheduled Pinned Locked Moved Developers' Forum
    11 Posts 8 Posters 1.7k Views 8 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • PixeroP Offline
      Pixero
      last edited by

      I've had this idea for quite some time and when Matt C posted his idea af a "auto unfold" script
      I thought it was time to see if I could get it to work.

      Note: It's a "proof of concept" and in it's current state isn't very useful in real life application.
      The unfolding works for simple geometry like cubes and such but fails for more advanced geometry.

      UVunwrap.jpg

      I'll try to explain how the script works.

      First, the script consists of three parts: "Unwrap", "Find face pairs" and "Apply".

      Unwrap sets a faceID and objID to every face to keep track of "which face goes where" when its unwrapped.
      ObjID is to make sure it will map the correct object if there are more than one unwrapped objects in the scene.
      The faceID and objID is kept between sessions and can be useful if you want to alter mapping without unwrapping again.
      The "uwrap" part is almost untoched by me (Matt C's auto unfold) since this is a proof of concept and there
      are better unwrapping algorithms availible that could be implemented later.
      (LSCM and Angle based flattening.)

      Second part: "Find face pairs" is a tool to visualize where a flattened face belongs on the unfolded geometry.
      Click a face and its "Pair" is also selected.

      Third part: Apply updates the UV's to the original geometry through the faceID and objID.
      I borrowed some code from Thomthom here.
      I've edited it some so it will work also for faces with less than 4 vertices as for faces with more than 4 vertices.

      You also need my UVprojection.rb script to project new UV's on the flattened faces.

      Known issues: Original object is exploded which obviously isnt soo great. (See line 124 under "activate".)
      Unwrap fails with more advanced meshes. Try with a box.

      Here is a movie clip of the workflow.
      It was done very quickly and has some errors in it but should give an idea how it works.
      http://www.pixero.com/stuff/UVunwrap.swf (30mb swf movie of workflow)

      First I unwrap a box and then rearrange the postion of the flattened faces.
      Since they have their faceID and objID we can copy them and move them around freely.
      You can even scale, rotate and move vertices. Only delete a face if you have copied it.
      I'm then deleting the originally placed face so that there are no duplicates.
      Last I use my project UVs script to make new UVs and applies them to the original box.

      My hopes are that if people like it, it could become a script developed by the community
      and maybe add LSCM mapping. (http://www.blender.org/download/sandbox/lscm-basics/)
      There is source code available for LSCM from the Roadkill UV app that in turn uses Blenders unwrap code.
      http://www.box.net/shared/static/gqlk7hi5ia.zip

      /Jan


      UVunwrap.rb


      UVprojection.rb

      1 Reply Last reply Reply Quote 0
      • PixeroP Offline
        Pixero
        last edited by

        Not a single comment?!
        I'm surprised of the lack of interest.
        I thought I was on to something big here...
        (Added image to post above.)

        1 Reply Last reply Reply Quote 0
        • Bob JamesB Offline
          Bob James
          last edited by

          You're on to something big here 😄
          Seriously

          i7-4930K 3.4Ghz, 2x GTX780 6GB, 32GB DDR3-1600 ECC, OCZ Vertex 4 500GB, WD Black 3TB, 32TB NAS, 4x 27" Monitors, SpaceMouse Pro, X-keys XK-60

          1 Reply Last reply Reply Quote 0
          • mitcorbM Offline
            mitcorb
            last edited by

            Hi, Pixero:
            I will second Bob's response. This is a major undertaking. As you mentioned, this currently handles simple meshes. Do you see on the horizon how it can advance to more complex meshes?

            I take the slow, deliberate approach in my aimless wandering.

            1 Reply Last reply Reply Quote 0
            • PixeroP Offline
              Pixero
              last edited by

              @mitcorb said:

              Do you see on the horizon how it can advance to more complex meshes?

              The current unwrapping is directly from Matt C's auto unfold script which is made for making paper models.
              Therefore it unwraps every face without any distortion which results in a flattened geometry with many seams and gaps.
              For UV purposes there are better algorithms availible, like LSCM (Least square conformal mapp).
              There is open source code availible that could be implemented either by translating it to ruby or through a so/dll file.
              That is something that I was hoping the community would want to help with.

              1 Reply Last reply Reply Quote 0
              • EarthMoverE Offline
                EarthMover
                last edited by

                Jan, definitely looks like you are one to something. 👍 From what I can tell, you are using the auto unfold that exists and using it to glean the texture coordinates of each face, which are then re-applied back to the "folded" geometry.

                What if once unfolded, you could also initiate the combine textures option, which would create a single texture in the material window of the unfolded faces combined. One could then take that texture and export it to a photo editor as a sort of packed UV map, add a texture, paint on it or whatever and then save it back into sketchup. From there, those coordinates are re-applied to the "folded" geometry. (I believe TGI3D has a feature similar to this)

                I like the direction you are headed. Keep pondering this and don't let the lack of response be discouraging.

                3D Artist at Clearstory 3D Imaging
                Guide Tool at Winning With Sketchup
                Content Creator at Skapeup

                1 Reply Last reply Reply Quote 0
                • K Offline
                  kyyu
                  last edited by

                  @unknownuser said:

                  Known issues: Original object is exploded which obviously isnt soo great. (See line 124 under "activate".)

                  I tweaked all 3 tools so, you don't have to explode that group. You still have to start with an ungrouped box, like before, that the plugin itself groups. I kinda have zero experience in texturing, but want to learn, so messed around with it a bit. I'm interested in unwrapping, too.

                  UVunwrap_group working.rb

                  1 Reply Last reply Reply Quote 0
                  • N Offline
                    notareal
                    last edited by

                    Looks interesting. 👍

                    Welcome to try [Thea Render](http://www.thearender.com/), Thea support | [kerkythea.net](http://www.kerkythea.net/) -team member

                    1 Reply Last reply Reply Quote 0
                    • EarthMoverE Offline
                      EarthMover
                      last edited by

                      I'm quite surprised by such a low number of downloads on this. I still think it's a great idea!

                      3D Artist at Clearstory 3D Imaging
                      Guide Tool at Winning With Sketchup
                      Content Creator at Skapeup

                      1 Reply Last reply Reply Quote 0
                      • N Offline
                        nomeradona
                        last edited by

                        wow this is something new. i just saw this today. but you are unearthing huge stuff here. I hope this one can be push more; first unwrapping with the organic forms.

                        visit my blog: http://www.nomeradona.blogspot.com

                        1 Reply Last reply Reply Quote 0
                        • McGyverM Offline
                          McGyver
                          last edited by

                          I keep peeking in here hoping I'll see something that will help me understand this better... But now I suppose I will actually download it and try and to figure it out... this is something akin to a Gerbil sitting in the cockpit of an F-22 and saying " I can do this!!"... But either way I've got to try it.
                          I wanted to say thanks for this script and for trying to find another easier way to help those of us that are UV mapping impaired!
                          I'm really hoping to figure out how to use this to texture cylinders... Too bad there is no simple native method to paint a seamless texture on a cylinder in SU... I'd think that would seem to be a basic necessity to the SU programers?
                          Thanks again!!

                          Edited to add- THANK YOU!! It worked!! Not right at first, it seemed to not want to activate, but after a few tries it did and I got it to work!
                          That is so COOL! I'm going to experiment some more... Thank you x 1000!

                          Oh yeah, I don't know if anyone else has this problem too, but when I am viewing the video clip you made, the bottom part of the screen is cut off... so when you click on your plugin the drop down menu is below the field of view and I can not see what option you are choosing. I just thought you might want to know.


                          Close up of how it appears on my screen.

                          [Visit My ShareCG Freebie Gallery](http://www.ShareCG.com/pf/full_uploads.php?pf_user_name)

                          1 Reply Last reply Reply Quote 0
                          • 1 / 1
                          • First post
                            Last post
                          Buy SketchPlus
                          Buy SUbD
                          Buy WrapR
                          Buy eBook
                          Buy Modelur
                          Buy Vertex Tools
                          Buy SketchCuisine
                          Buy FormFonts

                          Advertisement