cgv
|
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>
Public Member Functions | |
const vr_driver * | get_driver () const |
return driver | |
void * | get_handle () const |
return handle of vr kit More... | |
vr_camera * | get_camera () const |
return camera or nullptr if not available More... | |
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 More... | |
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 More... | |
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) More... | |
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 | |
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 | |
unsigned | width |
pixel dimensions of render targets | |
unsigned | multi_depth_buffer_id [2] |
ids of gl render objects | |
std::string | last_error |
store last error message | |
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:
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]).
vr_camera * vr::vr_kit::get_camera | ( | ) | const |
return camera or nullptr if not available
return camera
void * vr::vr_kit::get_handle | ( | ) | const |
return handle of vr kit
return device handle
|
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
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
state | state is returned by writing it into passed reference |
pose_query | is 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 |
|
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.