Qt Quick 3D Xr

Introduction

Extended Reality (XR) is a term that includes Virtual Reality (VR), Augmented Reality (AR), and Mixed Reality (MR). These technologies are used to create immersive experiences that can alter a user's perception of the world around them. The Qt Quick 3D Xr module provides APIs for developing XR applications with Qt Quick 3D, across a variety of devices and platforms.

Difference between a Qt Quick 3D and a Qt Quick 3D Xr application

The main difference between a Qt Quick 3D and a Qt Quick 3D Xr application, from a developer's perspective, is the scene's entry point and the importance of being aware of real-world units and tracking data.

In Qt Quick 3D, a minimal application would consist of a camera, light, and a 3D model. The positioning and size of these elements are defined in the scene's coordinate system, which is arbitrary and can be defined by the developer to fit the needs of the application.

View3D {
    width: 1280
    height: 720

    PerspectiveCamera {
        position: Qt.vector3d(0, 200, 300)
    }

    DirectionalLight {
    }

    Node {
        id: sceneRoot
        Model {
            id: model
            position: Qt.vector3d(0, -200, 0)
            source: "#Cylinder"
            materials: [ PrincipledMaterial {
                    baseColor: "red"
            }]
        }
    }
}

In an XR application, the scene's coordinate system is, normally, defined by the real-world units and tracking data. The camera's position and orientation are defined by the device's, or in the case of head-mounted displays (HMD), the user's head position and orientation. The scene's units are then defined so they match the real-world units, for example, you'd want a door or a desk to be the same size in the real world as in the virtual world. Note also that in an Qt Quick 3D Xr application the entry point is not a View3D but the XrView. In addition an XrOrigin is used to define the origin of the scene where tracked items are placed relative to.

XrView {
    DirectionalLight {
    }

    xrOrigin: XrOrigin {
        XrController {
            id: rightController
            controller: XrController.ControllerRight
        }
        XrController {
            id: leftController
            controller: XrController.ControllerLeft
        }
    }

    Node {
        id: sceneRoot
        Model {
            id: floor
            source: ":meshes/floor.mesh"
            materials: [ PrincipledMaterial {
                    baseColor: "green"
                }]
        }

        Model {
            id: table
            property real height: 0.7
            position: Qt.vector3d(0, height - 2.5, 0)
            source: ":meshes/table.mesh"
            materials: PrincipledMaterial {
                baseColor: "white"
            }
        }

        Model {
            id: monitor
            source: ":meshes/monitor.mesh"
            y: table.height
            XrItem {
                id: theScreen
                y: monitor.yOffset + height
                x: -width / 2
                width: monitor.width
                height: monitor.height
                contentItem: ScreenContent {}
            }
        }
    }
}

Where to go from here?

Depending on the target hardware, take a look at Getting Started With Meta Quest 3 or Getting Started With Apple Vision Pro for more information about how to get started with your specific device. Take a look at the Supported Platforms page for more information about other platforms and devices.

If you are looking for a specific Qt Quick 3D Xr API, take a look at the API Reference, or try out one of the Qt Quick 3D Xr Examples, which demonstrate how the Qt Quick 3D Xr APIs can be used.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.