예제 #1
0
void AreaLightsExample::keyPressEvent(KeyEvent& event) {
    /* If an input is focused, pass the events only to the UI */
    if(isTextInputActive() && _ui->focusedInputWidget()) {
        if(!_ui->focusedInputWidget()->handleKeyPress(event)) return;

    /* Movement */
    } else if(event.key() == KeyEvent::Key::W) {
        _cameraDirection = -_view.inverted().backward()*0.01f;
    } else if(event.key() == KeyEvent::Key::S) {
        _cameraDirection = _view.inverted().backward()*0.01f;
    } else if (event.key() == KeyEvent::Key::A) {
        _cameraDirection = Math::cross(_view.inverted().backward(), {0.0f, 1.0f, 0.0})*0.01f;
    } else if (event.key() == KeyEvent::Key::D) {
        _cameraDirection = -Math::cross(_view.inverted().backward(), { 0.0f, 1.0f, 0.0 })*0.01f;

    /* Increase/decrease roughness */
    } else if(event.key() == KeyEvent::Key::R) {
        _roughness = Math::clamp(
            _roughness + 0.01f*(event.modifiers() & KeyEvent::Modifier::Shift ? -1 : 1),
            0.1f, 1.0f);
        _areaLightShader.setRoughness(_roughness);
        _baseUiPlane->roughness.setValue(Utility::formatString("{:.5}", _roughness));

    /* Increase/decrease metalness */
    } else if(event.key() == KeyEvent::Key::M) {
        _metalness = Math::clamp(
            _metalness + 0.01f*(event.modifiers() & KeyEvent::Modifier::Shift ? -1 : 1),
            0.1f, 1.0f);
        _areaLightShader.setMetalness(_metalness);
        _baseUiPlane->metalness.setValue(Utility::formatString("{:.5}", _metalness));

    /* Increase/decrease f0 */
    } else if(event.key() == KeyEvent::Key::F) {
        _f0 = Math::clamp(
            _f0 + 0.01f*(event.modifiers() & KeyEvent::Modifier::Shift ? -1 : 1),
            0.1f, 1.0f);
        _areaLightShader.setF0(_f0);
        _baseUiPlane->f0.setValue(Utility::formatString("{:.5}", _f0));

    /* Reload shader */
    } else if(event.key() == KeyEvent::Key::F5) {
        #ifdef CORRADE_IS_DEBUG_BUILD
        Utility::Resource::overrideGroup("arealights-data", "../src/arealights/resources.conf");
        _areaLightShader = AreaLightShader{};
        #endif

    } else return;

    redraw();
}
예제 #2
0
void AreaLightsExample::textInputEvent(TextInputEvent& event) {
    if(isTextInputActive() && _ui->focusedInputWidget() && _ui->focusedInputWidget()->handleTextInput(event))
        redraw();
}