VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtVarjoProvider.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2024 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
6 #pragma once
7 
11 
12 
15 
16 #include <vrvUtil/DtQuat.h>
17 #include <matrix/vlVector.h>
18 
19 #include <osg/Matrixd>
20 #include <osg/RenderInfo>
21 
24 
25 #include <array>
26 #include <string>
27 #include <thread>
28 
29 #include <Varjo.h>
30 #include <Varjo_events.h>
31 #include <Varjo_layers.h>
32 #include <Varjo_mr.h>
33 #include <Varjo_world.h>
34 
35 
36 #define VARJO_USE_GAZE 1
37 
38 namespace makVrv
39 {
40 
41  class DtVirtualRealityChannel;
42  class DtVrsGazeMapUpdater;
43  class DtVarjoBeginFrameCallback;
44  class DtVarjoWaitForSyncThread;
45  class DtOpenVrWorldAnchor;
46 
49 
51  {
52  public:
55 
58  struct ViewSettings
59  {
61  ViewSettings(): myNearClip(1), myFarClip(10)
62  {
63  //intentional nop
64  }
65 
66  double myNearClip;
67  double myFarClip;
68  };
69 
70  public:
72  DtVarjoProvider(DtDe& de);
73 
75  virtual ~DtVarjoProvider();
76 
77  private:
80 
83 
85  DtVarjoProvider& operator=(const DtVarjoProvider&);
86 
87  public:
88 
90  virtual DtSubmitOverlayCallback* createOverlayCallback(osg::Texture* tex, DtDe& de, DtVirtualRealityDriver& driver);
91 
94 
96  virtual const std::string& providerName();
97 
99  virtual const std::string& deviceName();
100 
102  virtual bool initializeVR();
103 
105  virtual bool hasFocusViews();
106 
108  virtual bool useVrs();
109 
111  virtual DtVariableRateShadingImageUpdater* findVrsUpdater(DtVirtualRealityChannel* channel);
112 
114  virtual void getRecommendedRenderTargetSize(int& width, int& height, vrvVirtualReality::DtEye whichEye);
115 
117  virtual DtSwapChain* allocateSwapChain(vrvVirtualReality::DtEye whichEye, bool isOverlay);
118 
120  virtual void getProjectionAngles(vrvVirtualReality::DtEye eye, double& left, double& right, double& bottom, double& top, double znear, double zfar);
121 
123  virtual osg::Matrixd getEyeToHeadTransform(vrvVirtualReality::DtEye eye);
124 
126  virtual void commitEyeTexture(osg::RenderInfo& renderInfo, DtSwapChain* swapChain);
127 
129  virtual void commitHudTexture(osg::RenderInfo& renderInfo, DtSwapChain* swapChain);
130 
132  virtual void updateOverlayDimensions(float width, float height, float distance, int pixWidth, int pixHeight);
133 
135  virtual void tick();
136 
138  virtual void beginFrame();
139 
141  virtual void beginRendering();
142 
144  virtual void endRendering();
145 
147  virtual bool getHmdPose(DtVector& pos, DtQuat& ori);
148 
150  virtual void setHmdPoseOffset(const DtVector& pos, const DtQuat& ori);
151 
153  virtual bool getTrackedPose(DtVector& pos, DtQuat& ori, int index);
154 
156  virtual const std::unordered_map<int64_t, DtTrackedMarker>& getTrackedMarkers() const;
157 
159  virtual bool reset();
160 
162  virtual void triggerAction1();
163 
165  virtual bool shutdown();
166 
168  virtual bool hasTrackedCamera();
169 
171  virtual DtTrackedCamera* findTrackedCamera();
172 
174  virtual DtMixedRealityMask* findMixedRealityMask();
175 
177  virtual vrvVirtualReality::DtVrOverlayMode overlayMode();
178 
180  virtual void startMixedReality();
181 
183  virtual void stopMixedReality();
184 
186  virtual bool supportsMixedReality();
187 
189  virtual bool supportsDepthBufferSubmission();
190 
192  virtual bool supportsRealWorldDepthTesting();
193 
195  virtual void startRealWorldDepthTesting();
196 
198  virtual void stopRealWorldDepthTesting();
199 
201  void setOverlayEnabled(bool enabled);
202 
203  // need to do this to turn on mr
204  void calibrateEyeTracking();
205 
207 
209  varjo_Session* findVarjoSystem() const;
210 
211  public:
212 
215  static bool isVrAvailable();
216 
217  protected:
218 
220  virtual void initViewports();
221 
223  void commitEyeTexture(unsigned int viewIndex, varjo_Viewport& viewPort, int layer, varjo_SwapChain* swapChain, varjo_SwapChain* depthSwapChain);
224 
226  void commitHudTexture(unsigned int viewIndex, varjo_Viewport viewPort, varjo_SwapChain* swapChain);
227 
229  virtual void updateEyeProjections();
230 
232  virtual void updateEyeProjections(unsigned int viewIndex, DtVirtualRealityChannel* vrChannel, unsigned int layer, bool updateVarjoViewOnly = false, bool isHudView = false);
233 
235  varjo_Viewport calculateFocusRect(varjo_Viewport contextViewport, const double focusProjectionMatrix[16], const double contextProjectionMatrix[16]);
236 
237 #if VARJO_USE_GAZE == 1
238  varjo_Error initGaze();
240 
242  bool getGazeNormalizedCoords(const osg::Matrixd& leftProjection, const osg::Matrixd& rightProjection,
243  osg::Vec2* left, osg::Vec2* right) const;
244 #endif
245 
246  protected:
247 
248  varjo_Session* myVarjoSession;
249  int32_t myViewCount;
250  std::vector<varjo_Viewport> myViewports;
251  std::vector<ViewSettings> myViewSettings;
253  std::vector<varjo_LayerMultiProjView> myMultiprojectionViews;
254  std::vector<varjo_ViewExtensionDepth> myExtDepthViews;
255  std::vector<varjo_ViewExtensionDepthTestRange> myExtDepthTestRangeViews;
256  std::vector<varjo_LayerMultiProjView> myHudViews;
257  varjo_FrameInfo* myFrameInfo;
258  std::string myDeviceName;
259 
262  osg::Vec3d myHmdPostionOffset;
264 
265  varjo_World* myVarjoWorld;
266  std::unordered_map<int64_t, DtTrackedMarker> myTrackedMarkers;
267 
269  };
270 }
Drawable and pre Drawcallback that draw full screen quad to update vrs image.
std::vector< varjo_LayerMultiProjView > myMultiprojectionViews
Definition: DtVarjoProvider.h:253
std::vector< varjo_ViewExtensionDepth > myExtDepthViews
Definition: DtVarjoProvider.h:254
bool myEyeTrackingInitalized
Definition: DtVarjoProvider.h:260
Contains DLL export macros.
osg::Vec3d myHmdPostionOffset
Definition: DtVarjoProvider.h:262
std::vector< ViewSettings > myViewSettings
Definition: DtVarjoProvider.h:251
bool myHaveCalibratedEyeTracking
Definition: DtVarjoProvider.h:261
ViewSettings()
CTOR.
Definition: DtVarjoProvider.h:61
A Varjo implementation of the DtVirtualRealityProvider abstract base class.
Definition: DtVarjoProvider.h:50
An abstract interface that provides VR System API services.
DtOpenVrWorldAnchor * myAnchor
Definition: DtVarjoProvider.h:268
A Tracked camera is typically attached to the HMD and can provide position and orientation data in ad...
Definition: DtTrackedCamera.h:27
double myFarClip
Definition: DtVarjoProvider.h:67
Base class for GPU updates of the variable rate shading image Draw a full screen quad using a shader ...
Definition: DtVariableRateShadingImageUpdater.h:26
std::vector< varjo_Viewport > myViewports
Definition: DtVarjoProvider.h:250
A driver that manages virtual reality HMD and input devices.
Definition: DtVirtualRealityDriver.h:54
An OpenVR implementation of the DtVirtualRealityProvider abstract base class.
Definition: DtOpenVrWorldAnchor.h:39
#define DT_DLL_VRVVR
Definition: vrvVirtualReality.h:19
DtEye
A virtual reality eye.
Definition: vrvVirtualReality.h:37
varjo_Session * myVarjoSession
Definition: DtVarjoProvider.h:248
osg::Quat myHmdRotationOffset
Definition: DtVarjoProvider.h:263
DT_DLL_VRVCORE double distance(const makVrv::DtCoordinateSystem &, const DtVector &from, const DtVector &to)
Returns the distance from the two points. Coordinates are in local database coordinates The coordinat...
Base implementation of a texture swapchain.
Definition: DtSwapChain.h:37
std::vector< varjo_ViewExtensionDepthTestRange > myExtDepthTestRangeViews
Definition: DtVarjoProvider.h:255
An abstract interface that provides VR System API services. Providers are created and provided to the...
Definition: DtVirtualRealityProvider.h:47
Contains makVrv::DtQuat class.
DtVrOverlayMode
Virtual reality render mode.
Definition: vrvVirtualReality.h:63
A VRV channel that represents the eyes of the HMD A Virtual Reality channel can render in a few diffe...
Definition: DtVirtualRealityChannel.h:30
Object to handle rendering a mixed reality mask object into the scene. Typically the it renders an ob...
Definition: DtMixedRealityMask.h:38
An OSG camera callback that will submit the channel to the underlying VR system as an overlay channel...
Definition: DtSubmitOverlayCallback.h:32
friend DtVarjoBeginFrameCallback
Definition: DtVarjoProvider.h:53
varjo_World * myVarjoWorld
Definition: DtVarjoProvider.h:265
bool myUseDepthLayers
Definition: DtVarjoProvider.h:252
std::vector< varjo_LayerMultiProjView > myHudViews
Definition: DtVarjoProvider.h:256
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:76
A utility Quaternion class.
Definition: DtQuat.h:19
std::unordered_map< int64_t, DtTrackedMarker > myTrackedMarkers
Definition: DtVarjoProvider.h:266
varjo_FrameInfo * myFrameInfo
Definition: DtVarjoProvider.h:257
double myNearClip
Definition: DtVarjoProvider.h:66
friend DtVarjoWaitForSyncThread
Definition: DtVarjoProvider.h:54
Wraps functionality of Variable Rate Shading Image.
std::string myDeviceName
Definition: DtVarjoProvider.h:258
A post processing effect responsible for submitting and mirroring the eye views to the VR subsystem...
Definition: DtVirtualRealityPostProcessor.h:34
An OSG camera callback that will submit the channel to the underlying VR system as an overlay channel...
Definition: DtSubmitViewCallback.h:30
Holds settings related to a view.
Definition: DtVarjoProvider.h:58
int32_t myViewCount
Definition: DtVarjoProvider.h:249

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)