/src/alembic/lib/Alembic/AbcGeom/CameraSample.h
Line | Count | Source |
1 | | //-***************************************************************************** |
2 | | // |
3 | | // Copyright (c) 2009-2011, |
4 | | // Sony Pictures Imageworks, Inc. and |
5 | | // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. |
6 | | // |
7 | | // All rights reserved. |
8 | | // |
9 | | // Redistribution and use in source and binary forms, with or without |
10 | | // modification, are permitted provided that the following conditions are |
11 | | // met: |
12 | | // * Redistributions of source code must retain the above copyright |
13 | | // notice, this list of conditions and the following disclaimer. |
14 | | // * Redistributions in binary form must reproduce the above |
15 | | // copyright notice, this list of conditions and the following disclaimer |
16 | | // in the documentation and/or other materials provided with the |
17 | | // distribution. |
18 | | // * Neither the name of Sony Pictures Imageworks, nor |
19 | | // Industrial Light & Magic nor the names of their contributors may be used |
20 | | // to endorse or promote products derived from this software without specific |
21 | | // prior written permission. |
22 | | // |
23 | | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
24 | | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
25 | | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
26 | | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
27 | | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
28 | | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
29 | | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
30 | | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
31 | | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
32 | | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
33 | | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
34 | | // |
35 | | //-***************************************************************************** |
36 | | |
37 | | #ifndef Alembic_AbcGeom_CameraSample_h |
38 | | #define Alembic_AbcGeom_CameraSample_h |
39 | | |
40 | | #include <Alembic/Util/Export.h> |
41 | | #include <Alembic/AbcGeom/Foundation.h> |
42 | | #include <Alembic/AbcGeom/FilmBackXformOp.h> |
43 | | |
44 | | namespace Alembic { |
45 | | namespace AbcGeom { |
46 | | namespace ALEMBIC_VERSION_NS { |
47 | | |
48 | | //-***************************************************************************** |
49 | | class ALEMBIC_EXPORT CameraSample |
50 | | { |
51 | | public: |
52 | | |
53 | | //! Creates a default sample with a bunch of defaults set |
54 | 0 | CameraSample() { reset(); } |
55 | | |
56 | | //! Create a default sample and set the defaults so that they |
57 | | //! calculate the provided screen window. |
58 | | CameraSample( double iTop, double iBottom, double iLeft, double iRight ); |
59 | | |
60 | | void getScreenWindow( double & oTop, double & oBottom, double & oLeft, |
61 | | double & oRight ); |
62 | | |
63 | | //! get the camera focal length in millimeters. |
64 | 0 | double getFocalLength() const { return m_focalLength; } |
65 | | |
66 | | //! set the camera focal length in millimeters. |
67 | 0 | void setFocalLength( double iVal ) { m_focalLength = iVal; } |
68 | | |
69 | | //! get the horizontal camera film back in centimeters |
70 | 0 | double getHorizontalAperture() const { return m_horizontalAperture; } |
71 | | |
72 | | //! set the horizontal camera film back in centimeters |
73 | 0 | void setHorizontalAperture( double iVal ) { m_horizontalAperture = iVal; } |
74 | | |
75 | | //! get the horizontal film back offset in centimeters |
76 | 0 | double getHorizontalFilmOffset() const { return m_horizontalFilmOffset; } |
77 | | |
78 | | //! set the horizontal film back offset in centimeters |
79 | | void setHorizontalFilmOffset( double iVal ) |
80 | 0 | { m_horizontalFilmOffset = iVal; } |
81 | | |
82 | | //! get the vertical camera film back in centimeters |
83 | 0 | double getVerticalAperture() const { return m_verticalAperture; } |
84 | | |
85 | | //! set the vertical camera film back in centimeters |
86 | 0 | void setVerticalAperture( double iVal ) { m_verticalAperture = iVal; } |
87 | | |
88 | | //! get the vertical film back offset in centimeters |
89 | 0 | double getVerticalFilmOffset() const { return m_verticalFilmOffset; } |
90 | | |
91 | | //! set the vertical film back offset in centimeters |
92 | 0 | void setVerticalFilmOffset( double iVal ) { m_verticalFilmOffset = iVal; } |
93 | | |
94 | | //! get the amount the camera's lens compresses the image horizontally |
95 | | //! (width / height aspect ratio) |
96 | 0 | double getLensSqueezeRatio() const { return m_lensSqueezeRatio; } |
97 | | |
98 | | //! set the amount the camera's lens compresses the image horizontally |
99 | | //! (width / height aspect ratio) |
100 | | void setLensSqueezeRatio( double iVal ) |
101 | 0 | { m_lensSqueezeRatio = iVal; } |
102 | | |
103 | | //! get over scan fractional percentage for the left part of the |
104 | | //! screen window |
105 | 0 | double getOverScanLeft() { return m_overscanLeft; } |
106 | | |
107 | | //! set over scan fractional percentage for the left part of the |
108 | | //! screen window |
109 | 0 | void setOverScanLeft( double iVal ) { m_overscanLeft = iVal; } |
110 | | |
111 | | //! get over scan fractional percentage for the right part of the |
112 | | //! screen window |
113 | 0 | double getOverScanRight() const { return m_overscanRight; } |
114 | | |
115 | | //! set over scan fractional percentage for the right part of the |
116 | | //! screen window |
117 | 0 | void setOverScanRight( double iVal ) { m_overscanRight = iVal; } |
118 | | |
119 | | //! get over scan fractional percentage for the top part of the |
120 | | //! screen window |
121 | 0 | double getOverScanTop() const { return m_overscanTop; } |
122 | | |
123 | | //! get over scan fractional percentage for the top part of the |
124 | | //! screen window |
125 | 0 | void setOverScanTop( double iVal ) { m_overscanTop = iVal; } |
126 | | |
127 | | //! get over scan fractional percentage for the bottom part of the |
128 | | //! screen window |
129 | 0 | double getOverScanBottom() const { return m_overscanBottom; } |
130 | | |
131 | | //! set over scan fractional percentage for the bottom part of the |
132 | | //! screen window |
133 | 0 | void setOverScanBottom( double iVal ) { m_overscanBottom = iVal; } |
134 | | |
135 | | //! get the f-stop (focal length divided by "effective" lens diameter) |
136 | 0 | double getFStop() const { return m_fStop; } |
137 | | |
138 | | //! set the f-stop (focal length divided by "effective" lens diameter) |
139 | 0 | void setFStop( double iVal ) { m_fStop = iVal; } |
140 | | |
141 | | //! get the distance from the camera to the object being focused on |
142 | | //! in centimeters |
143 | 0 | double getFocusDistance() const { return m_focusDistance; } |
144 | | |
145 | | //! set the distance from the camera to the object being focused on |
146 | | //! in centimeters |
147 | 0 | void setFocusDistance( double iVal ) { m_focusDistance = iVal; } |
148 | | |
149 | | //! get the frame relative shutter open time in seconds. |
150 | 0 | double getShutterOpen() const { return m_shutterOpen; } |
151 | | |
152 | | //! set the frame relative shutter open time in seconds. |
153 | 0 | void setShutterOpen( double iVal ) { m_shutterOpen = iVal; } |
154 | | |
155 | | //! get the frame relative shutter close time in seconds. |
156 | 0 | double getShutterClose() const { return m_shutterClose; } |
157 | | |
158 | | //! set the frame relative shutter open time in seconds. |
159 | 0 | void setShutterClose( double iVal ) { m_shutterClose = iVal; } |
160 | | |
161 | | //! get the distance from the camera to the near clipping plane in |
162 | | //! centimeters |
163 | 0 | double getNearClippingPlane() const { return m_nearClippingPlane; } |
164 | | |
165 | | //! set the distance from the camera to the near clipping plane in |
166 | | //! centimeters |
167 | 0 | void setNearClippingPlane( double iVal ) { m_nearClippingPlane = iVal; } |
168 | | |
169 | | //! get the distance from the camera to the far clipping plane in |
170 | | //! centimeters |
171 | 0 | double getFarClippingPlane() const { return m_farClippingPlane; } |
172 | | |
173 | | //! set the distance from the camera to the near clipping plane in |
174 | | //! centimeters |
175 | 0 | void setFarClippingPlane( double iVal ) { m_farClippingPlane = iVal; } |
176 | | |
177 | 0 | Abc::Box3d getChildBounds() const { return m_childBounds; } |
178 | | void setChildBounds( const Abc::Box3d & iBounds ) |
179 | 0 | { m_childBounds = iBounds; } |
180 | | |
181 | | |
182 | | // helper function for getting one of the 16 core, non film back xform op |
183 | | // related values |
184 | | double getCoreValue( std::size_t iIndex ) const; |
185 | | |
186 | | // calculated the field of view in degrees |
187 | | double getFieldOfView() const;; |
188 | | |
189 | | // add an op and return the index of the op in its op-stack |
190 | | std::size_t addOp( FilmBackXformOp iOp ); |
191 | | |
192 | | FilmBackXformOp getOp( std::size_t iIndex ) const; |
193 | | FilmBackXformOp &operator[]( const std::size_t &iIndex ); |
194 | | const FilmBackXformOp &operator[]( const std::size_t &iIndex ) const; |
195 | | |
196 | | //! Returns the concatenated 3x3 film back matrix |
197 | | Abc::M33d getFilmBackMatrix () const; |
198 | | |
199 | | std::size_t getNumOps() const; |
200 | | std::size_t getNumOpChannels() const; |
201 | | |
202 | | void reset() |
203 | 0 | { |
204 | 0 | // in mm |
205 | 0 | m_focalLength = 35.0; |
206 | 0 |
|
207 | 0 | // in cm |
208 | 0 | m_horizontalAperture = 3.6; |
209 | 0 | m_horizontalFilmOffset = 0.0; |
210 | 0 | m_verticalAperture = 2.4; |
211 | 0 | m_verticalFilmOffset = 0.0; |
212 | 0 |
|
213 | 0 | // width/height lens aspect ratio |
214 | 0 | m_lensSqueezeRatio = 1.0; |
215 | 0 |
|
216 | 0 | m_overscanLeft = 0.0; |
217 | 0 | m_overscanRight = 0.0; |
218 | 0 | m_overscanTop = 0.0; |
219 | 0 | m_overscanBottom = 0.0; |
220 | 0 |
|
221 | 0 | // optical property of the lens, focal length divided by |
222 | 0 | // "effective" lens diameter |
223 | 0 | m_fStop = 5.6; |
224 | 0 |
|
225 | 0 | m_focusDistance = 5.0; |
226 | 0 | m_shutterOpen = 0.0; |
227 | 0 | m_shutterClose = 0.020833333333333332; |
228 | 0 |
|
229 | 0 | m_nearClippingPlane = 0.1; |
230 | 0 | m_farClippingPlane = 100000.0; |
231 | 0 |
|
232 | 0 | m_childBounds.makeEmpty(); |
233 | 0 | m_ops.clear(); |
234 | 0 | } |
235 | | |
236 | | private: |
237 | | double m_focalLength; |
238 | | double m_horizontalAperture; |
239 | | double m_horizontalFilmOffset; |
240 | | double m_verticalAperture; |
241 | | double m_verticalFilmOffset; |
242 | | double m_lensSqueezeRatio; |
243 | | |
244 | | double m_overscanLeft; |
245 | | double m_overscanRight; |
246 | | double m_overscanTop; |
247 | | double m_overscanBottom; |
248 | | |
249 | | double m_fStop; |
250 | | double m_focusDistance; |
251 | | double m_shutterOpen; |
252 | | double m_shutterClose; |
253 | | |
254 | | double m_nearClippingPlane; |
255 | | double m_farClippingPlane; |
256 | | |
257 | | Abc::Box3d m_childBounds; |
258 | | |
259 | | std::vector<FilmBackXformOp> m_ops; |
260 | | }; |
261 | | |
262 | | } // End namespace ALEMBIC_VERSION_NS |
263 | | |
264 | | using namespace ALEMBIC_VERSION_NS; |
265 | | |
266 | | } // End namespace AbcGeom |
267 | | } // End namespace Alembic |
268 | | |
269 | | #endif |