VR-Forces Development_Version 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>
15 
16 #include <OVR_CAPI.h>
17 #include <OVR_CAPI_GL.h>
18 
19 #include <oculusdevice.h>
20 
21 #ifdef LEAP_SUPPORT
22 #include <Leap.h>
23 #endif
24 
25 union ovrGLConfig;
26 
27 namespace makVrv
28 {
32  {
33  protected:
34  friend class DtOculusChannelCreator;
35  friend class DtOculusDrawable;
36  friend class DtOculusSwapCallback;
37 
41  DtOculusChannel(DtDe& de, DtOsgWindow* window,
42  DtChannelConfiguration& config);
43 
45  virtual ~DtOculusChannel();
46 
48 
49 
51  virtual bool initialize();
52 
56  virtual void initializeOculusDevice(osg::RenderInfo& renderInfo);
57 
59  virtual void initializeOculusChannel();
61 
63  virtual void update();
64 
67  virtual void updateProjection();
68 
71  virtual void projectFor3D();
72 
74  virtual void setupCullVisitor(osg::observer_ptr<osg::Camera> camera);
75 
77  virtual void getEulerFromQuat(osg::Quat q, double& heading,
78  double& attitude, double& bank);
79 
81  osg::Camera* createRTTCamera(int eye);
82 
87  virtual float getPixelsPerDisplayPixel();
88 
91  void blitMirrorTexture(osg::GraphicsContext *gc);
92 
93  public:
94 
96  virtual void resetSensor();
97 
99  virtual void resetYaw();
100 
103  virtual void onPreTick();
104 
108  virtual void onPostTick();
109 
112  virtual void onShutdown();
113 
116  //virtual void warnOnOVRErrors();
117 
122 
123  virtual void setMirroring(bool enabled);
124  virtual bool isMirroring();
126 
128  virtual std::vector<const osg::Camera*> getShadowableCameras() const;
129 
130  protected:
131  ovrSession mySession;
132  ovrHmdDesc myHmdDesc;
133  ovrPosef myEyeRenderPose[2];
134  ovrEyeRenderDesc myEyeRenderDesc[2];
135  ovrFovPort myEyeFov[2];
136  ovrTexture myEyeTexture[2];
137  ovrLayerEyeFov myLayer;
138 
139  osg::ref_ptr<OculusTextureBuffer> myTextureBuffer[2];
140  osg::ref_ptr<OculusMirrorTexture> myMirrorTexture;
141 
143 
146 
147  osg::ref_ptr<osg::Camera> myRTTCameras[2];
148  osg::ref_ptr<osg::Texture2D> myLeftDepthTexture;
149  osg::ref_ptr<osg::Texture2D> myRightDepthTexture;
150 
151  double myYaw;
153  osg::Vec3d myHMDOffset;
154 
155  osg::ref_ptr<DtOculusDrawable> myOculusDrawable;
156  osg::ref_ptr<osg::Group> myOculusDrawableGroup;
158 
159  osg::ref_ptr<osg::Billboard> myHUDBillboard;
160  osg::ref_ptr<osg::MatrixTransform> myHUDMatrixTransform;
161 
162  osg::ref_ptr<osg::GraphicsContext::SwapCallback> mySwapCallback;
163 
165 
166 #ifdef LEAP_SUPPORT
167  Leap::Controller myLeapController;
168  double myLastSimulationTime;
169 #endif
170  };
171 
175  {
176  public:
178  virtual DtChannel* create(DtDe& de, DtWindow* window, DtChannelConfiguration& config);
179  };
180 
185  class DT_DLL_VRVOCULUSCHANNELPLUGIN DtOculusDrawable : public osg::Drawable
186  {
187  public:
189  DtOculusDrawable(DtOculusChannel* channel) : myOculusChannel(channel) {};
190 
193  virtual void drawImplementation(osg::RenderInfo& renderInfo) const
194  {
195  DtOculusDrawable *mutableThis = const_cast< DtOculusDrawable *>(this);
196  mutableThis->myOculusChannel->initializeOculusDevice(renderInfo);
197  }
198 
199  virtual Object* cloneType() const {
200  return new DtOculusDrawable(myOculusChannel);
201  }
202  virtual Object* clone(const osg::CopyOp& copyop) const {
203  return new DtOculusDrawable(myOculusChannel);
204  }
205  protected:
207  };
208 
209  class DT_DLL_VRVOCULUSCHANNELPLUGIN DtOculusSwapCallback : public osg::GraphicsContext::SwapCallback
210  {
211  public:
212  DtOculusSwapCallback(DtOculusChannel* channel) : myChannel(channel) {};
213  void swapBuffersImplementation(osg::GraphicsContext *);
214 
215  protected:
217  };
218 }

Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)