File indexing completed on 2026-09-10 09:15:50
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
0048 public:
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
0082 virtual bool HasProjectionFrustums() const = 0;
0083
0084
0085 virtual void ProcessEvents() = 0;
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095 virtual bool SubmitEye(void* theTexture,
0096 Aspect_GraphicsLibrary theGraphicsLib,
0097 Aspect_ColorSpace theColorSpace,
0098 Aspect_Eye theEye) = 0;
0099
0100
0101 Standard_Real UnitFactor() const { return myUnitFactor; }
0102
0103
0104 void SetUnitFactor(Standard_Real theFactor) { myUnitFactor = theFactor; }
0105
0106
0107 Standard_Real Aspect() const { return myAspect; }
0108
0109
0110 Standard_Real FieldOfView() const { return myFieldOfView; }
0111
0112
0113
0114 Standard_Real IOD() const { return myIod; }
0115
0116
0117 Standard_ShortReal DisplayFrequency() const { return myDispFreq; }
0118
0119
0120
0121 const Aspect_FrustumLRBT<double>& ProjectionFrustum(Aspect_Eye theEye) const
0122 {
0123 return theEye == Aspect_Eye_Right ? myFrustumR : myFrustumL;
0124 }
0125
0126
0127
0128
0129
0130
0131 const gp_Trsf& HeadPose() const { return myHeadPose; }
0132
0133
0134 gp_Trsf LeftHandPose() const
0135 {
0136 const Standard_Integer aDevice = NamedTrackedDevice(Aspect_XRTrackedDeviceRole_LeftHand);
0137 return aDevice != -1 ? myTrackedPoses[aDevice].Orientation : gp_Trsf();
0138 }
0139
0140
0141 gp_Trsf RightHandPose() const
0142 {
0143 const Standard_Integer aDevice = NamedTrackedDevice(Aspect_XRTrackedDeviceRole_RightHand);
0144 return aDevice != -1 ? myTrackedPoses[aDevice].Orientation : gp_Trsf();
0145 }
0146
0147
0148 const Aspect_TrackedDevicePoseArray& TrackedPoses() const { return myTrackedPoses; }
0149
0150
0151 bool HasTrackedPose(Standard_Integer theDevice) const
0152 {
0153 return myTrackedPoses[theDevice].IsValidPose;
0154 }
0155
0156
0157 virtual Standard_Integer NamedTrackedDevice(Aspect_XRTrackedDeviceRole theDevice) const = 0;
0158
0159
0160
0161
0162
0163 Handle(Graphic3d_ArrayOfTriangles) LoadRenderModel(Standard_Integer theDevice,
0164 Handle(Image_Texture)& theTexture)
0165 {
0166 return loadRenderModel(theDevice, true, theTexture);
0167 }
0168
0169
0170
0171
0172
0173
0174 Handle(Graphic3d_ArrayOfTriangles) LoadRenderModel(Standard_Integer theDevice,
0175 Standard_Boolean theToApplyUnitFactor,
0176 Handle(Image_Texture)& theTexture)
0177 {
0178 return loadRenderModel(theDevice, theToApplyUnitFactor, theTexture);
0179 }
0180
0181
0182
0183 virtual Aspect_XRDigitalActionData GetDigitalActionData(
0184 const Handle(Aspect_XRAction)& theAction) const = 0;
0185
0186
0187
0188 virtual Aspect_XRAnalogActionData GetAnalogActionData(
0189 const Handle(Aspect_XRAction)& theAction) const = 0;
0190
0191
0192
0193
0194 virtual Aspect_XRPoseActionData GetPoseActionDataForNextFrame(
0195 const Handle(Aspect_XRAction)& theAction) const = 0;
0196
0197
0198 Standard_EXPORT void TriggerHapticVibrationAction(const Handle(Aspect_XRAction)& theAction,
0199 const Aspect_XRHapticActionData& theParams);
0200
0201
0202 Standard_EXPORT void AbortHapticVibrationAction(const Handle(Aspect_XRAction)& theAction);
0203
0204
0205 TrackingUniverseOrigin TrackingOrigin() const { return myTrackOrigin; }
0206
0207
0208 virtual void SetTrackingOrigin(TrackingUniverseOrigin theOrigin) { myTrackOrigin = theOrigin; }
0209
0210
0211 const Handle(Aspect_XRAction)& GenericAction(Aspect_XRTrackedDeviceRole theDevice,
0212 Aspect_XRGenericAction theAction) const
0213 {
0214 const NCollection_Array1<Handle(Aspect_XRAction)>& anActions = myRoleActions[theDevice];
0215 return anActions[theAction];
0216 }
0217
0218 public:
0219
0220 enum InfoString
0221 {
0222 InfoString_Vendor,
0223 InfoString_Device,
0224 InfoString_Tracker,
0225 InfoString_SerialNumber,
0226 };
0227
0228
0229 virtual TCollection_AsciiString GetString(InfoString theInfo) const = 0;
0230
0231 protected:
0232
0233 Standard_EXPORT Aspect_XRSession();
0234
0235
0236
0237
0238
0239
0240 virtual Handle(Graphic3d_ArrayOfTriangles) loadRenderModel(Standard_Integer theDevice,
0241 Standard_Boolean theToApplyUnitFactor,
0242 Handle(Image_Texture)& theTexture) = 0;
0243
0244
0245 virtual void triggerHapticVibrationAction(const Handle(Aspect_XRAction)& theAction,
0246 const Aspect_XRHapticActionData& theParams) = 0;
0247
0248 protected:
0249 NCollection_Array1<Handle(Aspect_XRAction)>
0250
0251 myRoleActions[Aspect_XRTrackedDeviceRole_NB];
0252 Aspect_XRActionSetMap myActionSets;
0253 TrackingUniverseOrigin myTrackOrigin;
0254 Aspect_TrackedDevicePoseArray myTrackedPoses;
0255 gp_Trsf myHeadPose;
0256 NCollection_Vec2<int> myRendSize;
0257 Aspect_FrustumLRBT<double> myFrustumL;
0258 Aspect_FrustumLRBT<double> myFrustumR;
0259 Standard_Real myUnitFactor;
0260
0261 Standard_Real myAspect;
0262 Standard_Real myFieldOfView;
0263 Standard_Real myIod;
0264 Standard_ShortReal myDispFreq;
0265 };
0266
0267 #endif