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
qquick3dxrcamera_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 QQUICK3DXRCAMERA_P_H
7#define QQUICK3DXRCAMERA_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 <QtQuick3DXr/qtquick3dxrglobal.h>
22
23#include <QObject>
24#include <QtQuick3D/private/qquick3dcamera_p.h>
25
27
28class QQuick3DXrOrigin;
29
30class Q_QUICK3DXR_EXPORT QQuick3DXrEyeCamera : public QQuick3DCamera
31{
32 Q_OBJECT
33 Q_PROPERTY(float leftTangent READ leftTangent WRITE setLeftTangent NOTIFY leftTangentChanged)
34 Q_PROPERTY(float rightTangent READ rightTangent WRITE setRightTangent NOTIFY rightTangentChanged)
35 Q_PROPERTY(float upTangent READ upTangent WRITE setUpTangent NOTIFY upTangentChanged)
36 Q_PROPERTY(float downTangent READ downTangent WRITE setDownTangent NOTIFY downTangentChanged)
37 Q_PROPERTY(float clipNear READ clipNear WRITE setClipNear NOTIFY clipNearChanged)
38 Q_PROPERTY(float clipFar READ clipFar WRITE setClipFar NOTIFY clipFarChanged)
39
40public:
41 explicit QQuick3DXrEyeCamera(QQuick3DXrOrigin *parent = nullptr);
42
43 float leftTangent() const;
44 float rightTangent() const;
45 float upTangent() const;
46 float downTangent() const;
47 float clipNear() const;
48 float clipFar() const;
49
50public Q_SLOTS:
51 void setLeftTangent(float leftTangent);
52 void setRightTangent(float rightTangent);
53 void setUpTangent(float upTangent);
54 void setDownTangent(float downTangent);
55 void setClipNear(float clipNear);
56 void setClipFar(float clipFar);
57 void setProjection(const QMatrix4x4 &projection);
58
59Q_SIGNALS:
60 void leftTangentChanged(float leftTangent);
61 void rightTangentChanged(float rightTangent);
62 void upTangentChanged(float upTangent);
63 void downTangentChanged(float downTangent);
64 void clipNearChanged(float clipNear);
65 void clipFarChanged(float clipFar);
66
67public:
68 QMatrix4x4 m_projection;
69
70protected:
71 QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;
72
73private:
74 enum DirtyFlag : quint8
75 {
76 ProjectionDirty = 0x1, // Camera projection matrix needs to be recalculated
77 ProjectionChanged = 0x2, // A camera projection matrix has changed (no recalculation needed)
78 ClipChanged = 0x4, // Camera clip planes have changed
79 };
80 using DirtyFlagT = std::underlying_type_t<DirtyFlag>;
81
82 void markDirty(DirtyFlag flag);
83 void maybeUpdateProjection();
84 float m_leftTangent = -0.017455064928218f; // tan(-1)
85 float m_rightTangent = 0.017455064928218f; // tan(1)
86 float m_upTangent = 0.017455064928218f; // tan(1)
87 float m_downTangent = -0.017455064928218f; // tan(-1)
88 float m_clipNear = 1.0f;
89 float m_clipFar = 10000.0f;
90 DirtyFlagT m_dirtyFlags = 0;
91};
92
93class Q_QUICK3DXR_EXPORT QQuick3DXrCamera : public QQuick3DNode
94{
95 Q_OBJECT
96 Q_PROPERTY(float clipNear READ clipNear WRITE setClipNear NOTIFY clipNearChanged FINAL)
97 Q_PROPERTY(float clipFar READ clipFar WRITE setClipFar NOTIFY clipFarChanged FINAL)
98 QML_NAMED_ELEMENT(XrCamera)
99 QML_ADDED_IN_VERSION(6, 8)
100
101public:
102 explicit QQuick3DXrCamera(QQuick3DXrOrigin *parent = nullptr);
103 ~QQuick3DXrCamera();
104 float clipNear() const;
105 float clipFar() const;
106
107public Q_SLOTS:
108 void setClipNear(float clipNear);
109 void setClipFar(float clipFar);
110
111Q_SIGNALS:
112 void clipNearChanged(float clipNear);
113 void clipFarChanged(float clipFar);
114
115protected:
116 void itemChange(ItemChange change, const ItemChangeData &data) override;
117
118private:
119 void syncCameraSettings();
120
121 float m_clipNear = 1.0f;
122 float m_clipFar = 10000.0f;
123};
124
125
126QT_END_NAMESPACE
127
128#endif // QQUICK3DXRCAMERA_P_H
bool event(QEvent *event) override
This virtual function receives events to an object and should return true if the event e was recogniz...
static constexpr QEvent::Type asQEvent(QQuick3DOpenXRThreadWorker::Event event)
static QQuick3DXrInputManagerPrivate * get(QQuick3DXrInputManager *inputManager)
QQuick3DXrManagerPrivate(QQuick3DXrManager &manager)
void setupWindow(QQuickWindow *window)
QtQuick3DXr::ReferenceSpace getReferenceSpace() const
void setReferenceSpace(QtQuick3DXr::ReferenceSpace newReferenceSpace)
bool setupGraphics(QQuickWindow *window)
static QQuick3DXrManagerPrivate * get(QQuick3DXrManager *manager)
void getDefaultClipDistances(float &nearClip, float &farClip) const
static bool isMultiviewRenderingDisabled()
Combined button and popup list for selecting options.
QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcQIORing)
#define MAKE_TO_STRING_FUNC(enumType)
static bool isApiLayerSupported(const char *layerName, const QVector< XrApiLayerProperties > &apiLayerProperties)
#define ENUM_CASE_STR(name, val)
static const char s_workerThreadName[]
static QtQuick3DXr::ReferenceSpace getReferenceSpaceType(XrReferenceSpaceType referenceSpace)
static std::pair< XrResult, XrFrameState > waitForNextFrame(XrSession session)
static bool isExtensionSupported(const char *extensionName, const QVector< XrExtensionProperties > &instanceExtensionProperties, uint32_t *extensionVersion=nullptr)