2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): none yet.
25 * ***** END GPL LICENSE BLOCK *****
28 #ifndef __BKE_CAMERA_H__
29 #define __BKE_CAMERA_H__
31 /** \file BKE_camera.h
33 * \brief Camera datablock and utility functions.
39 #include "DNA_vec_types.h"
53 /* Camera Datablock */
55 void BKE_camera_init(struct Camera *cam);
56 void *BKE_camera_add(struct Main *bmain, const char *name);
57 void BKE_camera_copy_data(struct Main *bmain, struct Camera *cam_dst, const struct Camera *cam_src, const int flag);
58 struct Camera *BKE_camera_copy(struct Main *bmain, const struct Camera *cam);
59 void BKE_camera_make_local(struct Main *bmain, struct Camera *cam, const bool lib_local);
60 void BKE_camera_free(struct Camera *ca);
64 float BKE_camera_object_dof_distance(struct Object *ob);
66 int BKE_camera_sensor_fit(int sensor_fit, float sizex, float sizey);
67 float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y);
71 * Intermediate struct for storing camera parameters from various sources,
72 * to unify computation of viewplane, window matrix, ... */
74 typedef struct CameraParams {
95 /* computed viewplane */
101 /* computed matrix */
105 /* values for CameraParams.zoom, need to be taken into account for some operations */
106 #define CAMERA_PARAM_ZOOM_INIT_CAMOB 1.0f
107 #define CAMERA_PARAM_ZOOM_INIT_PERSP 2.0f
109 void BKE_camera_params_init(CameraParams *params);
110 void BKE_camera_params_from_object(CameraParams *params, const struct Object *camera);
111 void BKE_camera_params_from_view3d(CameraParams *params, struct Depsgraph *depsgraph, const struct View3D *v3d, const struct RegionView3D *rv3d);
113 void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int winy, float aspx, float aspy);
114 void BKE_camera_params_compute_matrix(CameraParams *params);
116 /* Camera View Frame */
118 void BKE_camera_view_frame_ex(
119 const struct Scene *scene, const struct Camera *camera,
120 const float drawsize, const bool do_clip, const float scale[3],
121 float r_asp[2], float r_shift[2], float *r_drawsize, float r_vec[4][3]);
122 void BKE_camera_view_frame(
123 const struct Scene *scene, const struct Camera *camera,
126 bool BKE_camera_view_frame_fit_to_scene(
127 struct Depsgraph *depsgraph,
128 struct Scene *scene, struct Object *camera_ob,
129 float r_co[3], float *r_scale);
130 bool BKE_camera_view_frame_fit_to_coords(
131 const struct Depsgraph *depsgraph,
132 const float (*cos)[3], int num_cos,
133 struct Object *camera_ob,
134 float r_co[3], float *r_scale);
136 void BKE_camera_to_gpu_dof(struct Object *camera, struct GPUFXSettings *r_fx_settings);
138 /* Camera multi-view API */
140 struct Object *BKE_camera_multiview_render(struct Scene *scene, struct Object *camera, const char *viewname);
141 void BKE_camera_multiview_view_matrix(struct RenderData *rd, const struct Object *camera, const bool is_left, float r_viewmat[4][4]);
142 void BKE_camera_multiview_model_matrix(struct RenderData *rd, const struct Object *camera, const char *viewname, float r_modelmat[4][4]);
143 void BKE_camera_multiview_model_matrix_scaled(struct RenderData *rd, const struct Object *camera, const char *viewname, float r_modelmat[4][4]);
144 void BKE_camera_multiview_window_matrix(struct RenderData *rd, const struct Object *camera, const char *viewname, float r_winmat[4][4]);
145 float BKE_camera_multiview_shift_x(struct RenderData *rd, const struct Object *camera, const char *viewname);
146 void BKE_camera_multiview_params(struct RenderData *rd, struct CameraParams *params, const struct Object *camera, const char *viewname);
147 bool BKE_camera_multiview_spherical_stereo(struct RenderData *rd, const struct Object *camera);
149 /* Camera background image API */
150 struct CameraBGImage *BKE_camera_background_image_new(struct Camera *cam);
151 void BKE_camera_background_image_remove(struct Camera *cam, struct CameraBGImage *bgpic);
152 void BKE_camera_background_image_clear(struct Camera *cam);