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>
33 friend class vr_emulator;
44 quat hand_orientation[2];
47 quat tracker_orientations[4];
48 bool tracker_enabled[4];
49 TrackerAttachment tracker_attachments[4];
53 cgv::mat4 construct_homogeneous_matrix(
const quat& orientation,
const cgv::vec3& position);
54 void set_pose_matrix(
const cgv::mat4& H,
float* pose)
const;
55 void compute_state_poses();
58 vr_emulated_kit(
float _body_direction,
const cgv::vec3& _body_position,
float _body_height,
unsigned _width,
unsigned _height,
vr::vr_driver* _driver,
void* _handle,
const std::string& _name,
int _nr_trackers);
60 const std::vector<std::pair<int, int> >& get_controller_throttles_and_sticks(
int controller_index)
const;
61 const std::vector<std::pair<float, float> >& get_controller_throttles_and_sticks_deadzone_and_precision(
int controller_index)
const;
62 bool set_vibration(
unsigned controller_index,
float low_frequency_strength,
float high_frequency_strength);
64 void put_projection_matrix(
int eye,
float z_near,
float z_far,
float* projection_matrix,
const float* hmd_pose)
const;
82class CGV_API vr_emulator :
87 std::vector<vr_emulated_kit*> kits;
88 static bool gamepad_connected;
89 unsigned screen_width, screen_height;
95 InteractionMode interaction_mode;
102 std::vector<cgv::quat> base_orientations;
103 std::vector<cgv::vec3> base_positions;
104 std::vector<std::string> base_serials;
109 mutable std::map<std::string, vr::vr_trackable_state> transformed_reference_states;
115 bool left_ctrl, right_ctrl, up_ctrl, down_ctrl;
116 bool home_ctrl, end_ctrl, pgup_ctrl, pgdn_ctrl;
123 int current_kit_index;
126 void timer_event(
double t,
double dt);
131 void on_set(
void* member_ptr);
177#include <cgv/config/lib_end.h>
std::string name
store the name as a string
The node class keeps a pointer to its parent.
interface for all classes that want to receive events
class to represent all possible keyboard events with the EID_KEY
derive from this class to provide a gui to the current viewer
the self reflection handler is passed to the virtual self_reflect() method of cgv::base::base.
base class for all drawables, which is independent of the used rendering API.
base class for all drawables, which is independent of the used rendering API.
interface class for vr drivers.
a vr kit is composed of headset, two controllers, and two trackers, where all devices can be attached...
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...
void * handle
handle for internal use
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 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....
virtual void submit_frame()=0
submit the rendered stereo frame to the hmd
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....
cgv::mat3x4 construct_pos_matrix(const quat &orientation, const cgv::vec3 &position)
helper functions to construct matrices
void put_up_direction(float *up_dir) const
put a 3d up direction into passed array
void update_reference_states(int i=-1)
update a single renference state or all from base_orientations, base_positions and base_serials
bool self_reflect(cgv::reflect::reflection_handler &srh)
used for simple self reflection
void finish_frame(cgv::render::context &)
this method is called in one pass over all drawables after drawing
std::string get_type_name() const
return the type name
bool init(cgv::render::context &ctx)
this method is called after creation or recreation of the context, return whether all necessary funct...
void init_frame(cgv::render::context &)
this method is called in one pass over all drawables before the draw method
bool is_installed() const
return whether driver is installed
std::string get_driver_name() const
return name of driver
float get_action_zone_height() const
return height of action zone in meters
void stream_stats(std::ostream &)
overload to show the content of this object
void create_controller_gui(int i, vr::vr_controller_state &cs)
void draw(cgv::render::context &)
overload to draw the content of this drawable
void stream_help(std::ostream &os)
overload to stream help information to the given output stream
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...
float get_floor_level() const
return the floor level relativ to the world origin
void put_action_zone_bounary(std::vector< float > &boundary) const
return a vector of floor points defining the action zone boundary as a closed polygon
void create_gui()
you must overload this for gui creation
cgv::math::quaternion< float > quat
declare type of quaternion
cgv::math::fvec< float, 3 > vec3
declare type of 3d single precision floating point vectors
cgv::math::fmat< float, 4, 4 > mat4
declare type of 4x4 matrices
cgv::math::fmat< float, 3, 4 > mat3x4
declare type of 3x4 matrices which are often used to store a pose
VRButtonStateFlags
one flag for each vr controller button
std::vector< void * > scan_vr_kits()
iterate all registered vr drivers to scan for vr kits and return vector of vr kit handles
bool replace_by_pointer(vr_kit *old_kit_ptr, vr_kit *new_kit_ptr)
scan vr kits and if one with given pointer exists, replace it by passed kit; return whether replaceme...
vr_kit * replace_by_index(int vr_kit_index, vr_kit *new_kit_ptr)
scan vr kits and if one of given index exists replace it by passed kit and return index to replaced k...
Extends the trackable state by information on the buttons, input axes and vibration strengths.
structure that stores all information describing the state of a VR kit
a trackable knows whether it is tracked and its 6d pose stored as 3x4 matrix in column major format
defines the class vr::vr_driver class and gives access to the driver registry with the functions vr::...