PDA

View Full Version : How can I display a hollow cylinder.

jbarton
03-15-2002, 08:10 AM
I'm trying to find a technique for hiding all but the end circular and side lines for a cylinder. Similar to hidden lines. I think I'm just missing something simple.

nexusone
03-15-2002, 11:04 AM
My I suggest gluCylinder, a good example of it is on the http://nehe.gamedev.net

http://www.opengl.org/discussion_boards/ubb/smile.gif

Originally posted by jbarton:
I'm trying to find a technique for hiding all but the end circular and side lines for a cylinder. Similar to hidden lines. I think I'm just missing something simple.

DFrey
03-15-2002, 11:15 AM
Actually, nexusone, I think he is saying he wants the silhouette of the cylinder.

jbarton
03-15-2002, 11:18 AM
Yeah, I've played with that but I can't get rid of the other straight lines. Example: when viewed from a non-ortho position a hidden cylinder would have one ellipse, 2 lines and an elliptical arc. What I'm getting is the normal ellipse, elliptical arc and all the lines for each face. I'm looking a some combination of a boundary or subtracting the other lines some how.

DFrey
03-15-2002, 11:26 AM
The solution to this problem is very similar to that of "toon" shading. When toon shading, you have to take an arbitrarily complex 3D model and reduce it to its prominent edges. This sounds much like what you want to do but with a simple cylinder instead.

jbarton
03-15-2002, 11:30 AM
DFrey, that sounds right, but wouldn't that leave the other lines showing on the cylinder?
Right now I'm placing the same GL_FILL cylinder after a GL_Line cylinder in the background color and that works ok except for the other lines.

Thanks.

DFrey
03-15-2002, 11:43 AM
Which edges would show is tunable. Though I doubt you could guarantee that improper edges would never be shown. The only two other methods I can think of are:
1. The method you currently are using, which does not remove the interior edges (and may suffer from invariancy issues).
2. Draw the cylinder piecewise, taking into account the cylinder's view orientation.

[This message has been edited by DFrey (edited 03-15-2002).]

jbarton
03-15-2002, 11:47 AM
DFrey,
Do you know where I can find a good example of the toon method?

nexusone
03-15-2002, 11:50 AM
Are you also wanting to be able to look through the cylinder?
Maybe a texture map?
And if you needed to see through it add a apha channel for a mask.

Something like this:
-----
| |
| |
| |
-----

Another thought with a little math, build a custom function plot a circle and arc based on the rotation....

Originally posted by jbarton:
Yeah, I've played with that but I can't get rid of the other straight lines. Example: when viewed from a non-ortho position a hidden cylinder would have one ellipse, 2 lines and an elliptical arc. What I'm getting is the normal ellipse, elliptical arc and all the lines for each face. I'm looking a some combination of a boundary or subtracting the other lines some how.

[This message has been edited by nexusone (edited 03-15-2002).]

jbarton
03-15-2002, 11:53 AM
Nexusone,
No the cylinder should appear solid line a 2 line drawing. I'm trying to come up with a method to create a printable drawing for piping.

nexusone
03-15-2002, 11:59 AM
A custom function should not be hard to write, just draw a 2D circle, arc and connect them with two lines.

Originally posted by jbarton:
Nexusone,
No the cylinder should appear solid line a 2 line drawing. I'm trying to come up with a method to create a printable drawing for piping.

jbarton
03-15-2002, 12:03 PM
Ok, I'll give that a try. I'll have to figure out how to find the points I need based on the angle of view. Does that sound right?

Thanks for the help.

DFrey
03-15-2002, 12:07 PM
A quick search on Google turns up lots of hits. I've seen and learned alot from Jeff Lander's papers and demos. And I found a link for his paper on toon shading: http://www.darwin3d.com/gamedev/articles/col0300.pdf

If you want the cylinder to be a wireframe, you just use an appropriate 1D shading texture that allows the edges to be opaque and everything else to be transparent.

jbarton
03-15-2002, 12:24 PM
Thanks everyone you've given me a lot to try.