2011-11-05 13:00:39 +00:00
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#pragma once
|
2011-11-05 13:00:39 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup bke
|
2020-05-28 16:42:31 +10:00
|
|
|
* \brief Camera data-block and utility functions.
|
2011-11-05 13:00:39 +00:00
|
|
|
*/
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct Camera;
|
2018-01-18 15:58:02 +01:00
|
|
|
struct Depsgraph;
|
2013-02-05 12:46:15 +00:00
|
|
|
struct Main;
|
2011-11-05 13:00:39 +00:00
|
|
|
struct Object;
|
2011-11-18 21:19:03 +00:00
|
|
|
struct RegionView3D;
|
2011-11-05 13:00:39 +00:00
|
|
|
struct RenderData;
|
|
|
|
struct Scene;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct View3D;
|
2011-11-05 13:00:39 +00:00
|
|
|
struct rctf;
|
|
|
|
|
2011-11-18 21:19:03 +00:00
|
|
|
/* Camera Datablock */
|
|
|
|
|
2013-02-05 12:46:15 +00:00
|
|
|
void *BKE_camera_add(struct Main *bmain, const char *name);
|
2011-11-05 13:00:39 +00:00
|
|
|
|
2011-11-18 21:19:03 +00:00
|
|
|
/* Camera Usage */
|
2011-11-18 15:52:00 +00:00
|
|
|
|
2012-05-05 00:58:22 +00:00
|
|
|
float BKE_camera_object_dof_distance(struct Object *ob);
|
2011-11-18 15:52:00 +00:00
|
|
|
|
2012-05-05 00:58:22 +00:00
|
|
|
int BKE_camera_sensor_fit(int sensor_fit, float sizex, float sizey);
|
|
|
|
float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y);
|
2011-11-18 21:19:03 +00:00
|
|
|
|
2011-11-18 15:52:00 +00:00
|
|
|
/* Camera Parameters:
|
|
|
|
*
|
|
|
|
* Intermediate struct for storing camera parameters from various sources,
|
|
|
|
* to unify computation of viewplane, window matrix, ... */
|
|
|
|
|
|
|
|
typedef struct CameraParams {
|
|
|
|
/* lens */
|
2014-04-01 11:34:00 +11:00
|
|
|
bool is_ortho;
|
2011-11-18 15:52:00 +00:00
|
|
|
float lens;
|
|
|
|
float ortho_scale;
|
2011-11-18 21:19:03 +00:00
|
|
|
float zoom;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-18 15:52:00 +00:00
|
|
|
float shiftx;
|
|
|
|
float shifty;
|
2011-11-18 21:19:03 +00:00
|
|
|
float offsetx;
|
|
|
|
float offsety;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-18 15:52:00 +00:00
|
|
|
/* sensor */
|
|
|
|
float sensor_x;
|
|
|
|
float sensor_y;
|
|
|
|
int sensor_fit;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-18 15:52:00 +00:00
|
|
|
/* clipping */
|
2019-02-16 12:21:44 +11:00
|
|
|
float clip_start;
|
|
|
|
float clip_end;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-19 18:35:42 +00:00
|
|
|
/* computed viewplane */
|
2011-11-18 15:52:00 +00:00
|
|
|
float ycor;
|
|
|
|
float viewdx;
|
|
|
|
float viewdy;
|
|
|
|
rctf viewplane;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-19 18:35:42 +00:00
|
|
|
/* computed matrix */
|
2011-11-18 15:52:00 +00:00
|
|
|
float winmat[4][4];
|
|
|
|
} CameraParams;
|
|
|
|
|
2015-03-21 15:11:19 +11:00
|
|
|
/* values for CameraParams.zoom, need to be taken into account for some operations */
|
|
|
|
#define CAMERA_PARAM_ZOOM_INIT_CAMOB 1.0f
|
|
|
|
#define CAMERA_PARAM_ZOOM_INIT_PERSP 2.0f
|
|
|
|
|
2012-05-05 00:58:22 +00:00
|
|
|
void BKE_camera_params_init(CameraParams *params);
|
2020-09-04 20:59:13 +02:00
|
|
|
void BKE_camera_params_from_object(CameraParams *params, const struct Object *cam_ob);
|
2018-04-06 12:07:27 +02:00
|
|
|
void BKE_camera_params_from_view3d(CameraParams *params,
|
|
|
|
struct Depsgraph *depsgraph,
|
|
|
|
const struct View3D *v3d,
|
|
|
|
const struct RegionView3D *rv3d);
|
2011-11-19 18:35:42 +00:00
|
|
|
|
2012-05-05 00:58:22 +00:00
|
|
|
void BKE_camera_params_compute_viewplane(
|
|
|
|
CameraParams *params, int winx, int winy, float aspx, float aspy);
|
|
|
|
void BKE_camera_params_compute_matrix(CameraParams *params);
|
2011-11-05 13:00:39 +00:00
|
|
|
|
2011-11-18 15:52:00 +00:00
|
|
|
/* Camera View Frame */
|
2011-11-05 13:00:39 +00:00
|
|
|
|
2015-03-21 22:34:20 +11:00
|
|
|
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]);
|
|
|
|
void BKE_camera_view_frame(const struct Scene *scene,
|
|
|
|
const struct Camera *camera,
|
|
|
|
float r_vec[4][3]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-03-21 22:34:20 +11:00
|
|
|
bool BKE_camera_view_frame_fit_to_scene(struct Depsgraph *depsgraph,
|
2020-03-13 17:27:11 +11:00
|
|
|
const struct Scene *scene,
|
2018-06-22 07:54:55 +02:00
|
|
|
struct Object *camera_ob,
|
2015-03-21 22:34:20 +11:00
|
|
|
float r_co[3],
|
|
|
|
float *r_scale);
|
|
|
|
bool BKE_camera_view_frame_fit_to_coords(const struct Depsgraph *depsgraph,
|
|
|
|
const float (*cos)[3],
|
|
|
|
int num_cos,
|
2018-05-25 11:05:51 +02:00
|
|
|
struct Object *camera_ob,
|
2015-03-21 22:34:20 +11:00
|
|
|
float r_co[3],
|
|
|
|
float *r_scale);
|
2011-11-14 03:54:23 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* Camera multi-view API */
|
|
|
|
|
2020-03-13 17:27:11 +11:00
|
|
|
struct Object *BKE_camera_multiview_render(const struct Scene *scene,
|
2015-04-06 10:40:12 -03:00
|
|
|
struct Object *camera,
|
|
|
|
const char *viewname);
|
2020-03-13 17:27:11 +11:00
|
|
|
void BKE_camera_multiview_view_matrix(const struct RenderData *rd,
|
2018-05-25 11:05:51 +02:00
|
|
|
const struct Object *camera,
|
|
|
|
const bool is_left,
|
|
|
|
float r_viewmat[4][4]);
|
2020-03-13 17:27:11 +11:00
|
|
|
void BKE_camera_multiview_model_matrix(const struct RenderData *rd,
|
2018-05-25 11:05:51 +02:00
|
|
|
const struct Object *camera,
|
|
|
|
const char *viewname,
|
2019-01-11 18:58:09 -02:00
|
|
|
float r_modelmat[4][4]);
|
2020-03-13 17:27:11 +11:00
|
|
|
void BKE_camera_multiview_model_matrix_scaled(const struct RenderData *rd,
|
2019-01-11 18:58:09 -02:00
|
|
|
const struct Object *camera,
|
2019-01-11 13:38:18 -02:00
|
|
|
const char *viewname,
|
|
|
|
float r_modelmat[4][4]);
|
2020-03-13 17:27:11 +11:00
|
|
|
void BKE_camera_multiview_window_matrix(const struct RenderData *rd,
|
2019-01-11 13:38:18 -02:00
|
|
|
const struct Object *camera,
|
2018-05-25 11:05:51 +02:00
|
|
|
const char *viewname,
|
|
|
|
float r_winmat[4][4]);
|
2020-03-13 17:27:11 +11:00
|
|
|
float BKE_camera_multiview_shift_x(const struct RenderData *rd,
|
2018-05-25 11:05:51 +02:00
|
|
|
const struct Object *camera,
|
|
|
|
const char *viewname);
|
2020-03-13 17:27:11 +11:00
|
|
|
void BKE_camera_multiview_params(const struct RenderData *rd,
|
2018-05-25 11:05:51 +02:00
|
|
|
struct CameraParams *params,
|
2015-03-21 22:34:20 +11:00
|
|
|
const struct Object *camera,
|
2019-01-11 18:58:09 -02:00
|
|
|
const char *viewname);
|
2020-03-13 17:27:11 +11:00
|
|
|
bool BKE_camera_multiview_spherical_stereo(const struct RenderData *rd,
|
|
|
|
const struct Object *camera);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2017-10-26 21:40:37 +11:00
|
|
|
/* Camera background image API */
|
|
|
|
struct CameraBGImage *BKE_camera_background_image_new(struct Camera *cam);
|
|
|
|
void BKE_camera_background_image_remove(struct Camera *cam, struct CameraBGImage *bgpic);
|
|
|
|
void BKE_camera_background_image_clear(struct Camera *cam);
|
|
|
|
|
2011-11-05 13:00:39 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|