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  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
20 /** \file
21  * \ingroup DNA
22  */
23 
24 #pragma once
25 
26 #include "DNA_ID.h"
27 #include "DNA_defs.h"
28 #include "DNA_gpu_types.h"
29 #include "DNA_image_types.h"
30 #include "DNA_movieclip_types.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 struct AnimData;
37 struct Ipo;
38 struct Object;
39 
40 /* ------------------------------------------- */
41 /* Stereo Settings */
42 typedef struct CameraStereoSettings {
43   float interocular_distance;
44   float convergence_distance;
45   short convergence_mode;
46   short pivot;
47   short flag;
48   char _pad[2];
49   /* Cut-off angle at which interocular distance start to fade down. */
50   float pole_merge_angle_from;
51   /* Cut-off angle at which interocular distance stops to fade down. */
52   float pole_merge_angle_to;
53 } CameraStereoSettings;
54 
55 /* Background Picture */
56 typedef struct CameraBGImage {
57   struct CameraBGImage *next, *prev;
58 
59   struct Image *ima;
60   struct ImageUser iuser;
61   struct MovieClip *clip;
62   struct MovieClipUser cuser;
63   float offset[2], scale, rotation;
64   float alpha;
65   short flag;
66   short source;
67 } CameraBGImage;
68 
69 /** Properties for dof effect. */
70 typedef struct CameraDOFSettings {
71   /** Focal distance for depth of field. */
72   struct Object *focus_object;
73   float focus_distance;
74   float aperture_fstop;
75   float aperture_rotation;
76   float aperture_ratio;
77   int aperture_blades;
78   short flag;
79   char _pad[2];
80 } CameraDOFSettings;
81 
82 typedef struct Camera_Runtime {
83   /* For draw manager. */
84   float drw_corners[2][4][2];
85   float drw_tria[2][2];
86   float drw_depth[2];
87   float drw_focusmat[4][4];
88   float drw_normalmat[4][4];
89 } Camera_Runtime;
90 
91 typedef struct Camera {
92   ID id;
93   /** Animation data (must be immediately after id for utilities to use it). */
94   struct AnimData *adt;
95 
96   /** CAM_PERSP, CAM_ORTHO or CAM_PANO. */
97   char type;
98   /** Draw type extra. */
99   char dtx;
100   short flag;
101   float passepartalpha;
102   float clip_start, clip_end;
103   float lens, ortho_scale, drawsize;
104   float sensor_x, sensor_y;
105   float shiftx, shifty;
106   float dof_distance DNA_DEPRECATED;
107 
108   /** Old animation system, deprecated for 2.5. */
109   struct Ipo *ipo DNA_DEPRECATED;
110 
111   struct Object *dof_ob DNA_DEPRECATED;
112   struct GPUDOFSettings gpu_dof DNA_DEPRECATED;
113   struct CameraDOFSettings dof;
114 
115   /* CameraBGImage reference images */
116   struct ListBase bg_images;
117 
118   char sensor_fit;
119   char _pad[7];
120 
121   /* Stereo settings */
122   struct CameraStereoSettings stereo;
123 
124   /** Runtime data (keep last). */
125   Camera_Runtime runtime;
126 } Camera;
127 
128 /* **************** CAMERA ********************* */
129 
130 /* type */
131 enum {
132   CAM_PERSP = 0,
133   CAM_ORTHO = 1,
134   CAM_PANO = 2,
135 };
136 
137 /* dtx */
138 enum {
139   CAM_DTX_CENTER = (1 << 0),
140   CAM_DTX_CENTER_DIAG = (1 << 1),
141   CAM_DTX_THIRDS = (1 << 2),
142   CAM_DTX_GOLDEN = (1 << 3),
143   CAM_DTX_GOLDEN_TRI_A = (1 << 4),
144   CAM_DTX_GOLDEN_TRI_B = (1 << 5),
145   CAM_DTX_HARMONY_TRI_A = (1 << 6),
146   CAM_DTX_HARMONY_TRI_B = (1 << 7),
147 };
148 
149 /* flag */
150 enum {
151   CAM_SHOWLIMITS = (1 << 0),
152   CAM_SHOWMIST = (1 << 1),
153   CAM_SHOWPASSEPARTOUT = (1 << 2),
154   CAM_SHOW_SAFE_MARGINS = (1 << 3),
155   CAM_SHOWNAME = (1 << 4),
156   CAM_ANGLETOGGLE = (1 << 5),
157   CAM_DS_EXPAND = (1 << 6),
158 #ifdef DNA_DEPRECATED_ALLOW
159   CAM_PANORAMA = (1 << 7), /* deprecated */
160 #endif
161   CAM_SHOWSENSOR = (1 << 8),
162   CAM_SHOW_SAFE_CENTER = (1 << 9),
163   CAM_SHOW_BG_IMAGE = (1 << 10),
164 };
165 
166 /* Sensor fit */
167 enum {
168   CAMERA_SENSOR_FIT_AUTO = 0,
169   CAMERA_SENSOR_FIT_HOR = 1,
170   CAMERA_SENSOR_FIT_VERT = 2,
171 };
172 
173 #define DEFAULT_SENSOR_WIDTH 36.0f
174 #define DEFAULT_SENSOR_HEIGHT 24.0f
175 
176 /* stereo->convergence_mode */
177 enum {
178   CAM_S3D_OFFAXIS = 0,
179   CAM_S3D_PARALLEL = 1,
180   CAM_S3D_TOE = 2,
181 };
182 
183 /* stereo->pivot */
184 enum {
185   CAM_S3D_PIVOT_LEFT = 0,
186   CAM_S3D_PIVOT_RIGHT = 1,
187   CAM_S3D_PIVOT_CENTER = 2,
188 };
189 
190 /* stereo->flag */
191 enum {
192   CAM_S3D_SPHERICAL = (1 << 0),
193   CAM_S3D_POLE_MERGE = (1 << 1),
194 };
195 
196 /* CameraBGImage->flag */
197 /* may want to use 1 for select ? */
198 enum {
199   CAM_BGIMG_FLAG_EXPANDED = (1 << 1),
200   CAM_BGIMG_FLAG_CAMERACLIP = (1 << 2),
201   CAM_BGIMG_FLAG_DISABLED = (1 << 3),
202   CAM_BGIMG_FLAG_FOREGROUND = (1 << 4),
203 
204   /* Camera framing options */
205   CAM_BGIMG_FLAG_CAMERA_ASPECT = (1 << 5), /* don't stretch to fit the camera view  */
206   CAM_BGIMG_FLAG_CAMERA_CROP = (1 << 6),   /* crop out the image */
207 
208   /* Axis flip options */
209   CAM_BGIMG_FLAG_FLIP_X = (1 << 7),
210   CAM_BGIMG_FLAG_FLIP_Y = (1 << 8),
211 };
212 
213 /* CameraBGImage->source */
214 /* may want to use 1 for select ?*/
215 enum {
216   CAM_BGIMG_SOURCE_IMAGE = 0,
217   CAM_BGIMG_SOURCE_MOVIE = 1,
218 };
219 
220 /* CameraDOFSettings->flag */
221 enum {
222   CAM_DOF_ENABLED = (1 << 0),
223 };
224 
225 #ifdef __cplusplus
226 }
227 #endif
228