gVirtualXRay  2.0.10
VirtualX-RayImagingLibraryonGPU
StereoHelper.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (c) 2017, Dr Franck P. Vidal (franck.p.vidal@fpvidal.net),
4 http://www.fpvidal.net/
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation and/or
15 other materials provided with the distribution.
16 
17 3. Neither the name of the Bangor University nor the names of its contributors
18 may be used to endorse or promote products derived from this software without
19 specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 
32 */
33 
34 
64 #ifndef __StereoHelper_h
65 #define __StereoHelper_h
66 
67 
68 //******************************************************************************
69 // Include
70 //******************************************************************************
71 #ifndef GVXR_CONFIG_H
73 #endif
74 
75 #ifndef GVXR_MATRIX4X4_H
76 #include "gVirtualXRay/Matrix4x4.h"
77 #endif
78 
79 #ifndef GVXR_TYPES_H
80 #include "gVirtualXRay/Types.h"
81 #endif
82 
83 
84 //******************************************************************************
85 // namespace
86 //******************************************************************************
87 namespace gVirtualXRay {
88 
89 
90 //==============================================================================
96 //==============================================================================
98 //------------------------------------------------------------------------------
99 {
100 //******************************************************************************
101 public:
102  //--------------------------------------------------------------------------
104  //--------------------------------------------------------------------------
105  typedef enum EyeTypeTag
106  {
107  LEFT_EYE = 0, //< Left eye (stereo vision)
108  RIGHT_EYE = 1, //< Right eye (stereo vision)
109  MONO = 2 //< Monovision
110  } EyeType;
111 
112 
113  //--------------------------------------------------------------------------
115  //--------------------------------------------------------------------------
116  StereoHelper();
117 
118 
119  //--------------------------------------------------------------------------
121 
124  //--------------------------------------------------------------------------
125  void setIntraocularDistance(double aDistance);
126 
127 
128  //--------------------------------------------------------------------------
130 
133  //--------------------------------------------------------------------------
134  double getIntraocularDistance() const;
135 
136 
137  //--------------------------------------------------------------------------
139 
142  //--------------------------------------------------------------------------
143  void setScreenAspectRatio(double aRatio);
144 
145 
146  //--------------------------------------------------------------------------
148 
151  //--------------------------------------------------------------------------
152  void setFieldOfViewY(double aFOVY);
153 
154 
155  //--------------------------------------------------------------------------
157 
160  //--------------------------------------------------------------------------
161  double getFieldOfViewY() const;
162 
163 
164  //--------------------------------------------------------------------------
166 
169  //--------------------------------------------------------------------------
170  void setNear(double aPlane);
171 
172 
173  //--------------------------------------------------------------------------
175 
178  //--------------------------------------------------------------------------
179  double getNear() const;
180 
181 
182  //--------------------------------------------------------------------------
184 
187  //--------------------------------------------------------------------------
188  void setFar(double aPlane);
189 
190 
191  //--------------------------------------------------------------------------
193 
196  //--------------------------------------------------------------------------
197  double getFar() const;
198 
199 
200  //--------------------------------------------------------------------------
202 
205  //--------------------------------------------------------------------------
206  void setScreenProjectionPlane(double aPlane);
207 
208 
209  //--------------------------------------------------------------------------
211 
214  //--------------------------------------------------------------------------
216 
217 
218  //--------------------------------------------------------------------------
220 
223  //--------------------------------------------------------------------------
225 
226 
227  //--------------------------------------------------------------------------
229  //--------------------------------------------------------------------------
230  void swapEye();
231 
232 
233  //--------------------------------------------------------------------------
235  //--------------------------------------------------------------------------
236  bool enable();
237 
238 
239  //--------------------------------------------------------------------------
241  //--------------------------------------------------------------------------
242  void disable();
243 
244 
245  //--------------------------------------------------------------------------
247  //--------------------------------------------------------------------------
248  bool isActive() const;
249 
250 
251 //******************************************************************************
252 protected:
254  void update();
255 
256 
259 
260 
263 
264 
267 
268 
275 
276 
283 
284 
286  double m_near;
287 
288 
290  double m_far;
291 
292 
294  double m_fovy;
295 
296 
299 
300 
303 
304 
307 
308 
311 
312 
315 };
316 
317 
318 } // namespace gVirtualXRay
319 
320 
321 //******************************************************************************
322 #include "StereoHelper.inl"
323 
324 
325 #endif // __StereoHelper_h
void setScreenProjectionPlane(double aPlane)
Set the screen projection plane.
Type declarations.
double m_screen_aspect_ratio
Screen aspect ratio.
Definition: StereoHelper.h:298
void setNear(double aPlane)
Set the near clipping plane.
bool m_stereo_currently_in_use
Flag set to true when the stereo is in used.
Definition: StereoHelper.h:314
void swapEye()
Swap eye.
void setFieldOfViewY(double aFOVY)
Set the field of view along the y-axis.
double getFar() const
Accessor on the far clipping plane.
bool enable()
Enable the stereo if possible.
bool isActive() const
Accessor on the stereo flag.
StereoHelper is a class to handle stereo vision using OpenGL&#39;s quad buffer.
Definition: StereoHelper.h:97
EyeType
Enum defining eyes.
Definition: StereoHelper.h:105
bool m_matrices_are_up_to_date
Flag set to true when the matrices are up-to-date.
Definition: StereoHelper.h:306
Template class to handle a 4x4 matrixs.
double getFieldOfViewY() const
Accessor on the field of view along the y-axis.
EyeType m_current_eye
Current eye type.
Definition: StereoHelper.h:310
Class to handle stereo vision using OpenGL&#39;s quad buffer. The code is relying on // http://www...
const MATRIX4 & getLeftEyeProjectionMatrix()
Accessor on the projection matrix corresponding to the left eye.
double getNear() const
Accessor on the near clipping plane.
double m_screen_projection_plane
Screen projection plane.
Definition: StereoHelper.h:302
void update()
Compute the projection matrices.
void setIntraocularDistance(double aDistance)
Set the intraocular distance.
MATRIX4 m_left_eye_projection_matrix
The projection matrix corresponding to the left eye.
Definition: StereoHelper.h:262
double m_intraocular_distance
Intraocular distance.
Definition: StereoHelper.h:258
void disable()
Disable the stereo.
void setFar(double aPlane)
Set the far clipping plane.
MATRIX4 m_right_eye_projection_matrix
The projection matrix corresponding to the right eye.
Definition: StereoHelper.h:266
double m_near
Near clipping plane.
Definition: StereoHelper.h:286
double m_far
Far clipping plane.
Definition: StereoHelper.h:290
Matrix4x4 is a template class to handle a 4 by 4 matrix.
Definition: Matrix4x4.h:89
double m_fovy
Field of view along the y-axis.
Definition: StereoHelper.h:294
const MATRIX4 & getRightEyeProjectionMatrix()
Accessor on the projection matrix corresponding to the right eye.
void setScreenAspectRatio(double aRatio)
Set the screen aspect ratio.
StereoHelper()
Default constructor.
double getIntraocularDistance() const
Accessor on the intraocular distance.