1 year ago

#302000

test-img

DeveloperJohan

Birds eye view - QT3D - Camera

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";
    }
}

qt

3d

qt3d

qtwidgets

0 Answers

Your Answer

Accepted video resources