cgv
Loading...
Searching...
No Matches
vr::vr_kit Class Referenceabstract

a vr kit is composed of headset, two controllers, and two trackers, where all devices can be attached or detached More...

#include <vr_kit.h>

Inheritance diagram for vr::vr_kit:
vr::gl_vr_display vr_emulated_kit

Public Member Functions

const vr_driver * get_driver () const
 return driver
void * get_handle () const
 return handle of vr kit
vr_camera * get_camera () const
 return camera or nullptr if not available
const std::string & get_name () const
 return name of vr_kit
virtual ~vr_kit ()
 declare virtual destructor
const vr_kit_info & get_device_info () const
 return information on the currently attached devices
virtual void set_controller_input_config (int controller_index, int input_index, const controller_input_config &cic)
 set the configuration of a controller input
const controller_input_config & get_controller_input_config (int controller_index, int input_index) const
 query the configuration of a controller input
bool query_state (vr_kit_state &state, int pose_query=2)
 query current state of vr kit and return whether this was successful
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 is not connected anymore
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..right) to head coordinates
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..left, 1..right)
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, which is computed in default implementation from given 3x4 pose matrix and eye to head transformation
virtual void submit_frame ()=0
 submit the rendered stereo frame to the hmd
Public Member Functions inherited from vr::gl_vr_display
 gl_vr_display (unsigned _width, unsigned _height, unsigned _nr_multi_samples)
 construct
virtual ~gl_vr_display ()
 declare virtual destructor
const std::string & get_last_error () const
 return last error of vr_kit
int get_width () const
 return width in pixel of view
int get_height () const
 return height in pixel of view
virtual void set_size (int new_width, int new_height)
 allow to set a different size
virtual bool init_fbos (EyeSelection es=ES_BOTH)
 initialize render targets and framebuffer objects in current opengl context
virtual bool blit_fbo (int eye, int x, int y, int w, int h)
 initialize render targets and framebuffer objects in current opengl context
virtual bool fbos_initialized (EyeSelection es=ES_BOTH) const
 check whether fbos have been initialized
virtual void destruct_fbos (EyeSelection es=ES_BOTH)
 destruct render targets and framebuffer objects in current opengl context
virtual void enable_fbo (int eye)
 enable the framebuffer object of given eye (0..left, 1..right)
virtual void disable_fbo (int eye)
 disable the framebuffer object of given eye
virtual void bind_texture (int eye)
 bind texture of given eye to current texture unit

Protected Member Functions

void destruct_camera ()
 destruct camera
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
vr_tracking_system_info & ref_tracking_system_info ()
 write access to tracking system info
void clear_tracking_reference_states ()
 remove all reference states
void mark_tracking_references_as_untracked ()
 mark all reference states as untracked
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 calibration
 vr_kit (vr_driver *_driver, void *_handle, const std::string &_name, unsigned _width, unsigned _height, unsigned _nr_multi_samples=4)
 construct

Protected Attributes

vr_driver * driver
 pointer to driver that created the vr kit
void * handle
 handle for internal use
vr_camera * camera
 pointer to camera
bool skip_calibration
 whether to skip driver calibration - defaults to false
std::string name
 name in case driver provides this information (not reliable)
vr_kit_info info
 store vr kit info to be filled and updated by driver implementations
controller_input_config input_configs [4][5]
 store controller input configs per controller and input
Protected Attributes inherited from vr::gl_vr_display
unsigned width
 pixel dimensions of render targets
unsigned height
unsigned nr_multi_samples
unsigned multi_depth_buffer_id [2]
 ids of gl render objects
unsigned multi_tex_id [2]
unsigned multi_fbo_id [2]
unsigned tex_id [2]
unsigned fbo_id [2]
std::string last_error
 store last error message

Detailed Description

a vr kit is composed of headset, two controllers, and two trackers, where all devices can be attached or detached

each vr_kit is uniquely specified by a handle that is represented as void* and can be access via get_handle(). Furthermore, each kit has a human readable name [get_name()]. The corresponding driver is accessed through get_driver(). In case of an error, the error message can be accessed via get_last_error() of the base class gl_vr_display.

query_state(vr_kit_state& state, int pose_query) gives access to the state of the kit and comes in three variants distinguished by the pose_query parameter:

  • 0 ... query controller state only
  • 1 ... query most recent controller state and poses of hmd and controller
  • 2 ... wait for the optimal time to start a rendering process and query state and future poses

Information on the currently attached devices can be queried with get_device_info().

TODO: support for vibration based force feedback

