MinVR  0.9.0
A multi-platform virtual reality library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CameraOffAxis.H
Go to the documentation of this file.
1 //========================================================================
2 // MinVR
3 // Platform: Any
4 // API version: 1.0
5 //------------------------------------------------------------------------
6 // The MIT License (MIT)
7 //
8 // Copyright (c) 2013 Regents of the University of Minnesota
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a copy of
11 // this software and associated documentation files (the "Software"), to deal in
12 // the Software without restriction, including without limitation the rights to
13 // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
14 // the Software, and to permit persons to whom the Software is furnished to do so,
15 // subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included in all
18 // copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
22 // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
23 // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 //========================================================================
27 
28 #ifndef CAMERAOFFAXIS_H
29 #define CAMERAOFFAXIS_H
30 
31 #include <glm/glm.hpp>
32 #include <glm/gtc/matrix_access.hpp>
33 #include "MVRCore/AbstractCamera.H"
34 #include "MVRCore/StringUtils.H"
35 
36 namespace MinVR {
37 
44 {
45 public:
46  CameraOffAxis(glm::vec3 topLeft, glm::vec3 topRight, glm::vec3 botLeft, glm::vec3 botRight,
47  glm::mat4 initialHeadFrame, double interOcularDistance, double nearClipDist, double farClipDist);
48 
49  virtual ~CameraOffAxis();
50 
58  virtual void updateHeadTrackingFrame(glm::mat4 newHeadFrame);
59 
65  virtual void applyProjectionAndCameraMatrices();
66 
73 
80 
86  virtual void setObjectToWorldMatrix(glm::mat4 obj2World);
87 
94  glm::mat4 getLeftEyeFrame();
95 
102  glm::mat4 getRightEyeFrame();
103 
104 protected:
105 
106  glm::vec3 _topLeft;
107  glm::vec3 _topRight;
108  glm::vec3 _botLeft;
109  glm::vec3 _botRight;
110  glm::mat4 _headFrame;
111  double _iod;
112  double _nearClip;
113  double _farClip;
114  double _halfWidth;
115  double _halfHeight;
116  glm::mat4 _room2tile;
117 
118  glm::mat4 _projection;
119  glm::mat4 _projectionLeft;
120  glm::mat4 _projectionRight;
121  glm::mat4 _view;
122  glm::mat4 _viewLeft;
123  glm::mat4 _viewRight;
124  glm::mat4 _object2World;
125 
127 
128  virtual void applyProjectionAndCameraMatrices(const glm::mat4& projectionMat, const glm::mat4& viewMat);
129  glm::mat4 invertYMat();
130  glm::mat4 perspectiveProjection(double left, double right, double bottom, double top, double nearval, double farval, float upDirection = -1.0);
131 
132 };
133 
134 } //end namespace
135 #endif