limit pitch to [-90,90]
This commit is contained in:
parent
f5ee8a973d
commit
3be5793ffc
|
@ -72,17 +72,19 @@ void OglViewerWidget::mouseMoveEvent(QMouseEvent *e)
|
||||||
}
|
}
|
||||||
else if (m_rotDirections.x && m_rotDirections.y && !m_rotDirections.z)
|
else if (m_rotDirections.x && m_rotDirections.y && !m_rotDirections.z)
|
||||||
{
|
{
|
||||||
//float pitch, yaw, roll;
|
|
||||||
//m_rotation.getEulerAngles(&pitch, &yaw, &roll);
|
|
||||||
//pitch += diff.y() * 0.5;
|
|
||||||
//yaw += diff.x() * 0.5;
|
|
||||||
|
|
||||||
//std::cout << pitch << " - " << yaw << std::endl;
|
float pitch, yaw, roll;
|
||||||
|
m_rotation.getEulerAngles(&pitch, &yaw, &roll);
|
||||||
|
|
||||||
//m_rotation = QQuaternion::fromEulerAngles(pitch, yaw, roll);
|
pitch += diff.y() * 0.5;
|
||||||
|
yaw += diff.x() * 0.5;
|
||||||
|
|
||||||
m_rotation = QQuaternion::fromAxisAndAngle(QVector3D(0.0, 1.0, 0.0).normalized(), diff.x() * 0.5) + m_rotation;
|
if (pitch > 89)
|
||||||
m_rotation = QQuaternion::fromAxisAndAngle(QVector3D(1.0, 0.0, 0.0).normalized(), diff.y() * 0.5) + m_rotation;
|
pitch = 89;
|
||||||
|
else if (pitch < -89)
|
||||||
|
pitch = -89;
|
||||||
|
|
||||||
|
m_rotation = QQuaternion::fromEulerAngles(pitch, yaw, roll);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (m_rotDirections.x && !m_rotDirections.y && !m_rotDirections.z)
|
else if (m_rotDirections.x && !m_rotDirections.y && !m_rotDirections.z)
|
||||||
|
@ -97,6 +99,29 @@ void OglViewerWidget::mouseMoveEvent(QMouseEvent *e)
|
||||||
{
|
{
|
||||||
m_rotation = QQuaternion::fromAxisAndAngle(QVector3D(0.0, 0.0, 1.0).normalized(), diff.x() * 0.5) * m_rotation;
|
m_rotation = QQuaternion::fromAxisAndAngle(QVector3D(0.0, 0.0, 1.0).normalized(), diff.x() * 0.5) * m_rotation;
|
||||||
}
|
}
|
||||||
|
else if (m_rotDirections.x && !m_rotDirections.y && m_rotDirections.z)
|
||||||
|
{
|
||||||
|
float pitch, yaw, roll;
|
||||||
|
m_rotation.getEulerAngles(&pitch, &yaw, &roll);
|
||||||
|
roll -= diff.y() * 0.5;
|
||||||
|
yaw += diff.x() * 0.5;
|
||||||
|
|
||||||
|
m_rotation = QQuaternion::fromEulerAngles(pitch, yaw, roll);
|
||||||
|
}
|
||||||
|
else if (!m_rotDirections.x && m_rotDirections.y && m_rotDirections.z)
|
||||||
|
{
|
||||||
|
float pitch, yaw, roll;
|
||||||
|
m_rotation.getEulerAngles(&pitch, &yaw, &roll);
|
||||||
|
pitch += diff.y() * 0.5;
|
||||||
|
roll += diff.x() * 0.5;
|
||||||
|
|
||||||
|
if (pitch > 89)
|
||||||
|
pitch = 89;
|
||||||
|
else if (pitch < -89)
|
||||||
|
pitch = -89;
|
||||||
|
|
||||||
|
m_rotation = QQuaternion::fromEulerAngles(pitch, yaw, roll);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// request an update
|
// request an update
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue