Qt3D : MultiView with MultiCamera Controller

204 views Asked by At

I am using QML MultiViewport example.

I would like to use OrbitCameraController for cam1 and FirstPersonCameraController for cam2. Problem is that wherever I move the mouse, both cameras moves.

How do I do make OrbitCameraController move when I move the mouse from viewport1 and FirstPersonCameraController from viewport2 ?

1

There are 1 answers

0
AlexandreP On BEST ANSWER

I finnally manage camera changes with an QObjectPicker (implementation is cpp, but idea is the same for QML)

    auto picker = new Qt3DRender::QObjectPicker(rootNode);
    QObject::connect(picker, &Qt3DRender::QObjectPicker::pressed, [&](Qt3DRender::QPickEvent* pick) {
        if (pick->viewport() == viewport1)
        {
            orbitCameraController->setEnabled(true);
            firstPersonCameraController->setEnabled(false);
        }
        else if (pick->viewport() == viewport2)
        {
            orbitCameraController->setEnabled(false);
            firstPersonCameraController->setEnabled(true);
        }
    });
    rootNode->addComponent(picker);