1

Is possible to change the camera view in QT3D from frog view to birds-eye view? Am trying to set the camera to a "top down" view and "collapse" the z-coordinate.

Edit:

I am working on a project that is going to visualize stars in a solar system, and I want to have two different views/perspectives.

I) "A first person view", where you are standing on a star (think google street view, this part is already done) and II) "Birds eye view", where you should be able to see all stars in the same plane.

One possible solution I have thought of is looping through all stars, and setting their z-value to 0, and then moving the camera to a higher z-coordinate and angle it towards (0,0,0). I would much prefer to avoid the time complexity if possible.

My current thought process is to switch the "projection type" to orthographic. If my understanding of how the orthographic camera works in QT3D, all stars should be projected in the same plane, and all I would need to do is change the position of the camera? Am I making wrong assumptions of how the orthographic camera works?

If this implementation is not possible, is there other creative solution to this problem? The code I have written thus far, either shows the inside of a star, or no stars are showen when switching to the "orthographic view".

Edit 2:

The first picture shows the current progress, from a planets perspective; whilst the second show how I want the birds eye view to look like. First person view Birds eye view

    void Camera::switchView()
{
    if (orto)
    {
        m_camera->setProjectionType(Qt3DRender::QCameraLens::PerspectiveProjection);
        m_camera->setPosition(QVector3D(0,0,0));
        //m_currentstar->disableCurrentStar();
        orto = false;
        qDebug() << "Perspective";
    }
    else
    {
        m_camera->setProjectionType(Qt3DRender::QCameraLens::OrthographicProjection);
        m_camera->setPosition(QVector3D(0,0,2000));
        m_camera->setViewCenter(QVector3D(0,0,0));
        m_camera->lens()->setOrthographicProjection(-200, 200, -500, 0, 0, -100);
        //m_currentstar->enableCurrentStar();
        orto = true;
        qDebug() << "Orto";
    }
}
  • And what is not working? You need to describe your problem better. – Florian Blume Mar 18 '22 at 11:21
  • Clarified the problem, any ideas are welcome! – DeveloperJohan Mar 19 '22 at 13:56
  • OK that made it a bit clearer :) Although I'm still not completely following what you want to achieve. You mean like you want an overview over the available planets? I think I would make two framegraph brances: One renders the standing-on-the-planet-view. In the second branch you then put as many viewports as you have planets, and arrange them in a grid. Each viewport has its own camera rendering the respective planet. You can set the branches to enabled and disabled depending on the user's choice. – Florian Blume Mar 20 '22 at 14:40
  • Maybe [this Qt3D example](https://doc.qt.io/qt-5/qt3d-planets-qml-example.html) also helps. It's in QML but the general approach should be applicable to C++. – Florian Blume Mar 20 '22 at 14:41
  • Or is there any specific reason for why you want to use orthographic projection? Simply to create this overview, right? – Florian Blume Mar 20 '22 at 14:41
  • I don't understand what you mean by "two framegraph branches"? How would this work? How would creating a new viewport per star help? Not really a particular reason why I want to use the orthographic camera, just the first thought that came to mind. I added some pictures for clarification. – DeveloperJohan Mar 21 '22 at 08:39
  • If you don't know what a framegraph branch is then I suggest you read [this](https://doc.qt.io/qt-5/qt3drender-framegraph.html). It might be that I misunderstood you. I thought you want to have an overview over all planets like in the example that I commented above. The birds eye view picture you provided simply shows all stars right? I don't think you need orthographic projection there. Have you tried the `viewAll` method of `QCamera`? If you call this the camera should have all planets in focus. – Florian Blume Mar 21 '22 at 10:25
  • The viewAll method seems to be what I am after. But when I call the viewAll method, stars that are "behind" the original camera view are not shown. The [docs](https://doc.qt.io/qt-5/qt3drender-qcamera.html#viewAll) did not explain a lot. Is there a way to include every star in the scene? – DeveloperJohan Mar 21 '22 at 12:45
  • Could you maybe update your question? It's difficult giving advice here in the comments. – Florian Blume Mar 25 '22 at 08:12

0 Answers0