如何使 glOrtho 平行六面体旋转? [英] How can I make the glOrtho parallelepiped rotating?

查看:54
本文介绍了如何使 glOrtho 平行六面体旋转?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经渲染了我的世界.根据一些特定要求,它包括(有时)地板上的一些灯.我正在使用三角形基元渲染这些灯.现在我有以下代码来缩放和限制渲染区域:

I have my world rendered. Based on some specific requirements it includes (some time) some lights on the floor. I am rendering these lights using triangle primitives. Right now I have the following code to zoom and limit the rendering area:

            if(aspect>1)    
                gl.glOrtho(-scale*aspect, scale*aspect, -scale, scale, 0, 2);
            else
                gl.glOrtho(-scale, scale, -scale/aspect, scale/aspect, 0, 2);

正如你在这张图片中看到的,远平面将光穿过一条线(平行于 B 和 D 之间的圆上的线)

As you can see in this image, the far plane is cutting the light throught a line (parallel to the line on the circle between B and D)

当我旋转我的场景时出现问题... glOrtho框"保持固定.您可以通过始终查看灯上的切割线来注意到它.它不再平行于 B 和 D 之间的线...

The problem arises when I rotate my scene... the glOrtho "box" stays fix. You can notice it by looking always at the cutting line on the light. It is no more parallel to the line between B and D...

我的一位朋友推荐了我的这份文件.基本上它解释了如何提取平截头体平面...

One of my friend suggested my this document. Basically it explains how to extract frustum planes...

但这意味着我应该手动检查每个基元是否在里面..

But this would mean that I should check manually each primitive if it is inside or not..

是否有使用 glOrtho 调用的方法?

Is there a method using the glOrtho call?

我想获得这样的东西:

推荐答案

好的,经过评论中的选举解释后,答案是:您对什么是可视体积剪裁平面有误解.

Okay, after explanation by elect in the comments the answer is: You've got a misconception of what the viewing volume clip planes are.

它们不是某种与场景对齐的边界框.

They are not some sort of bounding box aligned with the scene.

近剪裁平面和远剪剪平面是屏幕到世界的投影,根据定义,它们始终与视图对齐.您对此无能为力,因为这是 OpenGL 使用的数学的基础.

The near and far clipping plane are sort of projections of the screen into the world and they are, by definition, alway aligned with the view. There's nothing you can do about this, because this is fundamental to the math used by OpenGL.

在 OpenGL 中也不可能让基元向无穷大扩展,因此无论如何都必须以某种方式限制几何体.

It is also impossible in OpenGL to let primitives expand toward infinity, so geometry has to be limited in some way anyhow.

这篇关于如何使 glOrtho 平行六面体旋转?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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