8 #ifndef META_OCEAN_PLATFORM_OPENXR_UTILITIES_H
9 #define META_OCEAN_PLATFORM_OPENXR_UTILITIES_H
39 static std::string
translateResult(
const XrInstance& xrInstance,
const XrResult xrResult);
68 static std::string
translatePath(
const XrInstance& xrInstance,
const XrPath& xrPath);
76 static XrPath
translatePath(
const XrInstance& xrInstance,
const std::string& path);
84 template <
typename T = Scalar>
93 template <
typename T = Scalar>
94 static inline QuaternionT<T> toQuaternion(
const XrQuaternionf& xrQuaternionf);
102 template <
typename T = Scalar>
103 static inline VectorT3<T> toVector3(
const XrVector3f& xrVector3f);
111 template <
typename T = Scalar>
130 template <
typename T = Scalar>
131 static inline HomogenousMatrixT4<T> determinePose(
const XrSpace& xrSpace,
const XrSpace& xrBaseSpace,
const XrTime& xrTime, XrSpaceLocationFlags* xrSpaceLocationFlags =
nullptr);
137 ocean_assert(
QuaternionF(xrPose.orientation.w, xrPose.orientation.x, xrPose.orientation.y, xrPose.orientation.z).isValid());
139 return HomogenousMatrixF4(
VectorF3(xrPose.position.x, xrPose.position.y, xrPose.position.z),
QuaternionF(xrPose.orientation.w, xrPose.orientation.x, xrPose.orientation.y, xrPose.orientation.z));
142 template <
typename T>
145 ocean_assert(
QuaternionF(xrPose.orientation.w, xrPose.orientation.x, xrPose.orientation.y, xrPose.orientation.z).isValid());
147 const VectorT3<T> position(T(xrPose.position.x), T(xrPose.position.y), T(xrPose.position.z));
148 const QuaternionT<T> orientation(T(xrPose.orientation.w), T(xrPose.orientation.x), T(xrPose.orientation.y), T(xrPose.orientation.z));
156 ocean_assert(
QuaternionF(xrQuaternionf.w, xrQuaternionf.x, xrQuaternionf.y, xrQuaternionf.z).isValid());
158 return QuaternionF(xrQuaternionf.w, xrQuaternionf.x, xrQuaternionf.y, xrQuaternionf.z);
161 template <
typename T>
164 ocean_assert(
QuaternionF(xrQuaternionf.w, xrQuaternionf.x, xrQuaternionf.y, xrQuaternionf.z).isValid());
166 const QuaternionT<T> orientation(T(xrQuaternionf.w), T(xrQuaternionf.x), T(xrQuaternionf.y), T(xrQuaternionf.z));
171 template <
typename T>
174 return VectorT3<T>(T(xrVector3f.x), T(xrVector3f.y), T(xrVector3f.z));
188 result.orientation.x = orientation.
x();
189 result.orientation.y = orientation.
y();
190 result.orientation.z = orientation.
z();
191 result.orientation.w = orientation.
w();
193 result.position.x = position.
x();
194 result.position.y = position.
y();
195 result.position.z = position.
z();
200 template <
typename T>
213 result.orientation.x = orientation.
x();
214 result.orientation.y = orientation.
y();
215 result.orientation.z = orientation.
z();
216 result.orientation.w = orientation.
w();
218 result.position.x = float(position.
x());
219 result.position.y = float(position.
y());
220 result.position.z = float(position.
z());
225 template <
typename T>
228 ocean_assert(xrSpace != XR_NULL_HANDLE);
229 ocean_assert(xrBaseSpace != XR_NULL_HANDLE);
231 XrSpaceLocation xrSpaceLocation = {XR_TYPE_SPACE_LOCATION};
232 const XrResult xrResult = xrLocateSpace(xrSpace, xrBaseSpace, xrTime, &xrSpaceLocation);
234 if (xrResult != XR_SUCCESS)
239 if (xrSpaceLocationFlags !=
nullptr)
241 *xrSpaceLocationFlags = xrSpaceLocation.locationFlags;
244 return toHomogenousMatrix4<T>(xrSpaceLocation.pose);
This class implements a 4x4 homogeneous transformation matrix using floating point values with the pr...
Definition: HomogenousMatrix4.h:110
SquareMatrixT3< T > rotationMatrix() const
Returns the rotation matrix of the transformation.
Definition: HomogenousMatrix4.h:1493
VectorT3< T > translation() const
Returns the translation of the transformation.
Definition: HomogenousMatrix4.h:1381
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition: HomogenousMatrix4.h:1806
QuaternionT< T > rotation() const
Returns the rotation of the transformation as quaternion.
Definition: HomogenousMatrix4.h:1388
This class provides basic numeric functionalities.
Definition: Numeric.h:57
static constexpr T weakEps()
Returns a weak epsilon.
This class implements a unit quaternion rotation.
Definition: Quaternion.h:100
bool normalize()
Normalizes the quaternion in place.
Definition: Quaternion.h:714
const T & x() const
Returns the x value of the quaternion.
Definition: Quaternion.h:917
const T & w() const
Returns the w value of the quaternion.
Definition: Quaternion.h:905
QuaternionT< T > normalized() const
Returns the normalized quaternion.
Definition: Quaternion.h:699
const T & y() const
Returns the y value of the quaternion.
Definition: Quaternion.h:929
const T & z() const
Returns the z value of the quaternion.
Definition: Quaternion.h:941
This class implements a 4x4 square matrix.
Definition: SquareMatrix4.h:85
This class implements a vector with three elements.
Definition: Vector3.h:97
const T & y() const noexcept
Returns the y value.
Definition: Vector3.h:812
const T & x() const noexcept
Returns the x value.
Definition: Vector3.h:800
const T & z() const noexcept
Returns the z value.
Definition: Vector3.h:824
QuaternionT< float > QuaternionF
Instantiation of the QuaternionT template class using a single precision float data type.
Definition: Quaternion.h:54
VectorT3< float > VectorF3
Definition of a 3D vector with float values.
Definition: Vector3.h:43
HomogenousMatrixT4< float > HomogenousMatrixF4
Instantiation of the HomogenousMatrixT4 template class using a float precision float data type.
Definition: HomogenousMatrix4.h:58
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15