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

    .get_front_UVQ return unexpected results

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 2 Posters 298 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.
    • thomthomT Offline
      thomthom
      last edited by

      I've been playing with mapping textures via ruby the last couple of days.

      I got a plugin which maps a texture to four-sided faces. I do so by taking the 3D co-ordinates of each corner and map the UV to 1 so the texture tiles exactly once across the face.

      Example
      When a face has been mapped and I want to retrieve the current position I face some strange results from faces that are not rectangular or parallelograms.

      For instance, when I set the texture position I use this value set:
      1. XYZ: Point3d(0, 400, 0) - UV: Point3d(0, 0, 1) 2. XYZ: Point3d(100, 400, 0) - UV: Point3d(1, 0, 1) 3. XYZ: Point3d(100, 500, 0) - UV: Point3d(1, 1, 1) 4. XYZ: Point3d(20, 480, 0) - UV: Point3d(0, 1, 1)

      But when I use .get_front_UVQ I get these values:
      1. XYZ: Point3d(0, 400, 0) - UV: Point3d(0, 0, 1.00007) 2. XYZ: Point3d(100, 400, 0) - UV: Point3d(1.33343, 0, 1.33343) 3. XYZ: Point3d(100, 500, 0) - UV: Point3d(1.00007, 1.00007, 1.00007) 4. XYZ: Point3d(20, 480, 0) - UV: Point3d(0, 0.800056, 0.800056)

      I don't understand why this happens. For rectangles, even parallelograms they are returned as I set them.

      Any ideas?

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

      1 Reply Last reply Reply Quote 0
      • AdamBA Offline
        AdamB
        last edited by

        I seem to remember position_material doesn't allow sheared UVs. You need to give it an orthogonal set of XYZ and UVs. I generally found it to be a little flakey too - if you give degenerate cases it will crash SU.

        So I guess I would take an edge of your face cross face.normal to get an orthogonal frame into which you can project UVs to give to position_material.

        Adam

        Developer of LightUp Click for website

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          @adamb said:

          I seem to remember position_material doesn't allow sheared UVs. You need to give it an orthogonal set of XYZ and UVs.

          So I can only position the texture in a rectangle format? In this plugin I'm working on, http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=18992, I currently allow it to fit to any face with four corners.

          @adamb said:

          I generally found it to be a little flakey too - if you give degenerate cases it will crash SU.

          Saying, that. I think I've experienced some oddities. But I attributed that to my Double-Cut plugin...

          So what you are saying is; you can skew and warp textures by using SU's UI, but doing so via the ruby API will cause instabilities?
          (Or have it misunderstood this?)

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

          1 Reply Last reply Reply Quote 0
          • AdamBA Offline
            AdamB
            last edited by

            @thomthom said:

            So I can only position the texture in a rectangle format? In this plugin I'm working on, viewtopic.php?f=180&t=18992, I currently allow it to fit to any face with four corners.

            Kinda - I think it will only allow an affine projection, so you're out of luck there for a general 4 point positioning.

            @adamb said:

            So what you are saying is; you can skew and warp textures by using SU's UI, but doing so via the ruby API will cause instabilities?
            (Or have it misunderstood this?)

            No, I remember if you give degenerate positioning info (eg points repeated), SU dies.

            But perhaps a better way of doing this is to use a PolyMesh and just explicitly set UVs.

            Adam

            Developer of LightUp Click for website

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              @adamb said:

              But perhaps a better way of doing this is to use a PolyMesh and just explicitly set UVs.

              Never used Polygon Meshes before.
              So to map existing faces I'd convert them to PolyMeshes?

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

              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