rendering to the hmd is done in current opengl context via init_fbos(), enable_fbo(eye), disable_fbo(eye) and submit_frame() (after rendering both eyes). The crg_vr_view plugin uses these functions and completely handles the rendering process. If you want to use the functions yourself, you need to ensure to make the opengl context current before calling them. In order to debug the vr views, the function blit_fbo(eye,x,y,w,h) allows to blit a vr view into the framebuffer currently bound to GL_DRAW_FRAMEBUFFER.

In order to build the modelview and projection matrices for rendering, the functions put_eye_to_head_matrix(eye,float[12]) provides a 3x4 pose matrix for each eye. Multiplying to the hmd pose matrix and inverting the matrix product yields the modelview matrix. The projection matrix can be accessed per eye via put_projection_matrix(eye,z_near,z_far,float[16]).

Definition at line 68 of file vr_kit.h.

Constructor & Destructor Documentation

◆ vr_kit()

vr::vr_kit::vr_kit ( vr_driver * _driver,
void * _handle,
const std::string & _name,
unsigned _width,
unsigned _height,
unsigned _nr_multi_samples = 4 )
protected

construct

Definition at line 39 of file vr_kit.cxx.

References camera, driver, vr::gl_vr_display::gl_vr_display(), handle, name, and skip_calibration.

Referenced by query_state_impl().

◆ ~vr_kit()

vr::vr_kit::~vr_kit ( )
virtual

declare virtual destructor

Definition at line 42 of file vr_kit.cxx.

References camera.

Member Function Documentation

◆ clear_tracking_reference_states()

void vr::vr_kit::clear_tracking_reference_states ( )
protected

remove all reference states

Definition at line 23 of file vr_kit.cxx.

References driver.

◆ destruct_camera()

void vr::vr_kit::destruct_camera ( )
protected

destruct camera

Definition at line 33 of file vr_kit.cxx.

References camera.

◆ get_camera()

vr_camera * vr::vr_kit::get_camera ( ) const

◆ get_controller_input_config()

const controller_input_config & vr::vr_kit::get_controller_input_config ( int controller_index,
int input_index ) const

query the configuration of a controller input

Definition at line 126 of file vr_kit.cxx.

References input_configs.

Referenced by cgv::gui::vr_server::emit_events_and_update_state(), vr_test::on_device_change(), vr_test::on_status_change(), and query_state_impl().

◆ get_device_info()

const vr_kit_info & vr::vr_kit::get_device_info ( ) const

◆ get_driver()

◆ get_handle()

void * vr::vr_kit::get_handle ( ) const

return handle of vr kit

return device handle

Definition at line 50 of file vr_kit.cxx.

References handle.

Referenced by query_state_impl().

◆ get_name()

const std::string & vr::vr_kit::get_name ( ) const

return name of vr_kit

Definition at line 54 of file vr_kit.cxx.

References name.

Referenced by query_state_impl(), and vr::vr_driver::register_vr_kit().

◆ mark_tracking_references_as_untracked()

void vr::vr_kit::mark_tracking_references_as_untracked ( )
protected

mark all reference states as untracked

Definition at line 28 of file vr_kit.cxx.

References driver.

◆ put_eye_to_head_matrix()

virtual void vr::vr_kit::put_eye_to_head_matrix ( int eye,
float * pose_matrix ) const
pure virtual

access to 3x4 matrix in column major format for transformation from eye (0..left, 1..right) to head coordinates

Implemented in vr_emulated_kit.

Referenced by vr_view_interactor::draw_vr_kits(), and put_world_to_eye_transform().

◆ put_projection_matrix()

virtual void vr::vr_kit::put_projection_matrix ( int eye,
float z_near,
float z_far,
float * projection_matrix,
const float * hmd_pose = 0 ) const
pure virtual

access to 4x4 matrix in column major format for perspective transformation from eye (0..left, 1..right)

pose matrix is not needed for most vr kits and can be set to nullptr; only in case of wall based vr kits the pose matrix needs to be specified

Implemented in vr_emulated_kit.

References put_world_to_eye_transform().

Referenced by vr::get_eye_projection_transform().

◆ put_world_to_eye_transform()

void vr::vr_kit::put_world_to_eye_transform ( int eye,
const float * hmd_pose,
float * modelview_matrix ) const
virtual

access to 4x4 modelview transformation matrix of given eye in column major format, which is computed in default implementation from given 3x4 pose matrix and eye to head transformation

Definition at line 92 of file vr_kit.cxx.

References put_eye_to_head_matrix().

Referenced by vr::get_world_to_eye_transform(), and put_projection_matrix().

◆ query_state()

