VR-Forces 4.3.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtOculusChannel.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (c) 2015 MAK Technologies, Inc.
3  * All rights reserved.
4  ******************************************************************************/
5 
9 
10 #pragma once
11 
13 #include <vrvOsg/DtOsgChannel.h>
14 #include <vrvOsg/DtOsgRenderer.h>
16 
17 #include <OVR_CAPI.h>
18 
19 #ifdef LEAP_SUPPORT
20 #include <Leap.h>
21 #endif
22 
23 union ovrGLConfig;
24 
25 namespace makVrv
26 {
27  // With SDK based rendering OVR will take care of calling swapbuffers;
28  // this null implementation will prevent OSG from also swapping which
29  // causes flicker.
30  class DtNullSwapCallback : public osg::GraphicsContext::SwapCallback
31  {
32  public:
33  void swapBuffersImplementation(osg::GraphicsContext *) {};
34  };
35 
39  {
40  protected:
41  friend class DtOculusChannelCreator;
42  friend class DtOculusDrawable;
43 
47  DtOculusChannel(ovrHmd theHMD, DtDe& de, DtOsgWindow* window, DtChannelConfiguration& config);
48 
50 
51 
53  virtual bool initialize();
54 
58  virtual void initializeOculusDevice();
59 
61  virtual void initializeOculusChannel();
63 
68  virtual void setupGLConfig(ovrGLConfig& cfg);
69 
71  virtual void update();
72 
75  virtual void updateProjection();
76 
79  virtual void projectFor3D();
80 
82  virtual void setupCullVisitor(osg::observer_ptr<osg::Camera> camera);
83 
85  virtual void getEulerFromQuat(osg::Quat q, double& heading,
86  double& attitude, double& bank);
87 
91  osg::Camera* createRTTCamera(osg::Texture* tex, int order);
92 
96  virtual double renderTargetScaleFactor();
97 
100  virtual void slot_viewportChanged(DtChannel* channel, int x, int y,
101  int width, int height);
102 
105  virtual unsigned getDistortionCaps() const;
106 
107  public:
109  virtual ~DtOculusChannel();
110 
112  virtual void resetSensor();
113 
115  virtual void resetYaw();
116 
119  virtual void onPreTick();
120 
124  virtual void onPostTick();
125 
126  // Sets myOculusInitialized to false and zeros the myHMD pointer. The
127  // HMD itself is destroyed by the plugin.
128  virtual void onShutdown();
129 
130  protected:
131  ovrHmd myHMD;
132  ovrPosef myEyeRenderPose[2];
133  ovrEyeRenderDesc myEyeRenderDesc[2];
134  ovrFovPort myEyeFov[2];
135  ovrTexture myEyeTexture[2];
137 
139 
140  osg::ref_ptr<osg::Camera> myLeftRTTCamera;
141  osg::ref_ptr<osg::Camera> myRightRTTCamera;
142 
143  double myYaw;
145  osg::Vec3d myHMDOffset;
146 
147  osg::ref_ptr<DtOculusDrawable> myOculusDrawable;
148  osg::ref_ptr<osg::Group> myOculusDrawableGroup;
150 
151  osg::ref_ptr<osg::Billboard> myHUDBillboard;
152  osg::ref_ptr<osg::MatrixTransform> myHUDMatrixTransform;
153 
154  osg::ref_ptr<DtNullSwapCallback> mySwapCallback;
155 
157 
158 #ifdef LEAP_SUPPORT
159  Leap::Controller myLeapController;
160  double myLastSimulationTime;
161 #endif
162  };
163 
167  {
168  public:
169  DtOculusChannelCreator(ovrHmd theHMD) : myHMD(theHMD) { }
170 
172  virtual DtChannel* create(DtDe& de, DtWindow* window, DtChannelConfiguration& config);
173 
174  ovrHmd myHMD;
175  };
176 
181  class DT_DLL_VRVOCULUSCHANNELPLUGIN DtOculusDrawable : public osg::Drawable
182  {
183  public:
185  DtOculusDrawable(DtOculusChannel* channel) : myOculusChannel(channel) {};
186 
189  virtual void drawImplementation(osg::RenderInfo& renderInfo) const
190  {
191  DtOculusDrawable *mutableThis = const_cast< DtOculusDrawable *>(this);
192  mutableThis->myOculusChannel->initializeOculusDevice();
193  }
194 
195  virtual Object* cloneType() const {
196  return new DtOculusDrawable(myOculusChannel);
197  }
198  virtual Object* clone(const osg::CopyOp& copyop) const {
199  return new DtOculusDrawable(myOculusChannel);
200  }
201  protected:
203  };
204 }

Document ID: Generated on Wed Jul 29 00:55:00 EDT 2015 from SVN revision 155257
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)