The open source OpenXR runtime
1// Copyright 2019-2020, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Wrapper around Mercury's parametric hand code, used by Index and OpenGloves to simulate hand tracking.
6 * @author Christoph Haag <christoph.haag@collabora.com>
7 * @ingroup aux_util
8 */
9
10#pragma once
11
12#include "xrt/xrt_defines.h"
13
14#include "util/u_misc.h"
15#include "util/u_hand_tracking.h"
16
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22struct u_hand_sim_metacarpal
23{
24 struct xrt_vec2 swing;
25 float twist;
26};
27
28struct u_hand_sim_finger
29{
30 struct u_hand_sim_metacarpal metacarpal;
31 struct xrt_vec2 proximal_swing;
32 // rotation at intermediate joint, then rotation at distal joint
33 float rotations[2];
34};
35
36struct u_hand_sim_thumb
37{
38 struct u_hand_sim_metacarpal metacarpal;
39 float rotations[2];
40};
41
42struct u_hand_sim_hand
43{
44 // Distance from wrist to middle-proximal.
45 bool is_right;
46 float hand_size;
47 struct xrt_space_relation wrist_pose;
48 struct xrt_space_relation hand_pose;
49
50 struct u_hand_sim_thumb thumb;
51 struct u_hand_sim_finger finger[4];
52};
53
54
55void
56u_hand_sim_simulate(struct u_hand_sim_hand *hand, struct xrt_hand_joint_set *out_set);
57
58void
59u_hand_sim_simulate_for_valve_index_knuckles(const struct u_hand_tracking_curl_values *values,
60 enum xrt_hand xhand,
61 const struct xrt_space_relation *root_pose,
62 struct xrt_hand_joint_set *out_set);
63
64void
65u_hand_sim_simulate_generic(const struct u_hand_tracking_values *values,
66 enum xrt_hand xhand,
67 const struct xrt_space_relation *root_pose,
68 struct xrt_hand_joint_set *out_set);
69
70#ifdef __cplusplus
71}
72#endif