bool vr::vr_kit::query_state ( vr_kit_state & state,
int pose_query = 2 )

query current state of vr kit and return whether this was successful

Parameters
statestate is returned by writing it into passed reference
pose_queryis 0 ... no poses are queried 1 ... most current pose for controller is queried for example to get pose at button press in highest precision 2 ... future pose for rendering next frame is queried for controllers and hmd add 4 to restrict query to left controller add 8 to restrict query to right controller add 12 to restrict query to both controllers

Definition at line 103 of file vr_kit.cxx.

References vr::vr_driver::calibrate_pose(), vr::vr_kit_state::controller, get_driver(), vr::vr_kit_state::hmd, vr::vr_driver::is_calibration_transformation_enabled(), vr::max_nr_controllers, vr::vr_trackable_state::pose, query_state_impl(), skip_calibration, vr::vr_trackable_state::status, and vr::VRS_TRACKED.

Referenced by cgv::gui::vr_server::check_and_emit_events(), vr_view_interactor::draw_vr_kits(), query_state_impl(), and cgv::gui::vr_calibration::update_driver_calibration().

◆ query_state_impl()

virtual bool vr::vr_kit::query_state_impl ( vr_kit_state & state,
int pose_query )
protectedpure virtual

derived kits implement this without caring about calibration; vr_kit::query_state() will apply driver calibration

Implemented in vr_emulated_kit.

References get_camera(), get_controller_input_config(), get_device_info(), get_driver(), get_handle(), get_name(), query_state(), set_controller_input_config(), and vr_kit().

Referenced by query_state().

◆ ref_tracking_reference_state()

vr_trackable_state & vr::vr_kit::ref_tracking_reference_state ( const std::string & serial_nummer)
protected

write access to the state of the tracking reference with given serial number

Definition at line 13 of file vr_kit.cxx.

References driver.

◆ ref_tracking_system_info()

vr_tracking_system_info & vr::vr_kit::ref_tracking_system_info ( )
protected

write access to tracking system info

Definition at line 18 of file vr_kit.cxx.

References driver.

◆ set_controller_input_config()

void vr::vr_kit::set_controller_input_config ( int controller_index,
int input_index,
const controller_input_config & cic )
virtual

set the configuration of a controller input

A controller can have up to 5 inputs, which can be 1-axis throttels and triggers or 2 axis touchpad (abbreviated as pad) and joysticks (abbreviated as stick). The input type can be checked in vr_kit_info queried with get_device_info(). The provided deadzone, precision and threshold information is used by cgv::gui::vr_server for detection and creation of events.

Definition at line 121 of file vr_kit.cxx.

References input_configs.

Referenced by vr_test::on_set(), and query_state_impl().

◆ set_vibration()

virtual bool vr::vr_kit::set_vibration ( unsigned controller_index,
float low_frequency_strength,
float high_frequency_strength )
pure virtual

set the vibration strength between 0 and 1 of low and high frequency motors, return false if device is not connected anymore

Implemented in vr_emulated_kit.

◆ submit_frame()

virtual void vr::vr_kit::submit_frame ( )
pure virtual

submit the rendered stereo frame to the hmd

Implemented in vr_emulated_kit.

Referenced by vr_view_interactor::after_finish().

Member Data Documentation

◆ camera

vr_camera* vr::vr_kit::camera
protected

pointer to camera

Definition at line 76 of file vr_kit.h.

Referenced by destruct_camera(), get_camera(), vr_kit(), and ~vr_kit().

◆ driver

vr_driver* vr::vr_kit::driver
protected

◆ handle

void* vr::vr_kit::handle
protected

handle for internal use

Definition at line 74 of file vr_kit.h.

Referenced by get_handle(), and vr_kit().

◆ info

vr_kit_info vr::vr_kit::info
protected

store vr kit info to be filled and updated by driver implementations

Definition at line 82 of file vr_kit.h.

Referenced by get_device_info(), and vr_emulated_kit::set_vibration().

◆ input_configs

controller_input_config vr::vr_kit::input_configs[4][5]
protected

store controller input configs per controller and input

Definition at line 84 of file vr_kit.h.

Referenced by get_controller_input_config(), and set_controller_input_config().

◆ name

std::string vr::vr_kit::name
protected

name in case driver provides this information (not reliable)

Definition at line 80 of file vr_kit.h.

Referenced by get_name(), and vr_kit().

◆ skip_calibration

bool vr::vr_kit::skip_calibration
protected

whether to skip driver calibration - defaults to false

Definition at line 78 of file vr_kit.h.

Referenced by query_state(), and vr_kit().


The documentation for this class was generated from the following files: