View.draw2d adds lots of bad lines?
-
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?
-
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
-
Do you have a standard def getExtents method that includes all picked / cursor points in the model's bounds ?
-
@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!
-
Without seeing your code I can't be sure...
Are you definitely only drawing a line over each edge's vertices points ?
The methoddraww2d
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 simpleredges.each{|e|draw.line(e.start.position, e.end.position)}
assuming that edges is an array of the edges you want to trace over ? -
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
-
@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.sIn the posted example you use just the start positions... just a typo in the posted example?
I've never seen any problems with
draw2d
andview.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?
-
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 ?
Advertisement