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

    The new HUD system - Guide

    Scheduled Pinned Locked Moved SketchyPhysics
    6 Posts 2 Posters 941 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.
    • W Offline
      Wacov
      last edited by

      This is a brief outline of what you can do with the new HUD system, included in SP 3.2.

      The commands:

      
      #drawing in 2d, to the screen
      @simulation.draw2D(type, points, color, size, stipple)
      
      #drawing in 3d model space
      @simulation.draw3D(type, points, color, size, stipple)
      

      The different values you can use for 'type' are:

      • "line": Draws a sequence of connected lines at the points specified (n-1 lines are drawn)
      • "loop": Draws a sequence of connected lines at the points specified, looping back to the starting point automatically (n lines are drawn)
      • "point": Draws points at the points specified (n points are drawn)
      • "triangle": Draws filled triangles, one with each triplet of points specified (n/3 triangles are drawn)
      • "quad": Draws filled quadrilaterals, one with each four points specified (n/4 quads are drawn)
      • "polygon": Draws a single filled, convex polygon, using all points specified

      'points' must be an array of points, which can be Geom::Point3d objects for both 3D and 2D operations (Z axis is ignored for 2D), or, in the case of 2D, an array of two values.
      E.g:

      p3d = Geom;;Point3d.new(0,100,50) #3D
      p2d = Geom;;Point3d.new(0,100,0) #2D, last value (Z) is not used in drawing
      p2d2 = [0,100] #2D
      

      'color' can be any valid SketchUp color value (see http://code.google.com/apis/sketchup/docs/ourdoc/color.html#introduction), and controls the color used for drawing with that particular draw call. Default value is "Black"

      'size' must be an integer value, and controls the width of lines (when drawing lines), and the size of points (in 3D). Default value is 1

      'stipple' controls the drawing style of lines. Valid strings are: ".", "-", "_", "-.-" and "", which produces a solid line. Default value is ""

      Hope that helps πŸ˜‰ If you want to see this in use (with lines), see: http://sketchup.google.com/3dwarehouse/details?mid=fa89a18ff1258124d595b43ed271a30e&prevstart=0

      If you're familiar with the SketchUp draw methods, you'll know there's plenty of functionality that hasn't been exposed yet (stuff like styling points, and a couple more drawing methods), but all the basic elements are there for you to use. One thing of note is that drawing filled shapes in 3D comes out very wierd, but as far as I know, there's nothing I can do about it 😒

      http://sketchup.google.com/3dwarehouse/cldetails?mid=3096a836877fb9af6cd8ad826e9017b8&prevstart=0

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

        Ja - it's an annoying long standing bug that polygons in 3d are drawn as black.
        Text is drawn in the same colour as the current edge style. No font options.
        draw_points blocks the next drawing operation (expects other draw_points) and should be the last in the draw stack

        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
          Wacov
          last edited by

          @thomthom said:

          Text is drawn in the same colour as the current edge style. No font options.
          draw_points blocks the next drawing operation (expects other draw_points) and should be the last in the draw stack

          I could never even get text to work πŸ˜•
          I had no idea about that points problem, thanks for the heads-up. Points don't seem to be that useful anyway, in 3D they aren't even covered by model geometry.

          http://sketchup.google.com/3dwarehouse/cldetails?mid=3096a836877fb9af6cd8ad826e9017b8&prevstart=0

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

            @wacov said:

            Points don't seem to be that useful anyway, in 3D they aren't even covered by model geometry.

            I know, very annoying when I wrote vertex tools. I ended up making a wrapper that drew a line segment simulating a point. πŸ˜’

            draw(GL_POINTS,pts) only draws single pixels... sigh

            and no transparency - much to be desired when it comes to the drawing commands.

            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
              Wacov
              last edited by

              @thomthom said:

              I ended up making a wrapper that drew a line segment simulating a point. πŸ˜’

              Nice idea, mind if I steal it? πŸ˜‰

              Yup, I'd used draw_points for the 3D side of it, but forgot to change the 2D code, so that can only draw single pixels. I was assuming the line_width setting would affect points too, but apparently not. Transparency would be really helpful, especially for this system (no-one wants a mini map that blocks the screen...), and I'd personally like the ability to load images to the screen - or even just be able to manipulate watermarks. I guess that doesn't fit in with SU's primary role though, right?

              http://sketchup.google.com/3dwarehouse/cldetails?mid=3096a836877fb9af6cd8ad826e9017b8&prevstart=0

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

                @wacov said:

                Nice idea, mind if I steal it? πŸ˜‰

                Go ahead - by all means.

                Here is my method from Vertex Tools:

                <span class="syntaxdefault"><br /></span><span class="syntaxcomment">#&nbsp;Because&nbsp;the&nbsp;SU&nbsp;API&nbsp;doesn't&nbsp;let&nbsp;one&nbsp;set&nbsp;the&nbsp;Point&nbsp;size&nbsp;and&nbsp;style&nbsp;when&nbsp;drawing&nbsp;3D&nbsp;points<br />#&nbsp;the&nbsp;vertices&nbsp;are&nbsp;simulated&nbsp;by&nbsp;using&nbsp;GL_LINES&nbsp;instead.&nbsp;There&nbsp;is&nbsp;a&nbsp;slight&nbsp;overhead&nbsp;by&nbsp;<br />#&nbsp;generating&nbsp;the&nbsp;new&nbsp;points&nbsp;like&nbsp;this,&nbsp;but&nbsp;it's&nbsp;the&nbsp;only&nbsp;solution&nbsp;at&nbsp;the&nbsp;moment.<br /></span><span class="syntaxdefault">def&nbsp;draw_points</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">points</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">color</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">view</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;return&nbsp;if&nbsp;</span><span class="syntaxdefault">points</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">is_a</span><span class="syntaxkeyword">?(Array)&nbsp;&&&nbsp;</span><span class="syntaxdefault">points</span><span class="syntaxkeyword">.empty?<br />&nbsp;&nbsp;</span><span class="syntaxdefault">view</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">drawing_color&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">color<br />&nbsp;&nbsp;points&nbsp;</span><span class="syntaxkeyword">=&nbsp;[</span><span class="syntaxdefault">points</span><span class="syntaxkeyword">]&nbsp;if&nbsp;</span><span class="syntaxdefault">points</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">is_a</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Vertex</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;</span><span class="syntaxdefault">half_size&nbsp;</span><span class="syntaxkeyword">=&nbsp;@</span><span class="syntaxdefault">settings</span><span class="syntaxkeyword">[;</span><span class="syntaxdefault">vertex_size</span><span class="syntaxkeyword">]&nbsp;/&nbsp;</span><span class="syntaxdefault">2.0<br />&nbsp;&nbsp;</span><span class="syntaxcomment">#&nbsp;line_width&nbsp;appear&nbsp;to&nbsp;be&nbsp;limited&nbsp;to&nbsp;10px<br />&nbsp;&nbsp;</span><span class="syntaxdefault">view</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">line_width&nbsp;</span><span class="syntaxkeyword">=&nbsp;@</span><span class="syntaxdefault">settings</span><span class="syntaxkeyword">[;</span><span class="syntaxdefault">vertex_size</span><span class="syntaxkeyword">]<br />&nbsp;&nbsp;</span><span class="syntaxdefault">hack_points&nbsp;</span><span class="syntaxkeyword">=&nbsp;[]<br />&nbsp;&nbsp;</span><span class="syntaxdefault">v1&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">view</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">camera</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">xaxis<br />&nbsp;&nbsp;v2&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">v1</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">reverse<br />&nbsp;&nbsp;</span><span class="syntaxkeyword">for&nbsp;</span><span class="syntaxdefault">v&nbsp;in&nbsp;points<br />&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">v</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">position<br />&nbsp;&nbsp;&nbsp;&nbsp;offset_length&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">view</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">pixels_to_model</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">half_size</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">p</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">hack_points&nbsp;</span><span class="syntaxkeyword"><<&nbsp;</span><span class="syntaxdefault">p</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">offset</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">v1</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">offset_length</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">hack_points&nbsp;</span><span class="syntaxkeyword"><<&nbsp;</span><span class="syntaxdefault">p</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">offset</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">v2</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">offset_length</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;</span><span class="syntaxdefault">end<br />&nbsp;&nbsp;view</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">draw</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">GL_LINES</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">hack_points</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">end<br /></span>
                

                Another observation in regard to drawing in SketchUp, on (either ATI or nVidia - can't remember atm) if you draw 2d lines with odd number thickness they will appear fuzzy.
                Say you draw a line from 50.0,50.0 to 100.0,50.0 in line width 3 it will not be a sharp and crisp line if the user has AA on. However, with even line width, like 2, it will look sharp.
                To ensure crisp lines with off line width one has to offset the lines by .5 - so as in the previous example one would have to draw 50.5,50.5 to 100.5,50.5 .

                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