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

    Point/Vertex.is_visible? how?

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 2 Posters 257 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 need to determine from a tool, if a given vertex/point3d is visible to the camera.

      I tried translating the point to screen-coords, getting a pickray for that point and then shooting a raytest - comparing the points. But it's no good - inaccurate.

      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
      • TIGT Offline
        TIG Moderator
        last edited by

        The vertex will have edges and possibly faces.
        Make an array of these.
        Get the vertex.position and camera.eye.position.
        Shoot a raytest from the eye_position to the vertex_position along that vector.
        If there is nothing in the way it will return one of the array items [as it will get to the vertex and I think that only edges/faces get returned ?].
        Test if array.include?(raytext[1][-1])
        If there is something in the way it will not be in the array so you know the vertex is hidden ?
        ❓

        TIG

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

          Ah, I was overthinking this. I tried to obtain the X, Y screen coords of where the point was and raytest that.

          
          sp = view.screen_coords(point)
          ray = view.pickray(sp.x, sp.y)
          item = view.model.raytest(ray)
          
          

          Using the camera eye was of course easier, and more logical.

          
          c = view.camera
          item = view.model.raytest([c.eye, c.eye.vector_to(point)])
          visible = (point == item.first)
          
          

          that's all I needed. πŸ˜„

          thanks TIG

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

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

            hmm... this is a slow method... are there alternatives?

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

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              If you place a temporary cpoint [or something else suitable if that is notraytest-able ?] at the eye-point and then test each vertex-position vector towards the eye-position, then if the first raytest result isn't the thing at the 'eye', the vertex can't see the eye and so the eye can't see the the vertex ? This way there are fewer things to test for hitting ❓ ?

              TIG

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

                I'm not sure if it's the number of items in between - I think that the raytest might be iterating the whole model to test. And I think it uses the whole model scope and not just the active - but in my tests everything is "loose" in the model scope.

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

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

                  One additional problem with raytest: if you have a group/component open and you want to get a list of visible verties/3d points, then raytest won't be any good if there is geometry outside that scope between the camera and the vertices. Even if Hide Rest of Model is enabled.
                  Alternative to that is to manually iterate all faces and intersect eye-point. Horrendously slow!

                  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