diff --git a/projet-code/cgp/library/cgp/graphics/camera/camera_controller/camera_controller_first_person_euler/camera_controller_first_person_euler.cpp b/projet-code/cgp/library/cgp/graphics/camera/camera_controller/camera_controller_first_person_euler/camera_controller_first_person_euler.cpp index faa67b9827364b2901be28c520a7d71367f31123..8b998c4dd2b1a0f74c3675198079cf5db390d1ac 100644 --- a/projet-code/cgp/library/cgp/graphics/camera/camera_controller/camera_controller_first_person_euler/camera_controller_first_person_euler.cpp +++ b/projet-code/cgp/library/cgp/graphics/camera/camera_controller/camera_controller_first_person_euler/camera_controller_first_person_euler.cpp @@ -3,6 +3,10 @@ namespace cgp { + void camera_controller_first_person_euler::trap_cursor(bool trapped) { + is_cursor_trapped = trapped; + } + void camera_controller_first_person_euler::update(mat4& camera_matrix_view) { camera_matrix_view = camera_model.matrix_view(); } diff --git a/projet-code/cgp/library/cgp/graphics/camera/camera_controller/camera_controller_first_person_euler/camera_controller_first_person_euler.hpp b/projet-code/cgp/library/cgp/graphics/camera/camera_controller/camera_controller_first_person_euler/camera_controller_first_person_euler.hpp index d9d9aac101779c3660781d3e75a84410a51c186f..ed50427bae9cf1cddd529820bbeadf50034d8111 100644 --- a/projet-code/cgp/library/cgp/graphics/camera/camera_controller/camera_controller_first_person_euler/camera_controller_first_person_euler.hpp +++ b/projet-code/cgp/library/cgp/graphics/camera/camera_controller/camera_controller_first_person_euler/camera_controller_first_person_euler.hpp @@ -19,6 +19,8 @@ namespace cgp void update(mat4& camera_matrix_view); + void trap_cursor(bool trapped); + private: // true = cursor captured (/infinite motion), false = cursor free bool is_cursor_trapped = false; diff --git a/projet-code/scenes_inf443/base/base.exe b/projet-code/scenes_inf443/base/base.exe index 7d4ce0b575770469e484370f5612caa093001fbe..dce488f2c1f3623a125c43b6c259dd7e8c6b341e 100644 Binary files a/projet-code/scenes_inf443/base/base.exe and b/projet-code/scenes_inf443/base/base.exe differ diff --git a/projet-code/scenes_inf443/base/src/scene.cpp b/projet-code/scenes_inf443/base/src/scene.cpp index 857419d8cbd436b03ad08eb3f42e5bb343b48cbf..6b3cb845b092eaa8389e1c9138551c645155b701 100644 --- a/projet-code/scenes_inf443/base/src/scene.cpp +++ b/projet-code/scenes_inf443/base/src/scene.cpp @@ -17,8 +17,15 @@ void scene_structure::initialize() { camera_control.initialize(inputs, window); // Give access to the inputs and window global state to the camera controler - camera_control.set_rotation_axis_z(); - camera_control.look_at({ 20.0f,15.0f,15.0f }, {0,0,0}); + + //for orbit camera + //camera_control.set_rotation_axis_z(); + //camera_control.look_at({ 20.0f,15.0f,15.0f }, {0,0,0}); + + //for first person camera + camera_control.camera_model.set_rotation_axis({ 0,0,1 }); + //custum function we added to ..first_person_euler + camera_control.trap_cursor(gui.trap_cursor); global_frame.initialize_data_on_gpu(mesh_primitive_frame()); @@ -109,6 +116,9 @@ void scene_structure::display_frame() // Update the current time timer.update(); + //custom function we added to ..first_person_eulor, changes whether the cursor is trapped or not + camera_control.trap_cursor(gui.trap_cursor); + // Set the light to the current position of the camera environment.light = camera_control.camera_model.position(); @@ -269,6 +279,7 @@ void scene_structure::display_gui() { ImGui::Checkbox("Frame", &gui.display_frame); ImGui::Checkbox("Wireframe", &gui.display_wireframe); + ImGui::Checkbox("Trapped Cursor", &gui.trap_cursor); ImGui::SliderFloat("Time", &timer_mvt.t, timer_mvt.t_min, timer_mvt.t_max); ImGui::SliderFloat("Time scale", &timer_mvt.scale, 0.0f, 2.0f); diff --git a/projet-code/scenes_inf443/base/src/scene.hpp b/projet-code/scenes_inf443/base/src/scene.hpp index fb5f0672cdb2601460ef0063a5f0ef159787dbf5..25b5280daed873d51875ad44c63a80999c115a82 100644 --- a/projet-code/scenes_inf443/base/src/scene.hpp +++ b/projet-code/scenes_inf443/base/src/scene.hpp @@ -22,6 +22,7 @@ struct gui_parameters { bool display_frame = true; bool display_wireframe = false; float k = 0.5f; + bool trap_cursor = true; }; // The structure of the custom scene @@ -30,7 +31,7 @@ struct scene_structure : cgp::scene_inputs_generic { // ****************************** // // Elements and shapes of the scene // ****************************** // - camera_controller_orbit_euler camera_control; + camera_controller_first_person_euler camera_control; camera_projection_perspective camera_projection; window_structure window;