2011-11-05 13:00:39 +00:00
|
|
|
/*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#ifndef __BKE_CAMERA_H__
|
|
|
|
#define __BKE_CAMERA_H__
|
2011-11-05 13:00:39 +00:00
|
|
|
|
|
|
|
/** \file BKE_camera.h
|
|
|
|
* \ingroup bke
|
|
|
|
* \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;
|
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;
|
2017-11-22 10:52:39 -02:00
|
|
|
struct ViewLayer;
|
2011-11-05 13:00:39 +00:00
|
|
|
struct rctf;
|
2011-11-14 03:54:23 +00:00
|
|
|
struct View3D;
|
2015-02-12 18:54:41 +01:00
|
|
|
struct GPUFXSettings;
|
2011-11-05 13:00:39 +00:00
|
|
|
|
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);
|
|
|
|
void BKE_camera_object_mode(struct RenderData *rd, 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 */
|
|
|
|
float clipsta;
|
|
|
|
float clipend;
|
|
|
|
|
|
|
|
/* fields */
|
|
|
|
int use_fields;
|
|
|
|
int field_second;
|
|
|
|
int field_odd;
|
|
|
|
|
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-01-18 15:58:02 +01:00
|
|
|
void BKE_camera_params_from_view3d(CameraParams *params, const 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(
|
2017-11-23 13:51:49 -02:00
|
|
|
struct Scene *scene, struct ViewLayer *view_layer, 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 Scene *scene,
|
|
|
|
const float (*cos)[3], int num_cos,
|
|
|
|
const struct Object *camera_ob,
|
|
|
|
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);
|
|
|
|
void BKE_camera_multiview_view_matrix(struct RenderData *rd, struct Object *camera, const bool is_left, float r_viewmat[4][4]);
|
|
|
|
void BKE_camera_multiview_model_matrix(struct RenderData *rd, struct Object *camera, const char *viewname, float r_modelmat[4][4]);
|
|
|
|
float BKE_camera_multiview_shift_x(struct RenderData *rd, struct Object *camera, const char *viewname);
|
|
|
|
void BKE_camera_multiview_params(struct RenderData *rd, struct CameraParams *params, struct Object *camera, const char *viewname);
|
Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices
The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)
Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).
* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER
* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)
* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).
* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.
* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.
* We have no support for interocular distance attenuation based on the proximity of the poles (which helps to reduce the pole rotation effect/artifact).
THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451
This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.
All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332
Reviewers: sergey, dingto
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1223
2016-03-10 09:28:29 -03:00
|
|
|
bool BKE_camera_multiview_spherical_stereo(struct RenderData *rd, 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
|
|
|
|
|