Commit ecac838d authored by Sylvain Thery's avatar Sylvain Thery
Browse files

in SimpleQT double click on background restore center of rotation

parent 2effd50f
...@@ -82,6 +82,8 @@ protected: ...@@ -82,6 +82,8 @@ protected:
float m_obj_sc; float m_obj_sc;
glm::vec3 m_obj_pos; glm::vec3 m_obj_pos;
glm::vec3 m_obj_pos_save;
float m_obj_width;
// width and height of windows // width and height of windows
int W; int W;
......
...@@ -69,6 +69,8 @@ void GLWidget::setParamObject(float width, float* pos) ...@@ -69,6 +69,8 @@ void GLWidget::setParamObject(float width, float* pos)
{ {
m_obj_sc = ((FAR_PLANE / 5.0f) / foc) / width; m_obj_sc = ((FAR_PLANE / 5.0f) / foc) / width;
m_obj_pos = glm::vec3(-pos[0], -pos[1], -pos[2]); m_obj_pos = glm::vec3(-pos[0], -pos[1], -pos[2]);
m_obj_pos_save = glm::vec3(pos[0], pos[1], pos[2]);
m_obj_width = width;
} }
void GLWidget::resetCenterOfRotation(float width, float* pos) void GLWidget::resetCenterOfRotation(float width, float* pos)
...@@ -76,13 +78,11 @@ void GLWidget::resetCenterOfRotation(float width, float* pos) ...@@ -76,13 +78,11 @@ void GLWidget::resetCenterOfRotation(float width, float* pos)
m_cbs->trans_x() = 0.; m_cbs->trans_x() = 0.;
m_cbs->trans_y() = 0.; m_cbs->trans_y() = 0.;
m_cbs->trans_z() = -FAR_PLANE / 5.0f; m_cbs->trans_z() = -FAR_PLANE / 5.0f;
m_obj_sc = ((FAR_PLANE / 5.0f) / foc) / width;
// float Z[3] = { 0.0f, 0.0f, 1.0f }; m_obj_pos = glm::vec3(-pos[0], -pos[1], -pos[2]);
// axis_to_quat(Z, 0.0f, m_cbs->curquat()); newModel=1;
setParamObject(width,pos);
recalcModelView();
} }
...@@ -261,6 +261,11 @@ void GLWidget::mouseDoubleClickEvent(QMouseEvent* event) ...@@ -261,6 +261,11 @@ void GLWidget::mouseDoubleClickEvent(QMouseEvent* event)
glm::vec3 P = glm::unProject(win, m_cbs->modelViewMatrix(), m_cbs->projectionMatrix(), viewport); glm::vec3 P = glm::unProject(win, m_cbs->modelViewMatrix(), m_cbs->projectionMatrix(), viewport);
changeCenterOfRotation(P); changeCenterOfRotation(P);
} }
else
{
resetCenterOfRotation(m_obj_width, static_cast<float*>(&m_obj_pos_save.x)) ;
updateGL();
}
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment