Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::OpenXrHelper Class Reference

Conversion and math helpers used by the OpenXR integration. More...

#include <OpenXrHelper.h>

Classes

struct  posef
 A glm based posef struct. More...

Public Types

typedef struct Engine::OpenXrHelper::posef posef
 A glm based posef struct.

Static Public Member Functions

template<typename T>
static void LoadXrFunction (XrInstance xrInstance, const std::string &functionName, T &functionPointer)
 Loads a function from openxr which is not loaded at compile time. Retrieves function pointer.
static XrPosef makeIdentityPose ()
 Makes identity pose.
static glm::mat4 poseToMatrix (const XrPosef &pose)
 Converts an XrPosef to a glm::mat4.
static glm::mat4 poseToMatrix (const OpenXrHelper::posef &pose)
 Pose of glm components to glm::mat4.
static glm::quat xrQuaternionfToGlmQuat (const XrQuaternionf &xrQuaternion)
 Turns the OpenXR quaternion into an OpenXR quaternion.
static XrQuaternionf glmQuatToXrQuaternionf (const glm::quat &glmQuaternion)
 Glm quaternion to xr quaternionf.
static glm::vec3 xrVector3fToGlmVec3 (const XrVector3f &xrVector3)
 Converts an OpenXR vector3 to a glm vector3.
static XrVector3f glmVec3ToXrVector3f (const glm::vec3 &glmVector3)
 Converts a glm::vec3 to a XrVector3f.
static float dot (const glm::quat &a, const glm::quat &b)
 Calculates the dot product between two glm quaternions.
static glm::quat lerpMix (const glm::quat &from, const glm::quat &to, float progress)
 Linearly interpolate between two quaternions.
static glm::vec3 lerpMix (const glm::vec3 &from, const glm::vec3 &to, float progress)
 Linearly interpolate between two glm vector3's.
static float lerpMix (float from, float to, float progress)
 Linearly interpolate between two float values.
static float dot (const glm::vec3 &a, const glm::vec3 &b)
 The dot product between two glm vector3's.
static glm::vec3 crossProductVector3 (const glm::vec3 &vector_a, const glm::vec3 &vector_b)
 Computes the cross product of two vectors.
static float clampf (float num, float left, float right)
 Clamps a float to an inclusive range.
static float lengthSquared (const glm::vec3 &vec)
 Computes squared vector length.
static float length (const glm::vec3 &vec)
 Computes vector length.
static glm::vec3 normalize (const glm::vec3 &vec)
 Normalizes a vector.
static float distanceSquared (const glm::vec3 &vec1, const glm::vec3 &vec2)
 Computes squared distance between two vectors.
static float distance (const glm::vec3 &vec1, const glm::vec3 &vec2)
 Computes distance between two vectors.
static glm::quat slerp (const glm::quat &start, const glm::quat &end, float percent)
 Spherically interpolates between two quaternions.
static glm::vec3 slerp (const glm::vec3 &start, const glm::vec3 &end, float percent)
 Spherically interpolates between two direction vectors.
static float vectorAngleAroundNormal (const glm::vec3 &vec1, const glm::vec3 &vec2, const glm::vec3 &norm)
 Computes the signed angle between two vectors around a normal.
static glm::mat4 rotationAroundPoint (glm::vec3 point, glm::mat4 rotationMatrix)
 Builds a transform that applies a rotation around a point.
static void quaternionToAngleAxis (const glm::quat &quat, float &angle, glm::vec3 &axis)
 Converts a quaternion to angle-axis form.
static glm::quat quaternionFromAngleAxis (const float &angle, const glm::vec3 &axis)
 Creates a quaternion from angle-axis form.
static posef xrPosefToGlmPosef (const XrPosef &xrPosef)
 Converts an OpenXR pose to a GLM-backed pose.
static glm::mat4 createProjectionMatrix (XrFovf fov, float nearClip, float farClip)
 Creates a reverse-Z projection matrix from OpenXR field-of-view angles.
static std::string sessionStateToString (XrSessionState state)
 Converts an OpenXR session state to its symbolic name.
static const char * GetXrStructureTypeName (XrStructureType type)
 Converts an OpenXR structure type to its symbolic name.

Detailed Description

Conversion and math helpers used by the OpenXR integration.

Definition at line 13 of file OpenXrHelper.h.

Member Typedef Documentation

◆ posef

typedef struct Engine::OpenXrHelper::posef Engine::OpenXrHelper::posef

A glm based posef struct.

Member Function Documentation

◆ clampf()

float Engine::OpenXrHelper::clampf ( float num,
float left,
float right )
static

Clamps a float to an inclusive range.

Parameters
numValue to clamp.
leftLower bound.
rightUpper bound.
Returns
Clamped value.

◆ createProjectionMatrix()

