cgv
vr Namespace Reference

the vr namespace for virtual reality support More...

Classes

struct  controller_input_config
 configuration of a controller input axis More...
 
struct  driver_registry
 use this template to register your own driver More...
 
class  gl_vr_display
 implements offscreen rendering More...
 
class  vr_calibration_base
 base class with write access to driver calibration matrix More...
 
class  vr_camera
 interface for mono or stereo cameras in VR headsets More...
 
struct  vr_controller_info
 information provided for controller devices More...
 
struct  vr_controller_state
 Extends the trackable state by information on the buttons, input axes and vibration strengths. More...
 
struct  vr_device_info
 information provided for any device type More...
 
class  vr_driver
 interface class for vr drivers. More...
 
struct  vr_hmd_info
 information provided for hmd device More...
 
class  vr_kit
 a vr kit is composed of headset, two controllers, and two trackers, where all devices can be attached or detached More...
 
struct  vr_kit_info
 information provided for a vr kit More...
 
struct  vr_kit_state
 structure that stores all information describing the state of a VR kit More...
 
class  vr_log
 helper struct for logging vr events More...
 
struct  vr_trackable_info
 information provided for trackable devices More...
 
struct  vr_trackable_state
 a trackable knows whether it is tracked and its 6d pose stored as 3x4 matrix in column major format More...
 
struct  vr_tracking_reference_info
 information provided for a base station / tracking reference More...
 
struct  vr_tracking_system_info
 information provided for tracking system More...
 

Enumerations

enum  EyeSelection
 enum to support restriction of eyes to a single eye
 
enum  CameraState
 different status values for a vr camera
 
enum  CameraFrameFormat
 currently only a single frame format supported
 
enum  CameraFrameSplit
 in case of stereo cameras a frame contains images of both eyes either split vertically (left right) or horizontally (top bottom)
 
enum  VRControllerType
 type of controller
 
enum  VRControllerRole
 role of controller
 
enum  VRInputType
 different controller input types
 
enum  VRAxisType
 different axis types of controller inputs
 
enum  KeyAction
 repeated definition from cgv/gui/key_event.h
 
enum  VRKeys { ,
  VR_SYSTEM, VR_MENU, VR_GRIP, VR_DPAD_DOWN_LEFT,
  VR_DPAD_DOWN, VR_DPAD_DOWN_RIGHT, VR_DPAD_LEFT, VR_DPAD_RIGHT,
  VR_DPAD_UP_LEFT, VR_DPAD_UP, VR_DPAD_UP_RIGHT, VR_A,
  VR_INPUT0_TOUCH, VR_INPUT0, VR_INPUT1_TOUCH, VR_INPUT1,
  VR_INPUT2_TOUCH, VR_INPUT2, VR_INPUT3_TOUCH, VR_INPUT3,
  VR_INPUT4_TOUCH, VR_INPUT4, VR_PROXIMITY, VR_END,
  VR_BEGIN =VR_SYSTEM
}
 enumerate all VR keys starting at 1024 More...
 
enum  VRButtonStateFlags {
  VRF_SYSTEM = 0x000001, VRF_MENU = 0x000002, VRF_GRIP = 0x000004, VRF_DPAD_LEFT = 0x000008,
  VRF_DPAD_RIGHT = 0x000010, VRF_DPAD_DOWN = 0x000020, VRF_DPAD_UP = 0x000040, VRF_A = 0x000080,
  VRF_INPUT0_TOUCH = 0x000100, VRF_INPUT0 = 0x000200, VRF_INPUT1_TOUCH = 0x000400, VRF_INPUT1 = 0x000800,
  VRF_INPUT2_TOUCH = 0x001000, VRF_INPUT2 = 0x002000, VRF_INPUT3_TOUCH = 0x004000, VRF_INPUT3 = 0x008000,
  VRF_INPUT4_TOUCH = 0x010000, VRF_INPUT4 = 0x020000, VRF_PROXIMITY = 0x040000
}
 one flag for each vr controller button More...
 
