VR-Forces 4.3 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 namespace makVrv
24 {
25  // With SDK based rendering OVR will take care of calling swapbuffers;
26  // this null implementation will prevent OSG from also swapping which
27  // causes flicker.
28  class DtNullSwapCallback : public osg::GraphicsContext::SwapCallback
29  {
30  public:
31  void swapBuffersImplementation(osg::GraphicsContext *) {};
32  };
33 
37  {
38  protected:
39  friend class DtOculusChannelCreator;
40  friend class DtOculusDrawable;
41 
45  DtOculusChannel(ovrHmd theHMD, DtDe& de, DtOsgWindow* window, DtChannelConfiguration& config);
46 
48 
49 
51  virtual bool initialize();
52 
56  virtual void initializeOculusDevice();
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 
83  osg::Camera* createRTTCamera(osg::Texture* tex, int order);
84 
88  virtual double renderTargetScaleFactor();
89 
90  public:
92  virtual ~DtOculusChannel();
93 
95  virtual void resetSensor();
96 
98  virtual void resetYaw();
99 
102  virtual void onPreTick();
103 
107  virtual void onPostTick();
108 
109  // Sets myOculusInitialized to false and zeros the myHMD pointer. The
110  // HMD itself is destroyed by the plugin.
111  virtual void onShutdown();
112 
113  protected:
114  ovrHmd myHMD;
115  ovrPosef myEyeRenderPose[2];
116  ovrEyeRenderDesc myEyeRenderDesc[2];
117  ovrFovPort myEyeFov[2];
118  ovrTexture myEyeTexture[2];
119 
121 
122  osg::ref_ptr<osg::Camera> myLeftRTTCamera;
123  osg::ref_ptr<osg::Camera> myRightRTTCamera;
124 
125  double myYaw;
127  osg::Vec3d myHMDOffset;
128 
129  osg::ref_ptr<DtOculusDrawable> myOculusDrawable;
130  osg::ref_ptr<osg::Group> myOculusDrawableGroup;
132 
133  osg::ref_ptr<osg::Billboard> myHUDBillboard;
134  osg::ref_ptr<osg::MatrixTransform> myHUDMatrixTransform;
135 
136  osg::ref_ptr<DtNullSwapCallback> mySwapCallback;
137 
139 
140 #ifdef LEAP_SUPPORT
141  Leap::Controller myLeapController;
142  double myLastSimulationTime;
143 #endif
144  };
145 
149  {
150  public:
151  DtOculusChannelCreator(ovrHmd theHMD) : myHMD(theHMD) { }
152 
154  virtual DtChannel* create(DtDe& de, DtWindow* window, DtChannelConfiguration& config);
155 
156  ovrHmd myHMD;
157  };
158 
163  class DT_DLL_VRVOCULUSCHANNELPLUGIN DtOculusDrawable : public osg::Drawable
164  {
165  public:
167  DtOculusDrawable(DtOculusChannel* channel) : myOculusChannel(channel) {};
168 
171  virtual void drawImplementation(osg::RenderInfo& renderInfo) const
172  {
173  DtOculusDrawable *mutableThis = const_cast< DtOculusDrawable *>(this);
174  mutableThis->myOculusChannel->initializeOculusDevice();
175  }
176 
177  virtual Object* cloneType() const {
178  return new DtOculusDrawable(myOculusChannel);
179  }
180  virtual Object* clone(const osg::CopyOp& copyop) const {
181  return new DtOculusDrawable(myOculusChannel);
182  }
183  protected:
185  };
186 }

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)