How can I make the glOrtho parallelepiped rotating?

佐手、 提交于 2020-01-06 10:40:44

问题


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);

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)

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..

Is there a method using the glOrtho call?

I would like to obtain something like this:


回答1:


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.

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.

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



来源:https://stackoverflow.com/questions/11722273/how-can-i-make-the-glortho-parallelepiped-rotating

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!