cgv
vr_view_interactor Class Reference

extends the stereo view interactor for vr support More...

#include <vr_view_interactor.h>

Inheritance diagram for vr_view_interactor:
vr::vr_calibration_base

Public Member Functions

vr event processing
cgv::gui::VREventTypeFlags get_event_type_flags () const
 query the currently set event type flags
 
void set_event_type_flags (cgv::gui::VREventTypeFlags flags)
 set the event type flags of to be emitted events
 
bool vr_event_debugging_enabled () const
 check whether vr events are printed to the console window
 
void enable_vr_event_debugging (bool enable=true)
 set whether vr events should be printed to the console window
 
const vr::vr_kit_stateget_current_vr_state () const
 return a pointer to the state of the current vr kit
 
vr::vr_kitget_current_vr_kit () const
 return a pointer to the current vr kit
 
void query_vr_states ()
 
vr viewing
dvec3 get_view_dir_of_kit (int vr_kit_idx=-1) const
 query view direction of a vr kit More...
 
dvec3 get_view_up_dir_of_kit (int vr_kit_idx=-1) const
 query view up direction of a vr kit More...
 
dvec3 get_eye_of_kit (int eye=0, int vr_kit_idx=-1) const
 query the eye position of a vr kit. More...
 
vr rendering
bool seperate_view_drawn () const
 check whether separate view is rendered
 
void draw_separate_view (bool do_draw)
 set whether to draw separate view
 
bool vr_kits_drawn () const
 check whether vr kits are drawn
 
void draw_vr_kits (bool do_draw)
 set whether to draw vr kits More...
 
bool action_zone_drawn () const
 check whether action zone is drawn
 
void draw_action_zone (bool do_draw)
 whether to draw action zone
 
bool blit_vr_views_enabled () const
 check whether vr views are blitted
 
void enable_blit_vr_views (bool enable)
 enable vr view blitting
 
int get_blit_vr_view_width () const
 return width of vr view blitting
 
void set_blit_vr_view_width (int width)
 set the width with which vr views are blit
 
vr render process
int get_rendered_eye () const
 return the currently rendered eye
 
vr::gl_vr_displayget_rendered_display () const
 
vr::vr_kitget_rendered_vr_kit () const
 
void on_set (void *member_ptr)
 
void stream_stats (std::ostream &)
 overload to show the content of this object
 
bool init (cgv::render::context &ctx)
 
void clear (cgv::render::context &ctx)
 
bool handle_vr_events (cgv::gui::event &e)
 overload and implement this method to handle events More...
 
bool handle (cgv::gui::event &e)
 overload and implement this method to handle events
 
void stream_help (std::ostream &os)
 overload to stream help information to the given output stream
 
void render_vr_kits (cgv::render::context &ctx)
 
void init_frame (cgv::render::context &)
 this method is called in one pass over all drawables before the draw method
 
void draw_vr_kits (cgv::render::context &ctx)
 draw the vr kits in the current view
 
void draw_action_zone (cgv::render::context &ctx)
 draw the action zone of the current vr kit
 
void draw (cgv::render::context &)
 draw all
 
void finish_frame (cgv::render::context &)
 this method is called in one pass over all drawables after drawing
 
void after_finish (cgv::render::context &ctx)
 this method is called in one pass over all drawables after finish frame
 
bool self_reflect (cgv::reflect::reflection_handler &srh)
 you must overload this for gui creation
 
void create_gui ()
 you must overload this for gui creation
 

Protected Member Functions

void set_driver_calibration_matrix (vr_driver *driver, const float calibration_matrix[12]) const
 single point of write access to calibration transformation of vr drivers
 

Protected Attributes

head tracking
mat3 head_tracker_orientation
 head orientation from tracker orientation
 
vec3 head_tracker_position
 head position from tracker location
 

calibation of tracker coordinate system

the calibration affects the tracked poses as follows:

mat3 rotation = cgv::math::rotate3<float>(tracking_rotation, vec3(0, 1, 0)); mat3 orientation_world = rotation * orientation_raw; vec3 position_world = rotation * (position_raw - tracking_rotation_origin) + tracking_origin;

or more brief: O = R*Q; p = R*(q-q0) + o;

p = R*(q-q0) + o; o = p - R*(q - q0);

to identify the current focus point f in world coordinates with the raw tracker position q and the rotation origin also with q we compute

q0 = q; o = p;

Now rotation will happen around calibration point.

typedef cgv::math::fmat< float, 3, 4 > mat34
 
float tracking_rotation
 rotation angle around the y-axis
 
vec3 tracking_rotation_origin
 location in tracking coordinate system around which rotation is defined
 
vec3 tracking_origin
 origin of tracking coordinate system given in world coordinates
 
std::string calibration_file_path
 path to calibration file
 
bool separate_view
 whether the window shows a separate view onto the scene or the one of the current vr kit
 
bool dont_render_kits
 whether to not render for kits
 
bool blit_vr_views
 whether to blit in the views of the vr kits
 
int blit_width
 
float blit_aspect_scale
 scale of aspect ratio used for blitting
 
int none_separate_view
 selection of view of current hmd used in case of no separate view (1 ... left, 2 ... right, 3 ... both)
 
int head_tracker
 
int rendered_eye
 
vr::gl_vr_displayrendered_display_ptr
 
int rendered_display_index
 
cgv::gui::VREventTypeFlags event_flags
 
bool debug_vr_events
 
VRkitVisType vis_type
 
VRkitVisType hmd_vis_type
 
VRkitVisType controller_vis_type
 
VRkitVisType tracker_vis_type
 
VRkitVisType base_vis_type
 
