Translate + Rotate problem.

Hi,

I want to rotate my object around the current center of view.

I have shifting functionality on clicked mouse move:


void GLWidget::mouseMoveEvent(QMouseEvent* event)
{
  double dCoeffX = 1.0 / ... //some calculations;
  double dCoeffY = 1.0 / ... //some calculations;

  double dXDifference = m_posMouse.x() - event->x();
  double dYDifference = m_posMouse.y() - event->y();

  m_dOffsetX += dXDifference * dCoeffX;
  m_dOffsetY += -dYDifference * dCoeffY;

  m_posMouse = event->pos();
}

So, the following code rotates around the center of object:

	
  glMatrixMode(GL_MODELVIEW);

  glTranslated(m_dOffsetX, m_dOffsetY, 0);
  glRotated(-m_iXAngle, 1.0, 0.0, 0.0);
  glRotated(-m_iZAngle, 0.0, 0.0, 1.0);

This code rotates around the current view center:


  glMatrixMode(GL_MODELVIEW);

  glRotated(-m_iXAngle, 1.0, 0.0, 0.0);
  glRotated(-m_iZAngle, 0.0, 0.0, 1.0);
  glTranslated(m_dOffsetX, m_dOffsetY, 0);

But after that if I move clicked mouse (i.e. shifting) picture becomes broken:

Rotated before move:

Rotated after move:

Who can help me ?
Thanks in advanceā€¦

The problem is solved, thanks.
Topic can be closed.

Would you be able to post your solution here for others?

Thanks.