PDA

View Full Version : rendering polygon elements edge-on & polygon offset



rlskinner
02-19-2004, 08:43 AM
Hi all,

I want to draw the outline of a polygon when viewed from any direction. I've disabled GL_CULL_FACE, so the outline is displayed from front or back, but it is not rendered when the polygon is parallel to the view direction, i.e. edge-on. Is there any way to force the outline to be drawn even when its edge-on?

What I'm *really* trying to do is apply a polygon offset to a bunch of lines. The background behind the question:

I'm working on a CAD program that displays the reinforcement bars in a concrete floor. When the top and bottom surfaces of the floor are also drawn, it is essentially a bunch of lines sandwiched between two outlined polygons.

This sandwich is very thin relative to its width, so I have problems with the lines poking through the floor surface polygon, even with a 24 bit Z buffer and a reasonable zfar/znear ratio of 3.

So, glPolygonOffset to the rescue, right? I can offset the floor surface polygons toward the viewer to keep the lines from poking through, but two problems come up:

1. the floor surface polygons share edges with vertical elements, like columns. A negative offset applied to all polygons causes the vertical elements to poke through the floor when viewed nearly edge on, i.e. when they have a high depth slope. I'm worried that offsetting only the floor surface polygon will cause gaps where the floor meets the vertical elements. (And setting the polygon offset factor parameter to zero never seems to work well for me.)

2. I will have to offset the surface polygon outlines toward the viewer by a greater amount, but I'm trying to use the smallest polygon offsets possible.

I would prefer to render the polygonal elements with no offsets (so that the edges will meet evenly), offset the polygon outlines toward the viewer, and offset the lines sandwiched between the floor surfaces away from the viewer. So what I'm really trying to do is get around the restriction that only polygon elements can be offset.

Ideas?

Thanks,