BKE_camera.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * ***** BEGIN GPL LICENSE BLOCK *****
  3. *
  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.
  8. *
  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.
  13. *
  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.
  17. *
  18. * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
  19. * All rights reserved.
  20. *
  21. * The Original Code is: all of this file.
  22. *
  23. * Contributor(s): none yet.
  24. *
  25. * ***** END GPL LICENSE BLOCK *****
  26. */
  27. #ifndef __BKE_CAMERA_H__
  28. #define __BKE_CAMERA_H__
  29. /** \file BKE_camera.h
  30. * \ingroup bke
  31. * \brief Camera datablock and utility functions.
  32. */
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. #include "DNA_vec_types.h"
  37. struct Camera;
  38. struct Main;
  39. struct Object;
  40. struct RegionView3D;
  41. struct RenderData;
  42. struct Scene;
  43. struct rctf;
  44. struct View3D;
  45. struct GPUFXSettings;
  46. /* Camera Datablock */
  47. void BKE_camera_init(struct Camera *cam);
  48. void *BKE_camera_add(struct Main *bmain, const char *name);
  49. struct Camera *BKE_camera_copy(struct Main *bmain, const struct Camera *cam);
  50. void BKE_camera_make_local(struct Main *bmain, struct Camera *cam, const bool lib_local);
  51. void BKE_camera_free(struct Camera *ca);
  52. /* Camera Usage */
  53. float BKE_camera_object_dof_distance(struct Object *ob);
  54. void BKE_camera_object_mode(struct RenderData *rd, struct Object *ob);
  55. int BKE_camera_sensor_fit(int sensor_fit, float sizex, float sizey);
  56. float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y);
  57. /* Camera Parameters:
  58. *
  59. * Intermediate struct for storing camera parameters from various sources,
  60. * to unify computation of viewplane, window matrix, ... */
  61. typedef struct CameraParams {
  62. /* lens */
  63. bool is_ortho;
  64. float lens;
  65. float ortho_scale;
  66. float zoom;
  67. float shiftx;
  68. float shifty;
  69. float offsetx;
  70. float offsety;
  71. /* sensor */
  72. float sensor_x;
  73. float sensor_y;
  74. int sensor_fit;
  75. /* clipping */
  76. float clipsta;
  77. float clipend;
  78. /* fields */
  79. int use_fields;
  80. int field_second;
  81. int field_odd;
  82. /* computed viewplane */
  83. float ycor;
  84. float viewdx;
  85. float viewdy;
  86. rctf viewplane;
  87. /* computed matrix */
  88. float winmat[4][4];
  89. } CameraParams;
  90. /* values for CameraParams.zoom, need to be taken into account for some operations */
  91. #define CAMERA_PARAM_ZOOM_INIT_CAMOB 1.0f
  92. #define CAMERA_PARAM_ZOOM_INIT_PERSP 2.0f
  93. void BKE_camera_params_init(CameraParams *params);
  94. void BKE_camera_params_from_object(CameraParams *params, const struct Object *camera);
  95. void BKE_camera_params_from_view3d(CameraParams *params, const struct View3D *v3d, const struct RegionView3D *rv3d);
  96. void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int winy, float aspx, float aspy);
  97. void BKE_camera_params_compute_matrix(CameraParams *params);
  98. /* Camera View Frame */
  99. void BKE_camera_view_frame_ex(
  100. const struct Scene *scene, const struct Camera *camera,
  101. const float drawsize, const bool do_clip, const float scale[3],
  102. float r_asp[2], float r_shift[2], float *r_drawsize, float r_vec[4][3]);
  103. void BKE_camera_view_frame(
  104. const struct Scene *scene, const struct Camera *camera,
  105. float r_vec[4][3]);
  106. bool BKE_camera_view_frame_fit_to_scene(
  107. struct Scene *scene, struct View3D *v3d, struct Object *camera_ob,
  108. float r_co[3], float *r_scale);
  109. bool BKE_camera_view_frame_fit_to_coords(
  110. const struct Scene *scene,
  111. const float (*cos)[3], int num_cos,
  112. const struct Object *camera_ob,
  113. float r_co[3], float *r_scale);
  114. void BKE_camera_to_gpu_dof(struct Object *camera, struct GPUFXSettings *r_fx_settings);
  115. /* Camera multi-view API */
  116. struct Object *BKE_camera_multiview_render(struct Scene *scene, struct Object *camera, const char *viewname);
  117. void BKE_camera_multiview_view_matrix(struct RenderData *rd, struct Object *camera, const bool is_left, float r_viewmat[4][4]);
  118. void BKE_camera_multiview_model_matrix(struct RenderData *rd, struct Object *camera, const char *viewname, float r_modelmat[4][4]);
  119. float BKE_camera_multiview_shift_x(struct RenderData *rd, struct Object *camera, const char *viewname);
  120. void BKE_camera_multiview_params(struct RenderData *rd, struct CameraParams *params, struct Object *camera, const char *viewname);
  121. bool BKE_camera_multiview_spherical_stereo(struct RenderData *rd, struct Object *camera);
  122. #ifdef __cplusplus
  123. }
  124. #endif
  125. #endif