Open CASCADE Technology  7.5.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

Aspect_OpenVRSession Class Reference

OpenVR wrapper implementing Aspect_XRSession interface. More...

#include <Aspect_OpenVRSession.hxx>

Inheritance diagram for Aspect_OpenVRSession:
Inheritance graph
[legend]

Public Member Functions

 Aspect_OpenVRSession ()
 Empty constructor. More...
 
virtual ~Aspect_OpenVRSession ()
 Destructor. More...
 
virtual bool IsOpen () const override
 Return TRUE if session is opened. More...
 
virtual bool Open () override
 Initialize session. More...
 
virtual void Close () override
 Release session. More...
 
virtual bool WaitPoses () override
 Fetch actual poses of tracked devices. More...
 
virtual NCollection_Vec2< int > RecommendedViewport () const override
 Return recommended viewport Width x Height for rendering into VR. More...
 
virtual NCollection_Mat4< double > EyeToHeadTransform (Aspect_Eye theEye) const override
 Return transformation from eye to head. vr::GetEyeToHeadTransform() wrapper. More...
 
virtual NCollection_Mat4< double > ProjectionMatrix (Aspect_Eye theEye, double theZNear, double theZFar) const override
 Return projection matrix. More...
 
virtual bool HasProjectionFrustums () const override
 Return TRUE. More...
 
virtual void ProcessEvents () override
 Receive XR events. More...
 
virtual bool SubmitEye (void *theTexture, Aspect_GraphicsLibrary theGraphicsLib, Aspect_ColorSpace theColorSpace, Aspect_Eye theEye) override
 Submit texture eye to XR Composer. More...
 
virtual TCollection_AsciiString GetString (InfoString theInfo) const override
 Query information. More...
 
virtual Standard_Integer NamedTrackedDevice (Aspect_XRTrackedDeviceRole theDevice) const override
 Return index of tracked device of known role. More...
 
virtual Aspect_XRDigitalActionData GetDigitalActionData (const Handle< Aspect_XRAction > &theAction) const override
 Fetch data for digital input action (like button). More...
 
virtual Aspect_XRAnalogActionData GetAnalogActionData (const Handle< Aspect_XRAction > &theAction) const override
 Fetch data for analog input action (like axis). More...
 
virtual Aspect_XRPoseActionData GetPoseActionDataForNextFrame (const Handle< Aspect_XRAction > &theAction) const override
 Fetch data for pose input action (like fingertip position). More...
 
virtual void SetTrackingOrigin (TrackingUniverseOrigin theOrigin) override
 Set tracking origin. More...
 
- Public Member Functions inherited from Aspect_XRSession
NCollection_Mat4< double > HeadToEyeTransform (Aspect_Eye theEye) const
 Return transformation from head to eye. More...
 
Standard_Real UnitFactor () const
 Return unit scale factor defined as scale factor for m (meters); 1.0 by default. More...
 
void SetUnitFactor (Standard_Real theFactor)
 Set unit scale factor. More...
 
Standard_Real Aspect () const
 Return aspect ratio. More...
 
Standard_Real FieldOfView () const
 Return field of view. More...
 
