Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qopenxrview_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QOPENXRVIEW_H
5#define QOPENXRVIEW_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18
19#include <QtCore/QObject>
20#include <QtQml/QQmlEngine>
21#include <QtQml/qqml.h>
22
23#include <QtQuick3D/private/qquick3dviewport_p.h>
24#include <QtQuick3D/private/qquick3dnode_p.h>
25#include <QtQuick3D/private/qquick3dsceneenvironment_p.h>
26#include <QtQuick3D/private/qquick3dpickresult_p.h>
27
28#include <QtQuick3DXr/private/qopenxrmanager_p.h>
29#include <QtQuick3DXr/private/qopenxrorigin_p.h>
30#include <QtQuick3DXr/private/qopenxrruntimeinfo_p.h>
31
33
38class QRhiTexture;
39
40class QOpenXRItem;
41
42class Q_QUICK3DXR_EXPORT QOpenXRView : public QQuick3DNode
43{
45
46 Q_PROPERTY(QOpenXROrigin *xrOrigin READ xrOrigin NOTIFY xrOriginChanged)
47 Q_PROPERTY(QQuick3DSceneEnvironment *environment READ environment WRITE setEnvironment NOTIFY environmentChanged)
48 Q_PROPERTY(QOpenXRHandInput *leftHandInput READ leftHandInput CONSTANT)
49 Q_PROPERTY(QOpenXRHandInput *rightHandInput READ rightHandInput CONSTANT)
50 Q_PROPERTY(QOpenXRHandTrackerInput *leftHandTrackerInput READ leftHandTrackerInput CONSTANT)
51 Q_PROPERTY(QOpenXRHandTrackerInput *rightHandTrackerInput READ rightHandTrackerInput CONSTANT)
52 Q_PROPERTY(QOpenXRGamepadInput *gamepadInput READ gamepadInput CONSTANT)
53 Q_PROPERTY(bool passthroughSupported READ isPassthroughSupported CONSTANT)
54 Q_PROPERTY(bool enablePassthrough READ enablePassthrough WRITE setEnablePassthrough NOTIFY enablePassthroughChanged FINAL)
55 Q_PROPERTY(QOpenXRRuntimeInfo *runtimeInfo READ runtimeInfo CONSTANT)
56 Q_PROPERTY(bool quitOnSessionEnd READ isQuitOnSessionEndEnabled WRITE setQuitOnSessionEnd NOTIFY quitOnSessionEndChanged FINAL)
57 Q_PROPERTY(QQuick3DRenderStats *renderStats READ renderStats CONSTANT)
58 Q_PROPERTY(FoveationLevel fixedFoveation READ fixedFoveation WRITE setFixedFoveation NOTIFY fixedFoveationChanged FINAL)
59 Q_PROPERTY(ReferenceSpace referenceSpace READ referenceSpace WRITE setReferenceSpace NOTIFY referenceSpaceChanged FINAL)
60 Q_PROPERTY(bool enableDepthSubmission READ isDepthSubmissionEnabled WRITE setEnableDepthSubmission NOTIFY enableDepthSubmissionChanged FINAL)
61 QML_NAMED_ELEMENT(XrView)
62
63public:
65 NoFoveation = 0,
66 LowFoveation = 1,
67 MediumFoveation = 2,
68 HighFoveation = 3
69 };
70 Q_ENUM(FoveationLevel)
71
72 enum class ReferenceSpace {
73 ReferenceSpaceUnknown,
74 ReferenceSpaceLocal,
75 ReferenceSpaceStage,
76 ReferenceSpaceLocalFloor
77 };
78 Q_ENUM(ReferenceSpace)
79
80 explicit QOpenXRView();
82
83 QOpenXROrigin *xrOrigin() const;
84 QQuick3DSceneEnvironment *environment() const;
85 QOpenXRHandInput *leftHandInput() const;
86 QOpenXRHandInput *rightHandInput() const;
87 QOpenXRHandTrackerInput *leftHandTrackerInput() const;
88 QOpenXRHandTrackerInput *rightHandTrackerInput() const;
89 QOpenXRGamepadInput *gamepadInput() const;
90
91 bool isPassthroughSupported() const;
92 bool enablePassthrough() const;
93
94 FoveationLevel fixedFoveation() const;
95 void setFixedFoveation(FoveationLevel level);
96
97 QOpenXRRuntimeInfo *runtimeInfo() const;
98
99 bool isQuitOnSessionEndEnabled() const;
100
101 QQuick3DRenderStats *renderStats() const;
102
103 Q_INVOKABLE QQuick3DPickResult rayPick(const QVector3D &origin, const QVector3D &direction) const;
104 Q_INVOKABLE QList<QQuick3DPickResult> rayPickAll(const QVector3D &origin, const QVector3D &direction) const;
105
106 Q_INVOKABLE void setTouchpoint(QQuickItem *target, const QPointF &position, int pointId, bool active);
107 Q_INVOKABLE QVector3D processTouch(const QVector3D &pos, int pointId);
108 Q_INVOKABLE QVariantMap touchpointState(int pointId) const;
109
110 ReferenceSpace referenceSpace() const;
111 void setReferenceSpace(ReferenceSpace newReferenceSpace);
112
113 bool isDepthSubmissionEnabled() const;
114
115 void registerXrItem(QOpenXRItem *newXrItem);
116 void unregisterXrItem(QOpenXRItem *xrItem);
117
118public Q_SLOTS:
119 void setEnvironment(QQuick3DSceneEnvironment * environment);
120 void setEnablePassthrough(bool enable);
121 void setQuitOnSessionEnd(bool enable);
122 void setEnableDepthSubmission(bool enable);
123
124private Q_SLOTS:
125 void updateViewportGeometry();
126 void handleSessionEnded();
127 void handleClearColorChanged();
128 void handleAAChanged();
129 bool init();
130
132 void initializeFailed(const QString &errorString);
139 void frameReady(QRhiTexture *colorBuffer); // tooling
142
143private:
144 // The XrView does not expose the View3D in its public interface. This is intentional.
145 QQuick3DViewport *view3d() const;
146
147 QPointer<QQuick3DSceneEnvironment> m_sceneEnvironment;
148 QOpenXRManager m_openXRManager;
149 mutable QOpenXRRuntimeInfo m_openXRRuntimeInfo;
150 bool m_quitOnSessionEnd = true;
151 bool m_inDestructor = false;
152 bool m_isInitialized = false;
153
155 QList<QOpenXRItem *> m_xrItems;
156 struct XrTouchState;
157 XrTouchState *m_touchState = nullptr;
158};
159
161
162#endif // QOPENXRVIEW_H
void frameReady(QRhiTexture *colorBuffer)
void sessionEnded()
void fixedFoveationChanged()
void enableDepthSubmissionChanged()
void enablePassthroughChanged(bool enable)
void quitOnSessionEndChanged()
void referenceSpaceChanged()
void environmentChanged(QQuick3DSceneEnvironment *environment)
void xrOriginChanged(QOpenXROrigin *xrOrigin)
void initializeFailed(const QString &errorString)
\inmodule QtCore\reentrant
Definition qpoint.h:217
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
\inmodule QtGui
Definition qrhi.h:895
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QVector3D class represents a vector or vertex in 3D space.
Definition qvectornd.h:171
direction
Combined button and popup list for selecting options.
GLenum GLuint GLint level
GLenum target
GLboolean enable
#define QML_NAMED_ELEMENT(NAME)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_INVOKABLE
#define Q_SLOTS
#define Q_SIGNALS