Monado OpenXR Runtime
u_distortion_mesh.h
Go to the documentation of this file.
1 // Copyright 2019, Collabora, Ltd.
2 // SPDX-License-Identifier: BSL-1.0
3 /*!
4  * @file
5  * @brief Code to generate disortion meshes.
6  * @author Jakob Bornecrantz <jakob@collabora.com>
7  * @ingroup aux_util
8  */
9 
10 #pragma once
11 
12 #include "xrt/xrt_device.h"
13 #include "xrt/xrt_defines.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 
20 /*!
21  * Values to create a distortion mesh from panotools values.
22  *
23  * @ingroup aux_util
24  */
26 {
27  //! Panotools universal distortion k (reverse order from OpenHMD).
28  float distortion_k[5];
29  //! Panotools post distortion scale, <r, g, b>.
30  float aberration_k[3];
31  //! Panotools warp scale.
32  float scale;
33  //! Center of the lens.
35  //! Viewport size.
37 };
38 
39 /*!
40  * Three UV pairs, one for each color channel in the source image.
41  *
42  * @ingroup aux_util
43  */
45 {
46  struct xrt_vec2 r, g, b;
47 };
48 
49 /*!
50  * Generator struct for building meshes, can be implemented by drivers for
51  * special meshes.
52  *
53  * @ingroup aux_util
54  */
56 {
57  void (*calc)(struct u_uv_generator *,
58  int view,
59  float u,
60  float v,
61  struct u_uv_triplet *result);
62 
63  void (*destroy)(struct u_uv_generator *);
64 };
65 
66 /*!
67  * Given a @ref u_uv_generator generates num_views meshes, populates target.
68  *
69  * @ingroup aux_util
70  */
71 void
73  int num_views,
74  struct xrt_hmd_parts *target);
75 
76 /*!
77  * Given two sets of panotools values creates a mesh generator, copies the
78  * values into it. This probably isn't the function you want.
79  *
80  * @ingroup aux_util
81  */
82 void
84  const struct u_panotools_values *left,
85  const struct u_panotools_values *right,
86  struct u_uv_generator **out_gen);
87 
88 /*!
89  * Given two sets of panotools values creates the left and th right uv meshes.
90  * This is probably the function you want.
91  *
92  * @ingroup aux_util
93  */
94 void
96  const struct u_panotools_values *right,
97  struct xrt_hmd_parts *target);
98 
99 /*!
100  * Create two distortion meshes with no distortion.
101  *
102  * @ingroup aux_util
103  */
104 void
105 u_distortion_mesh_none(struct xrt_hmd_parts *target);
106 
107 
108 #ifdef __cplusplus
109 }
110 #endif
void u_distortion_mesh_generator_from_panotools(const struct u_panotools_values *left, const struct u_panotools_values *right, struct u_uv_generator **out_gen)
Given two sets of panotools values creates a mesh generator, copies the values into it...
Definition: u_distortion_mesh.c:241
Values to create a distortion mesh from panotools values.
Definition: u_distortion_mesh.h:25
A 2 element vector with single floats.
Definition: xrt_defines.h:122
void u_distortion_mesh_from_gen(struct u_uv_generator *, int num_views, struct xrt_hmd_parts *target)
Given a u_uv_generator generates num_views meshes, populates target.
Definition: u_distortion_mesh.c:138
float distortion_k[5]
Panotools universal distortion k (reverse order from OpenHMD).
Definition: u_distortion_mesh.h:28
Header defining a xrt HMD device.
void u_distortion_mesh_none(struct xrt_hmd_parts *target)
Create two distortion meshes with no distortion.
Definition: u_distortion_mesh.c:274
Common defines and enums for XRT.
Generator struct for building meshes, can be implemented by drivers for special meshes.
Definition: u_distortion_mesh.h:55
All of the device components that deals with interfacing to a users head.
Definition: xrt_device.h:92
Three UV pairs, one for each color channel in the source image.
Definition: u_distortion_mesh.h:44
float aberration_k[3]
Panotools post distortion scale, <r, g, b>.
Definition: u_distortion_mesh.h:30
void u_distortion_mesh_from_panotools(const struct u_panotools_values *left, const struct u_panotools_values *right, struct xrt_hmd_parts *target)
Given two sets of panotools values creates the left and th right uv meshes.
Definition: u_distortion_mesh.c:229
struct xrt_vec2 lens_center
Center of the lens.
Definition: u_distortion_mesh.h:34
struct xrt_vec2 viewport_size
Viewport size.
Definition: u_distortion_mesh.h:36
float scale
Panotools warp scale.
Definition: u_distortion_mesh.h:32