Standard_Real IOD () const
 Return Intra-ocular Distance (IOD); also known as Interpupillary Distance (IPD). Defined in meters by default (. More...
 
Standard_ShortReal DisplayFrequency () const
 Return display frequency or 0 if unknown. More...
 
const Aspect_FrustumLRBT< double > & ProjectionFrustum (Aspect_Eye theEye) const
 Return projection frustum. More...
 
const gp_TrsfHeadPose () const
 Return head orientation in right-handed system: +y is up +x is to the right -z is forward Distance unit is meters by default (. More...
 
gp_Trsf LeftHandPose () const
 Return left hand orientation. More...
 
gp_Trsf RightHandPose () const
 Return right hand orientation. More...
 
const Aspect_TrackedDevicePoseArrayTrackedPoses () const
 Return number of tracked poses array. More...
 
bool HasTrackedPose (Standard_Integer theDevice) const
 Return TRUE if device orientation is defined. More...
 
Handle< Graphic3d_ArrayOfTrianglesLoadRenderModel (Standard_Integer theDevice, Handle< Image_Texture > &theTexture)
 Load model for displaying device. More...
 
Handle< Graphic3d_ArrayOfTrianglesLoadRenderModel (Standard_Integer theDevice, Standard_Boolean theToApplyUnitFactor, Handle< Image_Texture > &theTexture)
 Load model for displaying device. More...
 
void TriggerHapticVibrationAction (const Handle< Aspect_XRAction > &theAction, const Aspect_XRHapticActionData &theParams)
 Trigger vibration. More...
 
void AbortHapticVibrationAction (const Handle< Aspect_XRAction > &theAction)
 Abort vibration. More...
 
TrackingUniverseOrigin TrackingOrigin () const
 Return tracking origin. More...
 
const Handle< Aspect_XRAction > & GenericAction (Aspect_XRTrackedDeviceRole theDevice, Aspect_XRGenericAction theAction) const
 Return generic action for specific hand or NULL if undefined. More...
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor. More...
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing. More...
 
Standard_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter. More...
 
virtual ~Standard_Transient ()
 Destructor must be virtual. More...
 
virtual void Delete () const
 Memory deallocator for transient classes. More...
 
virtual const opencascade::handle< Standard_Type > & DynamicType () const
 Returns a type descriptor about this object. More...
 
Standard_Boolean IsInstance (const opencascade::handle< Standard_Type > &theType) const
 Returns a true value if this is an instance of Type. More...
 
Standard_Boolean IsInstance (const Standard_CString theTypeName) const
 Returns a true value if this is an instance of TypeName. More...
 
Standard_Boolean IsKind (const opencascade::handle< Standard_Type > &theType) const
 Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More...
 
Standard_Boolean IsKind (const Standard_CString theTypeName) const
 Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More...
 
Standard_TransientThis () const
 Returns non-const pointer to this object (like const_cast). For protection against creating handle to objects allocated in stack or call from constructor, it will raise exception Standard_ProgramError if reference counter is zero. More...
 
Standard_Integer GetRefCount () const
 Get the reference counter of this object. More...
 
void IncrementRefCounter () const
 Increments the reference counter of this object. More...
 
Standard_Integer DecrementRefCounter () const
 Decrements the reference counter of this object; returns the decremented value. More...
 

Static Public Member Functions

static bool IsHmdPresent ()
 Return TRUE if an HMD may be presented on the system (e.g. to show VR checkbox in application GUI). This is fast check, and even if it returns TRUE, opening session may fail. More...
 
- Static Public Member Functions inherited from Standard_Transient
static const char * get_type_name ()
 Returns a type descriptor about this object. More...
 
static const opencascade::handle< Standard_Type > & get_type_descriptor ()
 Returns type descriptor of Standard_Transient class. More...
 

Protected Member Functions

TCollection_AsciiString defaultActionsManifest ()
 Find location of default actions manifest file (based on CSF_OCCTResourcePath or CASROOT variables). More...
 
void closeVR ()
 Release OpenVR device. More...
 
virtual void updateProjectionFrustums ()
 Update projection frustums. More...
 
virtual bool initInput ()
 Init VR input. More...
 
virtual void onTrackedDeviceActivated (Standard_Integer theDeviceIndex)
 Handle tracked device activation. More...
 
virtual void onTrackedDeviceDeactivated (Standard_Integer theDeviceIndex)
 Handle tracked device deactivation. More...
 
virtual void onTrackedDeviceUpdated (Standard_Integer theDeviceIndex)
 Handle tracked device update. More...
 
virtual void triggerHapticVibrationAction (const Handle< Aspect_XRAction > &theAction, const Aspect_XRHapticActionData &theParams) override
 Trigger vibration. More...
 
virtual Handle< Graphic3d_ArrayOfTrianglesloadRenderModel (Standard_Integer theDevice, Standard_Boolean theToApplyUnitFactor, Handle< Image_Texture > &theTexture) override
 Return model for displaying device. More...
 
void * getVRSystem () const
 Access vr::IVRSystem* - OpenVR session object. More...
 
- Protected Member Functions inherited from Aspect_XRSession
 Aspect_XRSession ()
 Empty constructor. More...
 

Protected Attributes

VRContext * myContext
 
TCollection_AsciiString myActionsManifest
 
- Protected Attributes inherited from Aspect_XRSession
NCollection_Array1< Handle< Aspect_XRAction > > myRoleActions [Aspect_XRTrackedDeviceRole_NB]
 generic actions More...
 
Aspect_XRActionSetMap myActionSets
 actions sets More...
 
TrackingUniverseOrigin myTrackOrigin
 tracking origin More...
 
Aspect_TrackedDevicePoseArray myTrackedPoses
 array of tracked poses More...
 
gp_Trsf myHeadPose
 head orientation More...
 
NCollection_Vec2< int > myRendSize
 viewport Width x Height for rendering into VR More...
 
Aspect_FrustumLRBT< double > myFrustumL
 left eye projection frustum More...
 
Aspect_FrustumLRBT< double > myFrustumR
 right eye projection frustum More...
 
Standard_Real myUnitFactor
 unit scale factor defined as scale factor for m (meters) More...
 
Standard_Real myAspect
 aspect ratio More...
 
Standard_Real myFieldOfView
 field of view More...
 
Standard_Real myIod
 intra-ocular distance in meters More...
 
Standard_ShortReal myDispFreq
 display frequency More...
 

Additional Inherited Members

- Public Types inherited from Aspect_XRSession
enum  TrackingUniverseOrigin { TrackingUniverseOrigin_Seated, TrackingUniverseOrigin_Standing }
 Identifies which style of tracking origin the application wants to use for the poses it is requesting. More...
 
enum  InfoString { InfoString_Vendor, InfoString_Device, InfoString_Tracker, InfoString_SerialNumber }
 Info string enumeration. More...
 
- Public Types inherited from Standard_Transient
typedef void base_type
 Returns a type descriptor about this object. More...
 

Detailed Description

OpenVR wrapper implementing Aspect_XRSession interface.

Constructor & Destructor Documentation

◆ Aspect_OpenVRSession()

Aspect_OpenVRSession::Aspect_OpenVRSession ( )

Empty constructor.

◆ ~Aspect_OpenVRSession()

virtual Aspect_OpenVRSession::~Aspect_OpenVRSession ( )
virtual

Destructor.

Member Function Documentation

◆ Close()

virtual void Aspect_OpenVRSession::Close ( )
overridevirtual

Release session.

Implements Aspect_XRSession.

◆ closeVR()

void Aspect_OpenVRSession::closeVR ( )
protected

Release OpenVR device.

◆ defaultActionsManifest()

TCollection_AsciiString Aspect_OpenVRSession::defaultActionsManifest ( )
protected

Find location of default actions manifest file (based on CSF_OCCTResourcePath or CASROOT variables).

◆ EyeToHeadTransform()

virtual NCollection_Mat4<double> Aspect_OpenVRSession::EyeToHeadTransform ( Aspect_Eye  theEye) const
overridevirtual

Return transformation from eye to head. vr::GetEyeToHeadTransform() wrapper.

Implements Aspect_XRSession.

◆ GetAnalogActionData()

virtual Aspect_XRAnalogActionData Aspect_OpenVRSession::GetAnalogActionData ( const Handle< Aspect_XRAction > &  theAction) const
overridevirtual

Fetch data for analog input action (like axis).

Implements Aspect_XRSession.

◆ GetDigitalActionData()

virtual Aspect_XRDigitalActionData Aspect_OpenVRSession::GetDigitalActionData ( const Handle< Aspect_XRAction > &  theAction) const
overridevirtual

Fetch data for digital input action (like button).

Implements Aspect_XRSession.

◆ GetPoseActionDataForNextFrame()

virtual Aspect_XRPoseActionData Aspect_OpenVRSession::GetPoseActionDataForNextFrame ( const Handle< Aspect_XRAction > &  theAction) const
overridevirtual

Fetch data for pose input action (like fingertip position).

Implements Aspect_XRSession.

◆ GetString()

virtual TCollection_AsciiString Aspect_OpenVRSession::GetString ( InfoString  theInfo) const
overridevirtual

Query information.

Implements Aspect_XRSession.

◆ getVRSystem()

void* Aspect_OpenVRSession::getVRSystem ( ) const
protected

Access vr::IVRSystem* - OpenVR session object.

◆ HasProjectionFrustums()

virtual bool Aspect_OpenVRSession::HasProjectionFrustums ( ) const
inlineoverridevirtual

Return TRUE.

Implements Aspect_XRSession.

◆ initInput()

virtual bool Aspect_OpenVRSession::initInput ( )
protectedvirtual

Init VR input.

◆ IsHmdPresent()

static bool Aspect_OpenVRSession::IsHmdPresent ( )
static

Return TRUE if an HMD may be presented on the system (e.g. to show VR checkbox in application GUI). This is fast check, and even if it returns TRUE, opening session may fail.

◆ IsOpen()

virtual bool Aspect_OpenVRSession::IsOpen ( ) const
overridevirtual

Return TRUE if session is opened.

Implements Aspect_XRSession.

◆ loadRenderModel()

virtual Handle< Graphic3d_ArrayOfTriangles > Aspect_OpenVRSession::loadRenderModel ( Standard_Integer  theDevice,
Standard_Boolean  theToApplyUnitFactor,
Handle< Image_Texture > &  theTexture 
)
overrideprotectedvirtual

Return model for displaying device.

Implements Aspect_XRSession.

◆ NamedTrackedDevice()

virtual Standard_Integer Aspect_OpenVRSession::NamedTrackedDevice ( Aspect_XRTrackedDeviceRole  theDevice) const
overridevirtual

Return index of tracked device of known role.

Implements Aspect_XRSession.

◆ onTrackedDeviceActivated()

virtual void Aspect_OpenVRSession::onTrackedDeviceActivated ( Standard_Integer  theDeviceIndex)
protectedvirtual

Handle tracked device activation.

◆ onTrackedDeviceDeactivated()

virtual void Aspect_OpenVRSession::onTrackedDeviceDeactivated ( Standard_Integer  theDeviceIndex)
protectedvirtual

Handle tracked device deactivation.

◆ onTrackedDeviceUpdated()

virtual void Aspect_OpenVRSession::onTrackedDeviceUpdated ( Standard_Integer  theDeviceIndex)
protectedvirtual

Handle tracked device update.

◆ Open()

virtual bool Aspect_OpenVRSession::Open ( )
overridevirtual

Initialize session.

Implements Aspect_XRSession.

◆ ProcessEvents()

virtual void Aspect_OpenVRSession::ProcessEvents ( )
overridevirtual

Receive XR events.

Implements Aspect_XRSession.

◆ ProjectionMatrix()

virtual NCollection_Mat4<double> Aspect_OpenVRSession::ProjectionMatrix ( Aspect_Eye  theEye,
double  theZNear,
double  theZFar 
) const
overridevirtual

Return projection matrix.

Implements Aspect_XRSession.

◆ RecommendedViewport()

virtual NCollection_Vec2<int> Aspect_OpenVRSession::RecommendedViewport ( ) const
inlineoverridevirtual

Return recommended viewport Width x Height for rendering into VR.

Implements Aspect_XRSession.

◆ SetTrackingOrigin()

virtual void Aspect_OpenVRSession::SetTrackingOrigin ( TrackingUniverseOrigin  theOrigin)
overridevirtual

Set tracking origin.

Reimplemented from Aspect_XRSession.

◆ SubmitEye()

virtual bool Aspect_OpenVRSession::SubmitEye ( void *  theTexture,
Aspect_GraphicsLibrary  theGraphicsLib,
Aspect_ColorSpace  theColorSpace,
Aspect_Eye  theEye 
)
overridevirtual

Submit texture eye to XR Composer.

Parameters
theTexture[in] texture handle
theGraphicsLib[in] graphics library in which texture handle is defined
theColorSpace[in] texture color space; sRGB means no color conversion by composer; Linear means to sRGB color conversion by composer
theEye[in] eye to display
Returns
FALSE on error

Implements Aspect_XRSession.

◆ triggerHapticVibrationAction()

virtual void Aspect_OpenVRSession::triggerHapticVibrationAction ( const Handle< Aspect_XRAction > &  theAction,
const Aspect_XRHapticActionData theParams 
)
overrideprotectedvirtual

Trigger vibration.

Implements Aspect_XRSession.

◆ updateProjectionFrustums()

virtual void Aspect_OpenVRSession::updateProjectionFrustums ( )
protectedvirtual

Update projection frustums.

◆ WaitPoses()

virtual bool Aspect_OpenVRSession::WaitPoses ( )
overridevirtual

Fetch actual poses of tracked devices.

Implements Aspect_XRSession.

Field Documentation

◆ myActionsManifest

TCollection_AsciiString Aspect_OpenVRSession::myActionsManifest
protected

◆ myContext

VRContext* Aspect_OpenVRSession::myContext
protected

The documentation for this class was generated from the following file: