Example #1
0
        bool CameraTool::handleDrag(InputState& inputState) {
            if (inputState.mouseButtons() == MouseButtons::MBRight) {
                if (m_orbit) {
                    CameraOrbitEvent cameraEvent;
                    cameraEvent.setHAngle(inputState.deltaX() * lookSpeed(false));
                    cameraEvent.setVAngle(inputState.deltaY() * lookSpeed(true));
                    cameraEvent.setCenter(m_orbitCenter);
                    postEvent(cameraEvent);
                } else {
                    CameraLookEvent cameraEvent;
                    cameraEvent.setHAngle(inputState.deltaX() * lookSpeed(false));
                    cameraEvent.setVAngle(inputState.deltaY() * lookSpeed(true));
                    postEvent(cameraEvent);
                }
            } else if (inputState.mouseButtons() == MouseButtons::MBMiddle) {
                Preferences::PreferenceManager& prefs = Preferences::PreferenceManager::preferences();
                bool enableAltMove = prefs.getBool(Preferences::CameraEnableAltMove);

                CameraMoveEvent cameraEvent;
                if (enableAltMove && inputState.modifierKeys() == ModifierKeys::MKAlt) {
                    cameraEvent.setRight(inputState.deltaX() * panSpeed(false));
                    cameraEvent.setForward(inputState.deltaY() * -moveSpeed(true));
                } else {
                    cameraEvent.setRight(inputState.deltaX() * panSpeed(false));
                    cameraEvent.setUp(inputState.deltaY() * panSpeed(true));
                }
                postEvent(cameraEvent);
            }
            return true;
        }
 bool CameraTool::handleDrag(InputState& inputState) {
     if (inputState.mouseButtons() == MouseButtons::MBRight) {
         if (m_orbit) {
             CameraOrbitEvent cameraEvent;
             cameraEvent.setHAngle(inputState.deltaX() * lookSpeed(false));
             cameraEvent.setVAngle(inputState.deltaY() * lookSpeed(true));
             cameraEvent.setCenter(m_orbitCenter);
             postEvent(cameraEvent);
         } else {
             CameraLookEvent cameraEvent;
             cameraEvent.setHAngle(inputState.deltaX() * lookSpeed(false));
             cameraEvent.setVAngle(inputState.deltaY() * lookSpeed(true));
             postEvent(cameraEvent);
         }
     } else if (inputState.mouseButtons() == MouseButtons::MBMiddle) {
         CameraMoveEvent cameraEvent;
         cameraEvent.setRight(inputState.deltaX() * panSpeed(false));
         cameraEvent.setUp(inputState.deltaY() * panSpeed(true));
         postEvent(cameraEvent);
     }
     return true;
 }