OpenGL: setting a scene on the screen

I have a three-dimensional scene with a perspective projection.

I want to put the scene into the screen based on the bounding box ( minand max).

I focused my scene like this:

glm::vec3 center = (min + max) / 2.0f;
rootNode->translate(-center.x, -center.y, -center.z);

Now I need a scale factor to scale my rootNode to fit the screen. How to do it?

(this: 8.070 How can I automatically calculate the view displaying my entire model? (I know the border of the frame and up.) does not help, because it is based on orthogonal projection)

+4
source share
1 answer

, , , , min max, .

.

, theta, "", v. d ( v) , v. , , :

2 * d * tan(theta / 2).

z, d z.

, . "fovy" ( / ), - .

+2

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


All Articles