OpenGL: mix spelling and perspective

I want to mix perspective and spelling, but I can't get it to work.

I want the X and Y coordinates to be spelling and Z perspectives. For clarification, I added a sketch of the desired transformation from OpenGL coordinates to the screen:

sketch of desired view

(I started with a tutorial , but could not find how to get values ​​from above, from below, etc.)

+6
source share
2 answers

What you painted is just promising, not a mix. You just need to make sure that the viewing direction is parallel to the z axis so that the front and back sides of the box remain rectangular.

+1
source

You could use glFrustum to achieve this.

If you use the standard perspective matrix and the camera is facing the box in front, X / Y will be uniform, however the movement from the camera will move the X / Y coordinates to the center, reducing them for the standard parallax effect. What you painted is the movement to the top parts of the window. All you have to do is crop the perspective projection below its standard center. What is where glFrustum enters - move normally symmetric upper / lower arguments down, align the camera / view matrix along the desired axis, and you should have the desired projection.

Any rotation of the camera / view will destroy the uniform projection in the X / Y plane. To move the camera, you are then limited to panning and moving the borders of glFrustum .

EDIT Come up with this, you could just add glTranslatef(shearX, shearY, 0) before calling gluPerspective and achieve the same.

0
source

Source: https://habr.com/ru/post/958005/


All Articles