mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0029384: Visualization, TKOpenGl - basic integration with OpenVR
V3d_View::AutoZFit() is now called only before redraw within methods V3d_View::Redraw() and V3d_View::Update(). Graphic3d_CView now holds Aspect_ExtendedRealitySession object. Aspect_OpenVRSession implements new interface via optional OpenVR library. Graphic3d_CView::ProcessInput() - added new interface method which should be called for processing positional input (head tracking). Graphic3d_Camera now allows setting custom stereoscopic Projection matrices. OpenGl_Context::Camera() - context now holds Camera object in addition to active camera matrices. genproj.tcl has been extended to handle optional CSF_OpenVR dependency.
This commit is contained in:
26
src/Aspect/Aspect_ColorSpace.hxx
Normal file
26
src/Aspect/Aspect_ColorSpace.hxx
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) 2020 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Aspect_ColorSpace_HeaderFile
|
||||
#define _Aspect_ColorSpace_HeaderFile
|
||||
|
||||
#include <Aspect_GraphicsLibrary.hxx>
|
||||
|
||||
//! Texture color spaces accepted by XR composer.
|
||||
enum Aspect_ColorSpace
|
||||
{
|
||||
Aspect_ColorSpace_sRGB = 0, //!< non-linear sRGB color space
|
||||
Aspect_ColorSpace_Linear = 1, //!< linear RGB color space
|
||||
};
|
||||
|
||||
#endif // _Aspect_ColorSpace_HeaderFile
|
24
src/Aspect/Aspect_Eye.hxx
Normal file
24
src/Aspect/Aspect_Eye.hxx
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) 2020 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Aspect_Eye_HeaderFile
|
||||
#define _Aspect_Eye_HeaderFile
|
||||
|
||||
//! Camera eye index within stereoscopic pair.
|
||||
enum Aspect_Eye
|
||||
{
|
||||
Aspect_Eye_Left,
|
||||
Aspect_Eye_Right
|
||||
};
|
||||
|
||||
#endif // _Aspect_Eye_HeaderFile
|
55
src/Aspect/Aspect_FrustumLRBT.hxx
Normal file
55
src/Aspect/Aspect_FrustumLRBT.hxx
Normal file
@@ -0,0 +1,55 @@
|
||||
// Copyright (c) 2020 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Aspect_FrustumLRBT_HeaderFile
|
||||
#define _Aspect_FrustumLRBT_HeaderFile
|
||||
|
||||
//! Structure defining frustum boundaries.
|
||||
template<typename Elem_t>
|
||||
struct Aspect_FrustumLRBT
|
||||
{
|
||||
Elem_t Left;
|
||||
Elem_t Right;
|
||||
Elem_t Bottom;
|
||||
Elem_t Top;
|
||||
|
||||
//! Empty constructor.
|
||||
Aspect_FrustumLRBT() : Left (0), Right (0), Bottom (0), Top (0) {}
|
||||
|
||||
//! Copy/cast constructor.
|
||||
template<typename Other_t>
|
||||
explicit Aspect_FrustumLRBT (const Aspect_FrustumLRBT<Other_t>& theOther)
|
||||
: Left (static_cast<Elem_t> (theOther.Left)),
|
||||
Right (static_cast<Elem_t> (theOther.Right)),
|
||||
Bottom(static_cast<Elem_t> (theOther.Bottom)),
|
||||
Top (static_cast<Elem_t> (theOther.Top)) {}
|
||||
|
||||
//! Apply multiply factor.
|
||||
void Multiply (Elem_t theScale)
|
||||
{
|
||||
Left *= theScale;
|
||||
Right *= theScale;
|
||||
Bottom *= theScale;
|
||||
Top *= theScale;
|
||||
}
|
||||
|
||||
//! Return multiplied frustum.
|
||||
Aspect_FrustumLRBT<Elem_t> Multiplied (Elem_t theScale)
|
||||
{
|
||||
Aspect_FrustumLRBT<Elem_t> aCopy (*this);
|
||||
aCopy.Multiply (theScale);
|
||||
return aCopy;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _Aspect_FrustumLRBT_HeaderFile
|
24
src/Aspect/Aspect_GraphicsLibrary.hxx
Normal file
24
src/Aspect/Aspect_GraphicsLibrary.hxx
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) 2020 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Aspect_GraphicsLibrary_HeaderFile
|
||||
#define _Aspect_GraphicsLibrary_HeaderFile
|
||||
|
||||
//! Graphics API enumeration.
|
||||
enum Aspect_GraphicsLibrary
|
||||
{
|
||||
Aspect_GraphicsLibrary_OpenGL,
|
||||
Aspect_GraphicsLibrary_OpenGLES,
|
||||
};
|
||||
|
||||
#endif // _Aspect_GraphicsLibrary_HeaderFile
|
1151
src/Aspect/Aspect_OpenVRSession.cxx
Normal file
1151
src/Aspect/Aspect_OpenVRSession.cxx
Normal file
File diff suppressed because it is too large
Load Diff
149
src/Aspect/Aspect_OpenVRSession.hxx
Normal file
149
src/Aspect/Aspect_OpenVRSession.hxx
Normal file
@@ -0,0 +1,149 @@
|
||||
// Copyright (c) 2020 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Aspect_OpenVRSession_HeaderFile
|
||||
#define _Aspect_OpenVRSession_HeaderFile
|
||||
|
||||
#include <Aspect_XRSession.hxx>
|
||||
|
||||
//! OpenVR wrapper implementing Aspect_XRSession interface.
|
||||
class Aspect_OpenVRSession : public Aspect_XRSession
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Aspect_OpenVRSession, Aspect_XRSession)
|
||||
public:
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT static bool IsHmdPresent();
|
||||
|
||||
public:
|
||||
|
||||
//! Empty constructor.
|
||||
Standard_EXPORT Aspect_OpenVRSession();
|
||||
|
||||
//! Destructor.
|
||||
Standard_EXPORT virtual ~Aspect_OpenVRSession();
|
||||
|
||||
//! Return TRUE if session is opened.
|
||||
Standard_EXPORT virtual bool IsOpen() const Standard_OVERRIDE;
|
||||
|
||||
//! Initialize session.
|
||||
Standard_EXPORT virtual bool Open() Standard_OVERRIDE;
|
||||
|
||||
//! Release session.
|
||||
Standard_EXPORT virtual void Close() Standard_OVERRIDE;
|
||||
|
||||
//! Fetch actual poses of tracked devices.
|
||||
Standard_EXPORT virtual bool WaitPoses() Standard_OVERRIDE;
|
||||
|
||||
//! Return recommended viewport Width x Height for rendering into VR.
|
||||
virtual NCollection_Vec2<int> RecommendedViewport() const Standard_OVERRIDE { return myRendSize; }
|
||||
|
||||
//! Return transformation from eye to head.
|
||||
//! vr::GetEyeToHeadTransform() wrapper.
|
||||
Standard_EXPORT virtual NCollection_Mat4<double> EyeToHeadTransform (Aspect_Eye theEye) const Standard_OVERRIDE;
|
||||
|
||||
//! Return projection matrix.
|
||||
Standard_EXPORT virtual NCollection_Mat4<double> ProjectionMatrix (Aspect_Eye theEye,
|
||||
double theZNear,
|
||||
double theZFar) const Standard_OVERRIDE;
|
||||
|
||||
//! Return TRUE.
|
||||
virtual bool HasProjectionFrustums() const Standard_OVERRIDE { return true; }
|
||||
|
||||
//! Receive XR events.
|
||||
Standard_EXPORT virtual void ProcessEvents() Standard_OVERRIDE;
|
||||
|
||||
//! Submit texture eye to XR Composer.
|
||||
//! @param theTexture [in] texture handle
|
||||
//! @param theGraphicsLib [in] graphics library in which texture handle is defined
|
||||
//! @param theColorSpace [in] texture color space;
|
||||
//! sRGB means no color conversion by composer;
|
||||
//! Linear means to sRGB color conversion by composer
|
||||
//! @param theEye [in] eye to display
|
||||
//! @return FALSE on error
|
||||
Standard_EXPORT virtual bool SubmitEye (void* theTexture,
|
||||
Aspect_GraphicsLibrary theGraphicsLib,
|
||||
Aspect_ColorSpace theColorSpace,
|
||||
Aspect_Eye theEye) Standard_OVERRIDE;
|
||||
|
||||
//! Query information.
|
||||
Standard_EXPORT virtual TCollection_AsciiString GetString (InfoString theInfo) const Standard_OVERRIDE;
|
||||
|
||||
//! Return index of tracked device of known role.
|
||||
Standard_EXPORT virtual Standard_Integer NamedTrackedDevice (Aspect_XRTrackedDeviceRole theDevice) const Standard_OVERRIDE;
|
||||
|
||||
//! Fetch data for digital input action (like button).
|
||||
Standard_EXPORT virtual Aspect_XRDigitalActionData GetDigitalActionData (const Handle(Aspect_XRAction)& theAction) const Standard_OVERRIDE;
|
||||
|
||||
//! Fetch data for analog input action (like axis).
|
||||
Standard_EXPORT virtual Aspect_XRAnalogActionData GetAnalogActionData (const Handle(Aspect_XRAction)& theAction) const Standard_OVERRIDE;
|
||||
|
||||
//! Fetch data for pose input action (like fingertip position).
|
||||
Standard_EXPORT virtual Aspect_XRPoseActionData GetPoseActionDataForNextFrame (const Handle(Aspect_XRAction)& theAction) const Standard_OVERRIDE;
|
||||
|
||||
//! Set tracking origin.
|
||||
Standard_EXPORT virtual void SetTrackingOrigin (TrackingUniverseOrigin theOrigin) Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
//! Find location of default actions manifest file (based on CSF_OCCTResourcePath or CASROOT variables).
|
||||
Standard_EXPORT TCollection_AsciiString defaultActionsManifest();
|
||||
|
||||
//! Release OpenVR device.
|
||||
Standard_EXPORT void closeVR();
|
||||
|
||||
//! Update projection frustums.
|
||||
Standard_EXPORT virtual void updateProjectionFrustums();
|
||||
|
||||
//! Init VR input.
|
||||
Standard_EXPORT virtual bool initInput();
|
||||
|
||||
//! Handle tracked device activation.
|
||||
Standard_EXPORT virtual void onTrackedDeviceActivated (Standard_Integer theDeviceIndex);
|
||||
|
||||
//! Handle tracked device deactivation.
|
||||
Standard_EXPORT virtual void onTrackedDeviceDeactivated (Standard_Integer theDeviceIndex);
|
||||
|
||||
//! Handle tracked device update.
|
||||
Standard_EXPORT virtual void onTrackedDeviceUpdated (Standard_Integer theDeviceIndex);
|
||||
|
||||
//! Trigger vibration.
|
||||
Standard_EXPORT virtual void triggerHapticVibrationAction (const Handle(Aspect_XRAction)& theAction,
|
||||
const Aspect_XRHapticActionData& theParams) Standard_OVERRIDE;
|
||||
|
||||
//! Return model for displaying device.
|
||||
Standard_EXPORT virtual Handle(Graphic3d_ArrayOfTriangles) loadRenderModel (Standard_Integer theDevice,
|
||||
Standard_Boolean theToApplyUnitFactor,
|
||||
Handle(Image_Texture)& theTexture) Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
//! Access vr::IVRSystem* - OpenVR session object.
|
||||
Standard_EXPORT void* getVRSystem() const;
|
||||
|
||||
private:
|
||||
|
||||
//! Internal fields
|
||||
struct VRContext;
|
||||
class VRImagePixmap;
|
||||
class VRTextureSource;
|
||||
|
||||
protected:
|
||||
|
||||
VRContext* myContext;
|
||||
TCollection_AsciiString myActionsManifest;
|
||||
|
||||
};
|
||||
|
||||
#endif // _Aspect_OpenVRSession_HeaderFile
|
36
src/Aspect/Aspect_TrackedDevicePose.hxx
Normal file
36
src/Aspect/Aspect_TrackedDevicePose.hxx
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2020 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Aspect_TrackedDevicePose_HeaderFile
|
||||
#define _Aspect_TrackedDevicePose_HeaderFile
|
||||
|
||||
#include <gp_Trsf.hxx>
|
||||
#include <NCollection_Array1.hxx>
|
||||
|
||||
//! Describes a single pose for a tracked object (for XR).
|
||||
struct Aspect_TrackedDevicePose
|
||||
{
|
||||
gp_Trsf Orientation; //!< device to absolute transformation
|
||||
gp_Vec Velocity; //!< velocity in tracker space in m/s
|
||||
gp_Vec AngularVelocity; //!< angular velocity in radians/s
|
||||
bool IsValidPose; //!< indicates valid pose
|
||||
bool IsConnectedDevice; //!< indicates connected state
|
||||
|
||||
//! Empty constructor.
|
||||
Aspect_TrackedDevicePose() : IsValidPose (false), IsConnectedDevice (false) {}
|
||||
};
|
||||
|
||||
//! Array of tracked poses.
|
||||
typedef NCollection_Array1<Aspect_TrackedDevicePose> Aspect_TrackedDevicePoseArray;
|
||||
|
||||
#endif // _Aspect_TrackedDevicePose_HeaderFile
|
58
src/Aspect/Aspect_XRAction.hxx
Normal file
58
src/Aspect/Aspect_XRAction.hxx
Normal file
@@ -0,0 +1,58 @@
|
||||
// Copyright (c) 2020 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Aspect_XRAction_HeaderFile
|
||||
#define _Aspect_XRAction_HeaderFile
|
||||
|
||||
#include <Aspect_XRActionType.hxx>
|
||||
#include <NCollection_IndexedDataMap.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
//! XR action definition.
|
||||
class Aspect_XRAction : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Aspect_XRAction, Standard_Transient)
|
||||
public:
|
||||
|
||||
//! Return action id.
|
||||
const TCollection_AsciiString& Id() const { return myId; }
|
||||
|
||||
//! Return action type.
|
||||
Aspect_XRActionType Type() const { return myType; }
|
||||
|
||||
//! Return TRUE if action is defined.
|
||||
bool IsValid() const { return myRawHandle != 0; }
|
||||
|
||||
//! Return action handle.
|
||||
uint64_t RawHandle() const { return myRawHandle; }
|
||||
|
||||
//! Set action handle.
|
||||
void SetRawHandle (uint64_t theHande) { myRawHandle = theHande; }
|
||||
|
||||
//! Main constructor.
|
||||
Aspect_XRAction (const TCollection_AsciiString& theId,
|
||||
const Aspect_XRActionType theType)
|
||||
: myId (theId), myRawHandle (0), myType (theType) {}
|
||||
|
||||
protected:
|
||||
TCollection_AsciiString myId; //!< action id
|
||||
uint64_t myRawHandle; //!< action handle
|
||||
Aspect_XRActionType myType; //!< action type
|
||||
};
|
||||
|
||||
//! Map of actions with action Id as a key.
|
||||
typedef NCollection_IndexedDataMap<TCollection_AsciiString, Handle(Aspect_XRAction), TCollection_AsciiString> Aspect_XRActionMap;
|
||||
|
||||
#endif // _Aspect_XRAction_HeaderFile
|
55
src/Aspect/Aspect_XRActionSet.hxx
Normal file
55
src/Aspect/Aspect_XRActionSet.hxx
Normal file
@@ -0,0 +1,55 @@
|
||||
// Copyright (c) 2020 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Aspect_XRActionSet_HeaderFile
|
||||
#define _Aspect_XRActionSet_HeaderFile
|
||||
|
||||
#include <Aspect_XRAction.hxx>
|
||||
|
||||
//! XR action set.
|
||||
class Aspect_XRActionSet : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Aspect_XRActionSet, Standard_Transient)
|
||||
public:
|
||||
|
||||
//! Return action id.
|
||||
const TCollection_AsciiString& Id() const { return myId; }
|
||||
|
||||
//! Return action handle.
|
||||
uint64_t RawHandle() const { return myRawHandle; }
|
||||
|
||||
//! Set action handle.
|
||||
void SetRawHandle (uint64_t theHande) { myRawHandle = theHande; }
|
||||
|
||||
//! Add action.
|
||||
void AddAction (const Handle(Aspect_XRAction)& theAction)
|
||||
{
|
||||
myActions.Add (theAction->Id(), theAction);
|
||||
}
|
||||
|
||||
//! Return map of actions.
|
||||
const Aspect_XRActionMap& Actions() const { return myActions; }
|
||||
|
||||
//! Main constructor.
|
||||
Aspect_XRActionSet (const TCollection_AsciiString& theId)
|
||||
: myId (theId), myRawHandle (0) {}
|
||||
|
||||
protected:
|
||||
TCollection_AsciiString myId; //!< action set id
|
||||
uint64_t myRawHandle; //!< action set handle
|
||||
Aspect_XRActionMap myActions; //!< map of actions
|
||||
};
|
||||
|
||||
typedef NCollection_IndexedDataMap<TCollection_AsciiString, Handle(Aspect_XRActionSet), TCollection_AsciiString> Aspect_XRActionSetMap;
|
||||
|
||||
#endif // _Aspect_XRActionSet_HeaderFile
|
27
src/Aspect/Aspect_XRActionType.hxx
Normal file
27
src/Aspect/Aspect_XRActionType.hxx
Normal file
@@ -0,0 +1,27 @@
|
||||
// Copyright (c) 2020 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Aspect_XRActionType_HeaderFile
|
||||
#define _Aspect_XRActionType_HeaderFile
|
||||
|
||||
//! XR action type.
|
||||
enum Aspect_XRActionType
|
||||
{
|
||||
Aspect_XRActionType_InputDigital, //!< boolean input (like button)
|
||||
Aspect_XRActionType_InputAnalog, //!< analog input (1/2/3 axes)
|
||||
Aspect_XRActionType_InputPose, //!< positional input
|
||||
Aspect_XRActionType_InputSkeletal, //!< skeletal input
|
||||
Aspect_XRActionType_OutputHaptic //!< haptic output (vibration)
|
||||
};
|
||||
|
||||
#endif // _Aspect_XRActionType_HeaderFile
|
35
src/Aspect/Aspect_XRAnalogActionData.hxx
Normal file
35
src/Aspect/Aspect_XRAnalogActionData.hxx
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright (c) 2020 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Aspect_XRAnalogActionData_HeaderFile
|
||||
#define _Aspect_XRAnalogActionData_HeaderFile
|
||||
|
||||
#include <NCollection_Vec3.hxx>
|
||||
|
||||
//! Analog input XR action data.
|
||||
struct Aspect_XRAnalogActionData
|
||||
{
|
||||
uint64_t ActiveOrigin; //!< The origin that caused this action's current state
|
||||
float UpdateTime; //!< Time relative to now when this event happened. Will be negative to indicate a past time
|
||||
NCollection_Vec3<float> VecXYZ; //!< the current state of this action
|
||||
NCollection_Vec3<float> DeltaXYZ; //!< deltas since the previous update
|
||||
bool IsActive; //!< whether or not this action is currently available to be bound in the active action set
|
||||
|
||||
//! Return TRUE if delta is non-zero.
|
||||
bool IsChanged() { return !DeltaXYZ.IsEqual (NCollection_Vec3<float> (0.0f, 0.0f, 0.0f)); }
|
||||
|
||||
//! Empty constructor.
|
||||
Aspect_XRAnalogActionData() : ActiveOrigin (0), UpdateTime (0.0f), IsActive (false) {}
|
||||
};
|
||||
|
||||
#endif // _Aspect_XRAnalogActionData_HeaderFile
|
32
src/Aspect/Aspect_XRDigitalActionData.hxx
Normal file
32
src/Aspect/Aspect_XRDigitalActionData.hxx
Normal file
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) 2020 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Aspect_XRDigitalActionData_HeaderFile
|
||||
#define _Aspect_XRDigitalActionData_HeaderFile
|
||||
|
||||
#include <Standard_TypeDef.hxx>
|
||||
|
||||
//! Digital input XR action data.
|
||||
struct Aspect_XRDigitalActionData
|
||||
{
|
||||
uint64_t ActiveOrigin; //!< The origin that caused this action's current state
|
||||
float UpdateTime; //!< Time relative to now when this event happened. Will be negative to indicate a past time
|
||||
bool IsActive; //!< whether or not this action is currently available to be bound in the active action set
|
||||
bool IsPressed; //!< Aspect_InputActionType_Digital state - The current state of this action; will be true if currently pressed
|
||||
bool IsChanged; //!< Aspect_InputActionType_Digital state - this is true if the state has changed since the last frame
|
||||
|
||||
//! Empty constructor.
|
||||
Aspect_XRDigitalActionData() : ActiveOrigin (0), UpdateTime (0.0f), IsActive (false), IsPressed (false), IsChanged (false) {}
|
||||
};
|
||||
|
||||
#endif // _Aspect_XRDigitalActionData_HeaderFile
|
40
src/Aspect/Aspect_XRGenericAction.hxx
Normal file
40
src/Aspect/Aspect_XRGenericAction.hxx
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2020 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Aspect_XRGenericAction_HeaderFile
|
||||
#define _Aspect_XRGenericAction_HeaderFile
|
||||
|
||||
//! Generic XR action.
|
||||
enum Aspect_XRGenericAction
|
||||
{
|
||||
Aspect_XRGenericAction_IsHeadsetOn, //!< headset is on/off head
|
||||
Aspect_XRGenericAction_InputAppMenu, //!< application menu button pressed/released
|
||||
Aspect_XRGenericAction_InputSysMenu, //!< system menu button pressed/released
|
||||
Aspect_XRGenericAction_InputTriggerPull, //!< trigger squeezing [0..1], 1 to click
|
||||
Aspect_XRGenericAction_InputTriggerClick, //!< trigger clicked/released
|
||||
Aspect_XRGenericAction_InputGripClick, //!< grip state on/off
|
||||
Aspect_XRGenericAction_InputTrackPadPosition, //!< trackpad 2D position [-1,+1] with X and Y axes
|
||||
Aspect_XRGenericAction_InputTrackPadTouch, //!< trackpad touched/untouched
|
||||
Aspect_XRGenericAction_InputTrackPadClick, //!< trackpad clicked/released
|
||||
Aspect_XRGenericAction_InputThumbstickPosition, //!< thumbstick 2D position [-1,+1] with X and Y axes
|
||||
Aspect_XRGenericAction_InputThumbstickTouch, //!< thumbstick touched/untouched
|
||||
Aspect_XRGenericAction_InputThumbstickClick, //!< thumbstick clicked/released
|
||||
Aspect_XRGenericAction_InputPoseBase, //!< base position of hand
|
||||
Aspect_XRGenericAction_InputPoseFront, //!< front position of hand
|
||||
Aspect_XRGenericAction_InputPoseHandGrip, //!< position of main handgrip
|
||||
Aspect_XRGenericAction_InputPoseFingerTip, //!< position of main fingertip
|
||||
Aspect_XRGenericAction_OutputHaptic //!< haptic output (vibration)
|
||||
};
|
||||
enum { Aspect_XRGenericAction_NB = Aspect_XRGenericAction_OutputHaptic + 1 };
|
||||
|
||||
#endif // _Aspect_XRGenericAction_HeaderFile
|
38
src/Aspect/Aspect_XRHapticActionData.hxx
Normal file
38
src/Aspect/Aspect_XRHapticActionData.hxx
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright (c) 2020 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Aspect_XRHapticActionData_HeaderFile
|
||||
#define _Aspect_XRHapticActionData_HeaderFile
|
||||
|
||||
//! Haptic output XR action data.
|
||||
struct Aspect_XRHapticActionData
|
||||
{
|
||||
float Delay; //!< delay in seconds before start
|
||||
float Duration; //!< duration in seconds
|
||||
float Frequency; //!< vibration frequency
|
||||
float Amplitude; //!< vibration amplitude
|
||||
|
||||
//! Return TRUE if data is not empty.
|
||||
bool IsValid() const
|
||||
{
|
||||
return Duration > 0.0f
|
||||
&& Amplitude > 0.0f
|
||||
&& Frequency > 0.0f
|
||||
&& Delay >= 0.0f;
|
||||
}
|
||||
|
||||
//! Empty constructor.
|
||||
Aspect_XRHapticActionData() : Delay (0.0f), Duration (0.0f), Frequency (0.0f), Amplitude (0.0f) {}
|
||||
};
|
||||
|
||||
#endif // _Aspect_XRHapticActionData_HeaderFile
|
31
src/Aspect/Aspect_XRPoseActionData.hxx
Normal file
31
src/Aspect/Aspect_XRPoseActionData.hxx
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) 2020 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Aspect_XRPoseActionData_HeaderFile
|
||||
#define _Aspect_XRPoseActionData_HeaderFile
|
||||
|
||||
#include <Aspect_TrackedDevicePose.hxx>
|
||||
#include <Standard_TypeDef.hxx>
|
||||
|
||||
//! Pose input XR action data.
|
||||
struct Aspect_XRPoseActionData
|
||||
{
|
||||
Aspect_TrackedDevicePose Pose; //!< pose state
|
||||
uint64_t ActiveOrigin; //!< The origin that caused this action's current state
|
||||
bool IsActive; //!< whether or not this action is currently available to be bound in the active action set
|
||||
|
||||
//! Empty constructor.
|
||||
Aspect_XRPoseActionData() : ActiveOrigin (0), IsActive (false) {}
|
||||
};
|
||||
|
||||
#endif // _Aspect_XRPoseActionData_HeaderFile
|
60
src/Aspect/Aspect_XRSession.cxx
Normal file
60
src/Aspect/Aspect_XRSession.cxx
Normal file
@@ -0,0 +1,60 @@
|
||||
// Copyright (c) 2020 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <Aspect_XRSession.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Aspect_XRSession, Standard_Transient)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Aspect_XRAction, Standard_Transient)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Aspect_XRActionSet, Standard_Transient)
|
||||
|
||||
// =======================================================================
|
||||
// function : Aspect_XRSession
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Aspect_XRSession::Aspect_XRSession()
|
||||
: myTrackOrigin (TrackingUniverseOrigin_Standing),
|
||||
myTrackedPoses (0, 0),
|
||||
myUnitFactor (1.0),
|
||||
myAspect (1.0),
|
||||
myFieldOfView (90.0),
|
||||
myIod (0.0),
|
||||
myDispFreq (0.0f)
|
||||
{
|
||||
for (Standard_Integer aRoleIter = 0; aRoleIter < Aspect_XRTrackedDeviceRole_NB; ++aRoleIter)
|
||||
{
|
||||
myRoleActions[aRoleIter].Resize (0, Aspect_XRGenericAction_NB - 1, false);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AbortHapticVibrationAction
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Aspect_XRSession::AbortHapticVibrationAction (const Handle(Aspect_XRAction)& theAction)
|
||||
{
|
||||
triggerHapticVibrationAction (theAction, Aspect_XRHapticActionData());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : TriggerHapticVibrationAction
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Aspect_XRSession::TriggerHapticVibrationAction (const Handle(Aspect_XRAction)& theAction,
|
||||
const Aspect_XRHapticActionData& theParams)
|
||||
{
|
||||
if (!theParams.IsValid())
|
||||
{
|
||||
throw Standard_ProgramError("Aspect_OpenVRSession::TriggerHapticVibrationAction() called for wrong action");
|
||||
}
|
||||
triggerHapticVibrationAction (theAction, theParams);
|
||||
}
|
262
src/Aspect/Aspect_XRSession.hxx
Normal file
262
src/Aspect/Aspect_XRSession.hxx
Normal file
@@ -0,0 +1,262 @@
|
||||
// Copyright (c) 2020 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Aspect_XRSession_HeaderFile
|
||||
#define _Aspect_XRSession_HeaderFile
|
||||
|
||||
#include <Aspect_ColorSpace.hxx>
|
||||
#include <Aspect_Eye.hxx>
|
||||
#include <Aspect_FrustumLRBT.hxx>
|
||||
#include <Aspect_GraphicsLibrary.hxx>
|
||||
#include <Aspect_XRActionSet.hxx>
|
||||
#include <Aspect_XRAnalogActionData.hxx>
|
||||
#include <Aspect_XRDigitalActionData.hxx>
|
||||
#include <Aspect_XRGenericAction.hxx>
|
||||
#include <Aspect_XRHapticActionData.hxx>
|
||||
#include <Aspect_XRPoseActionData.hxx>
|
||||
#include <Aspect_XRTrackedDeviceRole.hxx>
|
||||
#include <gp_Trsf.hxx>
|
||||
#include <NCollection_Array1.hxx>
|
||||
|
||||
class Graphic3d_ArrayOfTriangles;
|
||||
class Image_Texture;
|
||||
|
||||
//! Extended Reality (XR) Session interface.
|
||||
class Aspect_XRSession : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Aspect_XRSession, Standard_Transient)
|
||||
public:
|
||||
|
||||
//! Identifies which style of tracking origin the application wants to use for the poses it is requesting.
|
||||
enum TrackingUniverseOrigin
|
||||
{
|
||||
TrackingUniverseOrigin_Seated, //! poses are provided relative to the seated zero pose
|
||||
TrackingUniverseOrigin_Standing, //! poses are provided relative to the safe bounds configured by the user
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
//! Return TRUE if session is opened.
|
||||
virtual bool IsOpen() const = 0;
|
||||
|
||||
//! Initialize session.
|
||||
virtual bool Open() = 0;
|
||||
|
||||
//! Release session.
|
||||
virtual void Close() = 0;
|
||||
|
||||
//! Fetch actual poses of tracked devices.
|
||||
virtual bool WaitPoses() = 0;
|
||||
|
||||
//! Return recommended viewport Width x Height for rendering into VR.
|
||||
virtual NCollection_Vec2<int> RecommendedViewport() const = 0;
|
||||
|
||||
//! Return transformation from eye to head.
|
||||
virtual NCollection_Mat4<double> EyeToHeadTransform (Aspect_Eye theEye) const = 0;
|
||||
|
||||
//! Return transformation from head to eye.
|
||||
NCollection_Mat4<double> HeadToEyeTransform (Aspect_Eye theEye) const
|
||||
{
|
||||
NCollection_Mat4<double> aMat;
|
||||
EyeToHeadTransform (theEye).Inverted (aMat);
|
||||
return aMat;
|
||||
}
|
||||
|
||||
//! Return projection matrix.
|
||||
virtual NCollection_Mat4<double> ProjectionMatrix (Aspect_Eye theEye,
|
||||
double theZNear,
|
||||
double theZFar) const = 0;
|
||||
|
||||
//! Return FALSE if projection frustums are unsupported and general 4x4 projection matrix should be fetched instead
|
||||
virtual bool HasProjectionFrustums() const = 0;
|
||||
|
||||
//! Receive XR events.
|
||||
virtual void ProcessEvents() = 0;
|
||||
|
||||
//! Submit texture eye to XR Composer.
|
||||
//! @param theTexture [in] texture handle
|
||||
//! @param theGraphicsLib [in] graphics library in which texture handle is defined
|
||||
//! @param theColorSpace [in] texture color space;
|
||||
//! sRGB means no color conversion by composer;
|
||||
//! Linear means to sRGB color conversion by composer
|
||||
//! @param theEye [in] eye to display
|
||||
//! @return FALSE on error
|
||||
virtual bool SubmitEye (void* theTexture,
|
||||
Aspect_GraphicsLibrary theGraphicsLib,
|
||||
Aspect_ColorSpace theColorSpace,
|
||||
Aspect_Eye theEye) = 0;
|
||||
|
||||
//! Return unit scale factor defined as scale factor for m (meters); 1.0 by default.
|
||||
Standard_Real UnitFactor() const { return myUnitFactor; }
|
||||
|
||||
//! Set unit scale factor.
|
||||
void SetUnitFactor (Standard_Real theFactor) { myUnitFactor = theFactor; }
|
||||
|
||||
//! Return aspect ratio.
|
||||
Standard_Real Aspect() const { return myAspect; }
|
||||
|
||||
//! Return field of view.
|
||||
Standard_Real FieldOfView() const { return myFieldOfView; }
|
||||
|
||||
//! Return Intra-ocular Distance (IOD); also known as Interpupillary Distance (IPD).
|
||||
//! Defined in meters by default (@sa UnitFactor()).
|
||||
Standard_Real IOD() const { return myIod; }
|
||||
|
||||
//! Return display frequency or 0 if unknown.
|
||||
Standard_ShortReal DisplayFrequency() const { return myDispFreq; }
|
||||
|
||||
//! Return projection frustum.
|
||||
//! @sa HasProjectionFrustums().
|
||||
const Aspect_FrustumLRBT<double>& ProjectionFrustum (Aspect_Eye theEye) const
|
||||
{
|
||||
return theEye == Aspect_Eye_Right ? myFrustumR : myFrustumL;
|
||||
}
|
||||
|
||||
//! Return head orientation in right-handed system:
|
||||
//! +y is up
|
||||
//! +x is to the right
|
||||
//! -z is forward
|
||||
//! Distance unit is meters by default (@sa UnitFactor()).
|
||||
const gp_Trsf& HeadPose() const { return myHeadPose; }
|
||||
|
||||
//! Return left hand orientation.
|
||||
gp_Trsf LeftHandPose() const
|
||||
{
|
||||
const Standard_Integer aDevice = NamedTrackedDevice (Aspect_XRTrackedDeviceRole_LeftHand);
|
||||
return aDevice != -1 ? myTrackedPoses[aDevice].Orientation : gp_Trsf();
|
||||
}
|
||||
|
||||
//! Return right hand orientation.
|
||||
gp_Trsf RightHandPose() const
|
||||
{
|
||||
const Standard_Integer aDevice = NamedTrackedDevice (Aspect_XRTrackedDeviceRole_RightHand);
|
||||
return aDevice != -1 ? myTrackedPoses[aDevice].Orientation : gp_Trsf();
|
||||
}
|
||||
|
||||
//! Return number of tracked poses array.
|
||||
const Aspect_TrackedDevicePoseArray& TrackedPoses() const { return myTrackedPoses; }
|
||||
|
||||
//! Return TRUE if device orientation is defined.
|
||||
bool HasTrackedPose (Standard_Integer theDevice) const { return myTrackedPoses[theDevice].IsValidPose; }
|
||||
|
||||
//! Return index of tracked device of known role, or -1 if undefined.
|
||||
virtual Standard_Integer NamedTrackedDevice (Aspect_XRTrackedDeviceRole theDevice) const = 0;
|
||||
|
||||
//! Load model for displaying device.
|
||||
//! @param theDevice [in] device index
|
||||
//! @param theTexture [out] texture source
|
||||
//! @return model triangulation or NULL if not found
|
||||
Handle(Graphic3d_ArrayOfTriangles) LoadRenderModel (Standard_Integer theDevice,
|
||||
Handle(Image_Texture)& theTexture)
|
||||
{
|
||||
return loadRenderModel (theDevice, true, theTexture);
|
||||
}
|
||||
|
||||
//! Load model for displaying device.
|
||||
//! @param theDevice [in] device index
|
||||
//! @param theToApplyUnitFactor [in] flag to apply unit scale factor
|
||||
//! @param theTexture [out] texture source
|
||||
//! @return model triangulation or NULL if not found
|
||||
Handle(Graphic3d_ArrayOfTriangles) LoadRenderModel (Standard_Integer theDevice,
|
||||
Standard_Boolean theToApplyUnitFactor,
|
||||
Handle(Image_Texture)& theTexture)
|
||||
{
|
||||
return loadRenderModel (theDevice, theToApplyUnitFactor, theTexture);
|
||||
}
|
||||
|
||||
//! Fetch data for digital input action (like button).
|
||||
//! @param theAction [in] action of Aspect_XRActionType_InputDigital type
|
||||
virtual Aspect_XRDigitalActionData GetDigitalActionData (const Handle(Aspect_XRAction)& theAction) const = 0;
|
||||
|
||||
//! Fetch data for digital input action (like axis).
|
||||
//! @param theAction [in] action of Aspect_XRActionType_InputAnalog type
|
||||
virtual Aspect_XRAnalogActionData GetAnalogActionData (const Handle(Aspect_XRAction)& theAction) const = 0;
|
||||
|
||||
//! Fetch data for pose input action (like fingertip position).
|
||||
//! The returned values will match the values returned by the last call to WaitPoses().
|
||||
//! @param theAction [in] action of Aspect_XRActionType_InputPose type
|
||||
virtual Aspect_XRPoseActionData GetPoseActionDataForNextFrame (const Handle(Aspect_XRAction)& theAction) const = 0;
|
||||
|
||||
//! Trigger vibration.
|
||||
Standard_EXPORT void TriggerHapticVibrationAction (const Handle(Aspect_XRAction)& theAction,
|
||||
const Aspect_XRHapticActionData& theParams);
|
||||
|
||||
//! Abort vibration.
|
||||
Standard_EXPORT void AbortHapticVibrationAction (const Handle(Aspect_XRAction)& theAction);
|
||||
|
||||
//! Return tracking origin.
|
||||
TrackingUniverseOrigin TrackingOrigin() const { return myTrackOrigin; }
|
||||
|
||||
//! Set tracking origin.
|
||||
virtual void SetTrackingOrigin (TrackingUniverseOrigin theOrigin) { myTrackOrigin = theOrigin; }
|
||||
|
||||
//! Return generic action for specific hand or NULL if undefined.
|
||||
const Handle(Aspect_XRAction)& GenericAction (Aspect_XRTrackedDeviceRole theDevice,
|
||||
Aspect_XRGenericAction theAction) const
|
||||
{
|
||||
const NCollection_Array1<Handle(Aspect_XRAction)>& anActions = myRoleActions[theDevice];
|
||||
return anActions[theAction];
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! Info string enumeration.
|
||||
enum InfoString
|
||||
{
|
||||
InfoString_Vendor,
|
||||
InfoString_Device,
|
||||
InfoString_Tracker,
|
||||
InfoString_SerialNumber,
|
||||
};
|
||||
|
||||
//! Query information.
|
||||
virtual TCollection_AsciiString GetString (InfoString theInfo) const = 0;
|
||||
|
||||
protected:
|
||||
|
||||
//! Empty constructor.
|
||||
Standard_EXPORT Aspect_XRSession();
|
||||
|
||||
//! Load model for displaying device.
|
||||
//! @param theDevice [in] device index
|
||||
//! @param theToApplyUnitFactor [in] flag to apply unit scale factor
|
||||
//! @param theTexture [out] texture source
|
||||
//! @return model triangulation or NULL if not found
|
||||
virtual Handle(Graphic3d_ArrayOfTriangles) loadRenderModel (Standard_Integer theDevice,
|
||||
Standard_Boolean theToApplyUnitFactor,
|
||||
Handle(Image_Texture)& theTexture) = 0;
|
||||
|
||||
//! Trigger vibration.
|
||||
virtual void triggerHapticVibrationAction (const Handle(Aspect_XRAction)& theAction,
|
||||
const Aspect_XRHapticActionData& theParams) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
NCollection_Array1<Handle(Aspect_XRAction)>
|
||||
myRoleActions[Aspect_XRTrackedDeviceRole_NB]; //!< generic actions
|
||||
Aspect_XRActionSetMap myActionSets; //!< actions sets
|
||||
TrackingUniverseOrigin myTrackOrigin; //!< tracking origin
|
||||
Aspect_TrackedDevicePoseArray myTrackedPoses; //!< array of tracked poses
|
||||
gp_Trsf myHeadPose; //!< head orientation
|
||||
NCollection_Vec2<int> myRendSize; //!< viewport Width x Height for rendering into VR
|
||||
Aspect_FrustumLRBT<double> myFrustumL; //!< left eye projection frustum
|
||||
Aspect_FrustumLRBT<double> myFrustumR; //!< right eye projection frustum
|
||||
Standard_Real myUnitFactor; //!< unit scale factor defined as scale factor for m (meters)
|
||||
Standard_Real myAspect; //!< aspect ratio
|
||||
Standard_Real myFieldOfView; //!< field of view
|
||||
Standard_Real myIod; //!< intra-ocular distance in meters
|
||||
Standard_ShortReal myDispFreq; //!< display frequency
|
||||
|
||||
};
|
||||
|
||||
#endif // _Aspect_XRSession_HeaderFile
|
27
src/Aspect/Aspect_XRTrackedDeviceRole.hxx
Normal file
27
src/Aspect/Aspect_XRTrackedDeviceRole.hxx
Normal file
@@ -0,0 +1,27 @@
|
||||
// Copyright (c) 2020 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Aspect_XRTrackedDeviceRole_HeaderFile
|
||||
#define _Aspect_XRTrackedDeviceRole_HeaderFile
|
||||
|
||||
//! Predefined tracked devices.
|
||||
enum Aspect_XRTrackedDeviceRole
|
||||
{
|
||||
Aspect_XRTrackedDeviceRole_Head, //!< head
|
||||
Aspect_XRTrackedDeviceRole_LeftHand, //!< left hand
|
||||
Aspect_XRTrackedDeviceRole_RightHand, //!< right hand
|
||||
Aspect_XRTrackedDeviceRole_Other, //!< other devices
|
||||
};
|
||||
enum { Aspect_XRTrackedDeviceRole_NB = Aspect_XRTrackedDeviceRole_Other + 1 };
|
||||
|
||||
#endif // _Aspect_XRTrackedDeviceRole_HeaderFile
|
@@ -5,26 +5,32 @@ Aspect_Background.cxx
|
||||
Aspect_Background.hxx
|
||||
Aspect_CircularGrid.cxx
|
||||
Aspect_CircularGrid.hxx
|
||||
Aspect_ColorSpace.hxx
|
||||
Aspect_Convert.hxx
|
||||
Aspect_Display.hxx
|
||||
Aspect_DisplayConnection.cxx
|
||||
Aspect_DisplayConnection.hxx
|
||||
Aspect_DisplayConnectionDefinitionError.hxx
|
||||
Aspect_Drawable.hxx
|
||||
Aspect_Eye.hxx
|
||||
Aspect_FBConfig.hxx
|
||||
Aspect_FillMethod.hxx
|
||||
Aspect_FrustumLRBT.hxx
|
||||
Aspect_GenId.cxx
|
||||
Aspect_GenId.hxx
|
||||
Aspect_GradientBackground.cxx
|
||||
Aspect_GradientBackground.hxx
|
||||
Aspect_GradientFillMethod.hxx
|
||||
Aspect_GraphicDeviceDefinitionError.hxx
|
||||
Aspect_GraphicsLibrary.hxx
|
||||
Aspect_Grid.cxx
|
||||
Aspect_Grid.hxx
|
||||
Aspect_GridDrawMode.hxx
|
||||
Aspect_GridType.hxx
|
||||
Aspect_NeutralWindow.cxx
|
||||
Aspect_NeutralWindow.hxx
|
||||
Aspect_OpenVRSession.cxx
|
||||
Aspect_OpenVRSession.hxx
|
||||
Aspect_Handle.hxx
|
||||
Aspect_HatchStyle.hxx
|
||||
Aspect_IdentDefinitionError.hxx
|
||||
@@ -37,6 +43,7 @@ Aspect_SequenceOfColor.hxx
|
||||
Aspect_ScrollDelta.hxx
|
||||
Aspect_Touch.hxx
|
||||
Aspect_TouchMap.hxx
|
||||
Aspect_TrackedDevicePose.hxx
|
||||
Aspect_TypeOfColorScaleData.hxx
|
||||
Aspect_TypeOfColorScaleOrientation.hxx
|
||||
Aspect_TypeOfColorScalePosition.hxx
|
||||
@@ -60,4 +67,15 @@ Aspect_Window.hxx
|
||||
Aspect_WindowDefinitionError.hxx
|
||||
Aspect_WindowError.hxx
|
||||
Aspect_XAtom.hxx
|
||||
Aspect_XRAction.hxx
|
||||
Aspect_XRActionSet.hxx
|
||||
Aspect_XRActionType.hxx
|
||||
Aspect_XRAnalogActionData.hxx
|
||||
Aspect_XRDigitalActionData.hxx
|
||||
Aspect_XRGenericAction.hxx
|
||||
Aspect_XRHapticActionData.hxx
|
||||
Aspect_XRPoseActionData.hxx
|
||||
Aspect_XRSession.cxx
|
||||
Aspect_XRSession.hxx
|
||||
Aspect_XRTrackedDeviceRole.hxx
|
||||
Aspect_XWD.hxx
|
||||
|
Reference in New Issue
Block a user