void FirstPersonNavigation::mouseMoveEvent(tgt::MouseEvent* mouseEve){ tgt::ivec2 newMouse = tgt::ivec2(mouseEve->x(), mouseEve->y()); if ((mouseEve->button() == buttonRotateUpAndStrafe_)){ if (lastMousePosition_.x != newMouse.x) rollCameraAroundUp(-computeRotationAngle(lastMousePosition_.x, newMouse.x)); if (lastMousePosition_.y != newMouse.y) rollCameraAroundStrafe(-computeRotationAngle(lastMousePosition_.y, newMouse.y)); } else if (mouseEve->button() == buttonRotateLook_) if (lastMousePosition_.x != newMouse.x) rollCameraAroundLook(computeRotationAngle(lastMousePosition_.x, newMouse.x)); lastMousePosition_ = newMouse; // consider movement for simultaneous use of mouse and keyboard move(); mouseEve->accept(); }
/** * @brief Computes and applies the rotation transformations to the trackball given new position. * @param pos New mouse position in normalized trackball system */ void rotateCamera (const Eigen::Vector2f& pos) { Eigen::Vector3f normalized_pos = computeSpherePosition(normalizePosition(pos)); if (!rotating) { rotating = true; initialPosition = normalized_pos; } else if ( pos != initialPosition.head(2)) { finalPosition = normalized_pos; computeRotationAngle(); updateViewMatrix(); initialPosition = finalPosition; } }