monado/src/xrt/auxiliary/util/u_distortion_mesh.h

118 lines
2.5 KiB
C
Raw Normal View History

// Copyright 2019, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Code to generate disortion meshes.
* @author Jakob Bornecrantz <jakob@collabora.com>
* @ingroup aux_util
*/
#pragma once
#include "xrt/xrt_device.h"
#include "xrt/xrt_defines.h"
#ifdef __cplusplus
extern "C" {
#endif
/*!
* Values to create a distortion mesh from panotools values.
*
* @ingroup aux_util
*/
struct u_panotools_values
{
//! Panotools universal distortion k (reverse order from OpenHMD).
float distortion_k[5];
//! Panotools post distortion scale, <r, g, b>.
float aberration_k[3];
//! Panotools warp scale.
float scale;
//! Center of the lens.
struct xrt_vec2 lens_center;
//! Viewport size.
struct xrt_vec2 viewport_size;
};
/*!
2020-01-26 16:00:14 +00:00
* Three UV pairs, one for each color channel in the source image.
2019-10-24 14:01:04 +00:00
*
2020-01-26 16:00:14 +00:00
* @ingroup aux_util
*/
struct u_uv_triplet
{
struct xrt_vec2 r, g, b;
};
/*!
2020-06-03 16:43:30 +00:00
* @interface u_uv_generator
*
* Generator interface for building meshes, can be implemented by drivers for
2020-01-26 16:00:14 +00:00
* special meshes.
*
* @ingroup aux_util
*/
2019-10-24 14:01:04 +00:00
struct u_uv_generator
{
void (*calc)(struct u_uv_generator *,
int view,
float u,
float v,
2020-01-26 16:00:14 +00:00
struct u_uv_triplet *result);
2019-10-24 14:01:04 +00:00
void (*destroy)(struct u_uv_generator *);
};
/*!
2020-01-26 16:00:14 +00:00
* Given a @ref u_uv_generator generates num_views meshes, populates target.
*
* @ingroup aux_util
2020-06-03 16:43:30 +00:00
* @public @memberof u_uv_generator
* @relatesalso xrt_hmd_parts
*/
void
2019-10-24 14:01:04 +00:00
u_distortion_mesh_from_gen(struct u_uv_generator *,
int num_views,
struct xrt_hmd_parts *target);
/*!
* Given two sets of panotools values creates a mesh generator, copies the
* values into it. This probably isn't the function you want.
*
* @ingroup aux_util
2020-06-03 16:43:30 +00:00
* @see u_distortion_mesh_from_panotools
2019-10-24 14:01:04 +00:00
*/
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 the left and th right uv meshes.
2019-10-24 14:01:04 +00:00
* This is probably the function you want.
*
* @ingroup aux_util
2020-06-03 16:43:30 +00:00
* @relates xrt_hmd_parts
*/
void
u_distortion_mesh_from_panotools(const struct u_panotools_values *left,
const struct u_panotools_values *right,
struct xrt_hmd_parts *target);
/*!
* Create two distortion meshes with no distortion.
*
* @ingroup aux_util
2020-06-03 16:43:30 +00:00
* @relates xrt_hmd_parts
*/
void
u_distortion_mesh_none(struct xrt_hmd_parts *target);
#ifdef __cplusplus
}
#endif