Qt 3D

Qt 3D provides functionality for near-realtime simulation systems with support for 2D and 3D rendering in both Qt C++ and Qt Quick applications.

Qt 3D 功能被劃分成下列 C++ 模塊:

Qt 3D Core C++ 類 Qt 3D 模塊包含支持近實時仿真係統的功能。
Qt 3D Input C++ 類 Qt 3D Input 模塊提供用於在使用 Qt3D 的應用程序中處理用戶輸入的類。
Qt 3D Logic C++ 類 Qt 3D Logic 模塊使幀能夠與 Qt 3D 後端同步。
Qt 3D Render C++ 類 Qt 3D Render 模塊包含使用 Qt 3D 支持 2D 和 3D 渲染的功能。

下列 C++ 模塊仍在開發,但可用作技術預覽:

Qt 3D Animation C++ 類 Qt 3D Animation 模塊提供一套預構建元素,以幫助您入門 Qt 3D。
Qt 3D Extras C++ 類 Qt 3D Extras 模塊提供一套預構建元素,以幫助您入門 Qt 3D。
Qt 3D Scene2D C++ 類 Qt 3D Scene2D 模塊提供把 Quick2 QML 內容渲染成 Qt 3D 紋理的辦法。

對於 Qt Quick 應用程序,Qt 3D 提供下列 QML 模塊:

Qt 3D Core QML 類型 提供核心 Qt 3D QML 類型。
Qt 3D Input QML 類型 為 Qt 3D 用戶輸入提供 QML 類型。
Qt 3D Logic QML 類型 提供同步幀與 3D 後端的 QML 類型。
Qt 3D Render QML 類型 為渲染提供 Qt 3D QML 類型。

下列 QML 模塊仍在開發,但可用作技術預覽:

Qt 3D Extras QML 類型 為 Extras 模塊提供 Qt 3D QML 類型。
Qt 3D Qt3DAnimation QML 類型 為動畫模塊提供 Qt 3D QML 類型。
Qt 3D Scene2D QML 類型 為 Scene2D 模塊提供 Qt 3D QML 類型。
Qt 3D Scene3D QML 類型 為 Scene3D 模塊提供 Qt 3D QML 類型。

使用模塊

For a C++ application that performs 2D or 3D rendering, collision detection, and handles user input, include the following directives of the modules' classes:

#include <Qt3DCore>
#include <Qt3DRender>
#include <Qt3DInput>
#include <Qt3DLogic>
#include <Qt3DExtras>
#include <Qt3DAnimation>
					

要導入 QML 類型到應用程序中,使用以下 import 語句在 .qml 文件中:

import Qt3D.Core
import Qt3D.Render
import Qt3D.Input
import Qt3D.Logic
import Qt3D.Extras
import Qt3D.Animation
import QtQuick.Scene2D
import QtQuick.Scene3D
					

Using a Qt module's C++ API requires linking against the module library, either directly or through other dependencies. Several build tools have dedicated support for this, including CMake and qmake .

構建采用 CMake

使用 find_package() 命令定位所需模塊組件在 Qt6 包:

find_package(Qt6 REQUIRED COMPONENTS
    3DCore
    3DRender
    3DInput
    3DLogic
    3DExtras
    3DAnimation
)
target_link_libraries(mytarget PRIVATE
    Qt6::3DCore
    Qt6::3DRender
    Qt6::3DLogic
    Qt6::3DExtras
    Qt6::3DAnimation
)
					

采用 qmake 構建

To configure the module for building with qmake, add the modules to the QT variable in the project's .pro file:

QT += 3dcore 3drender 3dinput 3dlogic 3dextras 3danimation
					

A Qt Quick application requires additional dependencies:

QT += 3dcore 3drender 3dinput 3dlogic 3dextras 3danimation qml quick 3dquick
					

概述

Qt 3D 高級設計、動機的描述在 Qt 3D 概述 . The Qt 3D Render offers support for data-driven configuration as described in Qt 3D 渲染 FrameGraph .

參考

Qt 3D 平颱支持

Qt 3D 支持下列平颱:

  • 微軟 Windows (win32) - 支持
  • Linux X11 - 支持
  • macOS - 支持 (盡管可能有一些視網膜比例縮放問題)
  • Android - 支持
  • 嵌入式 Linux - 支持
  • iOS - 從 Qt5.7 起支持
  • WinRT - 尚不支持

Module Evolution

Changes to Qt3D lists important changes in the module API and functionality that were done for the Qt 6 series of Qt.

許可和歸屬

Qt 3D 在商業許可下是可用的來自 Qt 公司 。此外,它是可用的根據 GNU LGPL (次一般公共許可) 第 3 版 ,或 GNU GPL (一般公共許可) 第 2 版 。見 Qt 許可 進一步瞭解細節。

此外,Qt 3D 包含的第 3 方模塊遵循下列準許許可:

Dear ImGui - ProggyClean.ttf MIT 許可
Dear ImGui - stb MIT 許可或公共領域
Dear ImGui,第 v1.66b 版 MIT 許可