sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Material with coloured or distorted texture

    Scheduled Pinned Locked Moved Developers' Forum
    15 Posts 6 Posters 2.4k Views 6 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.
    • W Offline
      Whaat
      last edited by

      @unknownuser said:

      1. My solution to the first is to check texture.average_color and compare it with the colour of the material, if != then coloured=true? Am I thinking right?.

      2. .. I have no solution.. comparing UVs using uv_at and using UVHelper? if == then distorted=false ?

      Hey Tomasz,
      I would guess that you are right about both 1 and 2. I haven't tried it, but the logic seems right.
      I've got a Ruby function written called "Explode Distorted Texture". It works pretty well. It exports the distorted texture with the texture writer (correcting the perspective), creates a new material with that texture, and then applies it back to the original face. The only downside is that it increases the number of materials in your model. However, in many cases, you only have to explode the distorted texture for one face and then you can use the new texture on any faces that face the same direction (e.g. explode the texture for a wall, and apply the same texture to a framed painting on the wall using the ink dropper).

      Whaat

      SketchUp Plugins for Professionals

      1 Reply Last reply Reply Quote 0
      • R Offline
        RickW
        last edited by

        On #1, do you want to see if a user has altered the color of the texture, or simply if there's a texture being used? If you want to find an altered-color texture, your suggested solution won't work. face.material.color always equals face.material.texture.average_color, where there is a texture applied to the face. What you could do is create a new material by querying the filename of the attached texture, then compare the average color of the face to the average color of the new material.

        I'll have to do some research on #2...

        RickW
        [www.smustard.com](http://www.smustard.com)

        1 Reply Last reply Reply Quote 0
        • T Offline
          tomasz
          last edited by

          Whaat & Rick
          I am trying to make SU2KT export distorted textures correctly. It exports coloured textures cos
          there is just one texture associated with a material. My script (beta) has problem with recognizing
          the first texture getting into texturewritter. When should I use uvHelp? I could use it for all faces, but it would be memory consuming and simply is not necessary.

          I have also noticed that UV coordinates obtained using UVHelper are affected when the faces are inside
          group or component. When exploded, UVs are correct. It is a surprise for me.

          Whaat, your script is an interesting one, but it is half-solution.
          Thanks
          Tomasz

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

          1 Reply Last reply Reply Quote 0
          • T Offline
            tomasz
            last edited by

            I have found following method:

            mat.materialType
            

            Types are not described anywhere in documentation, but are quite easy to figure out:
            0 - only colour
            1 - texture used
            2 - texture coloured
            I think I have found a ruby bug. When the texture colour is reset materialType returns still 2.
            It can be brought back to 0 when texture is removed.
            When the user will reset colour the method is useless cos it returns wrong value. 😞

            Tomasz

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

            1 Reply Last reply Reply Quote 0
            • T Offline
              tomasz
              last edited by

              Does anyone how why when I query the UVs of distorted texture located within a group or component, I am getting wrong coordinates? I thought UVs are independent of face location. What is the 'nature' of UV_helper? Do I need to apply global transformation of the face to UV_helper object to get correct UVs?

              Thanks
              Tomasz

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

              1 Reply Last reply Reply Quote 0
              • T Offline
                tomasz
                last edited by

                I have sorted out issue #2.
                For those interested how: I simply assign a texture to newly created group and write it to TW and then load again a face with the same texture to TW. If texture has been added twice it means it is distorted (photomatched).

                I still don't know how to get proper UVs for distorted texture within a group.

                Tomasz

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

                1 Reply Last reply Reply Quote 0
                • GaieusG Offline
                  Gaieus
                  last edited by

                  Tomasz,

                  Would the xml file be considerably bigger if all groups/components were exploded?

                  Gai...

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    tomasz
                    last edited by

                    @gaieus said:

                    Would the xml file be considerably bigger if all groups/components were exploded?

                    No. Only groups\components with photomatched textures need to be exploded prior to exporting. The rest of a model can stay untouched.
                    I want to export correct UVs from groups because it is a proper solution 😄

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

                    1 Reply Last reply Reply Quote 0
                    • T Offline
                      tomasz
                      last edited by

                      Is there way to get inside the group and select face as one can do directly in SU? I know how to add an entity to selection but how I can enter the group(component) to use local coordinates?

                      I hope someone will be able to help me on the matter.
                      Thanks

                      Tomasz

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

                      1 Reply Last reply Reply Quote 0
                      • daikuD Offline
                        daiku
                        last edited by

                        gourp.entites will give you the array of entities in the group. Then run through all the items in the array, and look for your face.

                        Clark Bremer
                        http://www.northernlightstimberframing.com

                        1 Reply Last reply Reply Quote 0
                        • GaieusG Offline
                          Gaieus
                          last edited by

                          Tomasz,

                          If there is no problem with the size of the xml file when there are groups or not, why don't you just explode all groups during the process? Users (like me) wouldn't find out anyway! 😄

                          Gai...

                          1 Reply Last reply Reply Quote 0
                          • T Offline
                            tomasz
                            last edited by

                            Thank you Clark. Unfortunately I am already finding faces as group entities but UVHelper doesn't give correct values or I am doing sth wrong.

                            Gaieus, I will issue SU2KT 2.3 without support for distorted textures within groups. I don't want to spend months on it. Exploding, exporting UVs and undoing explosion could be a solution!

                            Tomasz

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

                            1 Reply Last reply Reply Quote 0
                            • jujuJ Offline
                              juju
                              last edited by

                              AFAIK the POV-Ray script caused everything to be exploded, but it did create a backup of the skippy before doing so. Maybe you can look into a similar approach until such time as you have the code sorted?

                              Save the Earth, it's the only planet with chocolate.

                              1 Reply Last reply Reply Quote 0
                              • T Offline
                                tomasz
                                last edited by

                                @daiku said:

                                gourp.entites will give you the array of entities in the group. Then run through all the items in the array, and look for your face.

                                I just want to OPEN a group. I am using group.entities.. but it is not the case. uvHelper behaves different INSIDE.

                                There is method in model called close_active. But I cannot find make_active. How can I achieve it?
                                In other words - is there way to do outliner double click in Ruby?

                                Tomasz

                                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