コード例 #1
0
void BulletExample::keyPressEvent(KeyEvent& event) {
    /* Movement */
    if(event.key() == KeyEvent::Key::Down) {
        _cameraObject->rotateX(5.0_degf);
    } else if(event.key() == KeyEvent::Key::Up) {
        _cameraObject->rotateX(-5.0_degf);
    } else if(event.key() == KeyEvent::Key::Left) {
        _cameraRig->rotateY(-5.0_degf);
    } else if(event.key() == KeyEvent::Key::Right) {
        _cameraRig->rotateY(5.0_degf);

    /* Toggling draw modes */
    } else if(event.key() == KeyEvent::Key::D) {
        if(_drawCubes && _drawDebug) {
            _drawDebug = false;
        } else if(_drawCubes && !_drawDebug) {
            _drawCubes = false;
            _drawDebug = true;
        } else if(!_drawCubes && _drawDebug) {
            _drawCubes = true;
            _drawDebug = true;
        }

    /* What to shoot */
    } else if(event.key() == KeyEvent::Key::S) {
        _shootBox ^= true;
    } else return;

    event.setAccepted();
}
コード例 #2
0
void DualQuaternionTransformationTest::rotate() {
    {
        Object3D o;
        o.transform(DualQuaternion::translation({1.0f, -0.3f, 2.3f}));
        o.rotateX(Deg(17.0f))
            .rotateY(Deg(25.0f))
            .rotateZ(Deg(-23.0f))
            .rotate(Deg(96.0f), Vector3(1.0f/Constants::sqrt3()));
        CORRADE_COMPARE(o.transformationMatrix(),
            Matrix4::rotation(Deg(96.0f), Vector3(1.0f/Constants::sqrt3()))*
            Matrix4::rotationZ(Deg(-23.0f))*
            Matrix4::rotationY(Deg(25.0f))*
            Matrix4::rotationX(Deg(17.0f))*
            Matrix4::translation({1.0f, -0.3f, 2.3f}));
    } {
        Object3D o;
        o.transform(DualQuaternion::translation({1.0f, -0.3f, 2.3f}));
        o.rotateXLocal(Deg(17.0f))
            .rotateYLocal(Deg(25.0f))
            .rotateZLocal(Deg(-23.0f))
            .rotateLocal(Deg(96.0f), Vector3(1.0f/Constants::sqrt3()));
        CORRADE_COMPARE(o.transformationMatrix(),
            Matrix4::translation({1.0f, -0.3f, 2.3f})*
            Matrix4::rotationX(Deg(17.0f))*
            Matrix4::rotationY(Deg(25.0f))*
            Matrix4::rotationZ(Deg(-23.0f))*
            Matrix4::rotation(Deg(96.0f), Vector3(1.0f/Constants::sqrt3())));
    }
}
コード例 #3
0
void MotionBlurExample::drawEvent() {
    GL::defaultFramebuffer.clear(GL::FramebufferClear::Color|GL::FramebufferClear::Depth);
    camera->draw(drawables);
    swapBuffers();

    cameraObject->rotateX(Deg(0.5f));
    spheres[0]->rotateZ(Deg(-1.0f));
    spheres[1]->rotateZ(Deg(0.5f));
    spheres[2]->rotateZ(Deg(-0.25f));
    redraw();
}
コード例 #4
0
void MotionBlurExample::drawEvent() {
    defaultFramebuffer.clear(DefaultFramebuffer::Clear::Color|DefaultFramebuffer::Clear::Depth);
    camera->draw(drawables);
    swapBuffers();

    cameraObject->rotateX(1.0_degf);
    spheres[0]->rotateZ(-2.0_degf);
    spheres[1]->rotateZ(1.0_degf);
    spheres[2]->rotateZ(-0.5_degf);
    Utility::sleep(40);
    redraw();
}