sketchucation logo sketchucation
    • Login
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    View.draw2d adds lots of bad lines?

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 4 Posters 412 Views 4 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.
    • Chris FullmerC Offline
      Chris Fullmer
      last edited by

      Hey, when I use view.draw2d to draw geometry, I am getting a LOT of stray lines being drawn. It happens mostly (entirely?) when I zoom in and there are lots of points off screen. Its like SU is not interperting their vectors on the screen correctly. I've come across this now in 2 different projects. One was not a big deal, but in this case, its a bit of a problem really.

      Has anyone else seen this? Is there something I can do to limit the crazy lines? The first image shows the model actual geometry. I am drawing over the top of the existing lines. So the second image shows all the crazy extra lines that are being drawn to the screen.

      Any ideas?

      crazy_lines_off.jpg
      crazy_lines_on.jpg

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

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

        Chris,

        I believe this is a super old bug/feechur of SketchUp. I guess long ago - prior to h/w graphics - the decision was taken to do a cheap'n'cheerful perspective projection for these GUI lines. The result being they don't handle passing through the z=0 plane correctly - they get projected to in front of the camera when they're actually behind the camera!

        So short of you doing the z clip before giving the lines, not a lot you can do. Well complain to Uncle Google, aside. ๐Ÿ˜„

        Adam

        Developer of LightUp Click for website

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

          Do you have a standard def getExtents method that includes all picked / cursor points in the model's bounds ?

          TIG

          1 Reply Last reply Reply Quote 0
          • Chris FullmerC Offline
            Chris Fullmer
            last edited by

            @Adam - that makes sense. That is definitely what appears to be hapenning. It sure is a pain though.

            No, I'm not using that method at this point, because currently I am only drawing over existing actual geometry. So SU is not clipping any of my drawing elements, because they are all being drawn within the extexnts of the existing model.

            I did try using the 3d drawing method. That might actually work. I thought the existing edges would overpower the drawing lines. But they might not.

            Or my other option is to just assign actual colors to the SketchUp edges and use styles to display edges with color when I need to see the colors. That might also work for what I need. It just adds around 100 extra colors to my model materials list. oh well!

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

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

              Without seeing your code I can't be sure...
              Are you definitely only drawing a line over each edge's vertices points ?
              The method draww2d is pretty obscure, as you need to convert the edge's two points to 'screen coordinates' - some of which might not even be 'on-screen' ?
              Why not use the simpler edges.each{|e|draw.line(e.start.position, e.end.position)} assuming that edges is an array of the edges you want to trace over ?

              TIG

              1 Reply Last reply Reply Quote 0
              • Chris FullmerC Offline
                Chris Fullmer
                last edited by

                My code was along the lines of

                edges.each do |e| view.draw2d( GL_LINES, [view.screen_coords(e.start.position), view.screen_coords(e.start.position.)] ) end
                So I really was just taking all the edges and using their start and end points to draw to the screen. The reason for this was so that they were forced to be drawn over the top of the 3d lines, as they would be drawn directly to 2d screen space, instead of 3d model space. But drawing on top of the model in 3d spaces with a thick line looks to be working somewhat ok, using code very similar to what you posted TIG.

                I'll post screenshots of the different outcomes once I get them solidly worked out.

                Chris

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

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

                  @chris fullmer said:

                  My code was along the lines of

                  edges.each do |e| view.draw2d( GL_LINES, [view.screen_coords(e.start.position), view.screen_coords(e.start.position.)] ) end
                  So I really was just taking all the edges and using their start and end points to draw to the screen.s

                  In the posted example you use just the start positions... just a typo in the posted example?

                  I've never seen any problems with draw2d and view.screen_coords. I've used it a lot for some of my plugins. Maybe hardware specific issue - driver etc...?

                  Got a concrete reproducible sample script?

                  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

                    With draw2d if the user orbits/pans and the draw isn't updated don't you get weird effects?
                    Using draw.line would allow users to move around with colored lines overlaying the geometry consistently without need to redraw ?

                    TIG

                    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