Sign in to follow this  
vadim85

Hidden lines

Recommended Posts

A thorough implementation of that would be non-trivial, I would think. But here's something you could try in the meantime. This is based only on what I vaguely remember from the red book, so it could be way off.

I seem to remember there being 'stippled' modes for line drawing (I've never used them). Perhaps you could set up front facing tris to draw with normal lines, and backfacing polys to draw with stippled lines.

Actually, I'm not sure if you can specify different modes for front and back. You might have to set lines to normal and front facing to CCW (or whatever), and draw the object, then set lines to stippled and front facing to CW and draw it again.

Anyway, that could be way off. But maybe it'll work...

Share this post


Link to post
Share on other sites
Umm...I'm going off of jyk's post, because I don't really understand the OP.

You can change attributes of front or back-facing polygon draws with glPolygonMode(GL_FRONT|GL_BACK,GL_LINE|GL_FILL|GL_POINT). So if you wanted to draw all front and back lines as dotted lines, you could use glPolygonMode(GL_FRONT_AND_BACK,GL_LINE) and set the line stipple pattern with glLineStipple(factor,pattern). Again, I really, really don't understand either of the things in this topic, but you should do that anyway. It came out of this book that Dave Astle hypnotized me into buying.

Share this post


Link to post
Share on other sites
Maybe you can do this:
Build a style for your line drawing:

enum TPenstyle { psSolid, psDash, psDot, psDashDot, psDashDotDash, psDashDotDot};
TPenstyle style;
int LineWidth;

Later, when you're drawing lines, use:

glEnable(GL_LINE_STIPPLE);
switch(style)
{
case psSolid:
break;
case psDash:
glLineStipple(1, 0x0F0F);
break;
case psDot:
glLineStipple(1, 0x1111);
break;
case psDashDot:
glLineStipple(1, 0xFC30);
break;
case psDashDotDash:
glLineStipple(1, 0xF33C);
break;
case psDashDotDot:
glLineStipple(1, 0xF888);
break;
}

glLineWidth(LineWidth);
glBegin(GL_LINES);
glVertex2i(X1, Y1);
glVertex2i(X2, Y2);
glEnd();

glDisable(GL_LINE_STIPPLE);

rzv - Web: guide.jejik.com

Share this post


Link to post
Share on other sites
Quote:
Original post by Boku San
So if you wanted to draw all front and back lines as dotted lines, you could use glPolygonMode(GL_FRONT_AND_BACK,GL_LINE)


so are you are saying that this actually works for lines and that they DO have a front and back? because i think that was the part in question as it wouldnt make too much sense for them.

its also interesting to see how the real problem is carefully avoided. figuring out which lines are hidden and breaking up partially hidden lines into visible and hidden parts.

Share this post


Link to post
Share on other sites
Disclaimer: I know very little about 3d programming ;)

First draw the whole scene with invisible solid polygons to get some geometry into the z-buffer.
Draw all the stippled lines without any z-buffering.
Then switch z-buffer mode to a comparsion for equal depth and draw all of the solid lines.

Not exactly fast, but I think it could work..

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this