Blender  V2.93
BKE_camera.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
20 #pragma once
21 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 struct Camera;
31 struct Depsgraph;
32 struct Main;
33 struct Object;
34 struct RegionView3D;
35 struct RenderData;
36 struct Scene;
37 struct View3D;
38 struct rctf;
39 
40 /* Camera Datablock */
41 
42 void *BKE_camera_add(struct Main *bmain, const char *name);
43 
44 /* Camera Usage */
45 
46 float BKE_camera_object_dof_distance(struct Object *ob);
47 
48 int BKE_camera_sensor_fit(int sensor_fit, float sizex, float sizey);
49 float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y);
50 
51 /* Camera Parameters:
52  *
53  * Intermediate struct for storing camera parameters from various sources,
54  * to unify computation of viewplane, window matrix, ... */
55 
56 typedef struct CameraParams {
57  /* lens */
58  bool is_ortho;
59  float lens;
60  float ortho_scale;
61  float zoom;
62 
63  float shiftx;
64  float shifty;
65  float offsetx;
66  float offsety;
67 
68  /* sensor */
69  float sensor_x;
70  float sensor_y;
72 
73  /* clipping */
74  float clip_start;
75  float clip_end;
76 
77  /* computed viewplane */
78  float ycor;
79  float viewdx;
80  float viewdy;
82 
83  /* computed matrix */
84  float winmat[4][4];
86 
87 /* values for CameraParams.zoom, need to be taken into account for some operations */
88 #define CAMERA_PARAM_ZOOM_INIT_CAMOB 1.0f
89 #define CAMERA_PARAM_ZOOM_INIT_PERSP 2.0f
90 
94  struct Depsgraph *depsgraph,
95  const struct View3D *v3d,
96  const struct RegionView3D *rv3d);
97 
99  CameraParams *params, int winx, int winy, float aspx, float aspy);
101 
102 /* Camera View Frame */
103 
105  const struct Camera *camera,
106  const float drawsize,
107  const bool do_clip,
108  const float scale[3],
109  float r_asp[2],
110  float r_shift[2],
111  float *r_drawsize,
112  float r_vec[4][3]);
113 void BKE_camera_view_frame(const struct Scene *scene,
114  const struct Camera *camera,
115  float r_vec[4][3]);
116 
118  const struct Scene *scene,
119  struct Object *camera_ob,
120  float r_co[3],
121  float *r_scale);
123  const float (*cos)[3],
124  int num_cos,
125  struct Object *camera_ob,
126  float r_co[3],
127  float *r_scale);
128 
129 /* Camera multi-view API */
130 
132  struct Object *camera,
133  const char *viewname);
135  const struct Object *camera,
136  const bool is_left,
137  float r_viewmat[4][4]);
139  const struct Object *camera,
140  const char *viewname,
141  float r_modelmat[4][4]);
143  const struct Object *camera,
144  const char *viewname,
145  float r_modelmat[4][4]);
147  const struct Object *camera,
148  const char *viewname,
149  float r_winmat[4][4]);
151  const struct Object *camera,
152  const char *viewname);
154  struct CameraParams *params,
155  const struct Object *camera,
156  const char *viewname);
158  const struct Object *camera);
159 
160 /* Camera background image API */
162 void BKE_camera_background_image_remove(struct Camera *cam, struct CameraBGImage *bgpic);
163 void BKE_camera_background_image_clear(struct Camera *cam);
164 
165 #ifdef __cplusplus
166 }
167 #endif
float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y)
Definition: camera.c:242
void BKE_camera_multiview_params(const struct RenderData *rd, struct CameraParams *params, const struct Object *camera, const char *viewname)
void BKE_camera_view_frame_ex(const struct Scene *scene, const struct Camera *camera, const float drawsize, const bool do_clip, const float scale[3], float r_asp[2], float r_shift[2], float *r_drawsize, float r_vec[4][3])
float BKE_camera_multiview_shift_x(const struct RenderData *rd, const struct Object *camera, const char *viewname)
void BKE_camera_background_image_clear(struct Camera *cam)
Definition: camera.c:1153
void BKE_camera_multiview_view_matrix(const struct RenderData *rd, const struct Object *camera, const bool is_left, float r_viewmat[4][4])
struct Object * BKE_camera_multiview_render(const struct Scene *scene, struct Object *camera, const char *viewname)
float BKE_camera_object_dof_distance(struct Object *ob)
Definition: camera.c:227
int BKE_camera_sensor_fit(int sensor_fit, float sizex, float sizey)
Definition: camera.c:252
void BKE_camera_params_init(CameraParams *params)
Definition: camera.c:271
void BKE_camera_params_from_view3d(CameraParams *params, struct Depsgraph *depsgraph, const struct View3D *v3d, const struct RegionView3D *rv3d)
bool BKE_camera_view_frame_fit_to_coords(const struct Depsgraph *depsgraph, const float(*cos)[3], int num_cos, struct Object *camera_ob, float r_co[3], float *r_scale)
bool BKE_camera_view_frame_fit_to_scene(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *camera_ob, float r_co[3], float *r_scale)
void BKE_camera_multiview_model_matrix(const struct RenderData *rd, const struct Object *camera, const char *viewname, float r_modelmat[4][4])
void BKE_camera_multiview_model_matrix_scaled(const struct RenderData *rd, const struct Object *camera, const char *viewname, float r_modelmat[4][4])
void BKE_camera_params_from_object(CameraParams *params, const struct Object *cam_ob)
struct CameraBGImage * BKE_camera_background_image_new(struct Camera *cam)
Definition: camera.c:1131
void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int winy, float aspx, float aspy)
Definition: camera.c:370
bool BKE_camera_multiview_spherical_stereo(const struct RenderData *rd, const struct Object *camera)
void BKE_camera_multiview_window_matrix(const struct RenderData *rd, const struct Object *camera, const char *viewname, float r_winmat[4][4])
void BKE_camera_view_frame(const struct Scene *scene, const struct Camera *camera, float r_vec[4][3])
void * BKE_camera_add(struct Main *bmain, const char *name)
Definition: camera.c:217
void BKE_camera_params_compute_matrix(CameraParams *params)
Definition: camera.c:436
struct CameraParams CameraParams
void BKE_camera_background_image_remove(struct Camera *cam, struct CameraBGImage *bgpic)
Definition: camera.c:1146
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
static float is_left(const float p0[2], const float p1[2], const float p2[2])
Definition: convexhull_2d.c:51
Scene scene
const Depsgraph * depsgraph
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
Definition: rall1d.h:319
int sensor_fit
Definition: BKE_camera.h:71
float viewdy
Definition: BKE_camera.h:80
float ortho_scale
Definition: BKE_camera.h:60
float shifty
Definition: BKE_camera.h:64
float sensor_x
Definition: BKE_camera.h:69
float winmat[4][4]
Definition: BKE_camera.h:84
bool is_ortho
Definition: BKE_camera.h:58
float zoom
Definition: BKE_camera.h:61
float offsetx
Definition: BKE_camera.h:65
float ycor
Definition: BKE_camera.h:78
float offsety
Definition: BKE_camera.h:66
float lens
Definition: BKE_camera.h:59
float clip_start
Definition: BKE_camera.h:74
float clip_end
Definition: BKE_camera.h:75
float viewdx
Definition: BKE_camera.h:79
rctf viewplane
Definition: BKE_camera.h:81
float sensor_y
Definition: BKE_camera.h:70
float shiftx
Definition: BKE_camera.h:63
Definition: BKE_main.h:116