void CameraTool::handleScroll(InputState& inputState) {
            if (inputState.modifierKeys() != ModifierKeys::MKNone &&
                inputState.modifierKeys() != ModifierKeys::MKAlt)
                return;
            if (m_orbit) {
                const Renderer::Camera& camera = inputState.camera();
                Plane orbitPlane(camera.direction(), m_orbitCenter);
                float maxForward = orbitPlane.intersectWithRay(Ray(camera.position(), camera.direction())) - 32.0f;

                float forward = inputState.scrollY() * moveSpeed();
                if (maxForward < 0.0f)
                    maxForward = 0.0f;
                if (forward > maxForward)
                    forward = maxForward;
                
                CameraMoveEvent cameraEvent;
                cameraEvent.setForward(forward);
                postEvent(cameraEvent);
            } else {
                CameraMoveEvent cameraEvent;
                cameraEvent.setForward(inputState.scrollY() * moveSpeed());
                cameraEvent.setRight(inputState.scrollX() * moveSpeed());
                postEvent(cameraEvent);
            }
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
        void CameraTool::handleScroll(InputState& inputState) {
            if (inputState.modifierKeys() != ModifierKeys::MKNone &&
                inputState.modifierKeys() != ModifierKeys::MKAlt)
                return;
            if (m_orbit) {
                const Renderer::Camera& camera = inputState.camera();
                Planef orbitPlane(camera.direction(), m_orbitCenter);
                float maxForward = orbitPlane.intersectWithRay(Rayf(camera.position(), camera.direction())) - 32.0f;

                float forward = inputState.scrollY() * moveSpeed(false);
                if (maxForward < 0.0f)
                    maxForward = 0.0f;
                if (forward > maxForward)
                    forward = maxForward;
                
                CameraMoveEvent cameraEvent;
                cameraEvent.setForward(forward);
                postEvent(cameraEvent);
            } else {
                Preferences::PreferenceManager& prefs = Preferences::PreferenceManager::preferences();
                const Renderer::Camera& camera = inputState.camera();
                const Vec3f moveDirection = prefs.getBool(Preferences::CameraMoveInCursorDir) ? inputState.pickRay().direction : camera.direction();
                
                const float distance = inputState.scrollY() * moveSpeed(false);
                const Vec3f moveVector = distance * moveDirection;
                
                CameraMoveEvent cameraEvent;
                cameraEvent.setForward(moveVector.dot(camera.direction()));
                cameraEvent.setRight(moveVector.dot(camera.right()));
                cameraEvent.setUp(moveVector.dot(camera.up()));
                postEvent(cameraEvent);
            }
        }
 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;
 }