如何使魔方的背面虚线? [英] How do I make the back of a cube dashed?

查看:155
本文介绍了如何使魔方的背面虚线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在OpenGL中进行某种3D有线立方体建模.我的目标是使立方体在3D空间中旋转.

在学校,我们学习了如何在2D空间中绘制立方体.看不见的线将以虚线绘制.

问题是,如何旋转立方体并保持虚线看不见?

非常感谢.

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.

推荐答案

这是一个通常称为隐藏线清除(HRL)"的问题.有一些简单的技巧可以模拟HLR(在OpenGL中),其中之一是使用多边形偏移,并在实体模式下使用背景颜色绘制偏移对象,而在线框模式下使用原始对象绘制偏移对象.但是,这将完全隐藏看不见的线条.

如果要在其他线属性中显示隐藏线,则需要找出立方体的隐藏部分(边缘)的确切长度,然后使用该属性渲染该部分.为此,您需要使用投影算法来旋转对象后重新计算隐藏边缘的位置和方向.为此,您不能简单地使用绘制3d立方体本身的传统方式.您需要创建具有边,面和顶点的多维数据集的拓扑数据结构,因为在投影后处理隐藏的边将需要此信息.

我建议您阅读一些解释HLR,多边形剔除等的文章或书籍.我认为完全隐藏线条比绘制具有其他属性的线条容易得多.
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.


这篇关于如何使魔方的背面虚线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