2
$\begingroup$

In python, is there a method or function for adjusting the camera's parameters so that it covers a specific area, rather than just pointing at a specific point?

This would be handled by zooming in or out, but to what degree?

The following is one way to handle it, but not the only way - if there are other ideas I would appreciate the opportunity to learn about them.

Let's assume that I want the camera to point at (X,Y,Z).

I also want the camera's perspective to meet the following requirements: (a) left edge includes point (X-2,Y,Z) (b) right edge includes point (X+2,Y,Z) (c) top edge includes point (X,Y+2,Z) (d) bottom edge includes point (X,Y-2,Z)

As an illustration, I would pass the desired points to the function, which would position the camera in such a way that the points fall on the edges of the camera view as follows:

enter image description here

The above would not only aim the camera correctly, but would insure that all of the important elements of the scene are included.

Thanks in advance!

$\endgroup$
2
  • $\begingroup$ To clarify, this operation will only move the camera, not rotate it, right? $\endgroup$
    – Leander
    Sep 8, 2019 at 15:22
  • $\begingroup$ @Leander Camera location and rotation are fixed with the camera pointing at the center of the area. All that remains is to adjust the zoom/resolution to get the area of interest to fill the camera view. Camera pointing is done this way: blender.stackexchange.com/questions/150697/… $\endgroup$
    – vndep
    Sep 9, 2019 at 0:21

1 Answer 1

1
$\begingroup$

So basically you want to have a plane or area that should be included in camera view?

There are few way to include different area size:

  1. Actually move camera to get a better cover of view.
  2. Adjust the camera sensor size directly.
  3. Adjust FOV setting for wider view.

For the first one: view_selected is already include in Blender.

My naive solution is to actually create a mesh indicated your desired area and select it, view_selected it and move camera to here. But the size of the render view might cut up some places since the view won't be entire include in camera. So the things get more complicate if using existed function. Then writing some math function will be faster for sure.

You only need to calculate those coordinates from your points, using camera view coordinate system. Then other thing should be easily done

$\endgroup$
2
  • $\begingroup$ @Hikaiztw Can you provide a link to "camera view coordinate system?" $\endgroup$
    – vndep
    Sep 8, 2019 at 13:56
  • $\begingroup$ @vndep Camera View Trans. The CVC is just a transformation for better calculating of viewing element, it will be extremely helpful in your case $\endgroup$
    – HikariTW
    Sep 9, 2019 at 1:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .