Qt 6.4中的Qt Quick 3D物理

Qt Quick 3D Physics in Qt 6.4

Qt 6.4中的Qt Quick 3D物理

Friday July 15, 2022 by Jonas Karlsson | Comments

​2022年7月15日星期五Jonas Karlsson评论

Qt 6.4 includes the new module Qt Quick 3D Physics as tech preview. As the name implies, this is a module that adds physical simulation capabilities on top of Qt Quick 3D. In particular, it enables rigid body simulation using simple primitives (spheres, boxes, planes and capsules) as well as convex- and triangle meshes and heightmaps. Physical properties such as mass, density, gravity and friction are customizable. This makes it possible to create physically correct behavior in 3D scenes without having to handcraft animations.

Qt 6.4包括新模块Qt Quick 3D Physics作为技术预览。顾名思义,这是一个在Qt Quick 3D上添加物理模拟功能的模块。特别是,它支持使用简单的基本体(球体、长方体、平面和胶囊)以及凸面和三角形网格和高度图进行刚体模拟。物理特性(如质量、密度、重力和摩擦力)可自定义。这使得在3D场景中创建物理上正确的行为成为可能,而无需手工制作动画。

Adding physics to your scene is quite easy. The following snippet is all it takes to create and render a whole scene with a plane and a box interacting with each other:

将物理添加到场景中相当容易。以下片段是创建和渲染整个场景所需的全部内容,其中平面和长方体相互交互:


import QtQuick
import QtQuick3D
import QtQuick3D.Physics

Window {
    visible: true
    DynamicsWorld {}

    View3D {
        anchors.fill: parent

        PerspectiveCamera {
            position: Qt.vector3d(0, 100, 500)
            clipFar: 5000
            clipNear: 1
        }

        DirectionalLight {
            eulerRotation.x: -45
            eulerRotation.y: 45
            castsShadow: true
        }

        StaticRigidBody {
            position: Qt.vector3d(0, 0, 0)
            eulerRotation: Qt.vector3d(-90, 0, 0)
            collisionShapes: PlaneShape {}
            Model {
                source: "#Rectangle"
                scale: Qt.vector3d(10, 10, 10)
                materials: PrincipledMaterial {
                    baseColor: "green"
                }
                castsShadows: false
                receivesShadows: true
            }
        }

        DynamicRigidBody {
            position: Qt.vector3d(0, 200, 0)
            collisionShapes: BoxShape {}
            Model {
                source: "#Cube"
                materials: PrincipledMaterial {
                    baseColor: "yellow"
                }
            }
        }
    }
}

And this is how it looks:

这是它的外观:



Qt Quick 3D Physics is a pure QML API and is currently available as a tech preview in Qt 6.4. The documentation comes with a handful of explanatory examples showing off the different capabilities of the module. This is the best place to start if you want to try it out yourself.  There is a lot more that could be said about this module but since a picture says a thousand words I imagine this video of the examples will say even more.

​Qt Quick 3D Physics是一个纯QML API,目前在Qt 6.4中作为技术预览版提供。文档附带了几个解释性示例,展示了模块的不同功能。如果你想亲自尝试,这是最好的开始。关于这个模块还有很多要说的,但因为一张图片能说千言万语,我想这个例子的视频会说得更多。

https://play.hubspotvideo.com/dba0c1eb-69f5-4aae-af8f-f511db709390

I hope you found this blog post interesting and I look forward to seeing what you will create with this new module.

我希望你觉得这篇博文很有趣,我期待着看到你将用这个新模块创建什么。

<think>嗯,用户问的是Qt 6.4的安装链接有没有。首先,我需要确定Qt的官方网站,因为那里是最可靠的下载来源。Qt通常是通过他们的官方网站提供下载的,所以应该引导用户去那里。 然后,用户可能不太清楚具体的下载步骤,可能需要详细说明。比如,访问官网后需要注册或登录账户,选择开源版本还是商业版本,这些都需要解释清楚。特别是开源版本可能需要用户遵守LGPL协议,或者使用Qt的安装和维护工具Qt Maintenance Tool,这些信息对用户来说可能很重要。 另外,用户可能不知道如何选择正确的版本和组件。不同操作系统(Windows、macOS、Linux)的安装包不同,需要分别说明。同时,Qt在线安装器和离线安装包的区别也需要提到,因为在线安装器更灵活,而离线包适合网络不稳定的情况。 还要注意,用户可能对安装过程中的某些步骤有疑问,比如是否需要注册账号,如何选择安装路径,组件选择等。应该建议用户根据项目需求选择合适的组件,避免安装不必要的部分,节省磁盘空间。 最后,要提醒用户注意许可证问题,尤其是商业用途可能需要购买许可证,避免法律问题。如果有进一步的问题,提供帮助渠道也很重要,比如Qt的官方文档或社区支持。 总结一下,回答需要包括官网链接、下载步骤、版本选择建议、安装注意事项以及许可证提醒,确保用户能够顺利安装Qt 6.4。</think>以下是Qt 6.4的安装指南: 1. **官方下载地址**: 访问Qt官网下载页面:[https://www.qt.io/download](https://www.qt.io/download) ▶ 点击页面中的"Go Open Source"按钮(若用于开源项目) ▶ 或选择"Try Commercial"(商业用途) 2. **安装步骤**: - 选择 **Qt 6.4** 版本(注意版本号可能有更新) - 根据系统选择安装包: • Windows:`qt-unified-windows-x64-4.x.x-online.exe` • macOS:`qt-unified-macOS-x64-4.x.x-online.dmg` • Linux:`qt-unified-linux-x64-4.x.x-online.run` - 运行安装程序后需登录Qt账号(需免费注册) 3. **组件选择建议**: ```plaintext ✔ Qt 6.4.0 > MSVC 2019 64-bit(Windows必选) ✔ Qt Charts/Qt Quick/Qt Multimedia(按需选择) ✔ Developer and Designer Tools > Qt Creator 10+ ``` 4. **注意事项**: - 安装需要约15-30GB磁盘空间 - 建议勾选"Add Qt...to PATH"环境变量配置 - 开源用户需遵守LGPLv3协议 - 国内用户可使用清华镜像加速下载: ```bash qtmirror=https://mirrors.tuna.tsinghua.edu.cn/qt ``` 5. **验证安装**: 打开Qt Creator,新建Qt Widgets项目,编译运行示例程序确认环境正常。 建议优先使用在线安装器(Qt Maintenance Tool),可灵活管理多个Qt版本。若需离线安装包,可在安装器中选择"Archive"获取历史版本。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值