OpenGL 过剩视角
我正在建造建筑物和景观的比例模型。我正在使用 openGL 和 GLUT 以及函数 gluperspective。我知道函数的最后两个参数定义了 z 剪切路径,并且只能为正值。好吧,我有一些东西用负 z 值渲染。嗯,它被剪辑了,这是有道理的。有人建议如何阻止它以负 z 值剪裁我的东西吗?我对 gluperspective 的调用如下。
gluPerspective(50.0, (double)w / (double)h, 1.0, 300.0);
I am building a scale model of buildings and landscape. I'm using openGL and GLUT and the function gluperspective. I know that the last two parameters of the function define the z-clipping path and can only be positive. Well I have stuff getting rendered with a negative z value. Well it is getting clipped which makes sense. Does anyone have a suggestion on how to stop this from clipping my things with a negative z value? My call to the gluperspective is below.
gluPerspective(50.0, (double)w / (double)h, 1.0, 300.0);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
zbuffer 和 3d 空间中的 z 值之间存在差异。想象一下您有一台相机并将其举到眼前。 1.0 是相机的屏幕(即物体可以距离您最近的距离),300.0 是相机可以看到的最远距离。这些定义了 zbuffer 的“范围”(设置剪辑)。
现在如果你身后有一个物体怎么办?那么 z 值(不是 z 缓冲区)就是负值。你怎么看?只需转身(有效地将相机指向一个新方向。z 缓冲区保持不变(即距离小于 1.0 或远于 300.0 的对象不可见),但具有负 z 值的对象不可见。
所以使用 gluPerspective,您可以设置透视矩阵(即相机的视野和范围),然后要查看身后的物体,您需要设置视图矩阵(即相机的方向)。
编辑:因此,要查看具有负 z 值的内容(无需转身),请向后移动相机(即更改视图矩阵,使其位置更靠后)。
There is a difference between the zbuffer and the z value in 3d space. Imagine that you have a camera and are holding it up to your eye. The 1.0 is the camera's screen (i.e. the closest an object can get to you), and the 300.0 is the furthest the camera can see. These define the zbuffer's "range" (which sets up clipping).
Now what if you have an object behind you? Well then the z-VALUE (not z-buffer) is negative. How do you see it? Just turn around (effectively pointing the camera in a new direction. The z-buffer stays the same (i.e. objects closer than 1.0 or further than 300.0 are not visible), but the object that has the negative z-VALUE is not visible.
So with gluPerspective, you set up your perspective matrix (i.e. the camera's field ov view and range). Then to see objects behind you, you need to set up your view matrix (i.e. the camera's orientation).
Edit: So to see stuff that has a negative z-VALUE (without turning around), move your camera backwards (i.e. change your view matrix, so that it is positioned further back).