3d camera position taking into account some points

Heyo

I am currently working on a project where I need to place the camera so that the full movement of the character is viewable without moving the camera. I have a position in which the character begins, as well as the maximum distance that the character will move in all three directions (X, Y and Z). I also have a field of view (which is 90 degrees).

Is there an equation that will determine where I need to place the camera so that it does not move in order to see the full movement?

Note: this is using OpenGL.

Clarification: the camera should be “in front” of the symbol, which is in motion, and not above.

He will also move on the ground.

+3
source share
4 answers

If you are creating a limited point sphere, all you have to do is keep the camera at a distance greater than or equal to the radius of the bounding sphere / sin (FOV / 2).

For example, if you have a bounding sphere of radius radius and a given FOV field of view, your camera should be at the “Dist” point, pointing to the center of the bounding sphere.

The equation for calculating the distance: Dist = Radius / sin (FOV / 2);

This will work in 3D, for a camera with any orientation.

+1
source

. , , . - , . , 90 .

distance = sqrt(dx^2 + dy^2 + dz^2) / 2

.

, , . .

0

(X, Y, Z) , , .

, (X, Z) (.. ), 10 Y.

, 90 ° ± 10 X Z, , (Y = 0). , . 1 , (X, Z) ± 9 .

, . "" , . , .

0

It depends, for example, on whether the object will move in the plane, you can simply place the camera outside the ball, limited by its area of ​​motion (it depends on the fact that FOV is 90, which is a good angle).

If the object will move in 3D, it is much more complicated. This will help if you indicate the area in which the object is moving (cube against the ball ...), and the direction from which you want to see it.

0
source

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


All Articles