File indexing completed on 2025-01-18 10:02:59
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _Aspect_XRSession_HeaderFile
0015 #define _Aspect_XRSession_HeaderFile
0016
0017 #include <Aspect_ColorSpace.hxx>
0018 #include <Aspect_Eye.hxx>
0019 #include <Aspect_FrustumLRBT.hxx>
0020 #include <Aspect_GraphicsLibrary.hxx>
0021 #include <Aspect_XRActionSet.hxx>
0022 #include <Aspect_XRAnalogActionData.hxx>
0023 #include <Aspect_XRDigitalActionData.hxx>
0024 #include <Aspect_XRGenericAction.hxx>
0025 #include <Aspect_XRHapticActionData.hxx>
0026 #include <Aspect_XRPoseActionData.hxx>
0027 #include <Aspect_XRTrackedDeviceRole.hxx>
0028 #include <gp_Trsf.hxx>
0029 #include <NCollection_Array1.hxx>
0030
0031 class Graphic3d_ArrayOfTriangles;
0032 class Image_Texture;
0033
0034
0035 class Aspect_XRSession : public Standard_Transient
0036 {
0037 DEFINE_STANDARD_RTTIEXT(Aspect_XRSession, Standard_Transient)
0038 public:
0039
0040
0041 enum TrackingUniverseOrigin
0042 {
0043 TrackingUniverseOrigin_Seated,
0044 TrackingUniverseOrigin_Standing,
0045 };
0046
0047 public:
0048
0049
0050 virtual bool IsOpen() const = 0;
0051
0052
0053 virtual bool Open() = 0;
0054
0055
0056 virtual void Close() = 0;
0057
0058
0059 virtual bool WaitPoses() = 0;
0060
0061
0062 virtual NCollection_Vec2<int> RecommendedViewport() const = 0;
0063
0064
0065 virtual NCollection_Mat4<double> EyeToHeadTransform (Aspect_Eye theEye) const = 0;
0066
0067
0068 NCollection_Mat4<double> HeadToEyeTransform (Aspect_Eye theEye) const
0069 {
0070 NCollection_Mat4<double> aMat;
0071 EyeToHeadTransform (theEye).Inverted (aMat);
0072 return aMat;
0073 }
0074
0075
0076 virtual NCollection_Mat4<double> ProjectionMatrix (Aspect_Eye theEye,
0077 double theZNear,
0078 double theZFar) const = 0;
0079
0080
0081 virtual bool HasProjectionFrustums() const = 0;
0082
0083
0084 virtual void ProcessEvents() = 0;
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094 virtual bool SubmitEye (void* theTexture,
0095 Aspect_GraphicsLibrary theGraphicsLib,
0096 Aspect_ColorSpace theColorSpace,
0097 Aspect_Eye theEye) = 0;
0098
0099
0100 Standard_Real UnitFactor() const { return myUnitFactor; }
0101
0102
0103 void SetUnitFactor (Standard_Real theFactor) { myUnitFactor = theFactor; }
0104
0105
0106 Standard_Real Aspect() const { return myAspect; }
0107
0108
0109 Standard_Real FieldOfView() const { return myFieldOfView; }
0110
0111
0112
0113 Standard_Real IOD() const { return myIod; }
0114
0115
0116 Standard_ShortReal DisplayFrequency() const { return myDispFreq; }
0117
0118
0119
0120 const Aspect_FrustumLRBT<double>& ProjectionFrustum (Aspect_Eye theEye) const
0121 {
0122 return theEye == Aspect_Eye_Right ? myFrustumR : myFrustumL;
0123 }
0124
0125
0126
0127
0128
0129
0130 const gp_Trsf& HeadPose() const { return myHeadPose; }
0131
0132
0133 gp_Trsf LeftHandPose() const
0134 {
0135 const Standard_Integer aDevice = NamedTrackedDevice (Aspect_XRTrackedDeviceRole_LeftHand);
0136 return aDevice != -1 ? myTrackedPoses[aDevice].Orientation : gp_Trsf();
0137 }
0138
0139
0140 gp_Trsf RightHandPose() const
0141 {
0142 const Standard_Integer aDevice = NamedTrackedDevice (Aspect_XRTrackedDeviceRole_RightHand);
0143 return aDevice != -1 ? myTrackedPoses[aDevice].Orientation : gp_Trsf();
0144 }
0145
0146
0147 const Aspect_TrackedDevicePoseArray& TrackedPoses() const { return myTrackedPoses; }
0148
0149
0150 bool HasTrackedPose (Standard_Integer theDevice) const { return myTrackedPoses[theDevice].IsValidPose; }
0151
0152
0153 virtual Standard_Integer NamedTrackedDevice (Aspect_XRTrackedDeviceRole theDevice) const = 0;
0154
0155
0156
0157
0158
0159 Handle(Graphic3d_ArrayOfTriangles) LoadRenderModel (Standard_Integer theDevice,
0160 Handle(Image_Texture)& theTexture)
0161 {
0162 return loadRenderModel (theDevice, true, theTexture);
0163 }
0164
0165
0166
0167
0168
0169
0170 Handle(Graphic3d_ArrayOfTriangles) LoadRenderModel (Standard_Integer theDevice,
0171 Standard_Boolean theToApplyUnitFactor,
0172 Handle(Image_Texture)& theTexture)
0173 {
0174 return loadRenderModel (theDevice, theToApplyUnitFactor, theTexture);
0175 }
0176
0177
0178
0179 virtual Aspect_XRDigitalActionData GetDigitalActionData (const Handle(Aspect_XRAction)& theAction) const = 0;
0180
0181
0182
0183 virtual Aspect_XRAnalogActionData GetAnalogActionData (const Handle(Aspect_XRAction)& theAction) const = 0;
0184
0185
0186
0187
0188 virtual Aspect_XRPoseActionData GetPoseActionDataForNextFrame (const Handle(Aspect_XRAction)& theAction) const = 0;
0189
0190
0191 Standard_EXPORT void TriggerHapticVibrationAction (const Handle(Aspect_XRAction)& theAction,
0192 const Aspect_XRHapticActionData& theParams);
0193
0194
0195 Standard_EXPORT void AbortHapticVibrationAction (const Handle(Aspect_XRAction)& theAction);
0196
0197
0198 TrackingUniverseOrigin TrackingOrigin() const { return myTrackOrigin; }
0199
0200
0201 virtual void SetTrackingOrigin (TrackingUniverseOrigin theOrigin) { myTrackOrigin = theOrigin; }
0202
0203
0204 const Handle(Aspect_XRAction)& GenericAction (Aspect_XRTrackedDeviceRole theDevice,
0205 Aspect_XRGenericAction theAction) const
0206 {
0207 const NCollection_Array1<Handle(Aspect_XRAction)>& anActions = myRoleActions[theDevice];
0208 return anActions[theAction];
0209 }
0210
0211 public:
0212
0213
0214 enum InfoString
0215 {
0216 InfoString_Vendor,
0217 InfoString_Device,
0218 InfoString_Tracker,
0219 InfoString_SerialNumber,
0220 };
0221
0222
0223 virtual TCollection_AsciiString GetString (InfoString theInfo) const = 0;
0224
0225 protected:
0226
0227
0228 Standard_EXPORT Aspect_XRSession();
0229
0230
0231
0232
0233
0234
0235 virtual Handle(Graphic3d_ArrayOfTriangles) loadRenderModel (Standard_Integer theDevice,
0236 Standard_Boolean theToApplyUnitFactor,
0237 Handle(Image_Texture)& theTexture) = 0;
0238
0239
0240 virtual void triggerHapticVibrationAction (const Handle(Aspect_XRAction)& theAction,
0241 const Aspect_XRHapticActionData& theParams) = 0;
0242
0243 protected:
0244
0245 NCollection_Array1<Handle(Aspect_XRAction)>
0246 myRoleActions[Aspect_XRTrackedDeviceRole_NB];
0247 Aspect_XRActionSetMap myActionSets;
0248 TrackingUniverseOrigin myTrackOrigin;
0249 Aspect_TrackedDevicePoseArray myTrackedPoses;
0250 gp_Trsf myHeadPose;
0251 NCollection_Vec2<int> myRendSize;
0252 Aspect_FrustumLRBT<double> myFrustumL;
0253 Aspect_FrustumLRBT<double> myFrustumR;
0254 Standard_Real myUnitFactor;
0255 Standard_Real myAspect;
0256 Standard_Real myFieldOfView;
0257 Standard_Real myIod;
0258 Standard_ShortReal myDispFreq;
0259
0260 };
0261
0262 #endif