四边形的法线向量
我用 glBegin 和 glEnd 绘制了一个简单的四边形。通过 for 循环,我创建了四边形的副本,并在 3D 空间中围绕 y 轴旋转它。 现在的问题是我只能看到前面的四边形。后面的这些不显示。我认为问题出在法线向量内,该方向朝向我。是否有可能为一个四边形定义两个法向量。
I've drawn a simple quad with glBegin and glEnd. With a for-loop I create copies of the quad and rotate it around my y-Axis in 3D space.
Now the problem is that I only see the quads in the front. These in the back are not displayed. I assume that the problem lies within the normal vector, which direction is towards me. Is there a possibility to define two normal vectors for one quad.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来您需要禁用背面剔除:
Sounds like you need to disable backface culling:
问题不是法线向量,而是OpenGL认为的正面和背面。什么是什么是由屏幕上顶点的缠绕决定的。如果顶点在屏幕上按逆时针顺序排列,则默认情况下 OpenGL 会采用正面。如果启用背面剔除,则不会绘制背面。您可以禁用剔除,但随后您会得到奇怪的照明结果。
最好的方法是用它自己的一组四边形显式地绘制背面;绕组和法线已调整。
The problem is not the normal vector, but what OpenGL considers front side and backside. What's what is determined by the winding of the vertices on the screen. If the vertices are on screen in counterclockwise order, then by default OpenGL assumes the front face. If back face culling is enables, back faces will not be drawn. You can disable culling, but then you'll get odd lighting results.
The best way is to draw the back side explicitly with it's own set of quads; windings and normals adjusted.