Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qt3dxr.qdoc
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3/*!
4 \page qt-quick-3d-xr.html
5 \title \qxr
6 \image xr_development.webp {VR headset render}
7 \brief The \qxr module provides APIs for developing XR applications.
8
9 \section1 Introduction
10
11 Extended Reality (XR) is a term that includes Virtual Reality (VR), Augmented Reality (AR),
12 and Mixed Reality (MR). These technologies create immersive experiences that can
13 alter a user's perception of the world around them. The \qxr module provides APIs for developing
14 XR applications with Qt Quick 3D across a variety of devices and platforms.
15
16 \section1 Difference between Qt Quick 3D and \qxr applications
17
18 \section2 The entry point
19
20 The main difference between a Qt Quick 3D and a \qxr application, from a developer's perspective,
21 is the scene's entry point, and being aware of real-world units and tracking data is essential.
22
23 In Qt Quick 3D, a minimal application would consist of a camera, light, and a 3D model. The positioning
24 and size of these elements are defined in the scene's coordinate system, which is arbitrary and can be
25 defined by the developer to fit the needs of the application.
26
27 \qml
28 View3D {
29 width: 1280
30 height: 720
31
32 PerspectiveCamera {
33 position: Qt.vector3d(0, 200, 300)
34 }
35
36 DirectionalLight {
37 }
38
39 Node {
40 id: sceneRoot
41 Model {
42 id: model
43 position: Qt.vector3d(0, -200, 0)
44 source: "#Cylinder"
45 materials: [ PrincipledMaterial {
46 baseColor: "red"
47 }]
48 }
49 }
50 }
51 \endqml
52
53 In an XR application, consider real-world units and tracking data when defining the scene.
54 The camera's position and orientation are defined by the device's, or in the case of
55 head-mounted displays (HMD), the user's head position and orientation. The scene's units are
56 no longer arbitrary: one unit is one centimeter, so that a door or a desk is the same
57 size in the real world as in the virtual world. See
58 \l{Coordinate Systems and Units in \qxr} for the details.
59
60 \note The entry point in an \qxr application is not a \l View3D but the \l XrView. In addition,
61 an \l XrOrigin defines the scene's origin, which tracked items are placed relative to.
62
63 \qml
64 XrView {
65 referenceSpace: XrView.ReferenceSpaceLocalFloor
66 DirectionalLight {
67 }
68
69 xrOrigin: XrOrigin {
70 XrController {
71 id: rightController
72 controller: XrController.ControllerRight
73 }
74 XrController {
75 id: leftController
76 controller: XrController.ControllerLeft
77 }
78 }
79
80 Node {
81 id: sceneRoot
82 Model {
83 id: floor
84 source: ":meshes/floor.mesh"
85 materials: [ PrincipledMaterial {
86 baseColor: "green"
87 }]
88 }
89
90 Model {
91 id: table
92 // 75 cm, the height of a real desk
93 property real height: 75
94 source: ":meshes/table.mesh"
95 materials: PrincipledMaterial {
96 baseColor: "white"
97 }
98 }
99
100 Model {
101 id: monitor
102 source: ":meshes/monitor.mesh"
103 y: table.height
104 XrItem {
105 id: theScreen
106 y: monitor.yOffset + height
107 x: -width / 2
108 width: monitor.width
109 height: monitor.height
110 contentItem: ScreenContent {}
111 }
112 }
113 }
114 }
115 \endqml
116
117 \section2 Additional CMake functions
118
119 As can be seen in the \c CmakeLists.txt file for all the \l{\qxr Examples}, you need to add
120 some functions to your project's top-level CMakeLists file.
121
122 To specify a custom \c AndroidManifest.xml and to make sure it gets used by adding this line
123 to your project's CMakeLists file:
124
125 \quotefromfile xr_simple/CMakeLists.txt
126 \skipto if(ANDROID)
127 \printuntil endif()
128
129 For more details about setting up your \c AndroidManifest.xml, see the relevant section of
130 the \l{Getting Started With Meta Quest 3} page.
131
132 CMakeLists.txt changes also apply to visionOS, where we include the \c MacOSXBundleInfo.plist.in file:
133
134 \printto qt_finalize_executable(xr_simple)
135
136 \section1 Where to go from here?
137
138 Take a look at \l{Getting Started With Meta Quest 3} or \l{Getting Started With Apple Vision Pro}
139 for more information about how to get started with your specific device. See the
140 \l{Supported Platforms} page for more information about platforms and devices supported.
141
142 See \l{Coordinate Systems and Units in \qxr}, which explains what a
143 coordinate value means in the tracking space, in the 3D scene, and in 2D Qt Quick content.
144
145 If you are looking for a specific \qxr API, take a look at the \l{\qxr QML Types}{API Reference},
146 or try out one of the \l{\qxr Examples}, which demonstrate how the \qxr APIs can be used.
147
148 \section1 Quick Links
149
150 \list
151 \include qt3dxr-toc.qdoc listitems-quick-links
152 \endlist
153
154 //! NOTE: This table refers to list items in qt3dxr-toc.qdoc - add new items there
155 //! Using existing placeholder images for now
156 \table
157 \row
158 \include qt3dxr-toc.qdoc listitems-platforms-and-toolchains
159 \include qt3dxr-toc.qdoc listitems-getting-started
160 \include qt3dxr-toc.qdoc listitems-api-reference
161 \row
162 \include qt3dxr-toc.qdoc listitems-examples
163 \include qt3dxr-toc.qdoc tools-ide
164 \include qt3dxr-toc.qdoc developing-applications
165 \endtable
166
167*/