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

    Problem with texture coordinates

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 279 Views 2 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.
    • A Offline
      Aerilius
      last edited by

      Hello,
      I'm trying to match a texture to the corner points of a quadrangle (no rectangle). Somehow the texture does not display immediately how I expect it (image 1).
      screenshot1.jpg
      When I right click -> position texture and cancel without moving the texture position, it suddenly displays correctly (image 2). There is something that I miss and I don't know what. Can someone help me?

      c=[Point3d(0, 0, 0), Point3d(6.13575e+006, -2.05147e+006, 0), Point3d(4.22755e+006, 450980, 0), Point3d(-295726, 698978, 0)]
      face=entities.add_face(*c).reverse!
      # create material
      m=materials.add "material1"
      m.texture=imghref
      face.material=m
      
      # I want to match the texture coordinates to the corners of the face
      # c[i] are the corner points of the face
      pt_array = []
      pt_array[0] = c[0]
      pt_array[1] = Geom;;Point3d.new(0,0,0)
      pt_array[2] = c[1]
      pt_array[3] = Geom;;Point3d.new(1,0,0)
      pt_array[4] = c[2]
      pt_array[5] = Geom;;Point3d.new(1,1,0)
      pt_array[6] = c[3]
      pt_array[7] = Geom;;Point3d.new(0,1,0)
      on_front = true
      face.position_material m, pt_array, on_front
      
      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        I'm in a rush - so just a quick drive-by-post:
        I don't have time to analyse your code right now - but I have some code that does what you want to do in UV Toolkit: http://forums.sketchucation.com/viewtopic.php?f=323&t=18992&p=155759
        "Fit Texture to Quadface"

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

        1 Reply Last reply Reply Quote 0
        • A Offline
          Aerilius
          last edited by

          Thanks! I found the essential step in your code ( TT::Face.corners( e )).
          It seems to work for me just fine when I change the order of the points to (the array c contains always exactly 4 points in the same order).

          pt_array[0] = c[0]
          pt_array[1] = Geom;;Point3d.new(0,0,0)
          pt_array[2] = c[1]
          pt_array[3] = Geom;;Point3d.new(1,0,0)
          pt_array[4] = c[2]
          pt_array[5] = Geom;;Point3d.new(1,1,0)
          pt_array[6] = c[3]
          pt_array[7] = Geom;;Point3d.new(0,1,0)
          
          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