VR-Forces 4.5 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 
14 
15 #include <vrvOsg/DtOsgChannel.h>
16 
17 #include <vrvUtil/DtQuat.h>
18 
20 
21 #include <OVR_CAPI.h>
22 #include <OVR_CAPI_GL.h>
23 
24 
25 #ifdef LEAP_SUPPORT
26 #include <Leap.h>
27 #endif
28 
29 union ovrGLConfig;
30 
31 namespace makVrv
32 {
36  {
37  protected:
38  friend class DtOculusChannelCreator;
39  friend class DtOculusDrawable;
40  friend class DtOculusSwapCallback;
41 
45  DtOculusChannel(DtDe& de, DtOsgWindow* window,
46  DtChannelConfiguration& config);
47 
49  virtual ~DtOculusChannel();
50 
52 
53 
55  virtual bool initialize();
56 
60  virtual void initializeOculusDevice(osg::RenderInfo& renderInfo);
61 
63  virtual void initializeOculusChannel();
65 
67  virtual void update();
68 
71  virtual void updateProjection();
72 
75  virtual void projectFor3D();
76 
78  virtual void setupCullVisitor(osg::observer_ptr<osg::Camera> camera);
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 
100  virtual void onPreTick();
101 
105  virtual void onPostTick();
106 
109  virtual void onShutdown();
110 
113  //virtual void warnOnOVRErrors();
114 
119 
120  virtual void setMirroring(int view);
121  virtual int mirroring();
123 
125  virtual std::vector<const osg::Camera*> getShadowableCameras() const;
126 
127  virtual DtQuat hmdOrientation() {return DtQuat(myHmdOrientation.x(), myHmdOrientation.y(), myHmdOrientation.z(), myHmdOrientation.w()); }
128  virtual DtVector hmdPosition() {return DtVector(myHmdPosition.x(), myHmdPosition.y(), myHmdPosition.z()); }
129 
130  protected:
131  void updateEyes(double znear = 0.015, double zfar = 10000);
132 
133  ovrSession mySession;
134  ovrHmdDesc myHmdDesc;
135  ovrPosef myEyeRenderPose[2];
136  ovrEyeRenderDesc myEyeRenderDesc[2];
137  ovrFovPort myEyeFov[2];
138  ovrLayerEyeFov myLayer;
139 
140  osg::ref_ptr<OculusTextureBuffer> myTextureBuffer[2];
141  osg::ref_ptr<OculusMirrorTexture> myMirrorTexture;
142 
144 
147 
148  osg::ref_ptr<osg::Camera> myRTTCameras[2];
149  osg::ref_ptr<osg::Texture2D> myLeftDepthTexture;
150  osg::ref_ptr<osg::Texture2D> myRightDepthTexture;
151 
152  osg::Quat myHmdOrientation;
153  osg::Vec3d myHmdPosition;
156  osg::Matrixf myLeftEyeViewMatrix;
157  osg::Matrixf myRightEyeViewMatrix;
158 
159  osg::ref_ptr<DtOculusDrawable> myOculusDrawable;
160  osg::ref_ptr<osg::Group> myOculusDrawableGroup;
162 
163  osg::ref_ptr<osg::Billboard> myHUDBillboard;
164  osg::ref_ptr<osg::MatrixTransform> myHUDMatrixTransform;
165 
166  osg::ref_ptr<osg::GraphicsContext::SwapCallback> mySwapCallback;
167 
169 
170 #ifdef LEAP_SUPPORT
171  Leap::Controller myLeapController;
172  double myLastSimulationTime;
173 #endif
174  };
175 
179  {
180  public:
182  virtual DtChannel* create(DtDe& de, DtWindow* window, DtChannelConfiguration& config);
183  };
184 
189  class DT_DLL_VRVOCULUSCHANNELPLUGIN DtOculusDrawable : public osg::Drawable
190  {
191  public:
193  DtOculusDrawable(DtOculusChannel* channel) : myOculusChannel(channel) {};
194 
197  virtual void drawImplementation(osg::RenderInfo& renderInfo) const
198  {
199  DtOculusDrawable *mutableThis = const_cast< DtOculusDrawable *>(this);
200  mutableThis->myOculusChannel->initializeOculusDevice(renderInfo);
201  }
202 
203  virtual Object* cloneType() const {
204  return new DtOculusDrawable(myOculusChannel);
205  }
206  virtual Object* clone(const osg::CopyOp& copyop) const {
207  return new DtOculusDrawable(myOculusChannel);
208  }
209  protected:
211  };
212 
213  class DT_DLL_VRVOCULUSCHANNELPLUGIN DtOculusSwapCallback : public osg::GraphicsContext::SwapCallback
214  {
215  public:
216  DtOculusSwapCallback(DtOculusChannel* channel) : myChannel(channel) {};
217  void swapBuffersImplementation(osg::GraphicsContext *);
218 
219  protected:
221  };
222 }

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)