Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi, I am trying to make some kind of 3D wired cube-modeling in OpenGL. My goal is to make the cube rotated in 3D-space.

At school, we learned how to draw a cube in 2D-space. The unseen lines would be drawn in dashed style.

The problem is, how to rotate the cube and keep the unseen lines dashed?

Thank you very much.
Posted
Updated 13-Mar-10 8:42am
v2

1 solution

This is a problem commonly called as Hidden Line Removal (HRL). There there are trivial tricks to simulate HLR (in OpenGL), one of which is using polygon offset and drawing the offseted object with background color in solid mode and the original object in wireframe mode. However this will completely hide the unseen lines.

If you want to show the hidden lines in some other line attribute, you would need to find out the exact length of the hidden part (edge) of the cube and then render that portion using the attribute. For this you need to use projection algorithms to recompute the position and orientation of the hidden edges after rotating the object. And for this you cannot simple use the traditional way of drawing the 3d cube itself. You would need to make a topological datastructure of the cube with edges, faces and vertices as this information would be required to process the hidden edge after projection.

I would suggest you to read some articles or books which explain HLR, polygon culling etc. I think hiding the lines completely is far easier than drawing them with some other attributes.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900