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