OSVR-Core
ViewerEye.h
Go to the documentation of this file.
1 
11 // Copyright 2015 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_ViewerEye_h_GUID_B895D9B8_5FF1_4991_D174_4AF145F83172
26 #define INCLUDED_ViewerEye_h_GUID_B895D9B8_5FF1_4991_D174_4AF145F83172
27 
28 // Internal Includes
31 #include <osvr/Client/Export.h>
33 #include <osvr/Util/Pose3C.h>
35 #include <osvr/Util/Rect.h>
38 #include <osvr/Util/Angles.h>
39 
40 // Library/third-party includes
41 #include <boost/optional.hpp>
42 
43 // Standard includes
44 #include <vector>
45 #include <stdexcept>
46 #include <utility>
47 
48 namespace osvr {
49 namespace client {
50  class DisplayConfigFactory;
51  struct Viewport {
52  int32_t left;
53  int32_t bottom;
54  int32_t width;
55  int32_t height;
56  };
57  struct NoPoseYet : std::runtime_error {
58  NoPoseYet()
59  : std::runtime_error("No pose data yet for the interface!") {}
60  };
61  class ViewerEye {
62  public:
63  ViewerEye(ViewerEye const &) = delete;
64  ViewerEye &operator=(ViewerEye const &) = delete;
65  ViewerEye(ViewerEye &&other)
66  : m_pose(std::move(other.m_pose)), m_offset(other.m_offset),
67  m_viewport(other.m_viewport),
68  m_unitBounds(std::move(other.m_unitBounds)),
69  m_rot180(other.m_rot180), m_pitchTilt(other.m_pitchTilt),
70  m_radDistortParams(std::move(other.m_radDistortParams)),
71  m_displayInputIdx(other.m_displayInputIdx),
72  m_opticalAxisOffsetY(other.m_opticalAxisOffsetY) {}
73 
74  inline OSVR_SurfaceCount size() const { return 1; }
75 #if 0
76  inline OSVR_SurfaceCount size() const {
77  return static_cast<OSVR_SurfaceCount>(m_surfaces.size());
78  }
79  inline ViewerEyeSurface &operator[](OSVR_SurfaceCount index) {
80  return m_surfaces[index];
81  }
82  inline ViewerEyeSurface const &
83  operator[](OSVR_SurfaceCount index) const {
84  return m_surfaces[index];
85  }
86 #endif
87  OSVR_CLIENT_EXPORT OSVR_Pose3 getPose() const;
88  OSVR_CLIENT_EXPORT bool hasPose() const;
89 
90  OSVR_CLIENT_EXPORT Eigen::Matrix4d getView() const;
91 
92  bool wantDistortion() const {
93  return m_radDistortParams.is_initialized();
94  }
95 
96  boost::optional<OSVR_RadialDistortionParameters>
97  getRadialDistortionParams() const {
98  return m_radDistortParams;
99  }
100 
101  OSVR_DistortionPriority getRadialDistortionPriority() const {
102  return (m_radDistortParams.is_initialized())
103  ? 1
105  }
106 
109  OSVR_CLIENT_EXPORT Eigen::Matrix4d getProjection(double near,
110  double far) const;
111  OSVR_CLIENT_EXPORT Eigen::Matrix4d
112  getProjection(double near, double far,
113  OSVR_MatrixConventions flags) const;
114 
116  OSVR_CLIENT_EXPORT util::Rectd getRect() const;
117 
118  Viewport getDisplayRelativeViewport() const { return m_viewport; }
119 
120  OSVR_DisplayInputCount getDisplayInputIdx() const {
121  return m_displayInputIdx;
122  }
123 
124  private:
125  friend class DisplayConfigFactory;
126  ViewerEye(
127  OSVR_ClientContext ctx, Eigen::Vector3d const &offset,
128  const char path[], Viewport &&viewport, util::Rectd &&unitBounds,
129  bool rot180, double pitchTilt,
130  boost::optional<OSVR_RadialDistortionParameters> radDistortParams,
131  OSVR_DisplayInputCount displayInputIdx,
132  util::Angle opticalAxisOffsetY = 0. * util::radians);
133  util::Rectd m_getRect(double near, double far) const;
134  Eigen::Isometry3d getPoseIsometry() const;
135  InternalInterfaceOwner m_pose;
136  Eigen::Vector3d m_offset;
137 #if 0
138  std::vector<ViewerEyeSurface> m_surfaces;
139 #endif
140  Viewport m_viewport;
141  util::Rectd m_unitBounds;
142 
143  bool m_rot180;
144  double m_pitchTilt;
145  boost::optional<OSVR_RadialDistortionParameters> m_radDistortParams;
146  OSVR_DisplayInputCount m_displayInputIdx;
147  util::Angle m_opticalAxisOffsetY;
148  };
149 
150 } // namespace client
151 } // namespace osvr
152 
153 #endif // INCLUDED_ViewerEye_h_GUID_B895D9B8_5FF1_4991_D174_4AF145F83172
AngleRadiansd Angle
Default angle type.
Definition: Angles.h:63
Definition: ViewerEye.h:51
uint32_t OSVR_SurfaceCount
The integer type specifying the number of surfaces seen by a viewer&#39;s eye.
Definition: RenderingTypesC.h:108
Definition: ViewerEye.h:57
Header declaring opaque types used by Client and ClientKit.
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
int32_t OSVR_DistortionPriority
The integer type used to indicate relative priorities of a display distortion strategy.
Definition: RenderingTypesC.h:121
Header wrapping include of <Eigen/Core> and <Eigen/Geometry> for warning quieting.
Definition: ViewerEyeSurface.h:40
Class that should be used for all internally-used client interface objects as it handles ownership wi...
Definition: InternalInterfaceOwner.h:45
detail::size< coerce_list< Ts... >> size
Get the size of a list (number of elements.)
Definition: Size.h:56
Definition: DisplayConfig.h:50
Definition: Rect.h:39
#define OSVR_DISTORTION_PRIORITY_UNAVAILABLE
The constant to return as an OSVR_DistortionPriority if a given strategy is not available for a surfa...
Definition: RenderingTypesC.h:128
uint16_t OSVR_MatrixConventions
Type for passing matrix convention flags.
Definition: MatrixConventionsC.h:54
Header with integer types for Viewer, Eye, and Surface counts/indices, as well as viewport informatio...
Header.
Definition: ClientContext.h:50
Definition: ViewerEye.h:61
uint8_t OSVR_DisplayInputCount
A count or index for a display input in a display config.
Definition: RenderingTypesC.h:51
A structure defining a 3D (6DOF) rigid body pose: translation and rotation.
Definition: Pose3C.h:54
Header.
Header.
Definition: Transform.h:43