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
qquick3dxrview_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5
6#ifndef QQUICK3DXRVIEW_P_H
7#define QQUICK3DXRVIEW_P_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20
21#include <QtCore/QObject>
22#include <QtQml/QQmlEngine>
23#include <QtQml/qqml.h>
24
25#include <QtQuick3D/private/qquick3dviewport_p.h>
26#include <QtQuick3D/private/qquick3dnode_p.h>
27#include <QtQuick3D/private/qquick3dsceneenvironment_p.h>
28#include <QtQuick3D/private/qquick3dpickresult_p.h>
29
30#include <QtQuick3DXr/private/qquick3dxrmanager_p.h>
31#include <QtQuick3DXr/private/qquick3dxrorigin_p.h>
32#include <QtQuick3DXr/private/qquick3dxrruntimeinfo_p.h>
33
35
36class QQuick3DXrItem;
37
38class Q_QUICK3DXR_EXPORT QQuick3DXrView : public QQuick3DNode
39{
40 Q_OBJECT
41
42 Q_PROPERTY(QQuick3DXrOrigin *xrOrigin READ xrOrigin WRITE setXROrigin NOTIFY xrOriginChanged)
43 Q_PROPERTY(QQuick3DSceneEnvironment *environment READ environment WRITE setEnvironment NOTIFY environmentChanged)
44 Q_PROPERTY(bool passthroughSupported READ passthroughSupported CONSTANT)
45 Q_PROPERTY(bool passthroughEnabled READ passthroughEnabled WRITE setPassthroughEnabled NOTIFY passthroughEnabledChanged FINAL)
46 Q_PROPERTY(QQuick3DXrRuntimeInfo *runtimeInfo READ runtimeInfo CONSTANT)
47 Q_PROPERTY(bool quitOnSessionEnd READ isQuitOnSessionEndEnabled WRITE setQuitOnSessionEnd NOTIFY quitOnSessionEndChanged FINAL)
48 Q_PROPERTY(QQuick3DRenderStats *renderStats READ renderStats CONSTANT)
49 Q_PROPERTY(FoveationLevel fixedFoveation READ fixedFoveation WRITE setFixedFoveation NOTIFY fixedFoveationChanged FINAL)
50 Q_PROPERTY(ReferenceSpace referenceSpace READ referenceSpace WRITE setReferenceSpace NOTIFY referenceSpaceChanged FINAL)
51 Q_PROPERTY(bool depthSubmissionEnabled READ depthSubmissionEnabled WRITE setDepthSubmissionEnabled NOTIFY depthSubmissionEnabledChanged FINAL)
52 Q_PROPERTY(bool multiViewRenderingSupported READ isMultiViewRenderingSupported CONSTANT)
53 Q_PROPERTY(bool multiViewRenderingEnabled READ multiViewRenderingEnabled NOTIFY multiViewRenderingEnabledChanged FINAL)
54 QML_NAMED_ELEMENT(XrView)
55 QML_ADDED_IN_VERSION(6, 8)
56
57public:
58 enum FoveationLevel {
59 NoFoveation = 0,
60 LowFoveation = 1,
61 MediumFoveation = 2,
62 HighFoveation = 3
63 };
64 Q_ENUM(FoveationLevel)
65
66 enum class ReferenceSpace {
67 ReferenceSpaceUnknown,
68 ReferenceSpaceLocal,
69 ReferenceSpaceStage,
70 ReferenceSpaceLocalFloor
71 };
72 Q_ENUM(ReferenceSpace)
73
74 using TouchTarget = std::variant<std::monostate, QQuick3DXrItem*, QQuick3DModel*>;
75 struct TouchState
76 {
77 int pointId = -1;
78 TouchTarget target;
79 bool grabbed = false;
80 bool pressed = false;
81 qreal touchDistance = 1e6;
82 qreal touchDepth = 0;
83 QPointF cursorPos;
84 QVector3D previous; // Finger position when timer was started
85 QElapsedTimer timer;
86 QVector3D surfacePoint;
87 QVector3D normal;
88 QVector2D uvPosition;
89 };
90
91 explicit QQuick3DXrView();
92 ~QQuick3DXrView();
93
94 QQuick3DXrOrigin *xrOrigin() const;
95 QQuick3DSceneEnvironment *environment() const;
96
97 bool passthroughSupported() const;
98 bool passthroughEnabled() const;
99
100 FoveationLevel fixedFoveation() const;
101 void setFixedFoveation(FoveationLevel level);
102
103 QQuick3DXrRuntimeInfo *runtimeInfo() const;
104
105 bool isQuitOnSessionEndEnabled() const;
106
107 QQuick3DRenderStats *renderStats() const;
108
109 Q_INVOKABLE QQuick3DPickResult rayPick(const QVector3D &origin, const QVector3D &direction) const;
110 Q_INVOKABLE QList<QQuick3DPickResult> rayPickAll(const QVector3D &origin, const QVector3D &direction) const;
111 Q_REVISION(6, 11) Q_INVOKABLE QQuick3DPickResult rayPick(const QVector3D &origin, const QVector3D &direction, QQuick3DModel *model) const;
112 Q_REVISION(6, 11) Q_INVOKABLE QQuick3DPickResult closestPointPick(const QVector3D &origin, float radius, QQuick3DModel *model = nullptr) const;
113
114 Q_INVOKABLE void setTouchpoint(QQuickItem *target, const QPointF &position, int pointId, bool active);
115 Q_INVOKABLE QVector3D processTouch(const QVector3D &pos, int pointId);
116 Q_INVOKABLE QVariantMap touchpointState(int pointId) const;
117
118 ReferenceSpace referenceSpace() const;
119 void setReferenceSpace(ReferenceSpace newReferenceSpace);
120
121 bool depthSubmissionEnabled() const;
122
123 void registerXrItem(QQuick3DXrItem *newXrItem);
124 void unregisterXrItem(QQuick3DXrItem *xrItem);
125
126 bool isMultiViewRenderingSupported() const;
127 bool multiViewRenderingEnabled() const;
128
129 QQuick3DXrManager *xrManager() { return &m_xrManager; }
130
131public Q_SLOTS:
132 void setEnvironment(QQuick3DSceneEnvironment * environment);
133 void setPassthroughEnabled(bool enable);
134 void setQuitOnSessionEnd(bool enable);
135 void setDepthSubmissionEnabled(bool enable);
136 void setXROrigin(QQuick3DXrOrigin *newXrOrigin);
137
138private Q_SLOTS:
139 void updateViewportGeometry();
140 void handleSessionEnded();
141 void handleClearColorChanged();
142 void handleAAChanged();
143 bool init();
144
145Q_SIGNALS:
146 void initializeFailed(const QString &errorString);
147 void sessionEnded();
148 void xrOriginChanged();
149 void environmentChanged(QQuick3DSceneEnvironment * environment);
150 void passthroughEnabledChanged();
151 void quitOnSessionEndChanged();
152 void fixedFoveationChanged();
153 void frameReady(); // tooling
154 void referenceSpaceChanged();
155 void depthSubmissionEnabledChanged();
156 void multiViewRenderingEnabledChanged();
157
158private:
159 friend class QQuick3DXrViewPrivate;
160 // The XrView does not expose the View3D in its public interface. This is intentional.
161 QQuick3DViewport *view3d() const;
162
163 bool handleVirtualTouch(TouchTarget target, const QVector3D &pos, TouchState *touchState, QVector3D *offset);
164
165 QPointer<QQuick3DSceneEnvironment> m_pendingSceneEnvironment;
166 QQuick3DXrManager m_xrManager;
167 mutable QQuick3DXrRuntimeInfo m_xrRuntimeInfo;
168 bool m_quitOnSessionEnd = true;
169 bool m_inDestructor = false;
170 bool m_isInitialized = false;
171
172 friend class QQuick3DXrVirtualMouse;
173 QList<QQuick3DXrItem *> m_xrItems;
174 struct XrTouchStates;
175 XrTouchStates *m_touchStates = nullptr;
176 QQuick3DXrOrigin *m_xrOrigin = nullptr;
177};
178
179class Q_QUICK3DXR_EXPORT QQuick3DXrViewPrivate
180{
181 QQuick3DXrViewPrivate() = delete;
182public:
183 [[nodiscard]] static QQuick3DViewport *getView3d(QQuick3DXrView *view);
184};
185
186QT_END_NAMESPACE
187
188#endif // QQUICK3DXRVIEW_P_H
Combined button and popup list for selecting options.
QtQuick3DXr::Hand handForController(QQuick3DXrController::Controller controller)
QtQuick3DXr::HandPoseSpace pose_cast(QQuick3DXrController::HandPoseSpace poseSpace)