Blender  V2.93
rna_camera.c
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 
21 #include <stdlib.h>
22 
23 #include "DNA_camera_types.h"
24 
25 #include "BLI_math.h"
26 
27 #include "RNA_access.h"
28 #include "RNA_define.h"
29 
30 #include "rna_internal.h"
31 
32 #include "WM_api.h"
33 #include "WM_types.h"
34 
35 #ifdef RNA_RUNTIME
36 
37 # include "BKE_camera.h"
38 # include "BKE_object.h"
39 
40 # include "DEG_depsgraph.h"
41 # include "DEG_depsgraph_build.h"
42 
43 # include "SEQ_relations.h"
44 
45 static float rna_Camera_angle_get(PointerRNA *ptr)
46 {
47  Camera *cam = (Camera *)ptr->owner_id;
48  float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y);
49  return focallength_to_fov(cam->lens, sensor);
50 }
51 
52 static void rna_Camera_angle_set(PointerRNA *ptr, float value)
53 {
54  Camera *cam = (Camera *)ptr->owner_id;
55  float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y);
56  cam->lens = fov_to_focallength(value, sensor);
57 }
58 
59 static float rna_Camera_angle_x_get(PointerRNA *ptr)
60 {
61  Camera *cam = (Camera *)ptr->owner_id;
62  return focallength_to_fov(cam->lens, cam->sensor_x);
63 }
64 
65 static void rna_Camera_angle_x_set(PointerRNA *ptr, float value)
66 {
67  Camera *cam = (Camera *)ptr->owner_id;
68  cam->lens = fov_to_focallength(value, cam->sensor_x);
69 }
70 
71 static float rna_Camera_angle_y_get(PointerRNA *ptr)
72 {
73  Camera *cam = (Camera *)ptr->owner_id;
74  return focallength_to_fov(cam->lens, cam->sensor_y);
75 }
76 
77 static void rna_Camera_angle_y_set(PointerRNA *ptr, float value)
78 {
79  Camera *cam = (Camera *)ptr->owner_id;
80  cam->lens = fov_to_focallength(value, cam->sensor_y);
81 }
82 
83 static void rna_Camera_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
84 {
85  Camera *camera = (Camera *)ptr->owner_id;
86 
87  DEG_id_tag_update(&camera->id, 0);
88 }
89 
90 static void rna_Camera_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
91 {
92  Camera *camera = (Camera *)ptr->owner_id;
94  DEG_id_tag_update(&camera->id, 0);
95 }
96 
97 static CameraBGImage *rna_Camera_background_images_new(Camera *cam)
98 {
100 
102 
103  return bgpic;
104 }
105 
106 static void rna_Camera_background_images_remove(Camera *cam,
107  ReportList *reports,
108  PointerRNA *bgpic_ptr)
109 {
110  CameraBGImage *bgpic = bgpic_ptr->data;
111  if (BLI_findindex(&cam->bg_images, bgpic) == -1) {
112  BKE_report(reports, RPT_ERROR, "Background image cannot be removed");
113  }
114 
116  RNA_POINTER_INVALIDATE(bgpic_ptr);
117 
119 }
120 
121 static void rna_Camera_background_images_clear(Camera *cam)
122 {
124 
126 }
127 
128 static void rna_Camera_dof_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr))
129 {
132 }
133 
134 char *rna_CameraDOFSettings_path(PointerRNA *ptr)
135 {
136  /* if there is ID-data, resolve the path using the index instead of by name,
137  * since the name used is the name of the texture assigned, but the texture
138  * may be used multiple times in the same stack
139  */
140  if (ptr->owner_id) {
141  if (GS(ptr->owner_id->name) == ID_CA) {
142  return BLI_strdup("dof");
143  }
144  }
145 
146  return BLI_strdup("");
147 }
148 
149 static void rna_CameraDOFSettings_aperture_blades_set(PointerRNA *ptr, const int value)
150 {
151  CameraDOFSettings *dofsettings = (CameraDOFSettings *)ptr->data;
152 
153  if (value == 1 || value == 2) {
154  if (dofsettings->aperture_blades == 0) {
155  dofsettings->aperture_blades = 3;
156  }
157  else {
158  dofsettings->aperture_blades = 0;
159  }
160  }
161  else {
162  dofsettings->aperture_blades = value;
163  }
164 }
165 
166 #else
167 
169 {
170  StructRNA *srna;
171  PropertyRNA *prop;
172 
173  static const EnumPropertyItem bgpic_source_items[] = {
174  {CAM_BGIMG_SOURCE_IMAGE, "IMAGE", 0, "Image", ""},
175  {CAM_BGIMG_SOURCE_MOVIE, "MOVIE_CLIP", 0, "Movie Clip", ""},
176  {0, NULL, 0, NULL, NULL},
177  };
178 
179  static const EnumPropertyItem bgpic_camera_frame_items[] = {
180  {0, "STRETCH", 0, "Stretch", ""},
181  {CAM_BGIMG_FLAG_CAMERA_ASPECT, "FIT", 0, "Fit", ""},
182  {CAM_BGIMG_FLAG_CAMERA_ASPECT | CAM_BGIMG_FLAG_CAMERA_CROP, "CROP", 0, "Crop", ""},
183  {0, NULL, 0, NULL, NULL},
184  };
185 
186  static const EnumPropertyItem bgpic_display_depth_items[] = {
187  {0, "BACK", 0, "Back", ""},
188  {CAM_BGIMG_FLAG_FOREGROUND, "FRONT", 0, "Front", ""},
189  {0, NULL, 0, NULL, NULL},
190  };
191 
192  srna = RNA_def_struct(brna, "CameraBackgroundImage", NULL);
193  RNA_def_struct_sdna(srna, "CameraBGImage");
195  srna, "Background Image", "Image and settings for display in the 3D View background");
196 
198 
199  prop = RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE);
200  RNA_def_property_enum_sdna(prop, NULL, "source");
201  RNA_def_property_enum_items(prop, bgpic_source_items);
202  RNA_def_property_ui_text(prop, "Background Source", "Data source used for background");
204 
205  prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
206  RNA_def_property_pointer_sdna(prop, NULL, "ima");
207  RNA_def_property_ui_text(prop, "Image", "Image displayed and edited in this space");
211 
212  prop = RNA_def_property(srna, "clip", PROP_POINTER, PROP_NONE);
213  RNA_def_property_pointer_sdna(prop, NULL, "clip");
214  RNA_def_property_ui_text(prop, "MovieClip", "Movie clip displayed and edited in this space");
218 
219  prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NONE);
221  RNA_def_property_pointer_sdna(prop, NULL, "iuser");
223  prop,
224  "Image User",
225  "Parameters defining which layer, pass and frame of the image is displayed");
227 
228  prop = RNA_def_property(srna, "clip_user", PROP_POINTER, PROP_NONE);
230  RNA_def_property_struct_type(prop, "MovieClipUser");
231  RNA_def_property_pointer_sdna(prop, NULL, "cuser");
233  prop, "Clip User", "Parameters defining which frame of the movie clip is displayed");
235 
236  prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_XYZ);
237  RNA_def_property_float_sdna(prop, NULL, "offset");
238  RNA_def_property_ui_text(prop, "Offset", "");
239  RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1, RNA_TRANSLATION_PREC_DEFAULT);
241 
242  prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
243  RNA_def_property_float_sdna(prop, NULL, "scale");
244  RNA_def_property_ui_text(prop, "Scale", "Scale the background image");
245  RNA_def_property_range(prop, 0.0, FLT_MAX);
248 
249  prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ANGLE);
250  RNA_def_property_float_sdna(prop, NULL, "rotation");
252  prop, "Rotation", "Rotation for the background image (ortho view only)");
254 
255  prop = RNA_def_property(srna, "use_flip_x", PROP_BOOLEAN, PROP_NONE);
257  RNA_def_property_ui_text(prop, "Flip Horizontally", "Flip the background image horizontally");
259 
260  prop = RNA_def_property(srna, "use_flip_y", PROP_BOOLEAN, PROP_NONE);
262  RNA_def_property_ui_text(prop, "Flip Vertically", "Flip the background image vertically");
264 
265  prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE);
266  RNA_def_property_float_sdna(prop, NULL, "alpha");
268  prop, "Opacity", "Image opacity to blend the image against the background color");
269  RNA_def_property_range(prop, 0.0, 1.0);
271 
272  prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
275  RNA_def_property_ui_text(prop, "Show Expanded", "Show the expanded in the user interface");
276  RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1);
277 
278  prop = RNA_def_property(srna, "use_camera_clip", PROP_BOOLEAN, PROP_NONE);
280  RNA_def_property_ui_text(prop, "Camera Clip", "Use movie clip from active scene camera");
282 
283  prop = RNA_def_property(srna, "show_background_image", PROP_BOOLEAN, PROP_NONE);
285  RNA_def_property_ui_text(prop, "Show Background Image", "Show this image as background");
287 
288  prop = RNA_def_property(srna, "show_on_foreground", PROP_BOOLEAN, PROP_NONE);
291  prop, "Show On Foreground", "Show this image in front of objects in viewport");
293 
294  /* expose 1 flag as a enum of 2 items */
295  prop = RNA_def_property(srna, "display_depth", PROP_ENUM, PROP_NONE);
297  RNA_def_property_enum_items(prop, bgpic_display_depth_items);
298  RNA_def_property_ui_text(prop, "Depth", "Display under or over everything");
300 
301  /* expose 2 flags as a enum of 3 items */
302  prop = RNA_def_property(srna, "frame_method", PROP_ENUM, PROP_NONE);
304  RNA_def_property_enum_items(prop, bgpic_camera_frame_items);
305  RNA_def_property_ui_text(prop, "Frame Method", "How the image fits in the camera frame");
307 
309 }
310 
312 {
313  StructRNA *srna;
314  FunctionRNA *func;
315  PropertyRNA *parm;
316 
317  RNA_def_property_srna(cprop, "CameraBackgroundImages");
318  srna = RNA_def_struct(brna, "CameraBackgroundImages", NULL);
319  RNA_def_struct_sdna(srna, "Camera");
320  RNA_def_struct_ui_text(srna, "Background Images", "Collection of background images");
321 
322  func = RNA_def_function(srna, "new", "rna_Camera_background_images_new");
323  RNA_def_function_ui_description(func, "Add new background image");
324  parm = RNA_def_pointer(
325  func, "image", "CameraBackgroundImage", "", "Image displayed as viewport background");
326  RNA_def_function_return(func, parm);
327 
328  func = RNA_def_function(srna, "remove", "rna_Camera_background_images_remove");
329  RNA_def_function_ui_description(func, "Remove background image");
331  parm = RNA_def_pointer(
332  func, "image", "CameraBackgroundImage", "", "Image displayed as viewport background");
335 
336  func = RNA_def_function(srna, "clear", "rna_Camera_background_images_clear");
337  RNA_def_function_ui_description(func, "Remove all background images");
338 }
339 
341 {
342  StructRNA *srna;
343  PropertyRNA *prop;
344 
345  static const EnumPropertyItem convergence_mode_items[] = {
346  {CAM_S3D_OFFAXIS, "OFFAXIS", 0, "Off-Axis", "Off-axis frustums converging in a plane"},
347  {CAM_S3D_PARALLEL, "PARALLEL", 0, "Parallel", "Parallel cameras with no convergence"},
348  {CAM_S3D_TOE, "TOE", 0, "Toe-in", "Rotated cameras, looking at the convergence distance"},
349  {0, NULL, 0, NULL, NULL},
350  };
351 
352  static const EnumPropertyItem pivot_items[] = {
353  {CAM_S3D_PIVOT_LEFT, "LEFT", 0, "Left", ""},
354  {CAM_S3D_PIVOT_RIGHT, "RIGHT", 0, "Right", ""},
355  {CAM_S3D_PIVOT_CENTER, "CENTER", 0, "Center", ""},
356  {0, NULL, 0, NULL, NULL},
357  };
358 
359  srna = RNA_def_struct(brna, "CameraStereoData", NULL);
360  RNA_def_struct_sdna(srna, "CameraStereoSettings");
361  RNA_def_struct_nested(brna, srna, "Camera");
362  RNA_def_struct_ui_text(srna, "Stereo", "Stereoscopy settings for a Camera data-block");
363 
365 
366  prop = RNA_def_property(srna, "convergence_mode", PROP_ENUM, PROP_NONE);
367  RNA_def_property_enum_items(prop, convergence_mode_items);
368  RNA_def_property_ui_text(prop, "Mode", "");
370 
371  prop = RNA_def_property(srna, "pivot", PROP_ENUM, PROP_NONE);
372  RNA_def_property_enum_items(prop, pivot_items);
373  RNA_def_property_ui_text(prop, "Pivot", "");
375 
376  prop = RNA_def_property(srna, "interocular_distance", PROP_FLOAT, PROP_DISTANCE);
377  RNA_def_property_range(prop, 0.0f, FLT_MAX);
378  RNA_def_property_ui_range(prop, 0.0f, 1e4f, 1, 3);
380  prop,
381  "Interocular Distance",
382  "Set the distance between the eyes - the stereo plane distance / 30 should be fine");
384 
385  prop = RNA_def_property(srna, "convergence_distance", PROP_FLOAT, PROP_DISTANCE);
386  RNA_def_property_range(prop, 0.00001f, FLT_MAX);
387  RNA_def_property_ui_range(prop, 0.00001f, 15.0f, 1, 3);
389  "Convergence Plane Distance",
390  "The converge point for the stereo cameras "
391  "(often the distance between a projector and the projection screen)");
393 
394  prop = RNA_def_property(srna, "use_spherical_stereo", PROP_BOOLEAN, PROP_NONE);
397  "Spherical Stereo",
398  "Render every pixel rotating the camera around the "
399  "middle of the interocular distance");
401 
402  prop = RNA_def_property(srna, "use_pole_merge", PROP_BOOLEAN, PROP_NONE);
405  prop, "Use Pole Merge", "Fade interocular distance to 0 after the given cutoff angle");
407 
408  prop = RNA_def_property(srna, "pole_merge_angle_from", PROP_FLOAT, PROP_ANGLE);
409  RNA_def_property_range(prop, 0.0f, M_PI / 2.0);
411  prop, "Pole Merge Start Angle", "Angle at which interocular distance starts to fade to 0");
413 
414  prop = RNA_def_property(srna, "pole_merge_angle_to", PROP_FLOAT, PROP_ANGLE);
415  RNA_def_property_range(prop, 0.0f, M_PI / 2.0);
417  prop, "Pole Merge End Angle", "Angle at which interocular distance is 0");
419 
421 }
422 
424 {
425  StructRNA *srna;
426  PropertyRNA *prop;
427 
428  srna = RNA_def_struct(brna, "CameraDOFSettings", NULL);
429  RNA_def_struct_sdna(srna, "CameraDOFSettings");
430  RNA_def_struct_path_func(srna, "rna_CameraDOFSettings_path");
431  RNA_def_struct_ui_text(srna, "Depth of Field", "Depth of Field settings");
432 
434 
435  prop = RNA_def_property(srna, "use_dof", PROP_BOOLEAN, PROP_NONE);
437  RNA_def_property_ui_text(prop, "Depth of Field", "Use Depth of Field");
438  RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update");
439 
440  prop = RNA_def_property(srna, "focus_object", PROP_POINTER, PROP_NONE);
441  RNA_def_property_struct_type(prop, "Object");
442  RNA_def_property_pointer_sdna(prop, NULL, "focus_object");
446  prop, "Focus Object", "Use this object to define the depth of field focal point");
447  RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dependency_update");
448 
449  prop = RNA_def_property(srna, "focus_distance", PROP_FLOAT, PROP_DISTANCE);
450  // RNA_def_property_pointer_sdna(prop, NULL, "focus_distance");
451  RNA_def_property_range(prop, 0.0f, FLT_MAX);
452  RNA_def_property_ui_range(prop, 0.0f, 5000.0f, 1, 2);
454  prop, "Focus Distance", "Distance to the focus point for depth of field");
455  RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update");
456 
457  prop = RNA_def_property(srna, "aperture_fstop", PROP_FLOAT, PROP_NONE);
459  prop,
460  "F-Stop",
461  "F-Stop ratio (lower numbers give more defocus, higher numbers give a sharper image)");
462  RNA_def_property_range(prop, 0.0f, FLT_MAX);
463  RNA_def_property_ui_range(prop, 0.1f, 128.0f, 10, 1);
464  RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update");
465 
466  prop = RNA_def_property(srna, "aperture_blades", PROP_INT, PROP_NONE);
468  prop, "Blades", "Number of blades in aperture for polygonal bokeh (at least 3)");
469  RNA_def_property_range(prop, 0, 16);
470  RNA_def_property_int_funcs(prop, NULL, "rna_CameraDOFSettings_aperture_blades_set", NULL);
471  RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update");
472 
473  prop = RNA_def_property(srna, "aperture_rotation", PROP_FLOAT, PROP_ANGLE);
474  RNA_def_property_ui_text(prop, "Rotation", "Rotation of blades in aperture");
476  RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update");
477 
478  prop = RNA_def_property(srna, "aperture_ratio", PROP_FLOAT, PROP_NONE);
479  RNA_def_property_ui_text(prop, "Ratio", "Distortion to simulate anamorphic lens bokeh");
480  RNA_def_property_range(prop, 0.01f, FLT_MAX);
481  RNA_def_property_ui_range(prop, 1.0f, 2.0f, 0.1, 3);
482  RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update");
483 
485 }
486 
488 {
489  StructRNA *srna;
490  PropertyRNA *prop;
491  static const EnumPropertyItem prop_type_items[] = {
492  {CAM_PERSP, "PERSP", 0, "Perspective", ""},
493  {CAM_ORTHO, "ORTHO", 0, "Orthographic", ""},
494  {CAM_PANO, "PANO", 0, "Panoramic", ""},
495  {0, NULL, 0, NULL, NULL},
496  };
497  static const EnumPropertyItem prop_lens_unit_items[] = {
498  {0, "MILLIMETERS", 0, "Millimeters", "Specify the lens in millimeters"},
500  "FOV",
501  0,
502  "Field of View",
503  "Specify the lens as the field of view's angle"},
504  {0, NULL, 0, NULL, NULL},
505  };
506  static const EnumPropertyItem sensor_fit_items[] = {
508  "AUTO",
509  0,
510  "Auto",
511  "Fit to the sensor width or height depending on image resolution"},
512  {CAMERA_SENSOR_FIT_HOR, "HORIZONTAL", 0, "Horizontal", "Fit to the sensor width"},
513  {CAMERA_SENSOR_FIT_VERT, "VERTICAL", 0, "Vertical", "Fit to the sensor height"},
514  {0, NULL, 0, NULL, NULL},
515  };
516 
517  srna = RNA_def_struct(brna, "Camera", "ID");
518  RNA_def_struct_ui_text(srna, "Camera", "Camera data-block for storing camera settings");
519  RNA_def_struct_ui_icon(srna, ICON_CAMERA_DATA);
520 
522 
523  /* Enums */
524  prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
525  RNA_def_property_enum_items(prop, prop_type_items);
526  RNA_def_property_ui_text(prop, "Type", "Camera types");
527  RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
528 
529  prop = RNA_def_property(srna, "sensor_fit", PROP_ENUM, PROP_NONE);
530  RNA_def_property_enum_sdna(prop, NULL, "sensor_fit");
531  RNA_def_property_enum_items(prop, sensor_fit_items);
533  prop, "Sensor Fit", "Method to fit image and field of view angle inside the sensor");
534  RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
535 
536  /* Number values */
537 
538  prop = RNA_def_property(srna, "passepartout_alpha", PROP_FLOAT, PROP_FACTOR);
539  RNA_def_property_float_sdna(prop, NULL, "passepartalpha");
541  prop, "Passepartout Alpha", "Opacity (alpha) of the darkened overlay in Camera view");
543 
544  prop = RNA_def_property(srna, "angle_x", PROP_FLOAT, PROP_ANGLE);
545  RNA_def_property_range(prop, DEG2RAD(0.367), DEG2RAD(172.847));
547  RNA_def_property_ui_text(prop, "Horizontal FOV", "Camera lens horizontal field of view");
548  RNA_def_property_float_funcs(prop, "rna_Camera_angle_x_get", "rna_Camera_angle_x_set", NULL);
549  RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
550 
551  prop = RNA_def_property(srna, "angle_y", PROP_FLOAT, PROP_ANGLE);
552  RNA_def_property_range(prop, DEG2RAD(0.367), DEG2RAD(172.847));
554  RNA_def_property_ui_text(prop, "Vertical FOV", "Camera lens vertical field of view");
555  RNA_def_property_float_funcs(prop, "rna_Camera_angle_y_get", "rna_Camera_angle_y_set", NULL);
556  RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
557 
558  prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
559  RNA_def_property_range(prop, DEG2RAD(0.367), DEG2RAD(172.847));
561  RNA_def_property_ui_text(prop, "Field of View", "Camera lens field of view");
562  RNA_def_property_float_funcs(prop, "rna_Camera_angle_get", "rna_Camera_angle_set", NULL);
563  RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
564 
565  prop = RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_DISTANCE);
566  RNA_def_property_range(prop, 1e-6f, FLT_MAX);
567  RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
568  RNA_def_property_ui_text(prop, "Clip Start", "Camera near clipping distance");
570 
571  prop = RNA_def_property(srna, "clip_end", PROP_FLOAT, PROP_DISTANCE);
572  RNA_def_property_range(prop, 1e-6f, FLT_MAX);
573  RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
574  RNA_def_property_ui_text(prop, "Clip End", "Camera far clipping distance");
576 
577  prop = RNA_def_property(srna, "lens", PROP_FLOAT, PROP_DISTANCE_CAMERA);
578  RNA_def_property_float_sdna(prop, NULL, "lens");
579  RNA_def_property_range(prop, 1.0f, FLT_MAX);
580  RNA_def_property_ui_range(prop, 1.0f, 5000.0f, 100, 4);
581  RNA_def_property_ui_text(prop, "Focal Length", "Perspective Camera lens value in millimeters");
582  RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
583 
584  prop = RNA_def_property(srna, "sensor_width", PROP_FLOAT, PROP_DISTANCE_CAMERA);
585  RNA_def_property_float_sdna(prop, NULL, "sensor_x");
586  RNA_def_property_range(prop, 1.0f, FLT_MAX);
587  RNA_def_property_ui_range(prop, 1.0f, 100.0f, 100, 4);
589  prop, "Sensor Width", "Horizontal size of the image sensor area in millimeters");
590  RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
591 
592  prop = RNA_def_property(srna, "sensor_height", PROP_FLOAT, PROP_DISTANCE_CAMERA);
593  RNA_def_property_float_sdna(prop, NULL, "sensor_y");
594  RNA_def_property_range(prop, 1.0f, FLT_MAX);
595  RNA_def_property_ui_range(prop, 1.0f, 100.0f, 100, 4);
597  prop, "Sensor Height", "Vertical size of the image sensor area in millimeters");
598  RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
599 
600  prop = RNA_def_property(srna, "ortho_scale", PROP_FLOAT, PROP_NONE);
601  RNA_def_property_float_sdna(prop, NULL, "ortho_scale");
602  RNA_def_property_range(prop, FLT_MIN, FLT_MAX);
603  RNA_def_property_ui_range(prop, 0.001f, 10000.0f, 10, 3);
605  prop, "Orthographic Scale", "Orthographic Camera scale (similar to zoom)");
606  RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
607 
608  prop = RNA_def_property(srna, "display_size", PROP_FLOAT, PROP_DISTANCE);
609  RNA_def_property_float_sdna(prop, NULL, "drawsize");
610  RNA_def_property_range(prop, 0.01f, 1000.0f);
611  RNA_def_property_ui_range(prop, 0.01, 100, 1, 2);
613  prop, "Display Size", "Apparent size of the Camera object in the 3D View");
615 
616  prop = RNA_def_property(srna, "shift_x", PROP_FLOAT, PROP_NONE);
617  RNA_def_property_float_sdna(prop, NULL, "shiftx");
618  RNA_def_property_range(prop, -10.0f, 10.0f);
619  RNA_def_property_ui_range(prop, -2.0, 2.0, 1, 3);
620  RNA_def_property_ui_text(prop, "Shift X", "Camera horizontal shift");
621  RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
622 
623  prop = RNA_def_property(srna, "shift_y", PROP_FLOAT, PROP_NONE);
624  RNA_def_property_float_sdna(prop, NULL, "shifty");
625  RNA_def_property_range(prop, -10.0f, 10.0f);
626  RNA_def_property_ui_range(prop, -2.0, 2.0, 1, 3);
627  RNA_def_property_ui_text(prop, "Shift Y", "Camera vertical shift");
628  RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
629 
630  /* Stereo Settings */
631  prop = RNA_def_property(srna, "stereo", PROP_POINTER, PROP_NONE);
633  RNA_def_property_pointer_sdna(prop, NULL, "stereo");
634  RNA_def_property_struct_type(prop, "CameraStereoData");
635  RNA_def_property_ui_text(prop, "Stereo", "");
636 
637  /* flag */
638  prop = RNA_def_property(srna, "show_limits", PROP_BOOLEAN, PROP_NONE);
641  prop, "Show Limits", "Display the clipping range and focus point on the camera");
643 
644  prop = RNA_def_property(srna, "show_mist", PROP_BOOLEAN, PROP_NONE);
647  prop, "Show Mist", "Display a line from the Camera to indicate the mist area");
649 
650  prop = RNA_def_property(srna, "show_passepartout", PROP_BOOLEAN, PROP_NONE);
653  prop, "Show Passepartout", "Show a darkened overlay outside the image area in Camera view");
655 
656  prop = RNA_def_property(srna, "show_safe_areas", PROP_BOOLEAN, PROP_NONE);
659  prop, "Show Safe Areas", "Show TV title safe and action safe areas in Camera view");
661 
662  prop = RNA_def_property(srna, "show_safe_center", PROP_BOOLEAN, PROP_NONE);
665  "Show Center-Cut Safe Areas",
666  "Show safe areas to fit content in a different aspect ratio");
668 
669  prop = RNA_def_property(srna, "show_name", PROP_BOOLEAN, PROP_NONE);
671  RNA_def_property_ui_text(prop, "Show Name", "Show the active Camera's name in Camera view");
673 
674  prop = RNA_def_property(srna, "show_sensor", PROP_BOOLEAN, PROP_NONE);
677  prop, "Show Sensor Size", "Show sensor size (film gate) in Camera view");
679 
680  prop = RNA_def_property(srna, "show_background_images", PROP_BOOLEAN, PROP_NONE);
683  prop, "Display Background Images", "Display reference images behind objects in the 3D View");
685 
686  prop = RNA_def_property(srna, "lens_unit", PROP_ENUM, PROP_NONE);
688  RNA_def_property_enum_items(prop, prop_lens_unit_items);
689  RNA_def_property_ui_text(prop, "Lens Unit", "Unit to edit lens in for the user interface");
690 
691  /* dtx */
692  prop = RNA_def_property(srna, "show_composition_center", PROP_BOOLEAN, PROP_NONE);
695  prop, "Center", "Display center composition guide inside the camera view");
697 
698  prop = RNA_def_property(srna, "show_composition_center_diagonal", PROP_BOOLEAN, PROP_NONE);
701  prop, "Center Diagonal", "Display diagonal center composition guide inside the camera view");
703 
704  prop = RNA_def_property(srna, "show_composition_thirds", PROP_BOOLEAN, PROP_NONE);
707  prop, "Thirds", "Display rule of thirds composition guide inside the camera view");
709 
710  prop = RNA_def_property(srna, "show_composition_golden", PROP_BOOLEAN, PROP_NONE);
713  prop, "Golden Ratio", "Display golden ratio composition guide inside the camera view");
715 
716  prop = RNA_def_property(srna, "show_composition_golden_tria_a", PROP_BOOLEAN, PROP_NONE);
719  "Golden Triangle A",
720  "Display golden triangle A composition guide inside the camera view");
722 
723  prop = RNA_def_property(srna, "show_composition_golden_tria_b", PROP_BOOLEAN, PROP_NONE);
726  "Golden Triangle B",
727  "Display golden triangle B composition guide inside the camera view");
729 
730  prop = RNA_def_property(srna, "show_composition_harmony_tri_a", PROP_BOOLEAN, PROP_NONE);
733  prop, "Harmonious Triangle A", "Display harmony A composition guide inside the camera view");
735 
736  prop = RNA_def_property(srna, "show_composition_harmony_tri_b", PROP_BOOLEAN, PROP_NONE);
739  prop, "Harmonious Triangle B", "Display harmony B composition guide inside the camera view");
741 
742  /* pointers */
743  prop = RNA_def_property(srna, "dof", PROP_POINTER, PROP_NONE);
744  RNA_def_property_struct_type(prop, "CameraDOFSettings");
745  RNA_def_property_ui_text(prop, "Depth Of Field", "");
747 
748  prop = RNA_def_property(srna, "background_images", PROP_COLLECTION, PROP_NONE);
749  RNA_def_property_collection_sdna(prop, NULL, "bg_images", NULL);
750  RNA_def_property_struct_type(prop, "CameraBackgroundImage");
751  RNA_def_property_ui_text(prop, "Background Images", "List of background images");
753 
755 
757 
760 
761  /* Nested Data */
763 
764  /* *** Animated *** */
767 
768  /* Camera API */
769  RNA_api_camera(srna);
770 }
771 
772 #endif
Camera data-block and utility functions.
float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y)
Definition: camera.c:242
void BKE_camera_background_image_clear(struct Camera *cam)
Definition: camera.c:1153
struct CameraBGImage * BKE_camera_background_image_new(struct Camera *cam)
Definition: camera.c:1131
void BKE_camera_background_image_remove(struct Camera *cam, struct CameraBGImage *bgpic)
Definition: camera.c:1146
General operations, lookup, etc. for blender objects.
void BKE_report(ReportList *reports, ReportType type, const char *message)
Definition: report.c:104
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define M_PI
Definition: BLI_math_base.h:38
#define DEG2RAD(_deg)
float focallength_to_fov(float focal_length, float sensor)
float fov_to_focallength(float fov, float sensor)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
Definition: string.c:70
#define UNUSED(x)
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_relations_tag_update(struct Main *bmain)
@ ID_CA
Definition: DNA_ID_enums.h:68
@ CAM_DOF_ENABLED
@ CAM_DTX_GOLDEN_TRI_A
@ CAM_DTX_CENTER
@ CAM_DTX_HARMONY_TRI_A
@ CAM_DTX_GOLDEN
@ CAM_DTX_GOLDEN_TRI_B
@ CAM_DTX_HARMONY_TRI_B
@ CAM_DTX_CENTER_DIAG
@ CAM_DTX_THIRDS
@ CAM_SHOWLIMITS
@ CAM_SHOW_BG_IMAGE
@ CAM_SHOWPASSEPARTOUT
@ CAM_SHOW_SAFE_MARGINS
@ CAM_SHOW_SAFE_CENTER
@ CAM_SHOWMIST
@ CAM_ANGLETOGGLE
@ CAM_SHOWNAME
@ CAM_SHOWSENSOR
@ CAM_BGIMG_SOURCE_IMAGE
@ CAM_BGIMG_SOURCE_MOVIE
@ CAM_BGIMG_FLAG_FLIP_X
@ CAM_BGIMG_FLAG_FLIP_Y
@ CAM_BGIMG_FLAG_CAMERA_CROP
@ CAM_BGIMG_FLAG_CAMERACLIP
@ CAM_BGIMG_FLAG_CAMERA_ASPECT
@ CAM_BGIMG_FLAG_DISABLED
@ CAM_BGIMG_FLAG_FOREGROUND
@ CAM_BGIMG_FLAG_EXPANDED
@ CAM_S3D_PIVOT_CENTER
@ CAM_S3D_PIVOT_RIGHT
@ CAM_S3D_PIVOT_LEFT
@ CAM_PERSP
@ CAM_PANO
@ CAM_ORTHO
@ CAM_S3D_PARALLEL
@ CAM_S3D_OFFAXIS
@ CAM_S3D_TOE
@ CAMERA_SENSOR_FIT_HOR
@ CAMERA_SENSOR_FIT_AUTO
@ CAMERA_SENSOR_FIT_VERT
@ CAM_S3D_SPHERICAL
@ CAM_S3D_POLE_MERGE
#define RNA_POINTER_INVALIDATE(ptr)
Definition: RNA_access.h:1425
@ PARM_RNAPTR
Definition: RNA_types.h:339
@ PARM_REQUIRED
Definition: RNA_types.h:337
@ FUNC_USE_REPORTS
Definition: RNA_types.h:578
@ PROP_FLOAT
Definition: RNA_types.h:75
@ PROP_BOOLEAN
Definition: RNA_types.h:73
@ PROP_ENUM
Definition: RNA_types.h:77
@ PROP_INT
Definition: RNA_types.h:74
@ PROP_POINTER
Definition: RNA_types.h:78
@ PROP_COLLECTION
Definition: RNA_types.h:79
#define RNA_TRANSLATION_PREC_DEFAULT
Definition: RNA_types.h:104
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition: RNA_types.h:297
@ PROP_THICK_WRAP
Definition: RNA_types.h:270
@ PROP_ANIMATABLE
Definition: RNA_types.h:188
@ PROP_EDITABLE
Definition: RNA_types.h:175
@ PROP_NEVER_NULL
Definition: RNA_types.h:225
@ PROP_NO_DEG_UPDATE
Definition: RNA_types.h:286
@ PROP_XYZ
Definition: RNA_types.h:148
@ PROP_DISTANCE
Definition: RNA_types.h:135
@ PROP_ANGLE
Definition: RNA_types.h:132
@ PROP_DISTANCE_CAMERA
Definition: RNA_types.h:136
@ PROP_NONE
Definition: RNA_types.h:113
@ PROP_FACTOR
Definition: RNA_types.h:131
#define ND_SEQUENCER
Definition: WM_types.h:337
#define ND_DRAW
Definition: WM_types.h:362
#define NC_SCENE
Definition: WM_types.h:279
#define NC_CAMERA
Definition: WM_types.h:302
#define NC_OBJECT
Definition: WM_types.h:280
#define ND_DRAW_RENDER_VIEWPORT
Definition: WM_types.h:370
Scene scene
#define GS(x)
Definition: iris.c:241
void rna_def_animdata_common(StructRNA *srna)
static void rna_def_camera_stereo_data(BlenderRNA *brna)
Definition: rna_camera.c:340
void RNA_def_camera(BlenderRNA *brna)
Definition: rna_camera.c:487
static void rna_def_camera_dof_settings_data(BlenderRNA *brna)
Definition: rna_camera.c:423
static void rna_def_camera_background_image(BlenderRNA *brna)
Definition: rna_camera.c:168
static void rna_def_camera_background_images(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_camera.c:311
void RNA_api_camera(StructRNA *srna)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2762
void RNA_define_lib_overridable(const bool make_overridable)
Definition: rna_define.c:760
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
Definition: rna_define.c:1212
void RNA_define_animate_sdna(bool animate)
Definition: rna_define.c:766
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
Definition: rna_define.c:4159
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
Definition: rna_define.c:2257
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1555
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
Definition: rna_define.c:4302
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3153
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1676
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
Definition: rna_define.c:1684
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
Definition: rna_define.c:4262
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
Definition: rna_define.c:3462
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
Definition: rna_define.c:1259
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
Definition: rna_define.c:1892
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
Definition: rna_define.c:1067
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
Definition: rna_define.c:1757
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
Definition: rna_define.c:1792
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
Definition: rna_define.c:2791
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
Definition: rna_define.c:4337
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
Definition: rna_define.c:2927
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1279
void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2691
void RNA_def_function_flag(FunctionRNA *func, int flag)
Definition: rna_define.c:4332
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1517
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
Definition: rna_define.c:1047
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2623
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3055
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
Definition: rna_define.c:1267
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1512
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2515
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
Definition: rna_define.c:1706
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
Definition: rna_define.c:2348
void RNA_def_struct_nested(BlenderRNA *brna, StructRNA *srna, const char *structname)
Definition: rna_define.c:1138
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
Definition: rna_define.c:1525
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1547
void SEQ_relations_invalidate_scene_strips(Main *bmain, Scene *scene_target)
char sensor_fit
float sensor_y
struct ListBase bg_images
float sensor_x
char name[66]
Definition: DNA_ID.h:283
Definition: BKE_main.h:116
void * data
Definition: RNA_types.h:52
struct ID * owner_id
Definition: RNA_types.h:50
void WM_main_add_notifier(unsigned int type, void *reference)
PointerRNA * ptr
Definition: wm_files.c:3157