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

[REQ] Lock texture coordinates

Scheduled Pinned Locked Moved Plugins
28 Posts 7 Posters 3.5k Views
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.
  • D Offline
    dacad
    last edited by 1 Jun 2009, 22:11

    hi guys

    i don't know if this question has been made already but i was wondering if it's possible to lock the texture coordinates in the faces of a mesh? What i mean is for example having a human character modeled in the basic "da vinci" position and i texture it has i want but then i want to start deforming the mesh using the rotate, move or even the ffd plugin but i don't want to each triangular face to lose it's texture position has is it (if the faces change shape the textures in that face keep the same image even if it gest deformed, streteched etc)

    Is this possible? it's incredible important for texturing organic models, even basic ones. and i can't find a workable way in sketchup for this. for my last image ("future of plastic surgery") i had to redo the texture and edit the mesh of the final face model for it to work.
    This is an extremly important request, because i'm running out of tricks and workarounds for this problem 😞

    David

    1 Reply Last reply Reply Quote 0
    • D Offline
      dacad
      last edited by 2 Jun 2009, 11:17

      In this image you can see what i mean. If i deform a textured fece i want the limits of the texture to remain the same for the face even if it deforms, stretch, or shrink the texture. The only way for this to hapen right now is turning every single face os a mesh into a component and just using with the scale tool (that was what i did for this image).
      If the original texture was projected it will remain projected if i strech the face meaning that the face point will move but the texture position won't.

      Hope i'm making myself clear enough...


      Untitled-5.jpg

      1 Reply Last reply Reply Quote 0
      • G Offline
        Gaieus
        last edited by 2 Jun 2009, 12:27

        Yes, definitely the case is that in SU you don't fix the texture to a particular face (series of faces > surface) but to a certain, hidden co-ordinate system let it be the world co-ordinates or something related to the face (group/components it is inside).

        Gai...

        1 Reply Last reply Reply Quote 0
        • D Offline
          dacad
          last edited by 2 Jun 2009, 13:26

          Thanks for the answer Gaieus.

          A ruby or a sk feature like these is very important because without it we have to texture the mesh everytime we change his form, but if this worked we just have to texture it once and make infinite poses with the mesh while keeping always the same textures position.

          Just for curiosity, no one else thinks this would be usefull or need it for sketchup?

          1 Reply Last reply Reply Quote 0
          • G Offline
            Gaieus
            last edited by 2 Jun 2009, 13:30

            Of course I think it would be cool.

            From another point of usage imagine that I texture a cylinder with a certain, carved stone pattern and then I bend it with the new Shape bender plugin and all the textures are "stuck" to the geometry and I have a beautifully textured, ribbed arch for a Romanesque or Gothic church.

            So not only "posing" could benefit from something like this. πŸ˜‰

            Gai...

            1 Reply Last reply Reply Quote 0
            • D Offline
              dacad
              last edited by 2 Jun 2009, 16:36

              Completly agree with you Gaieus.

              Because most architectural stuff i've doing is more "cubic" stuff i almost forgot how usefull that could be for more than organic models. But using shape bender, as you said, would have to make a plugin like these compatible with all other modeling plugins, like a plugin working inside other plugin...don't think this is possible or is it?
              Maybe these shoulde be a sketchup 8 request instead of a ruby request...the problem is i really don't believe if it matters or not what we need for them...😞

              1 Reply Last reply Reply Quote 0
              • C Offline
                Chris Fullmer
                last edited by 2 Jun 2009, 17:12

                I have no idea if something like this is possible in Ruby. Seems like it could be. I've never looked at textures because I rarely use them. But I do see how it would be nice if it worked the way you described in some instances.

                Chris

                Lately you've been tan, suspicious for the winter.
                All my Plugins I've written

                1 Reply Last reply Reply Quote 0
                • T Offline
                  thomthom
                  last edited by 2 Jun 2009, 17:26

                  @chris fullmer said:

                  I have no idea if something like this is possible in Ruby. Seems like it could be. I've never looked at textures because I rarely use them. But I do see how it would be nice if it worked the way you described in some instances.

                  Chris

                  Problem is: observers. In order for this to work you need to detect when the model changes. And that is a can of blood-thirsty angry spaceworms.

                  What I somewhat imagine a ruby would work: the selected face is set to "lock textures". The ruby then samples the UV coordinates from each vertex (or selected points required). When the geometry changes, the ruby would then reapply the texture co-ordinates.
                  Given the headache I've had with observers and UV mapping I'm not sure if I'd touch this with a 10' stick. ...at least not for now...

                  Possible if it'd be acceptable to have a manual function to readjust the textures; might make things easier.

                  Thomas Thomassen β€” SketchUp Monkey & Coding addict
                  List of my plugins and link to the CookieWare fund

                  1 Reply Last reply Reply Quote 0
                  • C Offline
                    Chris Fullmer
                    last edited by 2 Jun 2009, 17:31

                    That idea of taking all the UV's and then re-applying them - is that fairly stable? I could incorporate it into shape bender, for eaxmple. So it wouldn't fix the problem outside of shape bender, but at least shape bender would be able to do it. AND I wouldn't have to touch any model observers.

                    Chris

                    Lately you've been tan, suspicious for the winter.
                    All my Plugins I've written

                    1 Reply Last reply Reply Quote 0
                    • T Offline
                      thomthom
                      last edited by 2 Jun 2009, 17:47

                      When you set textures in SU you take a set of 3D points and specify some co-ordiates on the texture that should relate to them.

                      ie.
                      point1 -> 0.0, 0.0
                      point2 -> 0.5, 0.0
                      point3 -> 0.5, 0.5

                      If point 1-3 was points in a rectangle face, then that would map the texture to tile half across the face.

                      So, what I imagine, is that applying the same UV co-ordinates to the same points when the points move, should make the texture 'lock'.

                      However, your Bender widget subdivides the mesh. So you'd have to sample the UV mapping after you subdivide, but before you apply the transformations.

                      Thomas Thomassen β€” SketchUp Monkey & Coding addict
                      List of my plugins and link to the CookieWare fund

                      1 Reply Last reply Reply Quote 0
                      • C Offline
                        Chris Fullmer
                        last edited by 2 Jun 2009, 17:53

                        Interesting, thats something I'll look into the next release of shape bender.

                        Chris

                        Lately you've been tan, suspicious for the winter.
                        All my Plugins I've written

                        1 Reply Last reply Reply Quote 0
                        • G Offline
                          Gaieus
                          last edited by 2 Jun 2009, 19:10

                          I'm listening guys, I'm listening... 😳

                          (BTW Thom; this is one aspect I mentioned before)

                          Gai...

                          1 Reply Last reply Reply Quote 0
                          • D Offline
                            dacad
                            last edited by 3 Jun 2009, 09:46

                            Thanks for the explanation thomthom and Chris Fullmer.

                            I was hoping it would be possible but that's too bad...😞. Even if it were updated manually as thom said it would still be great because i think most people would just want the textured model for the final image and not while modeling, posing or whatever, it wouldn't work just for animations.

                            I'm starting to see ruby as a way for sketchup developers don't work to much...

                            1 Reply Last reply Reply Quote 0
                            • T Offline
                              thomthom
                              last edited by 3 Jun 2009, 10:18

                              I might be possible. It's just not very easy to do. At least not automatically. UV mapping is one of the areas in SU scripting that currently feel like a bit of black magic.

                              @unknownuser said:

                              I'm starting to see ruby as a way for sketchup developers don't work to much...

                              ❓

                              Thomas Thomassen β€” SketchUp Monkey & Coding addict
                              List of my plugins and link to the CookieWare fund

                              1 Reply Last reply Reply Quote 0
                              • D Offline
                                dacad
                                last edited by 3 Jun 2009, 12:11

                                I mean that since ruby was introduced it was at the beggining a great way to add specific functions and automatize some actions, and then turn into part of sketchup develpment itself (every "new" stuff that it's presented it's a ruby plugin like DCs and sandbox, and this brings a dated engine to his knees) and the only hope to solve bugs and limitations of the software (we need a plugin to work as follow me was supost to, or just to draw a basic curve shape...) without google having to do nothing (the users work for advance features and solving bugs in the tools instead of the developers).

                                Keep in mind that we don't have any new modeling tool, animation tool or mapping/texture tool since follow me and sandbox in sketchup 4-5...but i believe that this develpment path was more a marketing decision then a development one, but still a (very) bad marketing decision

                                1 Reply Last reply Reply Quote 0
                                • D Offline
                                  dacad
                                  last edited by 3 Jun 2009, 12:19

                                  But back to topic, maybe the best way for this need is to export the mesh to other 3d package texture it there and import it again to set up the final scene, but the big problem here is that importers have big problems with keeping the textures in place with uvwarping or big meshs...But is there any better way to do this??

                                  1 Reply Last reply Reply Quote 0
                                  • D Offline
                                    dacad
                                    last edited by 3 Jun 2009, 12:44

                                    thanks thomthom.
                                    That's what i suspected. with so many software i use to each task, i'm starting to mix up shortcuts keys lolol.

                                    1 Reply Last reply Reply Quote 0
                                    • T Offline
                                      thomthom
                                      last edited by 3 Jun 2009, 12:50

                                      A different application might be the way to go at the moment. SU isn't very ideal for rigging. And I'm a believer of using the right tool for the right job. I think that SU might not be the right tool for this.

                                      Thomas Thomassen β€” SketchUp Monkey & Coding addict
                                      List of my plugins and link to the CookieWare fund

                                      1 Reply Last reply Reply Quote 0
                                      • W Offline
                                        Whaat
                                        last edited by 3 Jun 2009, 14:58

                                        Here are some methods to load and save UV sets. If someone wants to use them to create a 'lock texture' plugin, that's fine with me. πŸ˜„

                                        def store_uvs(ents,uvset)
                                        
                                        face=0
                                        case uvset
                                        	when 0
                                        		key="uv0"
                                        	when 1
                                        		key="uv1"
                                        	when 2
                                        		key="uv2"
                                        	when 3
                                        		key="uv3"
                                        end
                                        
                                        Sketchup.active_model.start_operation "Save UV set"
                                        
                                        for e in ents
                                        	
                                        	if (e.valid?) and (e.class==Sketchup;;Face)
                                        		
                                        		polymesh=e.mesh 5
                                        		uvs=polymesh.uvs 5
                                        		for i in (0..uvs.length-1)
                                        			uvs[i]=uvs[i].to_a  #converts the Point 3D objects to arrays so they won't be transformed
                                        		end
                                        		e.set_attribute 'uvs',key,uvs
                                        	
                                        	face=face+1
                                        	Sketchup.set_status_text("Stored uvs for #{face} faces.")
                                        	end
                                        		
                                        end
                                        
                                        UI.messagebox "UVs saved for #{face} faces."
                                        
                                        Sketchup.active_model.commit_operation
                                        
                                        end #function
                                        
                                        ###################position a texture on a material from a stored UV set
                                        def position_map(entities,set)
                                        
                                        face=0
                                        failed=0
                                        return if set=="SU"  
                                        key="uv"+set.to_s
                                        p "positioning map"
                                        p entities
                                        for e in entities
                                        	p e
                                        	if (e.valid?) and (e.class==Sketchup;;Face)
                                        		
                                        		uvs=e.get_attribute 'uvs',key    #gets the stored array of uv coordinates for this face for the given uv set
                                        		p uvs
                                        		if uvs
                                        			pos=[]
                                        			polymesh=e.mesh 5   #get a polygon mesh representation of the face
                                        			polygons=polymesh.polygons  
                                        			poly_index=0
                                        			begin
                                        				for p in polygons[poly_index]
                                        					point=polymesh.point_at(p.abs)
                                        					if point
                                        						pos.push(point) 
                                        						pos.push(uvs[p.abs-1])
                                        					end
                                        				end
                                        
                                        				e.position_material e.material, pos, true
                                        				face=face+1
                                        				Sketchup.set_status_text("Loaded uvs for #{face} faces")
                                        			rescue  #this is required because SketchUp sometimes fails to position the texture properly
                                        				poly_index=poly_index+1
                                        				if polygons[poly_index]
                                        					pos=[]
                                        					retry  #try to postion texture again using next polygon in the face
                                        				else
                                        					failed=failed+1
                                        				end
                                        			end
                                        	
                                        			
                                        		end
                                        	end
                                        end
                                        
                                        if failed>0
                                        	stext="Unable to load
                                        	UVs for #{failed} faces.  Loaded UVs for #{face} faces."
                                        else
                                        	stext="Loaded UVs for #{face} faces."
                                        end
                                        
                                        #UI.messagebox (stext)
                                        
                                        
                                        end  #end position map
                                        

                                        SketchUp Plugins for Professionals

                                        1 Reply Last reply Reply Quote 0
                                        • D Offline
                                          dacad
                                          last edited by 3 Jun 2009, 17:41

                                          WOW, thanks Whaat. Has always you're great!:)
                                          My knowledge in ruby is very limited so can anyone help with this? (or change the name of this topic to "[Request]Lock texture coordinates")
                                          Thanks in advance

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

                                          Advertisement