Jump to content
  • Advertisement


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



This topic is 5438 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I can''t use the glLineWidth with picking objects! is there a easy way around it? or, Am I doing something wrong? Bobby

Share this post

Link to post
Share on other sites
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:
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

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).


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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!