鸟瞰图 - QT3D - 相机

发布于 2025-01-15 07:37:39 字数 1499 浏览 0 评论 0 原文

是否可以将 QT3D 中的摄像机视图从青蛙视图更改为鸟瞰视图?我正在尝试将相机设置为“自上而下”视图并“折叠”z 坐标。

编辑:

我正在开展一个项目,该项目将可视化太阳系中的恒星,我想要有两种不同的视图/视角。

I)“第一人称视角”,你站在一颗星星上(想想谷歌街景,这部分已经完成)和 II)“鸟瞰图”,你应该能够在同一平面上看到所有星星。

我想到的一种可能的解决方案是循环遍历所有星星,并将它们的 z 值设置为 0,然后将相机移动到更高的 z 坐标并将其角度朝向 (0,0,0)。如果可能的话,我更愿意避免时间复杂度。

我目前的想法是将“投影类型”切换为正交。如果我理解正交相机在QT3D中的工作原理,所有星星都应该投影在同一个平面上,而我需要做的就是改变相机的位置?我是否对正交相机的工作原理做出了错误的假设?

如果这种实现不可能,是否有其他创造性的解决方案来解决这个问题?到目前为止,我编写的代码要么显示星星的内部,要么在切换到“正交视图”时不显示星星。

编辑2:

第一张图显示了当前的进展,从行星的角度来看;而第二个展示了我想要的鸟瞰图的样子。 第一人称查看></a>
<a href=

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文