glm::mat4 Engine::OpenXrHelper::createProjectionMatrix ( XrFovf fov,
float nearClip,
float farClip )
static

Creates a reverse-Z projection matrix from OpenXR field-of-view angles.

Parameters
fovOpenXR field of view.
nearClipNear clip plane distance.
farClipFar clip plane distance.
Returns
Projection matrix.

◆ crossProductVector3()

glm::vec3 Engine::OpenXrHelper::crossProductVector3 ( const glm::vec3 & vector_a,
const glm::vec3 & vector_b )
static

Computes the cross product of two vectors.

Parameters
vector_aFirst vector.
vector_bSecond vector.
Returns
Vector perpendicular to both inputs.

◆ distance()

float Engine::OpenXrHelper::distance ( const glm::vec3 & vec1,
const glm::vec3 & vec2 )
static

Computes distance between two vectors.

Parameters
vec1First point.
vec2Second point.
Returns
Distance between the points.

◆ distanceSquared()

float Engine::OpenXrHelper::distanceSquared ( const glm::vec3 & vec1,
const glm::vec3 & vec2 )
static

Computes squared distance between two vectors.

Parameters
vec1First point.
vec2Second point.
Returns
Squared distance.

◆ dot() [1/2]

float Engine::OpenXrHelper::dot ( const glm::quat & a,
const glm::quat & b )
static

Calculates the dot product between two glm quaternions.

Parameters
aA glm::quat to process.
bA glm::quat to process.
Returns
The dot product.
Date
2022-10-22
Author
janhsimon

◆ dot() [2/2]

float Engine::OpenXrHelper::dot ( const glm::vec3 & a,
const glm::vec3 & b )
static

The dot product between two glm vector3's.

Parameters
aA glm::vec3 to process.
bA glm::vec3 to process.
Returns
A float.
Date
2022-10-22
Author
janhsimon

◆ GetXrStructureTypeName()

const char * Engine::OpenXrHelper::GetXrStructureTypeName ( XrStructureType type)
static

Converts an OpenXR structure type to its symbolic name.

Parameters
typeStructure type to convert.
Returns
Structure type name, or a fallback for unknown values.

◆ glmQuatToXrQuaternionf()

XrQuaternionf Engine::OpenXrHelper::glmQuatToXrQuaternionf ( const glm::quat & glmQuaternion)
static

Glm quaternion to xr quaternionf.

Parameters
glmQuaternionSource for the.
Returns
A XrQuaternionf.

◆ glmVec3ToXrVector3f()

XrVector3f Engine::OpenXrHelper::glmVec3ToXrVector3f ( const glm::vec3 & glmVector3)
static

Converts a glm::vec3 to a XrVector3f.

Parameters
glmVector3the glm vector3 to convert.
Returns
A XrVector3f.
Date
2022-10-22
Author
janhsimon

◆ length()

float Engine::OpenXrHelper::length ( const glm::vec3 & vec)
static

Computes vector length.

Parameters
vecVector to measure.
Returns
Euclidean vector length.

◆ lengthSquared()

float Engine::OpenXrHelper::lengthSquared ( const glm::vec3 & vec)
static

Computes squared vector length.

Parameters
vecVector to measure.
Returns
Dot product of vec with itself.

◆ lerpMix() [1/3]

glm::quat Engine::OpenXrHelper::lerpMix ( const glm::quat & from,
const glm::quat & to,
float progress )
static

Linearly interpolate between two quaternions.

Parameters
fromThe start quaternion.
tothe target quaternion.
progressA float to process.
Returns
The interpolated quaternion at progress.
Date
2022-10-22
Author
janhsimon

◆ lerpMix() [2/3]

glm::vec3 Engine::OpenXrHelper::lerpMix ( const glm::vec3 & from,
const glm::vec3 & to,
float progress )
static

Linearly interpolate between two glm vector3's.

Parameters
fromThe vector3 to interpolate from.
toThe vector3 to interpolate to.
progressThe factor of how close return is to the target.
Returns
The interpolated vector3 at progress.
Date
2022-10-22
Author
janhsimon

◆ lerpMix() [3/3]

float Engine::OpenXrHelper::lerpMix ( float from,
float to,
float progress )
static

Linearly interpolate between two float values.

Parameters
fromThe float to interpolate from.
toThe float to interpolate to.
progressThe factor of how close return is to the target. 0.0f is from 1.0f is target.
Returns
A float.
Date
2022-10-22
Author
janhsimon

◆ LoadXrFunction()

template<typename T>
void Engine::OpenXrHelper::LoadXrFunction ( XrInstance xrInstance,
const std::string & functionName,
T & functionPointer )
inlinestatic

Loads a function from openxr which is not loaded at compile time. Retrieves function pointer.

