void PrimitivesExample::mouseMoveEvent(MouseMoveEvent& event) {
    if(!(event.buttons() & MouseMoveEvent::Button::Left)) return;

    const Vector2 delta = 3.0f*
        Vector2{event.position() - _previousMousePosition}/
        Vector2{GL::defaultFramebuffer.viewport().size()};

    _transformation =
        Matrix4::rotationX(Rad{delta.y()})*
        _transformation*
        Matrix4::rotationY(Rad{delta.x()});

    _previousMousePosition = event.position();
    event.setAccepted();
    redraw();
}
示例#2
0
void Menu::mouseMoveEvent(MouseMoveEvent& event) {
    Vector2 cursorPosition =
        Vector2::yScale(-1.0f)*(Vector2(event.position())/Vector2(defaultFramebuffer.viewport().size())-Vector2(0.5f))*camera->projectionSize();

    MenuItem* collisionBefore = static_cast<MenuItem*>(shapes.firstCollision(*cursor));
    cursor->resetTransformation().translate(cursorPosition);
    MenuItem* collisionAfter = static_cast<MenuItem*>(shapes.firstCollision(*cursor));

    if(collisionBefore != collisionAfter) {
        if(collisionBefore) collisionBefore->hoverChanged(false);
        if(collisionAfter) collisionAfter->hoverChanged(true);
    }

    event.setAccepted();
    redraw();
}