Called when a mouse motion event occurs
| 108 | |
| 109 | // Called when a mouse motion event occurs |
| 110 | bool Scene::mouseMotionEvent(double xMouse, double yMouse, int leftButtonState, |
| 111 | int rightButtonState, int middleButtonState, |
| 112 | int altKeyState) { |
| 113 | |
| 114 | // Zoom |
| 115 | if (leftButtonState == GLFW_PRESS && altKeyState == GLFW_PRESS) { |
| 116 | |
| 117 | float dy = static_cast<float>(yMouse - mLastMouseY); |
| 118 | float h = static_cast<float>(mWindowHeight); |
| 119 | |
| 120 | // Zoom the camera |
| 121 | zoom(-dy / h); |
| 122 | } |
| 123 | // Translation |
| 124 | else if (middleButtonState == GLFW_PRESS || rightButtonState == GLFW_PRESS || |
| 125 | (leftButtonState == GLFW_PRESS && altKeyState == GLFW_PRESS)) { |
| 126 | translate(xMouse, yMouse); |
| 127 | } |
| 128 | // Rotation |
| 129 | else if (leftButtonState == GLFW_PRESS) { |
| 130 | rotate(xMouse, yMouse); |
| 131 | } |
| 132 | |
| 133 | // Remember the mouse position |
| 134 | mLastMouseX = xMouse; |
| 135 | mLastMouseY = yMouse; |
| 136 | |
| 137 | return true; |
| 138 | } |
| 139 | |
| 140 | // Called when a scrolling event occurs |
| 141 | bool Scene::scrollingEvent(float /*xAxis*/, float yAxis, float scrollSensitivy) { |
no outgoing calls