| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#ifndef OSGXR_OPENXR_SPACE |
| 5 |
#define OSGXR_OPENXR_SPACE 1 |
| 6 |
|
| 7 |
#include "Action.h" |
| 8 |
#include "Path.h" |
| 9 |
#include "Session.h" |
| 10 |
|
| 11 |
#include <osg/Quat> |
| 12 |
#include <osg/Vec3f> |
| 13 |
#include <osg/observer_ptr> |
| 14 |
|
| 15 |
namespace osgXR { |
| 16 |
|
| 17 |
namespace OpenXR { |
| 18 |
|
| 19 |
class Space : public osg::Referenced |
| 20 |
{ |
| 21 |
public: |
| 22 |
|
| 23 |
|
| 24 |
Space(Session *session, XrReferenceSpaceType type); |
| 25 |
|
| 26 |
Space(Session *session, ActionPose *action, |
| 27 |
Path subactionPath = Path()); |
| 28 |
virtual ~Space(); |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
inline bool valid() const |
| 33 |
{ |
| 34 |
return _space != XR_NULL_HANDLE; |
| 35 |
} |
| 36 |
|
| 37 |
inline bool check(XrResult result, const char *actionMsg) const |
| 38 |
{ |
| 39 |
return _session->check(result, actionMsg); |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
inline XrSpace getXrSpace() const |
| 45 |
{ |
| 46 |
return _space; |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
class Location |
| 52 |
{ |
| 53 |
public: |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
Location(); |
| 58 |
Location(XrSpaceLocationFlags flags, |
| 59 |
const osg::Quat &orientation, |
| 60 |
const osg::Vec3f &position); |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
inline bool valid() const |
| 65 |
{ |
| 66 |
return _flags != 0; |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
bool isOrientationValid() const |
| 72 |
{ |
| 73 |
return _flags & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT; |
| 74 |
} |
| 75 |
|
| 76 |
bool isPositionValid() const |
| 77 |
{ |
| 78 |
return _flags & XR_SPACE_LOCATION_POSITION_VALID_BIT; |
| 79 |
} |
| 80 |
|
| 81 |
bool isOrientationTracked() const |
| 82 |
{ |
| 83 |
return _flags & XR_SPACE_LOCATION_ORIENTATION_TRACKED_BIT; |
| 84 |
} |
| 85 |
|
| 86 |
bool isPositionTracked() const |
| 87 |
{ |
| 88 |
return _flags & XR_SPACE_LOCATION_POSITION_TRACKED_BIT; |
| 89 |
} |
| 90 |
|
| 91 |
XrSpaceLocationFlags getFlags() const |
| 92 |
{ |
| 93 |
return _flags; |
| 94 |
} |
| 95 |
|
| 96 |
const osg::Quat &getOrientation() const |
| 97 |
{ |
| 98 |
return _orientation; |
| 99 |
} |
| 100 |
|
| 101 |
const osg::Vec3f &getPosition() const |
| 102 |
{ |
| 103 |
return _position; |
| 104 |
} |
| 105 |
|
| 106 |
protected: |
| 107 |
|
| 108 |
XrSpaceLocationFlags _flags; |
| 109 |
osg::Quat _orientation; |
| 110 |
osg::Vec3f _position; |
| 111 |
}; |
| 112 |
|
| 113 |
bool locate(const Space *baseSpace, XrTime time, |
| 114 |
Location &location); |
| 115 |
|
| 116 |
protected: |
| 117 |
|
| 118 |
osg::observer_ptr<Session> _session; |
| 119 |
XrSpace _space; |
| 120 |
}; |
| 121 |
|
| 122 |
} |
| 123 |
|
| 124 |
} |
| 125 |
|
| 126 |
#endif |