From 427a49f48a32d21166317dd9bc3916f48ff682c5 Mon Sep 17 00:00:00 2001 From: gumhold Date: Sun, 24 Mar 2019 14:51:31 +0100 Subject: [PATCH] added support for data path and vr mesh rendering of controller and hmd --- cgv/base/import.cxx | 1 - cgv/math/ftransform.h | 29 +++++ cgv/media/illum/textured_surface_material.cxx | 7 +- cgv/media/image/bmp_reader.cxx | 1 - cgv/media/mesh/obj_reader.cxx | 3 +- cgv/render/clipped_view.cxx | 7 +- define_data_dir.bat | 32 +++++ define_support_dir.bat | 2 +- libs/cgv_gl/gl/mesh_render_info.h | 2 + libs/cgv_gl/glsl/textured_surface.glfs | 9 +- libs/cgv_gl/glsl/textured_surface.glpr | 7 +- plugins/crg_vr_view/vr_view_interactor.cxx | 121 ++++++++++++------ plugins/crg_vr_view/vr_view_interactor.h | 7 + plugins/examples/buffer_test.cxx | 28 ++-- plugins/examples/shape.cxx | 31 +---- plugins/examples/shape.h | 10 +- plugins/vr_test/vr_test.pj | 2 +- show_system_variables.bat | 1 + 18 files changed, 194 insertions(+), 106 deletions(-) create mode 100644 define_data_dir.bat diff --git a/cgv/base/import.cxx b/cgv/base/import.cxx index 3336d8326..4f843b8aa 100644 --- a/cgv/base/import.cxx +++ b/cgv/base/import.cxx @@ -58,7 +58,6 @@ std::string find_data_file_1(const std::string& base_path, const std::string& su std::string find_data_file(const std::string& file_name, const std::string& strategy, const std::string& sub_directory, const std::string& master_path) { -// std::cout << "find " << file_name << " in " << std::endl; for (unsigned i=0; i fmat rotate4(const T& A, const T& ax, const T& ay, const T& az) { return rotate4(A, fvec(ax, ay, az)); } + /// construct 4x4 pose matrix from a 3x4 matrix + template fmat + pose4(const fmat& M) { + fmat M4; + M4.set_col(0, fvec(M.col(0), 0)); + M4.set_col(1, fvec(M.col(1), 0)); + M4.set_col(2, fvec(M.col(2), 0)); + M4.set_col(3, fvec(M.col(3), 1)); + return M4; + } + /// construct 4x4 pose matrix from a 3x3 rotation matrix and translation vector + template fmat + pose4(const fmat& R, const fvec& t) { + fmat M4; + M4.set_col(0, fvec(R.col(0), 0)); + M4.set_col(1, fvec(R.col(1), 0)); + M4.set_col(2, fvec(R.col(2), 0)); + M4.set_col(3, fvec(t, 1)); + return M4; + } + + /// construct 4x4 pose matrix from quaternion and translation vector + template fmat + pose4(const quaternion& q, const fvec& t) { + fmat R; + q.put_matrix(R); + return pose4(R, t); + } + /// return rigid body transformation that performs look at transformation template fmat look_at4(const fvec& eye, const fvec& focus, const fvec& view_up_dir) { diff --git a/cgv/media/illum/textured_surface_material.cxx b/cgv/media/illum/textured_surface_material.cxx index 03eeb801c..9dd77c22c 100644 --- a/cgv/media/illum/textured_surface_material.cxx +++ b/cgv/media/illum/textured_surface_material.cxx @@ -32,7 +32,7 @@ textured_surface_material::textured_surface_material( normal_index = -1; bump_index = -1; specular_index = -1; - sRGBA_textures = true; + sRGBA_textures = false; } /// set whether textures are interpreted in sRGB format @@ -44,6 +44,7 @@ void textured_surface_material::set_sRGBA_textures(bool do_set) /// convert obj material textured_surface_material::textured_surface_material(const obj_material& obj_mat) { + sRGBA_textures = false; diffuse_index = -1; roughness_index = -1; metalness_index = -1; @@ -57,7 +58,9 @@ textured_surface_material::textured_surface_material(const obj_material& obj_mat set_name(obj_mat.get_name()); set_brdf_type(BrdfType(BT_LAMBERTIAN + BT_PHONG)); obj_material::color_type a = obj_mat.get_ambient(), d = obj_mat.get_diffuse(); - set_ambient_occlusion(sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]) / sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2])); + float la = sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]); + float ld = sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]); + set_ambient_occlusion(la >= ld ? la : la/ld); set_diffuse_reflectance(obj_mat.get_diffuse()); set_specular_reflectance(obj_mat.get_specular()); set_emission(obj_mat.get_emission()); diff --git a/cgv/media/image/bmp_reader.cxx b/cgv/media/image/bmp_reader.cxx index af33366be..34575f7c1 100644 --- a/cgv/media/image/bmp_reader.cxx +++ b/cgv/media/image/bmp_reader.cxx @@ -61,7 +61,6 @@ bool bmp_reader::open(const std::string& file_name, data_format& df, std::vector palette.clear(); fp = cgv::base::open_data_file(file_name.c_str(), "rb"); -// fp = fopen(file_name.c_str(), "rb"); if (!fp) { last_error = "could not open file: "; last_error += file_name; diff --git a/cgv/media/mesh/obj_reader.cxx b/cgv/media/mesh/obj_reader.cxx index ab123ba00..d7c3bc56a 100644 --- a/cgv/media/mesh/obj_reader.cxx +++ b/cgv/media/mesh/obj_reader.cxx @@ -1,5 +1,6 @@ #include "obj_reader.h" #include +#include #include #include #include @@ -177,7 +178,7 @@ template bool obj_reader_generic::read_obj(const std::string& file_name) { std::string content; - if (!file::read(file_name, content, true)) + if (!cgv::base::read_data_file(file_name, content, true)) return false; path_name = file::get_path(file_name); diff --git a/cgv/render/clipped_view.cxx b/cgv/render/clipped_view.cxx index 208a844ee..882d3334d 100644 --- a/cgv/render/clipped_view.cxx +++ b/cgv/render/clipped_view.cxx @@ -94,7 +94,12 @@ void clipped_view::compute_clipping_planes(const cgv::render::view& view, double if (z_min > z_near) z_near_derived = z_min; if (z_max > z_near) - z_far_derived = 1.2*z_max; + z_far_derived = z_max; + + if (clip_relative_to_extent) { + z_near_derived *= z_near; + z_far_derived *= z_far; + } } else if (clip_relative_to_extent) { z_near_derived = y_extent_at_focus*z_near; diff --git a/define_data_dir.bat b/define_data_dir.bat new file mode 100644 index 000000000..3c35b41ef --- /dev/null +++ b/define_data_dir.bat @@ -0,0 +1,32 @@ +@echo off +setlocal EnableDelayedExpansion +%~d0 +cd %~p0 +set my_path=%~dp0 +set cgvdir=%my_path:~0,-1% +set cgvdata=%cgvdir%\data +if [%1] == [] ( + set param="" +) else ( + set param=%1 +) +set param=%param:"=% +if NOT [%1] == [] ( + if EXIST "%param%\..\%~n1" ( + call set cgvdata=%param% + ) else ( + echo only directories valid as data path argument + echo "%param%\..\%~n1" does not exist + pause + goto:eof + ) +) else ( + echo no cgv data directory dragged onto batch script + pause + goto:eof +) +call reg ADD HKEY_CURRENT_USER\Environment /v CGV_DATA /t REG_SZ /d "%cgvdata%" /f > nul 2> nul +bin\setx CGV_DUMMY "" +call reg DELETE HKEY_CURRENT_USER\Environment /v CGV_DUMMY /f >nul 2> nul +echo set CGV_DATA to %cgvdata% +pause diff --git a/define_support_dir.bat b/define_support_dir.bat index e0183eaea..61602075e 100644 --- a/define_support_dir.bat +++ b/define_support_dir.bat @@ -21,7 +21,7 @@ if NOT [%1] == [] ( goto:eof ) ) else ( - echo no cgv project directory dragged onto batch script + echo no cgv support directory dragged onto batch script pause goto:eof ) diff --git a/libs/cgv_gl/gl/mesh_render_info.h b/libs/cgv_gl/gl/mesh_render_info.h index 7ae191995..167044bd5 100644 --- a/libs/cgv_gl/gl/mesh_render_info.h +++ b/libs/cgv_gl/gl/mesh_render_info.h @@ -33,6 +33,8 @@ namespace cgv { mesh_render_info(); /// void destruct(cgv::render::context& ctx); + /// check whether info is constructed + bool is_constructed() const { return vbo.is_created(); } /// void construct_base(cgv::render::context& c, const cgv::media::mesh::simple_mesh_base& mesh, std::vector& vertex_indices, std::vector& unique_triples, diff --git a/libs/cgv_gl/glsl/textured_surface.glfs b/libs/cgv_gl/glsl/textured_surface.glfs index 3eeb4fc2d..e9e4f43c3 100644 --- a/libs/cgv_gl/glsl/textured_surface.glfs +++ b/libs/cgv_gl/glsl/textured_surface.glfs @@ -5,9 +5,10 @@ in vec3 position_eye; in vec4 color_fs; in vec2 texcoord_fs; -out vec4 frag_color; - +//***** begin interface of fragment.glfs *********************************** uniform float gamma = 2.2; +void finish_fragment(vec4 color); +//***** end interface of fragment.glfs *********************************** //***** begin interface of surface.glsl *********************************** struct Material { @@ -43,7 +44,5 @@ void main() if (!keep_this_side(position_eye, normal, side)) discard; - frag_color = compute_reflected_appearance_texture(position_eye, normal, texcoord_fs, color_fs, side); - // perform inverse gamma correction - frag_color.rgb = pow(frag_color.rgb, vec3(gamma)); + finish_fragment(compute_reflected_appearance_texture(position_eye, normal, texcoord_fs, color_fs, side)); } \ No newline at end of file diff --git a/libs/cgv_gl/glsl/textured_surface.glpr b/libs/cgv_gl/glsl/textured_surface.glpr index 842dd3c56..7e1a19fa6 100644 --- a/libs/cgv_gl/glsl/textured_surface.glpr +++ b/libs/cgv_gl/glsl/textured_surface.glpr @@ -1,8 +1,9 @@ files:textured_surface -fragment_file:lights.glsl -fragment_file:brdf.glsl -fragment_file:bump_map.glfs vertex_file:brdf.glsl vertex_file:view.glsl +fragment_file:fragment.glfs fragment_file:side.glsl fragment_file:surface.glsl +fragment_file:lights.glsl +fragment_file:brdf.glsl +fragment_file:bump_map.glfs diff --git a/plugins/crg_vr_view/vr_view_interactor.cxx b/plugins/crg_vr_view/vr_view_interactor.cxx index 55ed660df..024924fd5 100644 --- a/plugins/crg_vr_view/vr_view_interactor.cxx +++ b/plugins/crg_vr_view/vr_view_interactor.cxx @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,9 @@ vr_view_interactor::vr_view_interactor(const char* name) : stereo_view_interacto fence_frequency = 5; fence_line_width = 3; show_vr_kits = true; + show_vr_kits_as_spheres = false; + show_vr_kits_as_meshes = true; + show_action_zone = false; current_vr_handle = 0; current_vr_handle_index = 0; @@ -171,6 +175,21 @@ void vr_view_interactor::stream_stats(std::ostream& os) bool vr_view_interactor::init(cgv::render::context& ctx) { cgv::render::ref_sphere_renderer(ctx, 1); + cgv::media::mesh::simple_mesh M; + if (M.read(cgv::base::find_data_file("vr_controller_vive_1_5.obj", "D"))) + MI_controller.construct(ctx, M); + cgv::media::mesh::simple_mesh M2; + if (M2.read(cgv::base::find_data_file("generic_hmd.obj", "D"))) + MI_hmd.construct(ctx, M2); + + if (!MI_hmd.is_constructed() && !MI_controller.is_constructed()) { + show_vr_kits_as_meshes = false; + on_set(&show_vr_kits_as_meshes); + if (!show_vr_kits_as_spheres) { + show_vr_kits_as_spheres = true; + on_set(&show_vr_kits_as_spheres); + } + } return stereo_view_interactor::init(ctx); } @@ -434,53 +453,75 @@ void vr_view_interactor::draw(cgv::render::context& ctx) vr::vr_kit_state state; vr::vr_kit_state* state_ptr = &state; if (handle == current_vr_handle) - state_ptr = &kit_states[current_vr_handle_index-1]; + state_ptr = &kit_states[current_vr_handle_index - 1]; else if (!kit_ptr->query_state(state, 1)) continue; - float left_eye_to_head[12]; - float right_eye_to_head[12]; - kit_ptr->put_eye_to_head_matrix(0, left_eye_to_head); - kit_ptr->put_eye_to_head_matrix(1, right_eye_to_head); - const mat3& R_w_h = reinterpret_cast(state_ptr->hmd.pose[0]); - const vec3& p_w_h = reinterpret_cast(state_ptr->hmd.pose[9]); + if (show_vr_kits_as_meshes && MI_hmd.is_constructed()) { + if (kit_ptr != rendered_kit_ptr) { + ctx.push_modelview_matrix(); + ctx.mul_modelview_matrix( + cgv::math::pose4(reinterpret_cast(state_ptr->hmd.pose[0]))* + cgv::math::translate4(0, 0.1f, -0.1f) + ); + MI_hmd.render_mesh(ctx); + ctx.pop_modelview_matrix(); + } + } + if (show_vr_kits_as_spheres || !MI_hmd.is_constructed()) { + float left_eye_to_head[12]; + float right_eye_to_head[12]; + kit_ptr->put_eye_to_head_matrix(0, left_eye_to_head); + kit_ptr->put_eye_to_head_matrix(1, right_eye_to_head); + const mat3& R_w_h = reinterpret_cast(state_ptr->hmd.pose[0]); + const vec3& p_w_h = reinterpret_cast(state_ptr->hmd.pose[9]); - const mat3& R_h_l = reinterpret_cast(left_eye_to_head[0]); - const vec3& p_h_l = reinterpret_cast(left_eye_to_head[9]); - const mat3& R_h_r = reinterpret_cast(right_eye_to_head[0]); - const vec3& p_h_r = reinterpret_cast(right_eye_to_head[9]); + const mat3& R_h_l = reinterpret_cast(left_eye_to_head[0]); + const vec3& p_h_l = reinterpret_cast(left_eye_to_head[9]); - vec4 s_l(0, 0, 0, 0.012f); - vec4 s_r = s_l; - reinterpret_cast(s_l) = R_w_h * p_h_l + p_w_h; - reinterpret_cast(s_r) = R_w_h * p_h_r + p_w_h; + const mat3& R_h_r = reinterpret_cast(right_eye_to_head[0]); + const vec3& p_h_r = reinterpret_cast(right_eye_to_head[9]); - if (kit_ptr != rendered_kit_ptr || rendered_eye != 0) { - spheres.push_back(s_l); - sphere_colors.push_back(rgb(1, 0, 0)); - } - if (kit_ptr != rendered_kit_ptr || rendered_eye != 1) { - spheres.push_back(s_r); - sphere_colors.push_back(rgb(0, 0, 1)); + vec4 s_l(0, 0, 0, 0.012f); + vec4 s_r = s_l; + reinterpret_cast(s_l) = R_w_h * p_h_l + p_w_h; + reinterpret_cast(s_r) = R_w_h * p_h_r + p_w_h; + + if (kit_ptr != rendered_kit_ptr || rendered_eye != 0) { + spheres.push_back(s_l); + sphere_colors.push_back(rgb(1, 0, 0)); + } + if (kit_ptr != rendered_kit_ptr || rendered_eye != 1) { + spheres.push_back(s_r); + sphere_colors.push_back(rgb(0, 0, 1)); + } } for (unsigned i = 0; i < 2; ++i) { - const mat3& R_ci = reinterpret_cast(state_ptr->controller[i].pose[0]); - const vec3& p_ci = reinterpret_cast(state_ptr->controller[i].pose[9]); - spheres.push_back(vec4(p_ci, 0.04f)); - spheres.push_back(vec4(p_ci + 0.05f*R_ci.col(0), 0.01f)); - spheres.push_back(vec4(p_ci - 0.05f*R_ci.col(0), 0.01f)); - spheres.push_back(vec4(p_ci + 0.05f*R_ci.col(1), 0.01f)); - spheres.push_back(vec4(p_ci - 0.05f*R_ci.col(1), 0.01f)); - spheres.push_back(vec4(p_ci + 0.05f*R_ci.col(2), 0.01f)); - spheres.push_back(vec4(p_ci - 0.05f*R_ci.col(2), 0.01f)); - sphere_colors.push_back(rgb(0.5f + (1 - i)*0.5f, 0.5f, 0.5f + 0.5f*i)); - sphere_colors.push_back(rgb(1, 0, 0)); - sphere_colors.push_back(rgb(1, 0.5f, 0.5f)); - sphere_colors.push_back(rgb(0, 1, 0)); - sphere_colors.push_back(rgb(0.5f, 1, 0.5f)); - sphere_colors.push_back(rgb(0, 0, 1)); - sphere_colors.push_back(rgb(0.5f, 0.5f, 1)); + if (show_vr_kits_as_meshes && MI_controller.is_constructed()) { + ctx.push_modelview_matrix(); + ctx.mul_modelview_matrix(cgv::math::pose4(reinterpret_cast(state_ptr->controller[i].pose[0]))); + MI_controller.render_mesh(ctx); + ctx.pop_modelview_matrix(); + } + if (show_vr_kits_as_spheres || !MI_controller.is_constructed()) { + const mat3& R_ci = reinterpret_cast(state_ptr->controller[i].pose[0]); + const vec3& p_ci = reinterpret_cast(state_ptr->controller[i].pose[9]); + spheres.push_back(vec4(p_ci, 0.04f)); + spheres.push_back(vec4(p_ci + 0.05f*R_ci.col(0), 0.01f)); + spheres.push_back(vec4(p_ci - 0.05f*R_ci.col(0), 0.01f)); + spheres.push_back(vec4(p_ci + 0.05f*R_ci.col(1), 0.01f)); + spheres.push_back(vec4(p_ci - 0.05f*R_ci.col(1), 0.01f)); + spheres.push_back(vec4(p_ci + 0.05f*R_ci.col(2), 0.01f)); + spheres.push_back(vec4(p_ci - 0.05f*R_ci.col(2), 0.01f)); + sphere_colors.push_back(rgb(0.5f + (1 - i)*0.5f, 0.5f, 0.5f + 0.5f*i)); + sphere_colors.push_back(rgb(1, 0, 0)); + sphere_colors.push_back(rgb(1, 0.5f, 0.5f)); + sphere_colors.push_back(rgb(0, 1, 0)); + sphere_colors.push_back(rgb(0.5f, 1, 0.5f)); + sphere_colors.push_back(rgb(0, 0, 1)); + sphere_colors.push_back(rgb(0.5f, 0.5f, 1)); + } } } if (!spheres.empty()) { @@ -558,7 +599,9 @@ void vr_view_interactor::create_gui() align("\b"); end_tree_node(fence_color1); } - add_member_control(this, "show_vr_kits", show_vr_kits, "check"); + add_member_control(this, "show kits", show_vr_kits, "toggle", "w=62", " "); + add_member_control(this, "as meshes", show_vr_kits_as_meshes, "toggle", "w=61", " "); + add_member_control(this, "as spheres", show_vr_kits_as_spheres, "toggle", "w=61"); if (begin_tree_node("sphere styles", srs, false, "level=3")) { align("\a"); add_gui("sphere style", srs); diff --git a/plugins/crg_vr_view/vr_view_interactor.h b/plugins/crg_vr_view/vr_view_interactor.h index 3572070f0..bb425a672 100644 --- a/plugins/crg_vr_view/vr_view_interactor.h +++ b/plugins/crg_vr_view/vr_view_interactor.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "lib_begin.h" @@ -54,6 +55,8 @@ bool your_class::init(cgv::render::context& ctx) class CGV_API vr_view_interactor : public stereo_view_interactor { +public: + typedef cgv::math::fmat mat34; protected: /// whether the window shows a separate view onto the scene or the one of the current vr kit bool separate_view; @@ -65,6 +68,8 @@ class CGV_API vr_view_interactor : int rendered_eye; vr::vr_kit* rendered_kit_ptr; int rendered_kit_index; + cgv::render::mesh_render_info MI_controller, MI_hmd; + cgv::gui::VREventTypeFlags event_flags; static dmat4 hmat_from_pose(float pose_matrix[12]); @@ -73,6 +78,8 @@ class CGV_API vr_view_interactor : // visualization of kits and action zone bool show_vr_kits; + bool show_vr_kits_as_spheres; + bool show_vr_kits_as_meshes; bool show_action_zone; rgb fence_color1, fence_color2; float fence_frequency; diff --git a/plugins/examples/buffer_test.cxx b/plugins/examples/buffer_test.cxx index 7a393b318..62fa19674 100644 --- a/plugins/examples/buffer_test.cxx +++ b/plugins/examples/buffer_test.cxx @@ -31,9 +31,6 @@ class buffer_test : public base, public provider, public drawable ctx.set_bg_alpha(1); return true; } - void init_frame(context& ctx) - { - } void small_square(context& ctx, const std::string& text) { ctx.push_projection_matrix(); @@ -42,24 +39,23 @@ class buffer_test : public base, public provider, public drawable ctx.set_modelview_matrix(cgv::math::scale4(0.25, 0.25, 0.25)); cgv::render::shader_program& prog = ctx.ref_default_shader_program(); prog.enable(ctx); - ctx.set_color(cgv::media::illum::surface_material::color_type(1,0,0)); + ctx.set_color(rgb(1,0,0)); ctx.tesselate_unit_square(); - ctx.set_color(cgv::media::illum::surface_material::color_type(1, 1, 1)); - glColor3f(1, 1, 1); - ctx.enable_font_face(ctx.get_current_font_face(),20); - ctx.set_cursor(cgv::math::vec(0,0,0), text, cgv::render::TA_BOTTOM); - ctx.output_stream() << text << std::endl; + //ctx.set_color(rgb(1, 1, 1)); + //ctx.enable_font_face(ctx.get_current_font_face(),20); + //ctx.set_cursor(vec3(0,0,0).to_vec(), text, cgv::render::TA_BOTTOM); + //ctx.output_stream() << text << std::endl; } void large_square(context& ctx, const std::string& text) { ctx.mul_modelview_matrix(cgv::math::scale4(2,2,2)); - ctx.set_color(cgv::media::illum::surface_material::color_type(0, 1, 0)); + ctx.set_color(rgb(0, 1, 0)); ctx.tesselate_unit_square(); - ctx.set_color(cgv::media::illum::surface_material::color_type(0, 0, 0)); - glColor3f(0, 0, 0); - ctx.enable_font_face(ctx.get_current_font_face(),20); - ctx.set_cursor(cgv::math::vec(0,0,0), text, cgv::render::TA_BOTTOM); - ctx.output_stream() << text << std::endl; + //ctx.set_color(rgb(0, 0, 0)); + //glColor3f(0, 0, 0); + //ctx.enable_font_face(ctx.get_current_font_face(),20); + //ctx.set_cursor(vec3(0,0,0).to_vec(), text, cgv::render::TA_BOTTOM); + //ctx.output_stream() << text << std::endl; ctx.ref_default_shader_program().disable(ctx); ctx.pop_modelview_matrix(); ctx.pop_projection_matrix(); @@ -111,5 +107,5 @@ class buffer_test : public base, public provider, public drawable } }; -factory_registration bt_fac("buffer_test", "shortcut='Shift-Ctrl-B';menu_text='new/buffer test'", true); +factory_registration bt_fac("buffer_test", "shortcut='u';menu_text='new/buffer test'", true); diff --git a/plugins/examples/shape.cxx b/plugins/examples/shape.cxx index ccb2521f3..17c408cb9 100644 --- a/plugins/examples/shape.cxx +++ b/plugins/examples/shape.cxx @@ -30,11 +30,6 @@ shape::shape(const char* name) : group(name), node_flag(true), ax(0), ay(0), shp = CUBE; flip_normals = false; resolution = 25; - if (mesh.read(QUOTE_SYMBOL_VALUE(INPUT_DIR) "/example.obj")) { - shp = MESH; - } - else - std::cerr << "could not read mesh" << std::endl; key_control* kc = new key_control("ax", ax, "speed=100;more='X';less='Shift-X'"); connect_copy(kc->value_change, rebind(static_cast(this), &shape::post_redraw)); @@ -141,13 +136,6 @@ void shape::draw_shape(context& c, bool edges) } } -/// -bool shape::init(cgv::render::context& ctx) -{ - mesh_info.construct(ctx, mesh); - return true; -} - void shape::draw(context& c) { c.push_modelview_matrix(); @@ -161,23 +149,14 @@ void shape::draw(context& c) c.ref_default_shader_program().enable(c); c.set_color(col); glLineWidth(3); - if (shp == MESH) - mesh_info.render_wireframe(c); - else - draw_shape(c, true); - + draw_shape(c, true); c.ref_default_shader_program().disable(c); } if (show_faces) { - if (shp == MESH) { - mesh_info.render_mesh(c); - } - else { - c.ref_surface_shader_program().enable(c); - c.set_material(mat); - draw_shape(c, false); - c.ref_surface_shader_program().disable(c); - } + c.ref_surface_shader_program().enable(c); + c.set_material(mat); + draw_shape(c, false); + c.ref_surface_shader_program().disable(c); } c.pop_modelview_matrix(); diff --git a/plugins/examples/shape.h b/plugins/examples/shape.h index bb91da9ba..0efea4d06 100644 --- a/plugins/examples/shape.h +++ b/plugins/examples/shape.h @@ -27,7 +27,7 @@ class shape : /// resolution of smooth shapes int resolution; /// different shape types - enum Shape { CUBE, PRI, TET, OCT, DOD, ICO, CYL, CONE, DISK, ARROW, SPHERE, MESH } shp; + enum Shape { CUBE, PRI, TET, OCT, DOD, ICO, CYL, CONE, DISK, ARROW, SPHERE } shp; /// store rotation angle double ax, ay; /// store location along x-axis @@ -36,12 +36,6 @@ class shape : cgv::media::illum::surface_material mat; /// cgv::media::illum::surface_material::color_type col; - /// - typedef cgv::media::mesh::simple_mesh mesh_type; - typedef mesh_type::idx_type idx_type; - typedef mesh_type::vec3i vec3i; - mesh_type mesh; - cgv::render::mesh_render_info mesh_info; /// whether to flip the normals bool flip_normals; @@ -59,8 +53,6 @@ class shape : void stream_help(std::ostream& os); /// optional method of drawable void draw_shape(cgv::render::context&, bool); - /// - bool init(cgv::render::context&); /// optional method of drawable void draw(cgv::render::context&); /// return a path in the main menu to select the gui diff --git a/plugins/vr_test/vr_test.pj b/plugins/vr_test/vr_test.pj index 5f1f46b04..aa1907c95 100644 --- a/plugins/vr_test/vr_test.pj +++ b/plugins/vr_test/vr_test.pj @@ -5,7 +5,7 @@ projectName="vr_test"; projectGUID="8FFA22FA-141A-4BC8-8731-5D1A29BFD1E5"; addProjectDirs=[CGV_DIR."/plugins", CGV_DIR."/libs", CGV_DIR."/test"]; addProjectDeps=["cgv_utils", "cgv_type", "cgv_data", "cgv_base", "cgv_math", - "cgv_media", "cgv_gui", "cgv_render", + "cgv_media", "cgv_gui", "cgv_render", "cmi_io", "cgv_viewer", "cg_fltk", "crg_grid", "cg_ext", "cgv_gl", "crg_vr_view", "cg_vr", "vr_emulator", "openvr_driver", "cg_gamepad", "gamepad" diff --git a/show_system_variables.bat b/show_system_variables.bat index a7e765cfb..4b0545aa8 100644 --- a/show_system_variables.bat +++ b/show_system_variables.bat @@ -16,6 +16,7 @@ echo CGV_COMPILER: %CGV_COMPILER% echo CGV_PLATFORM: %CGV_PLATFORM% echo CGV_PROJECT_DIR: %CGV_PROJECT_DIR% echo CGV_SUPPORT_DIR: %CGV_SUPPORT_DIR% +echo CGV_DATA: %CGV_DATA% pause goto:eof