cgv
Loading...
Searching...
No Matches
vr_kit.h
1#pragma once
2
3#include "vr_state.h"
4#include "vr_camera.h"
5#include "vr_info.h"
6#include "gl_vr_display.h"
7
8#include "lib_begin.h"
9
12
14namespace vr {
16 class CGV_API vr_driver;
17
20 {
22
24 float dead_zone;
26
27 float precision;
29
30 float threshold;
33 };
34
37
68 class CGV_API vr_kit : public gl_vr_display
69 {
70 protected:
74 void* handle;
80 std::string name;
86 void destruct_camera();
88 vr_trackable_state& ref_tracking_reference_state(const std::string& serial_nummer);
96 virtual bool query_state_impl(vr_kit_state& state, int pose_query) = 0;
98 vr_kit(vr_driver* _driver, void* _handle, const std::string& _name, unsigned _width, unsigned _height, unsigned _nr_multi_samples = 4);
99 public:
101 const vr_driver* get_driver() const;
103 void* get_handle() const;
105 vr_camera* get_camera() const;
107 const std::string& get_name() const;
109 virtual ~vr_kit();
111 const vr_kit_info& get_device_info() const;
113
118 virtual void set_controller_input_config(int controller_index, int input_index, const controller_input_config& cic);
120 const controller_input_config& get_controller_input_config(int controller_index, int input_index) const;
122
131 bool query_state(vr_kit_state& state, int pose_query = 2);
133 virtual bool set_vibration(unsigned controller_index, float low_frequency_strength, float high_frequency_strength) = 0;
135 virtual void put_eye_to_head_matrix(int eye, float* pose_matrix) const = 0;
137
139 virtual void put_projection_matrix(int eye, float z_near, float z_far, float* projection_matrix, const float* hmd_pose = 0) const = 0;
141 virtual void put_world_to_eye_transform(int eye, const float* hmd_pose, float* modelview_matrix) const;
143 virtual void submit_frame() = 0;
144 };
145}
146
148
149#include <cgv/config/lib_end.h>
gl_vr_display(unsigned _width, unsigned _height, unsigned _nr_multi_samples)
construct
interface for mono or stereo cameras in VR headsets
Definition vr_camera.h:39
interface class for vr drivers.
Definition vr_driver.h:57
virtual void put_world_to_eye_transform(int eye, const float *hmd_pose, float *modelview_matrix) const
access to 4x4 modelview transformation matrix of given eye in column major format,...
Definition vr_kit.cxx:92
vr_kit(vr_driver *_driver, void *_handle, const std::string &_name, unsigned _width, unsigned _height, unsigned _nr_multi_samples=4)
construct
Definition vr_kit.cxx:39
vr_trackable_state & ref_tracking_reference_state(const std::string &serial_nummer)
write access to the state of the tracking reference with given serial number
Definition vr_kit.cxx:13
vr_camera * get_camera() const
return camera or nullptr if not available
Definition vr_kit.cxx:52
vr_kit_info info
store vr kit info to be filled and updated by driver implementations
Definition vr_kit.h:82
controller_input_config input_configs[4][5]
store controller input configs per controller and input
Definition vr_kit.h:84
void destruct_camera()
destruct camera
Definition vr_kit.cxx:33
virtual bool set_vibration(unsigned controller_index, float low_frequency_strength, float high_frequency_strength)=0
set the vibration strength between 0 and 1 of low and high frequency motors, return false if device i...
const controller_input_config & get_controller_input_config(int controller_index, int input_index) const
query the configuration of a controller input
Definition vr_kit.cxx:126
bool query_state(vr_kit_state &state, int pose_query=2)
query current state of vr kit and return whether this was successful
Definition vr_kit.cxx:103
const vr_kit_info & get_device_info() const
return information on the currently attached devices
Definition vr_kit.cxx:117
void * get_handle() const
return handle of vr kit
Definition vr_kit.cxx:50
const vr_driver * get_driver() const
return driver
Definition vr_kit.cxx:48
const std::string & get_name() const
return name of vr_kit
Definition vr_kit.cxx:54
virtual void set_controller_input_config(int controller_index, int input_index, const controller_input_config &cic)
set the configuration of a controller input
Definition vr_kit.cxx:121
void * handle
handle for internal use
Definition vr_kit.h:74
bool skip_calibration
whether to skip driver calibration - defaults to false
Definition vr_kit.h:78
vr_driver * driver
pointer to driver that created the vr kit
Definition vr_kit.h:72
void clear_tracking_reference_states()
remove all reference states
Definition vr_kit.cxx:23
virtual bool query_state_impl(vr_kit_state &state, int pose_query)=0
derived kits implement this without caring about calibration; vr_kit::query_state() will apply driver...
virtual void put_eye_to_head_matrix(int eye, float *pose_matrix) const =0
access to 3x4 matrix in column major format for transformation from eye (0..left, 1....
vr_camera * camera
pointer to camera
Definition vr_kit.h:76
virtual void submit_frame()=0
submit the rendered stereo frame to the hmd
void mark_tracking_references_as_untracked()
mark all reference states as untracked
Definition vr_kit.cxx:28
std::string name
name in case driver provides this information (not reliable)
Definition vr_kit.h:80
vr_tracking_system_info & ref_tracking_system_info()
write access to tracking system info
Definition vr_kit.cxx:18
virtual void put_projection_matrix(int eye, float z_near, float z_far, float *projection_matrix, const float *hmd_pose=0) const =0
access to 4x4 matrix in column major format for perspective transformation from eye (0....
the vr namespace for virtual reality support
configuration of a controller input axis
Definition vr_kit.h:20
float precision
if precision is larger than zero, values are rounded to multiples of precision.
Definition vr_kit.h:27
float dead_zone
all input values below dead_zone are clamped to 0.
Definition vr_kit.h:24
float threshold
if value gets larger than threshold a key press event is triggered if this is enabled.
Definition vr_kit.h:30
controller_input_config()
initialize to defaults (dead_zone=precision=0;threshold=0.5)
Definition vr_kit.cxx:7
information provided for a vr kit
Definition vr_info.h:146
structure that stores all information describing the state of a VR kit
Definition vr_state.h:139
a trackable knows whether it is tracked and its 6d pose stored as 3x4 matrix in column major format
Definition vr_state.h:94
information provided for tracking system
Definition vr_info.h:176
defines camera class for camera provided by vr_kit
defines types to store the state vr::vr_kit_state of a vr kit, which is split into sub states for the...