Go to the documentation of this file.
3 #include <cgv/base/base.h>
4 #include <cgv/render/drawable.h>
5 #include <cgv/math/quaternion.h>
6 #include <cgv/gui/provider.h>
7 #include <cgv/gui/event_handler.h>
8 #include <cgv/gui/key_event.h>
12 #include "lib_begin.h"
20 class CGV_API vr_emulator;
22 enum TrackerAttachment
30 class CGV_API vr_emulated_kit :
public vr::vr_kit,
public cgv::render::render_types
35 friend class vr_emulator;
45 vec3 hand_position[2];
46 quat hand_orientation[2];
48 vec3 tracker_positions[4];
49 quat tracker_orientations[4];
50 bool tracker_enabled[4];
51 TrackerAttachment tracker_attachments[4];
54 mat3x4 construct_pos_matrix(
const quat& orientation,
const vec3& position);
55 mat4 construct_homogeneous_matrix(
const quat& orientation,
const vec3& position);
56 void set_pose_matrix(
const mat4& H,
float* pose)
const;
57 void compute_state_poses();
60 vr_emulated_kit(
float _body_direction,
const vec3& _body_position,
float _body_height,
unsigned _width,
unsigned _height,
vr::vr_driver* _driver,
void* _handle,
const std::string& _name);
61 vec3 get_body_direction()
const;
62 const std::vector<std::pair<int, int> >& get_controller_throttles_and_sticks(
int controller_index)
const;
63 const std::vector<std::pair<float, float> >& get_controller_throttles_and_sticks_deadzone_and_precision(
int controller_index)
const;
64 bool set_vibration(
unsigned controller_index,
float low_frequency_strength,
float high_frequency_strength);
66 void put_projection_matrix(
int eye,
float z_near,
float z_far,
float* projection_matrix,
const float* hmd_pose)
const;
70 enum InteractionMode {
84 class CGV_API vr_emulator :
90 std::vector<vr_emulated_kit*> kits;
91 static bool gamepad_connected;
92 unsigned screen_width, screen_height;
97 InteractionMode interaction_mode;
98 quat hand_orientation[2];
101 quat coordinate_rotation;
102 vec3 coordinate_displacement;
104 std::vector<quat> base_orientations;
105 std::vector<vec3> base_positions;
106 std::vector<std::string> base_serials;
108 void update_reference_states(
int i = -1);
111 mutable std::map<std::string, vr::vr_trackable_state> transformed_reference_states;
117 bool left_ctrl, right_ctrl, up_ctrl, down_ctrl;
118 bool home_ctrl, end_ctrl, pgup_ctrl, pgdn_ctrl;
121 void create_tracker_gui(vr_emulated_kit* kit,
int i);
125 int current_kit_index;
128 void timer_event(
double t,
double dt);
133 void on_set(
void* member_ptr);
179 #include <cgv/config/lib_end.h>
virtual float get_floor_level() const =0
return the floor level relativ to the world origin
std::string get_type_name() const
overload to return the type name of this object
Definition: node.cxx:47
virtual void finish_frame(context &)
this method is called in one pass over all drawables after drawing
Definition: drawable.cxx:119
interface for all classes that want to receive events
Definition: event_handler.h:15
class to represent all possible keyboard events with the EID_KEY
Definition: key_event.h:23
virtual void stream_stats(std::ostream &)
overload to show the content of this object
Definition: base.cxx:25
VRButtonStateFlags
one flag for each vr controller button
Definition: vr_state.h:62
a vr kit is composed of headset, two controllers, and two trackers, where all devices can be attached...
Definition: vr_kit.h:69
bool create_gui(provider *p, const std::string &label, void *value_ptr, const std::string &value_type, const std::string &gui_type, const std::string &options, bool *toggles)
create the gui for a composed structure
Definition: gui_creator.cxx:21
virtual bool init(context &)
this method is called after creation or recreation of the context, return whether all necessary funct...
Definition: drawable.cxx:98
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....
interface class for vr drivers.
Definition: vr_driver.h:57
virtual vr_kit * replace_by_index(int &index, vr_kit *new_kit_ptr)=0
scan all connected vr kits and return a vector with their ids
virtual bool self_reflect(cgv::reflect::reflection_handler &)
used for simple self reflection
Definition: base.cxx:161
derive from this class to provide a gui to the current viewer
Definition: provider.h:64
virtual void init_frame(context &)
this method is called in one pass over all drawables before the draw method
Definition: drawable.cxx:107
virtual bool is_installed() const =0
return whether driver is installed
Definition: reflection_handler.h:63
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 std::string get_driver_name() const =0
return name of driver
a trackable knows whether it is tracked and its 6d pose stored as 3x4 matrix in column major format
Definition: vr_state.h:94
virtual void stream_help(std::ostream &os)=0
overload to stream help information to the given output stream
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...
virtual void draw(context &)
overload to draw the content of this drawable
Definition: drawable.cxx:111
virtual bool handle(event &e)=0
overload and implement this method to handle events
virtual float get_action_zone_height() const =0
return height of action zone in meters
Extends the trackable state by information on the buttons, input axes and vibration strengths.
Definition: vr_state.h:118
virtual void put_up_direction(float *up_dir) const =0
put a 3d up direction into passed array
virtual bool replace_by_pointer(vr_kit *old_kit_ptr, vr_kit *new_kit_ptr)=0
scan all connected vr kits and return a vector with their ids
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....
virtual void on_set(void *member_ptr)
this callback is called when the set_void method has changed a member and can be overloaded in derive...
Definition: base.cxx:210
virtual void submit_frame()=0
submit the rendered stereo frame to the hmd
Definition: drawable.h:15
structure that stores all information describing the state of a VR kit
Definition: vr_state.h:139
virtual void put_action_zone_bounary(std::vector< float > &boundary) const =0
return a vector of floor points defining the action zone boundary as a closed polygon
virtual std::vector< void * > scan_vr_kits()=0
scan all connected vr kits and return a vector with their ids
Definition: context.h:525