Archived

This topic is now archived and is closed to further replies.

BGCJR

glLineWidth

Recommended Posts

Guest Anonymous Poster
not sure, but if you''re using glLineWidth for the NeHe cel-shading routines, there''s a (barely) better way to do outlines. (I hope this preserves line breaks)

1) somewhere define a constant outline scalar (it should be rather small):
const float cfOutlineScalar = 0.01;

2) when you draw your mesh, draw it once like normal

3) then, set up for outline drawing:
glCullFace(GL_FRONT);
glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
glColor3f(0.0f, 0.0f, 0.0f);
/*notice, I did _not_ tell it to draw lines*/

4) draw an "extruded" version of your mesh. at each vertex, don''t draw (v.x, v.y, v.z) draw
(v.x+n.x*cfOutlineScalar,
v.y+n.y*cfOutlineScalar,
v.z+n.z*cfOutlineScalar)

This will clean up a lot of ugly corners in your outline, and if you use the extruded mesh to do the selection, it''ll work like a charm.

Share this post


Link to post
Share on other sites
i''m drawing bones of models with gl_lines.
then to pick the bones with code similiar to nehe''s picking tut.
but when i render them for object picking. The glLineWidth doesn''t effect it. so when i move the mouse over the bone, It only picks then glLineWidth(1), but i want glLineWidth(8).

:S

Share this post


Link to post
Share on other sites
What I say now is only how I think it is. I can't guarantee it's correct.

The selection mode does not work by rasterizing pixel, but by mathematically checking if the primitive intersects the picking region (or view volume if you were to render it on screen instead of picking it). So if you pick a thick line, and pick on it's edge, the mathematical line, which is infinitely thin, will not intersect the picking region. If you pick the line's center (or at least the pixel where the center is), you would get a hit.

So if you want to pick a thick line, you either have to make the picking region larger (large enough so that the mathematical line is within the picking region even if you pick on the edge), or replace the line during picking with a quad of equal size and shape. To change the size of the picking region, change the width and height parameter of gluPickMatrix, I think (if you use that function).

[edited by - Brother Bob on July 31, 2003 5:14:35 PM]

Share this post


Link to post
Share on other sites
At first glance I thought it was either a driver issue or maybe an application issue, but in fact that''s the correct OpenGL behaviour.

It is clearly specified that lines or points are not rasterized when offscreen, even if the point size or line width is large enough to intersect the screen.
Imagine a big point (POINT_SIZE=100) is at the edge of the screen, say at window coordinate (795, 300) in a (800, 600) viewport. This point will be rendered. Now if the window coordinate of the point is at (805, 300), it will be clipped (since 805 exceeds the 800 viewport limit) even though a part of it could be visible because the point size is extended to 100 pixels wide (as defined by glPointSize). That clipping is undesirable but affordable in many cases, except for some rare cases like picking ! Generally, the solution is to extend the picking window size to the maximum line width / point size.

Share this post


Link to post
Share on other sites