This commit is contained in:
Guillaume Meunier
2024-01-28 11:33:34 +01:00
parent 7ee4e9a4d2
commit 8dbd47c859
12 changed files with 802 additions and 55 deletions
+31
View File
@@ -35,6 +35,8 @@
#include <openxr/openxr_reflection.h>
#include "vk_mem_alloc.h"
#include "singleton.h"
#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>
class scene;
@@ -195,6 +197,35 @@ public:
}
static std::pair<XrAction, XrActionType> get_action(const std::string & name);
static std::optional<std::pair<glm::vec3, glm::quat>> locate_controller(XrSpace space, XrSpace reference, XrTime time)
{
XrSpaceLocation location{.type = XR_TYPE_SPACE_LOCATION};
assert(space != XR_NULL_HANDLE);
assert(reference != XR_NULL_HANDLE);
xrLocateSpace(space, reference, time, &location);
auto req_flags = XR_SPACE_LOCATION_ORIENTATION_VALID_BIT | XR_SPACE_LOCATION_POSITION_VALID_BIT;
if ((location.locationFlags & req_flags) != req_flags)
return {};
glm::vec3 position{
location.pose.position.x,
location.pose.position.y,
location.pose.position.z,
};
glm::quat orientation{
location.pose.orientation.w,
location.pose.orientation.x,
location.pose.orientation.y,
location.pose.orientation.z,
};
return std::make_pair(position, orientation);
}
static XrPath string_to_path(const std::string & s)
{
return instance().xr_instance.string_to_path(s);