enum  VRStatus { VRS_DETACHED, VRS_ATTACHED, VRS_TRACKED }
 different status values for a trackable More...
 
enum  VRMeshId
 enumerate for different mesh types
 

Functions

std::map< void *, vr_kit * > & ref_vr_kit_map ()
 access to vr_kit map singleton
 
std::vector< vr_driver * > & ref_drivers ()
 return registered drivers
 
std::ostream & operator<< (std::ostream &os, const vr_device_info &di)
 stream out operator for device infos
 
std::ostream & operator<< (std::ostream &os, const vr_trackable_info &TI)
 stream out operator for trackable device infos
 
std::ostream & operator<< (std::ostream &os, const vr_hmd_info &HI)
 stream out operator for hmd device infos
 
std::ostream & operator<< (std::ostream &os, const vr_controller_info &CI)
 stream out operator for controller device infos
 
std::ostream & operator<< (std::ostream &os, const vr_kit_info &VI)
 stream out operator for vr kit info
 
std::ostream & operator<< (std::ostream &os, const vr_tracking_reference_info &TI)
 stream out operator for tracking reference device infos
 
std::ostream & operator<< (std::ostream &os, const vr_tracking_system_info &TSI)
 stream out operator for tracking system infos
 
std::string get_key_string (unsigned short key)
 convert key to string
 
std::string get_state_flag_string (VRButtonStateFlags flags)
 convert flags to string
 
std::string get_status_string (VRStatus status)
 convert flags to string
 
const std::string & get_vrmesh_file_name (VRMeshId id)
 return the file name for the given vrmesh type
 
void set_vrmesh_file_name (VRMeshId id, const std::string &file_name)
 set the file name for the given vrmesh type
 
cgv::render::mesh_render_infoget_vrmesh_render_info (cgv::render::context &ctx, VRMeshId id)
 return a pointer to a mesh info structure for the given mesh type (read and construct if necessary); returns 0 pointer if mesh is not available
 
cgv::render::render_types::mat4 get_mat4_from_pose (const float pose_matrix[12])
 convert pose to mat4
 
cgv::render::render_types::mat4 get_world_to_eye_transform (const vr_kit *vr_kit_ptr, const vr_kit_state &state, int eye)
 compute lookat matrix for a given eye (0 ... left, 1 ... right)
 
cgv::render::render_types::mat4 get_world_to_camera_transform (const vr_kit *vr_kit_ptr, const vr_kit_state &state, int eye)
 compute lookat matrix for a given camera (0 ... left, 1 ... right)
 
cgv::render::render_types::mat4 get_eye_projection_transform (const vr_kit *vr_kit_ptr, const vr_kit_state &state, float z_near, float z_far, int eye)
 query projection matrix for a given eye (0 ... left, 1 ... right)
 
cgv::render::render_types::mat4 get_camera_projection_transform (const vr_kit *vr_kit_ptr, float z_near, float z_far, int eye, bool undistorted)
 query projection matrix for a given camera (0 ... left or mono, 1 ... right only for stereo cameras)
 
cgv::render::render_types::mat4 get_texture_transform (const vr_kit *vr_kit_ptr, const vr_kit_state &state, float z_near, float z_far, int eye, bool undistorted)
 query the texture matrix needed for projective texture mapping for a given camera (0 ... left or mono, 1 ... right only for stereo cameras)
 
bool configure_seethrough_shader_program (cgv::render::context &ctx, cgv::render::shader_program &prog, uint32_t frame_width, uint32_t frame_height, const vr_kit *vr_kit_ptr, const vr_kit_state &state, float z_near, float z_far, int eye, bool undistorted)
 set all uniforms of seethrough shader program for a given camera (0 ... left or mono, 1 ... right only for stereo cameras). More...
 

Variables

const unsigned max_nr_controllers = 8
 maximum number of attachable controller and tracker devices
 
const unsigned max_nr_controller_inputs = 5
 maximum number of inputs per controller
 
const unsigned max_nr_controller_axes = 8
 maximum number of axes per controller
 

vr driver management