bool show_action_zone
 
rgb fence_color1
 
rgb fence_color2
 
float fence_frequency
 
float fence_line_width
 
void * current_vr_handle
 
int current_vr_handle_index
 
std::string kit_enum_definition
 
std::vector< vr::vr_kit_statekit_states
 
std::vector< void * > new_kits
 
std::vector< void * > kits
 
std::vector< void * > old_kits
 
int pose_query
 type of pose query according to vr::vr_kit::query_state function's 2nd parameter
 
cgv::render::box_renderer br
 
cgv::render::surface_render_style brs
 
cgv::render::sphere_render_style srs
 
std::string hmd_mesh_file_name
 
std::string controller_mesh_file_name
 
std::string tracker_mesh_file_name
 
std::string base_mesh_file_name
 
float mesh_scales [4]
 
void calibrate_driver ()
 perform driver calibration
 
vr::vr_kitget_vr_kit_from_index (int i) const
 
void configure_kits ()
 
void on_status_change (void *handle, int controller_index, vr::VRStatus old_status, vr::VRStatus new_status)
 
virtual void on_device_change (void *handle, bool attach)
 
void add_trackable_spheres (const float *pose, int i, std::vector< vec4 > &spheres, std::vector< rgb > &sphere_colors)
 helper to visualize pose with colored spheres
 
void set_tracking_rotation (float tr)
 
float get_tracking_rotation ()
 
void set_tracking_origin (vec3 ori)
 
vec3 get_tracking_origin ()
 
 vr_view_interactor (const char *name)
 
std::string get_type_name () const
 return the type name
 

Detailed Description

extends the stereo view interactor for vr support

Besides adding the crg_vr_view plugin to your project, you can configure the vr_view_interactor in your cgv::render::drawable::init() function similar to the following example:

#include <vr_view_interactor.h>
bool your_class::init(cgv::render::context& ctx)
{
auto view_ptr = find_view_as_node();
if (view_ptr) {
// if the view points to a vr_view_interactor
vr_view_ptr = dynamic_cast<vr_view_interactor*>(view_ptr);
if (vr_view_ptr) {
// configure vr event processing
vr_view_ptr->set_event_type_flags(
cgv::gui::VRE_THROTTLE+
cgv::gui::VRE_STICK +
cgv::gui::VRE_STICK_KEY +
));
vr_view_ptr->enable_vr_event_debugging(false);
// configure vr rendering
vr_view_ptr->draw_action_zone(false);
vr_view_ptr->draw_vr_kits(true);
vr_view_ptr->enable_blit_vr_views(true);
vr_view_ptr->set_blit_vr_view_width(200);
}
}
// more application specific init here
return true;
}

Member Function Documentation

◆ draw_vr_kits()

void vr_view_interactor::draw_vr_kits ( bool  do_draw)

set whether to draw vr kits

whether to draw vr kits

◆ get_eye_of_kit()

vr_view_interactor::dvec3 vr_view_interactor::get_eye_of_kit ( int  eye = 0,
int  vr_kit_idx = -1 
) const

query the eye position of a vr kit.

parameter eye is one of -1 .. left eye 0 .. cyclopic eye 1 .. right eye if parameter vr_kit_idx defaults to -1, the eye position of the current vr kit is returned if there are not vr kits or the vr_kit_idx parameter is invalid the eye position of the vr_view_interactor is returned

◆ get_rendered_display()

vr::gl_vr_display* vr_view_interactor::get_rendered_display ( ) const
inline

return the vr kit currently rendered return a pointer to the current vr kit

◆ get_view_dir_of_kit()

vr_view_interactor::dvec3 vr_view_interactor::get_view_dir_of_kit ( int  vr_kit_idx = -1) const

query view direction of a vr kit

if parameter vr_kit_idx defaults to -1, the view direction of the current vr kit is returned if there are not vr kits or the vr_kit_idx parameter is invalid the view direction of the vr_view_interactor is returned

◆ get_view_up_dir_of_kit()

vr_view_interactor::dvec3 vr_view_interactor::get_view_up_dir_of_kit ( int  vr_kit_idx = -1) const

query view up direction of a vr kit

if parameter vr_kit_idx defaults to -1, the view up direction of the current vr kit is returned if there are not vr kits or the vr_kit_idx parameter is invalid the view up direction of the vr_view_interactor is returned

◆ handle_vr_events()

bool vr_view_interactor::handle_vr_events ( cgv::gui::event e)

overload and implement this method to handle events

factored our vr event handling


The documentation for this class was generated from the following files:
vr_view_interactor
extends the stereo view interactor for vr support
Definition: vr_view_interactor.h:67
vr_view_interactor::set_event_type_flags
void set_event_type_flags(cgv::gui::VREventTypeFlags flags)
set the event type flags of to be emitted events
Definition: vr_view_interactor.cxx:162
cgv::gui::view_ptr
data::ref_ptr< abst_view > view_ptr
ref counted pointer to abst view
Definition: view.h:36
cgv::gui::connect_vr_server
void connect_vr_server(bool connect_device_change_only_to_animation_trigger, cgv::gui::window_ptr w)
connect the gamepad server to the given window or the first window of the application,...
Definition: vr_server.cxx:414
cgv::gui::VRE_KEY
@ VRE_KEY
key events
Definition: vr_server.h:31
cgv::gui::VREventTypeFlags
VREventTypeFlags
flags to define which events should be generated by server
Definition: vr_server.h:27
cgv::gui::VRE_POSE
@ VRE_POSE
pose events
Definition: vr_server.h:36
cgv::render::context
Definition: context.h:525