2#include <cgv/base/node.h>
3#include <cgv/render/drawable.h>
4#include <cgv/gui/provider.h>
5#include <cgv/gui/event_handler.h>
6#include <cgv_gl/box_renderer.h>
7#include <cgv_gl/gl/mesh_render_info.h>
8#include <cgv_gl/sphere_renderer.h>
9#include <cgv_gl/cone_renderer.h>
10#include <cgv/render/shader_program.h>
11#include <cgv_gl/cone_renderer.h>
12#include <cgv/render/frame_buffer.h>
23#include <cg_vr/vr_server.h>
24#include <plugins/crg_vr_view/vr_view_interactor.h>
25#include <plugins/crg_vr_view/vr_render_helpers.h>
46 enum InteractionState {
54 std::vector<box3> boxes;
55 std::vector<rgb> box_colors;
64 dquat mesh_orientation;
70 std::string label_text;
80 unsigned label_resolution;
85 std::vector<const char*> font_names;
86 std::string font_enum_decl;
93 std::vector<vr::controller_input_config> left_inp_cfg;
96 void* last_kit_handle;
105 std::vector<box3> movable_boxes;
106 std::vector<rgb> movable_box_colors;
107 std::vector<vec3> movable_box_translations;
108 std::vector<quat> movable_box_rotations;
111 std::vector<box3> frame_boxes;
112 std::vector<rgb> frame_box_colors;
113 std::vector<vec3> frame_box_translations;
114 std::vector<quat> frame_box_rotations;
117 std::vector<vec3> intersection_points;
118 std::vector<rgb> intersection_colors;
119 std::vector<int> intersection_box_indices;
120 std::vector<int> intersection_controller_indices;
123 InteractionState state[4];
131 int frame_width, frame_height;
133 float seethrough_gamma;
134 mat4 camera_to_head_matrix[2];
136 vec2 focal_lengths[4];
137 vec2 camera_centers[4];
140 GLuint camera_tex_id;
145 bool show_seethrough;
147 float background_distance;
148 float background_extent;
169 void construct_room(
float w,
float d,
float h,
float W,
bool walls,
bool ceiling);
175 void build_scene(
float w,
float d,
float h,
float W,
float tw,
float td,
float th,
float tW);
179 std::string get_type_name() {
return "vr_test"; }
183 void on_set(
void* member_ptr);
202 bool save_boxes(
const std::string fn,
const std::vector<box3>& boxes,
const std::vector<rgb>& box_colors,
const std::vector<vec3>& box_translations,
const std::vector<quat>& box_rotations);
206 bool load_boxes(
const std::string fn, std::vector<box3>& boxes, std::vector<rgb>& box_colors, std::vector<vec3>& box_translations, std::vector<quat>& box_rotations);
210 void on_save_movable_boxes_cb();
211 void on_load_movable_boxes_cb();
212 void on_load_wireframe_boxes_cb();
213 void clear_movable_boxes();
214 void clear_frame_boxes();
The node class keeps a pointer to its parent.
interface for all classes that want to receive events
derive from this class to provide a gui to the current viewer
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.
this class encapsulate frame buffers that live on the GPU and can be used as destination for the rend...
the mesh_render_info structure manages vertex buffer objects for attribute and element buffers as wel...
a shader program combines several shader code fragments to a complete definition of the shading pipel...
the texture class encapsulates all functionality independent of the rendering api.
a vr kit is composed of headset, two controllers, and two trackers, where all devices can be attached...
void build_scene(float w, float d, float h, float W, float tw, float td, float th, float tW)
construct a scene with a table
bool save_boxes(const std::string fn, const std::vector< box3 > &boxes, const std::vector< rgb > &box_colors, const std::vector< vec3 > &box_translations, const std::vector< quat > &box_rotations)
stores configuration of the movable boxes inside a file
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...
bool load_boxes(const std::string fn, std::vector< box3 > &boxes, std::vector< rgb > &box_colors, std::vector< vec3 > &box_translations, std::vector< quat > &box_rotations)
loads boxes stored by the save_boxes method from a file
void clear(cgv::render::context &ctx)
clear all objects living in the context like textures or display lists
void init_frame(cgv::render::context &ctx)
this method is called in one pass over all drawables before the draw method
void construct_movable_boxes(float tw, float td, float th, float tW, size_t nr)
construct boxes that represent a table of dimensions tw,td,th and leg width tW
void construct_table(float tw, float td, float th, float tW)
construct boxes that represent a table of dimensions tw,td,th and leg width tW
void on_status_change(void *kit_handle, int ci, vr::VRStatus old_status, vr::VRStatus new_status)
keep track of status changes
void construct_environment(float s, float ew, float ed, float w, float d, float h)
construct boxes for environment
void stream_help(std::ostream &os)
overload to stream help information to the given output stream
void construct_room(float w, float d, float h, float W, bool walls, bool ceiling)
construct boxes that represent a room of dimensions w,d,h and wall width W
void on_device_change(void *kit_handle, bool attach)
register on device change events
void draw(cgv::render::context &ctx)
overload to draw the content of this drawable
bool handle(cgv::gui::event &e)
overload and implement this method to handle events
void finish_draw(cgv::render::context &ctx)
this method is called when the current drawable is left in a tree traversal that calls the draw metho...
void create_gui()
you must overload this for gui creation
bool init(cgv::render::context &ctx)
this method is called after creation or recreation of the context, return whether all necessary funct...
void compute_intersections(const vec3 &origin, const vec3 &direction, int ci, const rgb &color)
compute intersection points of controller ray with movable boxes
extends the stereo view interactor for vr support
cgv::math::quaternion< double > dquat
declare type of double quaternion
cgv::media::color< float, cgv::media::RGB, cgv::media::OPACITY > rgba
declare rgba color type with 32 bit components
cgv::math::quaternion< float > quat
declare type of quaternion
cgv::math::fvec< double, 3 > dvec3
declare type of 3d double precision floating point vectors
cgv::media::axis_aligned_box< float, 3 > box3
declare type of 3d single precision floating point axis-aligned boxes
cgv::media::color< float, cgv::media::RGB > rgb
declare rgb color type with 32 bit components
cgv::math::fmat< float, 3, 3 > mat3
declare type of 3x3 matrices
cgv::math::fvec< float, 2 > vec2
declare type of 2d single precision floating point vectors
cgv::math::fvec< float, 3 > vec3
declare type of 3d single precision floating point vectors
cgv::math::fvec< double, 2 > dvec2
declare type of 2d double precision floating point vectors
cgv::math::fmat< float, 4, 4 > mat4
declare type of 4x4 matrices
VRStatus
different status values for a trackable
boxes use surface render styles
render style for sphere rendere
defines the class vr::vr_driver class and gives access to the driver registry with the functions vr::...