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
|
|
|
#ifndef __BKE_CAMERA_H__
|
|
|
|
#define __BKE_CAMERA_H__
|
2011-11-05 13:00:39 +00:00
|
|
|
|
2019-02-06 15:42:22 +11:00
|
|
|
/** \file \ingroup bke
|
2011-11-05 13:00:39 +00:00
|
|
|
* \brief Camera datablock and utility functions.
|
|
|
|
*/
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2011-11-18 15:52:00 +00:00
|
|
|
#include "DNA_vec_types.h"
|
|
|
|
|
2011-11-05 13:00:39 +00:00
|
|
|
struct Camera;
|
2018-01-18 15:58:02 +01:00
|
|
|
struct Depsgraph;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct GPUFXSettings;
|
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;
|
2017-11-22 10:52:39 -02:00
|
|
|
struct ViewLayer;
|
2011-11-05 13:00:39 +00:00
|
|
|
struct rctf;
|
|
|
|
|
2011-11-18 21:19:03 +00:00
|
|
|
/* Camera Datablock */
|
|
|
|
|
First step to handle missing libs/datablocks when reading a file.
Idea is, instead of ignoring completely missing linked datablocks, to
create void placeholders for them.
That way, you can work on your file, save it, and find again your missing data once
lib becomes available again. Or you can edit missing lib's path (in Outliner),
save and reload the file, and you are done.
Also, Outliner now shows broken libraries (and placeholders) with a 'broken lib' icon.
Future plans are also to be able to relocate missing libs and reload them at runtime.
Code notes:
- Placeholder ID is just a regular datablock of same type as expected linked one,
with 'default' data, and a LIB_MISSING bitflag set.
- To allow creation of such datablocks, creation of datablocks in BKE was split in two step:
+ Allocation of memory itself.
+ Setting of all internal data to default values.
See also the design task (T43351).
Reviewed by @campbellbarton, thanks a bunch!
Differential Revision: https://developer.blender.org/D1394
2015-10-20 14:44:57 +02:00
|
|
|
void BKE_camera_init(struct Camera *cam);
|
2013-02-05 12:46:15 +00:00
|
|
|
void *BKE_camera_add(struct Main *bmain, const char *name);
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
void BKE_camera_copy_data(struct Main *bmain, struct Camera *cam_dst, const struct Camera *cam_src, const int flag);
|
2017-06-14 22:36:30 +02:00
|
|
|
struct Camera *BKE_camera_copy(struct Main *bmain, const struct Camera *cam);
|
2016-07-20 19:49:45 +02:00
|
|
|
void BKE_camera_make_local(struct Main *bmain, struct Camera *cam, const bool lib_local);
|
2012-05-05 00:58:22 +00:00
|
|
|
void BKE_camera_free(struct Camera *ca);
|
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;
|
2011-11-18 15:52:00 +00:00
|
|
|
|
|
|
|
float shiftx;
|
|
|
|
float shifty;
|
2011-11-18 21:19:03 +00:00
|
|
|
float offsetx;
|
|
|
|
float offsety;
|
2011-11-18 15:52:00 +00:00
|
|
|
|
|
|
|
/* sensor */
|
|
|
|
float sensor_x;
|
|
|
|
float sensor_y;
|
|
|
|
int sensor_fit;
|
|
|
|
|
|
|
|
/* clipping */
|
2019-02-16 12:21:44 +11:00
|
|
|
float clip_start;
|
|
|
|
float clip_end;
|
2011-11-18 15:52:00 +00: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;
|
|
|
|
|
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);
|
2015-03-21 22:34:20 +11:00
|
|
|
void BKE_camera_params_from_object(CameraParams *params, const struct Object *camera);
|
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]);
|
|
|
|
|
|
|
|
bool BKE_camera_view_frame_fit_to_scene(
|
2018-04-06 12:07:27 +02:00
|
|
|
struct Depsgraph *depsgraph,
|
2018-06-22 07:54:55 +02:00
|
|
|
struct Scene *scene, 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(
|
2018-05-25 11:05:51 +02:00
|
|
|
const struct Depsgraph *depsgraph,
|
2015-03-21 22:34:20 +11:00
|
|
|
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-02-12 18:54:41 +01:00
|
|
|
void BKE_camera_to_gpu_dof(struct Object *camera, struct GPUFXSettings *r_fx_settings);
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* Camera multi-view API */
|
|
|
|
|
|
|
|
struct Object *BKE_camera_multiview_render(struct Scene *scene, struct Object *camera, const char *viewname);
|
2018-05-25 11:05:51 +02:00
|
|
|
void BKE_camera_multiview_view_matrix(struct RenderData *rd, const struct Object *camera, const bool is_left, float r_viewmat[4][4]);
|
|
|
|
void BKE_camera_multiview_model_matrix(struct RenderData *rd, const struct Object *camera, const char *viewname, float r_modelmat[4][4]);
|
2019-01-11 18:58:09 -02:00
|
|
|
void BKE_camera_multiview_model_matrix_scaled(struct RenderData *rd, const struct Object *camera, const char *viewname, float r_modelmat[4][4]);
|
2019-01-11 13:38:18 -02:00
|
|
|
void BKE_camera_multiview_window_matrix(struct RenderData *rd, const struct Object *camera, const char *viewname, float r_winmat[4][4]);
|
2018-05-25 11:05:51 +02:00
|
|
|
float BKE_camera_multiview_shift_x(struct RenderData *rd, const struct Object *camera, const char *viewname);
|
|
|
|
void BKE_camera_multiview_params(struct RenderData *rd, struct CameraParams *params, const struct Object *camera, const char *viewname);
|
|
|
|
bool BKE_camera_multiview_spherical_stereo(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
|
|
|
|
|
|
|
|
#endif
|