0
$\begingroup$

My question: How can I set the parameters of orthographic camera, to look only at a specific plane from orthogonal position, and at the same time to see the whole plane on the render (fit the size of render to the plane size of a plane)?

Big picture: I have multiple planes in 3D space and I want to take a photo of each plane (render each plane) using python script. I want to set the parameters of orthographic camera, such that the camera is looking at one plane at a time from orthogonal position and the whole plane is visible on the render. Planes should not be moved in 3D space and planes are rectangular, and can be of any width/height combination.

-Just as an idea: Maybe a part of the solution would to use the "Damped track constraint", but I'm still not sure about setting the camera orthogonally and to see the whole plane. Graphical presentation of a problem. Thank you very much for your time!

$\endgroup$
2
$\begingroup$

You can create a macro with the following steps for each plane:

  1. set plane as active object.
  2. bpy.ops.view3d.view_axis(type='TOP', align_active=True)
  3. bpy.ops.view3d.camera_to_view()
  4. bpy.ops.view3d.camera_to_view_selected()
  5. if needed, change your render resolution to the same dimensions of the plane.
$\endgroup$
  • $\begingroup$ Thank you for your quick answer. As step 2) I used view3d.viewnumpad(type='TOP', align_active=True) as it's the new name. Now I face another problem, since I don't know in advance which "type" (TOP/ BOTTOM/ LEFT etc.) parameter is the right one (for randomly given plane) in advance. For example if I dismantle a cube to "plane" meshes, for some planes "TOP" is ok, but for some nothig is captured. Will have to calculate a normal vector or something to decite the type? Do you know maybe how to approach it? I would like to take max 2 images (from both perpendicular sides) of the current plane. $\endgroup$ – pro Jan 7 at 14:42
  • $\begingroup$ Tough question! If your planes are not aligned to the object vectors, the only way to do this would be to jump in edit mode, check the normals, build a new matrix and throw that matrix into the camera. This is even worse if your planes are no planes at all.. nothing can prevent this. $\endgroup$ – Secrop Jan 8 at 16:47
  • $\begingroup$ All planes have 3 or 4 coplanar vertices, so there is no fear that they are not planes. Which function should I use to build a new matrix and throw it into a camera - for example we tried with camera_fit_coords (thread is accessible here blender.stackexchange.com/questions/128185/…), but it seems to work only when plane has z axis oriented normal? Thank you for your suggestions! $\endgroup$ – pro Jan 9 at 6:51
  • $\begingroup$ remember that 4 vertices might not be coplanar. only 3 vertices are for sure. About the matrix, I don't know if there's a function for that. I'd build the matrix on my own, since you need to define what will be the X, Y and Z of your plane. And this is the difficult part... If you know what those axis are, building the matrix is easy. $\endgroup$ – Secrop Jan 9 at 7:47
  • $\begingroup$ Sorry, I didnt say it properly - in my case all 4 points of rectangle are guaranteed to be coplanar. I updated my code, implementing that idea as far as i got in that question blender.stackexchange.com/questions/128185/… $\endgroup$ – pro Jan 9 at 12:38

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.