Parameters
xrInstanceThe instance.
functionNameName of the function.
[out]functionPointerThe function pointer.
Exceptions
std::runtime_errorRaised when the requested function was not found.
Template Parameters
TThe class of the function pointer.

Definition at line 38 of file OpenXrHelper.h.

◆ makeIdentityPose()

XrPosef Engine::OpenXrHelper::makeIdentityPose ( )
static

Makes identity pose.

Returns
An XrPosef.
Date
2022-10-22
Author
janhsimon

◆ normalize()

glm::vec3 Engine::OpenXrHelper::normalize ( const glm::vec3 & vec)
static

Normalizes a vector.

Parameters
vecVector to normalize.
Returns
Unit-length vector in the same direction.

◆ poseToMatrix() [1/2]

glm::mat4 Engine::OpenXrHelper::poseToMatrix ( const OpenXrHelper::posef & pose)
static

Pose of glm components to glm::mat4.

Parameters
poseThe pose.
Returns
A glm::mat4.

◆ poseToMatrix() [2/2]

glm::mat4 Engine::OpenXrHelper::poseToMatrix ( const XrPosef & pose)
static

Converts an XrPosef to a glm::mat4.

Parameters
poseThe pose XrPose.
Returns
A glm::mat4.
Date
2022-10-22
Author
janhsimon

◆ quaternionFromAngleAxis()

glm::quat Engine::OpenXrHelper::quaternionFromAngleAxis ( const float & angle,
const glm::vec3 & axis )
static

Creates a quaternion from angle-axis form.

Parameters
angleRotation angle in radians.
axisRotation axis.
Returns
Quaternion representing the rotation.

◆ quaternionToAngleAxis()

void Engine::OpenXrHelper::quaternionToAngleAxis ( const glm::quat & quat,
float & angle,
glm::vec3 & axis )
static

Converts a quaternion to angle-axis form.

Parameters
quatQuaternion to convert.
angleReceives the angle in radians.
axisReceives the rotation axis.

◆ rotationAroundPoint()

glm::mat4 Engine::OpenXrHelper::rotationAroundPoint ( glm::vec3 point,
glm::mat4 rotationMatrix )
static

Builds a transform that applies a rotation around a point.

Parameters
pointPivot point.
rotationMatrixRotation matrix to apply around the pivot.
Returns
Combined transform matrix.

◆ sessionStateToString()

std::string Engine::OpenXrHelper::sessionStateToString ( XrSessionState state)
static

Converts an OpenXR session state to its symbolic name.

Parameters
stateSession state to convert.
Returns
State name, or the numeric value for unknown states.

◆ slerp() [1/2]

glm::quat Engine::OpenXrHelper::slerp ( const glm::quat & start,
const glm::quat & end,
float percent )
static

Spherically interpolates between two quaternions.

Parameters
startStart quaternion.
endTarget quaternion.
percentInterpolation factor.
Returns
Interpolated quaternion.

◆ slerp() [2/2]

glm::vec3 Engine::OpenXrHelper::slerp ( const glm::vec3 & start,
const glm::vec3 & end,
float percent )
static

Spherically interpolates between two direction vectors.

Parameters
startStart direction.
endTarget direction.
percentInterpolation factor.
Returns
Interpolated direction vector.

◆ vectorAngleAroundNormal()

float Engine::OpenXrHelper::vectorAngleAroundNormal ( const glm::vec3 & vec1,
const glm::vec3 & vec2,
const glm::vec3 & norm )
static

Computes the signed angle between two vectors around a normal.

Parameters
vec1First normalized vector.
vec2Second normalized vector.
normNormal that defines the positive rotation direction.
Returns
Signed angle in radians.

◆ xrPosefToGlmPosef()

posef Engine::OpenXrHelper::xrPosefToGlmPosef ( const XrPosef & xrPosef)
static

Converts an OpenXR pose to a GLM-backed pose.

Parameters
xrPosefOpenXR pose to convert.
Returns
Pose with GLM quaternion and vector components.

◆ xrQuaternionfToGlmQuat()

glm::quat Engine::OpenXrHelper::xrQuaternionfToGlmQuat ( const XrQuaternionf & xrQuaternion)
static

Turns the OpenXR quaternion into an OpenXR quaternion.

Parameters
xrQuaternionSource for the.
Returns
A glm::quat.
Date
2022-10-22
Author
janhsimon

◆ xrVector3fToGlmVec3()

glm::vec3 Engine::OpenXrHelper::xrVector3fToGlmVec3 ( const XrVector3f & xrVector3)
static

Converts an OpenXR vector3 to a glm vector3.

Parameters
xrVector3OpenXR vector3 to convert.
Returns
A glm::vec3.
Date
2022-10-22
Author
janhsimon

The documentation for this class was generated from the following file:
  • /workspace/magerbeton/gl3-vulkan/code/Engine/include/Engine/Core/OpenXrHelper.h