#ifndef DEPTHGUIDE_CAMERA_AUGMENT_HELPER_V2_IMPL_H #define DEPTHGUIDE_CAMERA_AUGMENT_HELPER_V2_IMPL_H #include "module/camera_augment_helper_v2.h" #include "core/math_helper.hpp" #include "module/viewport_downloader.hpp" struct camera_augment_helper_v2::impl { camera_augment_helper_v2 *q_this = nullptr; std::string transform_var; // sophiar std::optional tracked_transform; // transform matrix from sophiar bool is_missing = false; int time_offset = -76000; // -76ms transform_buffer track_pool; augment_manager_v2 *manager = nullptr; sophiar_conn_type *sophiar_conn = nullptr; using io_context = boost::asio::io_context; io_context *ctx = nullptr; struct ui_conf { bool ignore_missing = false; bool enable_active_guide = false; float near = 10.0f; float far = 1000.0f; // clip range (mm) }; std::shared_ptr ui = std::make_shared(); // for all float fov = 60.0f; // field of view glm::mat4 transform; // standard camera transform struct fixed_info_type { glm::vec3 extra_offset = glm::vec3(); glm::vec3 extra_rotation = glm::vec3(); glm::mat4 extra_transform() const; } fixed_info; struct freedom_info_type { glm::vec3 eye = glm::vec3(); glm::vec3 center = glm::vec3(0.0f, 0.0f, 100.0f); // focus glm::vec3 view_up = glm::vec3(0.0f, -1.0f, 0.0f); float angle_speed = 5.0f; // degree float linear_speed = 20.0f; // mm impl *pimpl = nullptr; void reset(); glm::vec3 view_dir() const; float view_dis() const; void translate(glm::vec3 offset); void forward(float dis); void move_right(float dis); void move_up(float dis); void center_forward(float dis); void roll(float deg); void yaw(float deg); void pitch(float deg); glm::mat4 to_transform(); } freedom_info; struct { impl *parent; glm::mat4 transform; } relative_info; enum { MODE_FIXED, MODE_RELATIVE, MODE_FREEDOM } mode; // for off-screen rendering smart_frame_buffer::create_config fbo_conf = {}; smart_frame_buffer fbo; std::unique_ptr img_downloader; // for interaction using conn_type = boost::signals2::connection; conn_type pre_render_conn; camera_info last_camera; cv::Size last_vp_size; // active guidance bool allow_active_guide = false; cursor_guide *act_guide; // passive guidance bool enable_passive_guide = false; guide_info pas_info; // cursor_guide pas_guide; explicit impl(const create_config &conf); ~impl(); void update_tracked_transform(); void update_freedom(); void update_fixed(); void update_relative(); void update_transform(); void update_camera(); void render(); void render_image(output_config conf); void show_freedom(); void show_fixed(); void show(); // get cursor position in world coordinate // must be called during rendering process // s_pos: mouse position in screen std::optional get_cursor_coordinate(glm::vec2 s_pos); void pre_render_slot(const scene_ptr &info); }; #endif //DEPTHGUIDE_CAMERA_AUGMENT_HELPER_V2_IMPL_H