Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void GLWidget::mouseMoveEvent(QMouseEvent *event)
- {
- /*
- int dx = event->x() - m_lastPos.x();
- int dy = event->y() - m_lastPos.y();
- */
- int dx = event->x() - width()/2;
- int dy = event->y() - height()/2;
- float phi = atan2(m_player.direction.z(), m_player.direction.x());
- float theta = acos(m_player.direction.y());
- phi = phi + dx * 0.005;
- theta = theta + dy * 0.005;
- if(theta < 0.01) theta = 0.01;
- if(theta > 3.14) theta = 3.14;
- m_player.direction.setX(sin(theta) * cos(phi));
- m_player.direction.setY(cos(theta));
- m_player.direction.setZ(sin(theta) * sin(phi));
- /*
- if (event->buttons() & Qt::LeftButton) {
- setXRotation(m_camXRot + 0.5f * dy);
- setYRotation(m_camYRot + 0.5f * dx);
- } else if (event->buttons() & Qt::RightButton) {
- setXRotation(m_camXRot + 0.5f * dy);
- setZRotation(m_camZRot + 0.5f * dx);
- }
- m_lastPos = event->pos();
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement