diff --git a/include/igl/opengl/ViewerCore.cpp b/include/igl/opengl/ViewerCore.cpp index 80f179fb6..15f37ff90 100644 --- a/include/igl/opengl/ViewerCore.cpp +++ b/include/igl/opengl/ViewerCore.cpp @@ -26,7 +26,7 @@ IGL_INLINE void igl::opengl::ViewerCore::align_camera_center( if(V.rows() == 0) return; - get_scale_and_shift_to_fit_mesh(V,F,camera_base_zoom,camera_translation); + get_scale_and_shift_to_fit_mesh(V,F,camera_base_zoom,camera_base_translation); // Rather than crash on empty mesh... if(V.size() > 0) { @@ -60,7 +60,7 @@ IGL_INLINE void igl::opengl::ViewerCore::align_camera_center( if(V.rows() == 0) return; - get_scale_and_shift_to_fit_mesh(V,camera_base_zoom,camera_translation); + get_scale_and_shift_to_fit_mesh(V,camera_base_zoom,camera_base_translation); // Rather than crash on empty mesh... if(V.size() > 0) { @@ -132,7 +132,7 @@ IGL_INLINE void igl::opengl::ViewerCore::draw( look_at( camera_eye, camera_center, camera_up, view); view = view * (trackball_angle * Eigen::Scaling(camera_zoom * camera_base_zoom) - * Eigen::Translation3f(camera_translation)).matrix(); + * Eigen::Translation3f(camera_translation + camera_base_translation)).matrix(); // Set projection if (orthographic) @@ -352,6 +352,7 @@ IGL_INLINE igl::opengl::ViewerCore::ViewerCore() camera_view_angle = 45.0; camera_dnear = 1.0; camera_dfar = 100.0; + camera_base_translation << 0,0,0; camera_translation << 0,0,0; camera_eye << 0, 0, 5; camera_center << 0, 0, 0; diff --git a/include/igl/opengl/ViewerCore.h b/include/igl/opengl/ViewerCore.h index f64760b85..44772b5e2 100644 --- a/include/igl/opengl/ViewerCore.h +++ b/include/igl/opengl/ViewerCore.h @@ -107,6 +107,7 @@ public: float camera_base_zoom; float camera_zoom; bool orthographic; + Eigen::Vector3f camera_base_translation; Eigen::Vector3f camera_translation; Eigen::Vector3f camera_eye; Eigen::Vector3f camera_up; @@ -155,6 +156,7 @@ namespace igl { SERIALIZE_MEMBER(camera_base_zoom); SERIALIZE_MEMBER(camera_zoom); SERIALIZE_MEMBER(orthographic); + SERIALIZE_MEMBER(camera_base_translation); SERIALIZE_MEMBER(camera_translation); SERIALIZE_MEMBER(camera_view_angle); SERIALIZE_MEMBER(camera_dnear); diff --git a/python/modules/py_igl_opengl_glfw.cpp b/python/modules/py_igl_opengl_glfw.cpp index dd1ba9694..7a730bea2 100644 --- a/python/modules/py_igl_opengl_glfw.cpp +++ b/python/modules/py_igl_opengl_glfw.cpp @@ -258,6 +258,14 @@ py::class_ viewercore_class(me, "ViewerCore"); core.camera_translation = Eigen::Vector3f(v.cast()); }) + .def_property("camera_base_translation", + [](const igl::opengl::ViewerCore& core) {return Eigen::MatrixXd(core.camera_base_translation.cast());}, + [](igl::opengl::ViewerCore& core, const Eigen::MatrixXd& v) + { + assert_is_Vector3("camera_base_translation",v); + core.camera_base_translation = Eigen::Vector3f(v.cast()); + }) + .def_readwrite("camera_zoom",&igl::opengl::ViewerCore::camera_zoom) .def_readwrite("orthographic",&igl::opengl::ViewerCore::orthographic)