Пример #1
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);
            }
        }
        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);
            }
        }
Пример #3
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;
        }
Пример #4
0
        bool CreateBrushTool::handleStartPlaneDrag(InputState& inputState, Planef& plane, Vec3f& initialPoint) {
            assert(m_brush == NULL);
            
            Model::EditStateManager& editStateManager = document().editStateManager();
            if (inputState.mouseButtons() != MouseButtons::MBLeft ||
                inputState.modifierKeys() != ModifierKeys::MKNone ||
                editStateManager.selectionMode() != Model::EditStateManager::SMNone)
                return false;
            
            Model::FaceHit* hit = static_cast<Model::FaceHit*>(inputState.pickResult().first(Model::HitType::FaceHit, true, m_filter));
            if (hit != NULL) {
                initialPoint = hit->hitPoint();
            } else {
                Renderer::Camera& camera = view().camera();
                initialPoint = camera.defaultPoint(inputState.pickRay().direction);
            }

            plane = Planef(Vec3f::PosZ, initialPoint);
            m_initialPoint = initialPoint;
            updateBounds(m_initialPoint);
            
            Preferences::PreferenceManager& prefs = Preferences::PreferenceManager::preferences();
            Renderer::TextureRendererManager& textureRendererManager = document().sharedResources().textureRendererManager();

            m_brushFigure = new Renderer::BrushFigure(textureRendererManager);
            m_brushFigure->setFaceColor(prefs.getColor(Preferences::FaceColor));
            m_brushFigure->setEdgeColor(prefs.getColor(Preferences::SelectedEdgeColor));
            m_brushFigure->setOccludedEdgeColor(prefs.getColor(Preferences::OccludedSelectedEdgeColor));
            m_brushFigure->setEdgeMode(Renderer::BrushFigure::EMRenderOccluded);

            m_brush = new Model::Brush(document().map().worldBounds(), document().map().forceIntegerFacePoints(), m_bounds, document().mruTexture());
            m_brushFigure->setBrush(*m_brush);
            
            return true;
        }
Пример #5
0
 bool CameraTool::handleStartDrag(InputState& inputState) {
     if (inputState.mouseButtons() == MouseButtons::MBRight) {
         if (inputState.modifierKeys() == ModifierKeys::MKAlt) {
             Model::Hit* hit = inputState.pickResult().first(Model::HitType::ObjectHit, true, m_filter);
             if (hit != NULL)
                 m_orbitCenter = hit->hitPoint();
             else
                 m_orbitCenter = inputState.camera().defaultPoint();
             m_orbit = true;
             return true;
         } else if (inputState.modifierKeys() == ModifierKeys::MKNone) {
             return true;
         }
     } else if (inputState.mouseButtons() == MouseButtons::MBMiddle &&
                (inputState.modifierKeys() == ModifierKeys::MKNone || inputState.modifierKeys() == ModifierKeys::MKAlt)) {
         return true;
     }
     
     return false;
 }
 RestrictedDragPolicy::DragInfo ClipToolController::MoveClipPointPart::doStartDrag(const InputState& inputState) {
     if (inputState.mouseButtons() != MouseButtons::MBLeft ||
         inputState.modifierKeys() != ModifierKeys::MKNone)
         return DragInfo();
     
     Vec3 initialPoint;
     if (!m_callback->tool()->beginDragPoint(inputState.pickResult(), initialPoint))
         return DragInfo();
     
     DragRestricter* restricter = m_callback->createDragRestricter(inputState, initialPoint);
     DragSnapper* snapper = m_callback->createDragSnapper(inputState);
     return DragInfo(restricter, snapper, initialPoint);
 }
 RestrictedDragPolicy::DragInfo ClipToolController::AddClipPointPart::doStartDrag(const InputState& inputState) {
     if (inputState.mouseButtons() != MouseButtons::MBLeft ||
         inputState.modifierKeys() != ModifierKeys::MKNone)
         return DragInfo();
     
     Vec3 initialPoint;
     if (!m_callback->addClipPoint(inputState, initialPoint))
         return DragInfo();
     
     m_secondPointSet = false;
     DragRestricter* restricter = m_callback->createDragRestricter(inputState, initialPoint);
     DragSnapper* snapper = m_callback->createDragSnapper(inputState);
     return DragInfo(restricter, snapper, initialPoint);
 }
Пример #8
0
 void CreateBrushTool::handleResetPlane(InputState& inputState, Planef& plane, Vec3f& initialPoint) {
     float distance = plane.intersectWithRay(inputState.pickRay());
     if (Math<float>::isnan(distance))
         return;
     initialPoint = inputState.pickRay().pointAtDistance(distance);
     
     if (inputState.modifierKeys() == ModifierKeys::MKAlt) {
         Vec3f planeNorm = inputState.pickRay().direction;
         planeNorm[2] = 0.0f;
         planeNorm.normalize();
         plane = Planef(planeNorm, initialPoint);
     } else {
         plane = Planef::horizontalDragPlane(initialPoint);
     }
 }
        bool RotateObjectsTool::handleStartDrag(InputState& inputState) {
            if (inputState.mouseButtons() != MouseButtons::MBLeft ||
                inputState.modifierKeys() != ModifierKeys::MKNone)
                return false;

            Model::EditStateManager& editStateManager = document().editStateManager();
            const Model::EntityList& entities = editStateManager.selectedEntities();
            const Model::BrushList& brushes = editStateManager.selectedBrushes();
            if (entities.empty() && brushes.empty())
                return false;

            Model::RotateHandleHit* hit = static_cast<Model::RotateHandleHit*>(inputState.pickResult().first(Model::HitType::RotateHandleHit, true, view().filter()));

            if (hit == NULL)
                return false;

            Vec3f test = hit->hitPoint() - m_rotateHandle.position();
            switch (hit->hitArea()) {
                case Model::RotateHandleHit::HAXAxis:
                    m_axis = Vec3f::PosX;
                    m_invert = ((test.dot(Vec3f::PosX) > 0.0f) == (test.dot(Vec3f::PosY) > 0.0f));
                    break;
                case Model::RotateHandleHit::HAYAxis:
                    m_axis = Vec3f::PosY;
                    m_invert = ((test.dot(Vec3f::PosX) > 0.0f) != (test.dot(Vec3f::PosY) > 0.0f));
                    break;
                case Model::RotateHandleHit::HAZAxis:
                    m_axis = Vec3f::PosZ;
                    m_invert = false;
                    break;
            }

            m_startX = inputState.x();
            m_startY = inputState.y();
            m_angle = 0.0f;
            m_center = m_rotateHandle.position();
            m_rotateHandle.lock();
            beginCommandGroup(Controller::Command::makeObjectActionName(wxT("Rotate"), entities, brushes));

            return true;
        }