Customizable use of 6 dof camera
This commit is contained in:
parent
62e60bcb43
commit
9df7eb4e08
5 changed files with 33 additions and 5 deletions
|
@ -87,6 +87,11 @@ void AppConfig::set_defaults()
|
|||
if (get("use_perspective_camera").empty())
|
||||
set("use_perspective_camera", "1");
|
||||
|
||||
#if ENABLE_6DOF_CAMERA
|
||||
if (get("use_free_camera").empty())
|
||||
set("use_free_camera", "0");
|
||||
#endif // ENABLE_6DOF_CAMERA
|
||||
|
||||
// Remove legacy window positions/sizes
|
||||
erase("", "main_frame_maximized");
|
||||
erase("", "main_frame_pos");
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
#endif // !ENABLE_THUMBNAIL_GENERATOR
|
||||
#include "GUI_App.hpp"
|
||||
#include "AppConfig.hpp"
|
||||
#if ENABLE_CAMERA_STATISTICS
|
||||
#if ENABLE_6DOF_CAMERA
|
||||
#include "Mouse3DController.hpp"
|
||||
#endif // ENABLE_6DOF_CAMERA
|
||||
#endif // ENABLE_CAMERA_STATISTICS
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
|
@ -373,6 +378,12 @@ void Camera::debug_render() const
|
|||
imgui.begin(std::string("Camera statistics"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
std::string type = get_type_as_string();
|
||||
#if ENABLE_6DOF_CAMERA
|
||||
if (wxGetApp().plater()->get_mouse3d_controller().is_running() || (wxGetApp().app_config->get("use_free_camera") == "1"))
|
||||
type += "/free";
|
||||
else
|
||||
type += "/constrained";
|
||||
#endif // ENABLE_6DOF_CAMERA
|
||||
Vec3f position = get_position().cast<float>();
|
||||
Vec3f target = m_target.cast<float>();
|
||||
float distance = (float)get_distance();
|
||||
|
@ -420,7 +431,7 @@ void Camera::translate_world(const Vec3d& displacement)
|
|||
}
|
||||
}
|
||||
|
||||
void Camera::rotate_on_sphere(double delta_azimut_rad, double delta_zenit_rad, bool apply_limit)
|
||||
void Camera::rotate_on_sphere(double delta_azimut_rad, double delta_zenit_rad)
|
||||
{
|
||||
Vec3d target = m_target;
|
||||
translate_world(-target);
|
||||
|
|
|
@ -130,7 +130,7 @@ public:
|
|||
|
||||
// rotate the camera on a sphere having center == m_target and radius == m_distance
|
||||
// using the given variations of spherical coordinates
|
||||
void rotate_on_sphere(double delta_azimut_rad, double delta_zenit_rad, bool apply_limit);
|
||||
void rotate_on_sphere(double delta_azimut_rad, double delta_zenit_rad);
|
||||
|
||||
// rotate the camera around three axes parallel to the camera local axes and passing through m_target
|
||||
void rotate_local_around_target(const Vec3d& rotation_rad);
|
||||
|
|
|
@ -3290,9 +3290,12 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
{
|
||||
const Vec3d& orig = m_mouse.drag.start_position_3D;
|
||||
#if ENABLE_6DOF_CAMERA
|
||||
m_camera.rotate_on_sphere(Geometry::deg2rad((pos(0) - orig(0))* (double)TRACKBALLSIZE),
|
||||
Geometry::deg2rad((pos(1) - orig(1))* (double)TRACKBALLSIZE),
|
||||
wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA);
|
||||
double x = Geometry::deg2rad(pos(0) - orig(0)) * (double)TRACKBALLSIZE;
|
||||
double y = Geometry::deg2rad(pos(1) - orig(1)) * (double)TRACKBALLSIZE;
|
||||
if (wxGetApp().plater()->get_mouse3d_controller().is_running() || (wxGetApp().app_config->get("use_free_camera") == "1"))
|
||||
m_camera.rotate_local_around_target(Vec3d(y, x, 0.0));
|
||||
else
|
||||
m_camera.rotate_on_sphere(x, y);
|
||||
#else
|
||||
float sign = m_camera.inverted_phi ? -1.0f : 1.0f;
|
||||
m_camera.phi += sign * ((float)pos(0) - (float)orig(0)) * TRACKBALLSIZE;
|
||||
|
|
|
@ -124,6 +124,15 @@ void PreferencesDialog::build()
|
|||
option = Option(def, "use_perspective_camera");
|
||||
m_optgroup->append_single_option_line(option);
|
||||
|
||||
#if ENABLE_6DOF_CAMERA
|
||||
def.label = L("Use free camera");
|
||||
def.type = coBool;
|
||||
def.tooltip = L("If enabled, use free camera. If not enabled, use constrained camera.");
|
||||
def.set_default_value(new ConfigOptionBool(app_config->get("use_free_camera") == "1"));
|
||||
option = Option(def, "use_free_camera");
|
||||
m_optgroup->append_single_option_line(option);
|
||||
#endif // ENABLE_6DOF_CAMERA
|
||||
|
||||
def.label = L("Use custom size for toolbar icons");
|
||||
def.type = coBool;
|
||||
def.tooltip = L("If enabled, you can change size of toolbar icons manually.");
|
||||
|
|
Loading…
Reference in a new issue