OCULUS Scol plugin
 All Classes Functions Groups Pages
sOculus.h
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OpenSpace3D
4 For the latest info, see http://www.openspace3d.com
5 
6 Copyright (c) 2012 I-maginer
7 
8 This program is free software; you can redistribute it and/or modify it under
9 the terms of the GNU Lesser General Public License as published by the Free Software
10 Foundation; either version 2 of the License, or (at your option) any later
11 version.
12 
13 This program is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License along with
18 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20 http://www.gnu.org/copyleft/lesser.txt
21 
22 -----------------------------------------------------------------------------
23 */
24 
25 #ifndef S_OCULUS_H
26 #define S_OCULUS_H
27 
28 #include <scolPlugin.h>
29 #include <boost/thread/thread.hpp>
30 #include <boost/bind.hpp>
31 
32 #include <OVR.h>
33 using namespace OVR;
34 
38 class SCbData
39 {
40 public:
41  Vector3f vec;
42  Quatf quat;
43 protected:
44 private:
45 
46 public:
47  SCbData() {};
48 
49  ~SCbData() {};
50 protected:
51 private:
52 };
53 
57 class sOculus
58 {
59 public:
60  static bool isInitialized;
61 protected:
62  bool mConnected;
63 
64 private:
65  boost::thread mThread;
66  boost::mutex mMutex;
67  bool mTerminate;
68  double mTimeWarpOffset;
69  bool mDebug;
70  bool mUpdated;
71  ovrHmd mHmd;
72  ovrFrameTiming mFrameTiming;
73  ovrTrackingState mTrackingState;
74  ovrPosef mEyepos[2];
75  double mLastTime;
76 public:
80  sOculus();
81 
85  ~sOculus();
86 
87  bool Connect();
88  void Disconnect();
89  void ResetSensor();
90  bool IsConnected();
91 
92  Quatf GetSensorOrientation();
93  Vector3f GetSensorYawPitchRoll();
94  Vector3f GetSensorAcceleration();
95  Vector3f GetSensorPosition();
96 
97  ovrHmdType GetType();
98  void SetLowPersistance(bool state);
99  bool GetLowPersistance();
100  bool GetStereoConfigDistortionMesh(ovrEyeType eye, ovrDistortionMesh &mesh);
101  bool GetProjectionMatrix(ovrEyeType eye, float nearclip, float farclip, ovrMatrix4f &mat);
102  void WaitForFrame();
103  bool GetTimeWarpMatrix(ovrEyeType eye, ovrMatrix4f* mat);
104  Sizei GetStereoConfigFovTextureSize(ovrEyeType eye);
105  bool GetStereoConfigUvScaleOffset(ovrEyeType eye, Sizei textSize, Vector2f &scale, Vector2f &offset);
106  bool GetWindowPosAndSize(Vector2i &pos, Sizei &size, int &monitorIndex);
107  float GetStereoConfigAspect();
108  float GetStereoConfigFovY();
109  float GetStereoIPD();
110  bool UpdateStart();
111  void UpdateEnd();
112  void SetTimewarpOffset(double value);
113 protected:
114 private:
115  void UpdateThread();
116 };
117 
118 #endif