How can I make the glOrtho parallelepiped rotating

2019-08-22 01: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.