class CGV_API vr_driver
 forward declaration of vr driver class More...
 
void register_driver (vr_driver *vrd)
 register a new driver
 
std::vector< vr_driver * > & get_vr_drivers ()
 return a vector with all registered vr drivers
 

Detailed Description

the vr namespace for virtual reality support

provides functions bridging the basic vr support with the cgv framework

the helper functions allow to compute the modelview, projection and texture matrices needed for rendering.

Enumeration Type Documentation

◆ VRButtonStateFlags

one flag for each vr controller button

Enumerator
VRF_SYSTEM 

system button

VRF_MENU 

application menu button

VRF_GRIP 

grip button

VRF_DPAD_LEFT 

direction pad left button

VRF_DPAD_RIGHT 

direction pad right button

VRF_DPAD_DOWN 

direction pad down button

VRF_DPAD_UP 

direction pad up button

VRF_A 

A button.

VRF_INPUT0_TOUCH 

touch sensor for input 0 which often is touchpad or stick

VRF_INPUT0 

button of input 0

VRF_INPUT1_TOUCH 

touch sensor for input 1 which often is touchpad or stick

VRF_INPUT1 

button of input 1

VRF_INPUT2_TOUCH 

touch sensor for input 2 which often is touchpad or stick

VRF_INPUT2 

button of input 2

VRF_INPUT3_TOUCH 

touch sensor for input 3 which often is touchpad or stick

VRF_INPUT3 

button of input 3

VRF_INPUT4_TOUCH 

touch sensor for input 4 which often is touchpad or stick

VRF_INPUT4 

button of input 4

VRF_PROXIMITY 

proximity sensor

◆ VRKeys

enum vr::VRKeys

enumerate all VR keys starting at 1024

Enumerator
VR_SYSTEM 

VIVE: system button; occulus: ???

VR_MENU 

VIVE: menu button; occulus: start button.

VR_GRIP 

grip button

VR_DPAD_DOWN_LEFT 

direction pad diagonally down and left

VR_DPAD_DOWN 

direction pad down

VR_DPAD_DOWN_RIGHT 

direction pad diagonally down and right

VR_DPAD_LEFT 

direction pad left

VR_DPAD_RIGHT 

direction pad right

VR_DPAD_UP_LEFT 

direction pad diagonally up and left

VR_DPAD_UP 

direction pad up

VR_DPAD_UP_RIGHT 

direction pad diagonally up and right

VR_A 

A button.

VR_INPUT0_TOUCH 

touched input 0

VR_INPUT0 

input 0

VR_INPUT1_TOUCH 

touched input 1

VR_INPUT1 

input 1

VR_INPUT2_TOUCH 

touched input 2

VR_INPUT2 

input 2

VR_INPUT3_TOUCH 

touched input 3

VR_INPUT3 

input 3

VR_INPUT4_TOUCH 

touched input 4

VR_INPUT4 

input 4

VR_PROXIMITY 

proximity sensor

VR_END 

end marker used in for loops over all VR keys

VR_BEGIN 

begin marker used in for loops over all VR keys

◆ VRStatus

different status values for a trackable

Enumerator
VRS_DETACHED 

trackable is not reachable via wireless

VRS_ATTACHED 

trackable is connected via wireless but not tracked

VRS_TRACKED 

trackable is connected and tracked

Function Documentation

◆ configure_seethrough_shader_program()

CGV_API bool vr::configure_seethrough_shader_program ( cgv::render::context ctx,
cgv::render::shader_program prog,
uint32_t  frame_width,
uint32_t  frame_height,
const vr_kit vr_kit_ptr,
const vr_kit_state state,
float  z_near,
float  z_far,
int  eye,
bool  undistorted 
)

set all uniforms of seethrough shader program for a given camera (0 ... left or mono, 1 ... right only for stereo cameras).

For this the get_texture_transform is used to compute the texture matrix. Return whether setting the uniforms was successful.

Variable Documentation

◆ vr_driver

class CGV_API vr::vr_driver

forward declaration of vr driver class

give vr driver access to camera initialization and destruction