• Login
sketchucation logo sketchucation
  • Login
๐Ÿค‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Exporting UVs for Groups via PolygonMesh

Scheduled Pinned Locked Moved Developers' Forum
9 Posts 5 Posters 1.8k Views 5 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.
  • E Offline
    eczkchtl
    last edited by 6 Aug 2008, 23:17

    Hi, I have trouble exporting UVs from groups in my Ruby plugin.

    When creating a group and then assigning a material to the whole group there seem to be a problem with generating UVs. Textures show up correctly in sketchup but when iterating through all faces in the group, and converting them to polygon meshes, UVs are incorrect.

    It's easily fixed by exploding the group and then group it again, but that shouldn't be necessary. Also the UVs are slightly changed when exploding. I haven't tried using the UVHelpers in the script though, might get correct UVs then. Nonetheless I think it ought to be fixed in future versions of sketchup.

    Have anyone noticed the this problem?

    1 Reply Last reply Reply Quote 0
    • P Offline
      plot-paris
      last edited by 7 Aug 2008, 08:23

      I think this is because a texture has to be applied directly to a face to contain any uv information.
      thats why you can't right click a group and choose the texture position options - SketchUp has no idea which of all the faces within the group you are refering to. neither is it possible to select several faces at once to position a texture.

      1 Reply Last reply Reply Quote 0
      • E Offline
        eczkchtl
        last edited by 7 Aug 2008, 09:28

        @plot-paris said:

        I think this is because a texture has to be applied directly to a face to contain any uv information.
        thats why you can't right click a group and choose the texture position options - SketchUp has no idea which of all the faces within the group you are refering to. neither is it possible to select several faces at once to position a texture.

        But still you can texture a whole group and sketchup generates some UVs for its internal use. And I suspect there's no way to get these coordinates from a ruby script?

        1 Reply Last reply Reply Quote 0
        • B Offline
          Burkhard
          last edited by 7 Aug 2008, 09:46

          eczkchtl, your name, how to keep it in mind? makes me real nervous to read and typing ๐Ÿ‘Š

          [http://www.ia-plus.de(http://www.ia-plus.de)]

          1 Reply Last reply Reply Quote 0
          • T Offline
            tbd
            last edited by 7 Aug 2008, 09:58

            try and apply a 1m x 1m texture on :

            • a face 1m x 1m
            • a face 1m x 1m inside a group
            • on a group that contains a default 1m x 1m face

            you can check your code on this and see what is wrong (usually inside a group there is wrong units).
            I use also http://bgdm.katorlegaz.com/lscm_tute/Tute_Images/UV.jpg as test texture to see when it has wrong direction

            SketchUp Ruby Consultant | Podium 1.x developer
            http://plugins.ro

            1 Reply Last reply Reply Quote 0
            • E Offline
              eczkchtl
              last edited by 7 Aug 2008, 10:37

              @unknownuser said:

              try and apply a 1m x 1m texture on :

              • a face 1m x 1m
              • a face 1m x 1m inside a group
              • on a group that contains a default 1m x 1m face
                ...

              Yes, if you group the face, set material, move the group and then explode it, the texture will be offset to the coordinates of the new position. I don't mind this behavior. Maybe there are other grouping "quirks" also.

              However, this has little to do with my problem ๐Ÿ™‚
              At least the groups have some UVs which are visible in sketchup and the artist may be fine with these if they look OK. Then when exporting they get mashed. When you get the UVs with PolygonMesh from a script they are just random large numbers (i.e. not initialized) in the group-before-material case.

              1 Reply Last reply Reply Quote 0
              • T Offline
                tbd
                last edited by 7 Aug 2008, 10:48

                I didn't say anything about exploding. if you will do that test you will be able to see what the problem is and code accordingly.

                @unknownuser said:

                group-before-setting-material-case they are just random large numbers

                if a face exists in a group there are two possibilities:

                • default material -> will use the group material with simple planar UV if exists, otherwise default front/back color
                • has material -> will use the material with it's UV data

                if you have a group with all faces default and no group material (or parent if it is nested) then ignore the UV

                SketchUp Ruby Consultant | Podium 1.x developer
                http://plugins.ro

                1 Reply Last reply Reply Quote 0
                • E Offline
                  eczkchtl
                  last edited by 7 Aug 2008, 10:54

                  @unknownuser said:

                  • default material -> will use the group material with simple planar UV if exists, otherwise default front/back color

                  It is this case which is a little torublesome, with a default material for the group and no material for the faces in the group. So how do I get these "simple planar UV" coordinates? And do I need to do some conversion to get the UVs which in the end are used for rendering?

                  What I do now:

                  for each face in group;
                    mesh = face.mesh(5) # Get points, normals and UVs for front faces
                    for each vertex;
                      uv = mesh.uv_at(index,1)
                  

                  EDIT:

                  I think i've got it now. The UVs from PolygonMesh are in the case above not rendering UVs but instead need to be divided by the width and height of the material. Me getting uninitialized values was just an error in the importer-program which read the files I've exported. It's still peculiar that getting UVs with PolygonMesh for ungrouped faces gives actual rendering UVs while with a group material they need to be converted. We end up with some extra (unnecessary?) special cases.

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    tomasz
                    last edited by 24 Aug 2008, 17:31

                    @eczkchtl said:

                    We end up with some extra (unnecessary?) special cases.

                    I am glad you have found the solution. What about projected \ photomatched textures? Have you tried exporting them? We end up with a lot of extra very special cases ๐Ÿ˜ก There is no built-in method, I am aware of, that would give you an answer if a face is being painted with projected texture or not!

                    Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

                    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