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
qquick3dviewport_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QSSGVIEW3D_H
5#define QSSGVIEW3D_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#include <QtQuick/QQuickItem>
19#include <QtCore/qurl.h>
20
21#include <QtQuick3D/qtquick3dglobal.h>
22#include <QtQuick3D/private/qquick3dpickresult_p.h>
23#include <QtQuick/private/qquickshadereffectsource_p.h>
24
25#include <QtQuick3DRuntimeRender/private/qssgrenderpickresult_p.h>
26
30
32
33class QSSGView3DPrivate;
34class QQuick3DCamera;
36class QQuick3DNode;
41
45
46class Q_QUICK3D_EXPORT QQuick3DViewport : public QQuickItem
47{
49 Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false FINAL)
50 Q_PROPERTY(QQuick3DCamera *camera READ camera WRITE setCamera NOTIFY cameraChanged FINAL)
51 Q_PROPERTY(QQuick3DSceneEnvironment *environment READ environment WRITE setEnvironment NOTIFY environmentChanged FINAL)
52 Q_PROPERTY(QQuick3DNode *scene READ scene NOTIFY sceneChanged)
53 Q_PROPERTY(QQuick3DNode *importScene READ importScene WRITE setImportScene NOTIFY importSceneChanged FINAL)
54 Q_PROPERTY(RenderMode renderMode READ renderMode WRITE setRenderMode NOTIFY renderModeChanged FINAL)
55 Q_PROPERTY(QQuickShaderEffectSource::Format renderFormat READ renderFormat WRITE setRenderFormat NOTIFY renderFormatChanged FINAL REVISION(6, 4))
56 Q_PROPERTY(QQuick3DRenderStats *renderStats READ renderStats CONSTANT)
57 Q_PROPERTY(QQmlListProperty<QQuick3DObject> extensions READ extensions FINAL REVISION(6, 6))
58 Q_PROPERTY(int explicitTextureWidth READ explicitTextureWidth WRITE setExplicitTextureWidth NOTIFY explicitTextureWidthChanged FINAL REVISION(6, 7))
59 Q_PROPERTY(int explicitTextureHeight READ explicitTextureHeight WRITE setExplicitTextureHeight NOTIFY explicitTextureHeightChanged FINAL REVISION(6, 7))
60 Q_PROPERTY(QSize effectiveTextureSize READ effectiveTextureSize NOTIFY effectiveTextureSizeChanged FINAL REVISION(6, 7))
61 Q_CLASSINFO("DefaultProperty", "data")
62
63 QML_NAMED_ELEMENT(View3D)
64
65public:
72 Q_ENUM(RenderMode)
73
74 explicit QQuick3DViewport(QQuickItem *parent = nullptr);
75 ~QQuick3DViewport() override;
76
77 QQmlListProperty<QObject> data();
78
79 QQuick3DCamera *camera() const;
80 QQuick3DSceneEnvironment *environment() const;
81 QQuick3DNode *scene() const;
82 QQuick3DNode *importScene() const;
83 RenderMode renderMode() const;
84 Q_REVISION(6, 4) QQuickShaderEffectSource::Format renderFormat() const;
85 QQuick3DRenderStats *renderStats() const;
86
87 QQuick3DSceneRenderer *createRenderer() const;
88
89 bool isTextureProvider() const override;
90 QSGTextureProvider *textureProvider() const override;
91 void releaseResources() override;
92
93 Q_INVOKABLE QVector3D mapFrom3DScene(const QVector3D &scenePos) const;
94 Q_INVOKABLE QVector3D mapTo3DScene(const QVector3D &viewPos) const;
95
96 Q_INVOKABLE QQuick3DPickResult pick(float x, float y) const;
98 Q_REVISION(6, 8) Q_INVOKABLE QList<QQuick3DPickResult> pickSubset(float x, float y, const QJSValue &models) const;
99 Q_REVISION(6, 2) Q_INVOKABLE QList<QQuick3DPickResult> pickAll(float x, float y) const;
100 Q_REVISION(6, 2) Q_INVOKABLE QQuick3DPickResult rayPick(const QVector3D &origin, const QVector3D &direction) const;
101 Q_REVISION(6, 2) Q_INVOKABLE QList<QQuick3DPickResult> rayPickAll(const QVector3D &origin, const QVector3D &direction) const;
102
103 void processPointerEventFromRay(const QVector3D &origin, const QVector3D &direction, QPointerEvent *event);
104
105 Q_REVISION(6, 8) Q_INVOKABLE void setTouchpoint(QQuickItem *target, const QPointF &position, int pointId, bool active);
106
107 QQuick3DLightmapBaker *maybeLightmapBaker();
108 QQuick3DLightmapBaker *lightmapBaker();
109
110 Q_INVOKABLE void bakeLightmap();
111
113
114 Q_REVISION(6, 7) int explicitTextureWidth() const;
115 Q_REVISION(6, 7) int explicitTextureHeight() const;
116 Q_REVISION(6, 7) QSize effectiveTextureSize() const;
117
118 // Private helpers
119 [[nodiscard]] bool extensionListDirty() const { return m_extensionListDirty; }
120 [[nodiscard]] const QList<QQuick3DObject *> &extensionList() const { return m_extensions; }
121 void clearExtensionListDirty() { m_extensionListDirty = false; }
122
123 Q_REVISION(6, 7) Q_INVOKABLE void rebuildExtensionList();
124
125protected:
126 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
127 QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
128 void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) override;
129
130 bool event(QEvent *) override;
131 void componentComplete() override;
132
133public Q_SLOTS:
134 void setCamera(QQuick3DCamera *camera);
135 void setEnvironment(QQuick3DSceneEnvironment * environment);
136 void setImportScene(QQuick3DNode *inScene);
137 void setRenderMode(QQuick3DViewport::RenderMode renderMode);
138 Q_REVISION(6, 4) void setRenderFormat(QQuickShaderEffectSource::Format format);
139 Q_REVISION(6, 7) void setExplicitTextureWidth(int width);
140 Q_REVISION(6, 7) void setExplicitTextureHeight(int height);
141 void cleanupDirectRenderer();
142
143 // Setting this true enables picking for all the models, regardless of
144 // the models pickable property.
145 void setGlobalPickingEnabled(bool isEnabled);
146
148 void invalidateSceneGraph();
149 void updateInputProcessing();
150 void onReleaseCachedResources();
151
153 void cameraChanged();
154 void environmentChanged();
155 void sceneChanged();
156 void importSceneChanged();
157 void renderModeChanged();
158 Q_REVISION(6, 4) void renderFormatChanged();
159 Q_REVISION(6, 7) void explicitTextureWidthChanged();
160 Q_REVISION(6, 7) void explicitTextureHeightChanged();
161 Q_REVISION(6, 7) void effectiveTextureSizeChanged();
162
163private:
164 void setMultiViewCameras(QQuick3DCamera **firstCamera, int count);
165
167 friend class QOpenXRManager;
169
170 Q_DISABLE_COPY(QQuick3DViewport)
171 struct SubsceneInfo {
172 QQuick3DObject* obj = nullptr;
173 QVarLengthArray<QPointF, 16> eventPointScenePositions;
174 };
175 QQuick3DSceneRenderer *getRenderer() const;
176 void updateDynamicTextures();
177 QSGNode *setupOffscreenRenderer(QSGNode *node);
178 QSGNode *setupInlineRenderer(QSGNode *node);
179 void setupDirectRenderer(RenderMode mode);
180 bool checkIsVisible() const;
181 bool internalPick(QPointerEvent *event, const QVector3D &origin = QVector3D(), const QVector3D &direction = QVector3D()) const;
182 QVarLengthArray<QSSGRenderPickResult, 20> getPickResults(QQuick3DSceneRenderer *renderer, const QVector3D &origin, const QVector3D &direction) const;
183 QVarLengthArray<QSSGRenderPickResult, 20> getPickResults(QQuick3DSceneRenderer *renderer, const QEventPoint &eventPoint) const;
184 bool forwardEventToSubscenes(QPointerEvent *event,
185 bool useRayPicking,
187 const QFlatMap<QQuickItem *, SubsceneInfo> &visitedSubscenes) const;
188
189 void processPickedObject(const QSSGRenderGraphObject *backendObject,
190 const QSSGRenderPickResult &pickResult,
191 int pointIndex,
193 QFlatMap<QQuickItem *, SubsceneInfo> &vistedSubscenes) const;
194 QQuickItem *getSubSceneRootItem(QQuick3DMaterial *material) const;
195 QQuick3DPickResult getNearestPickResult(const QVarLengthArray<QSSGRenderPickResult, 20> &pickResults) const;
196 QQuick3DPickResult processPickResult(const QSSGRenderPickResult &pickResult) const;
197 QQuick3DObject *findFrontendNode(const QSSGRenderGraphObject *backendObject) const;
198 QQuick3DSceneManager *findChildSceneManager(QQuick3DObject *inObject, QQuick3DSceneManager *manager = nullptr);
199 QQuick3DCamera *m_camera = nullptr;
200 QVarLengthArray<QQuick3DCamera *, 2> m_multiViewCameras;
201 QQuick3DSceneEnvironment *m_environment = nullptr;
202 QQuick3DSceneRootNode *m_sceneRoot = nullptr;
203 QQuick3DNode *m_importScene = nullptr;
204 mutable SGFramebufferObjectNode *m_node = nullptr;
205 mutable QQuick3DSGRenderNode *m_renderNode = nullptr;
206 mutable QQuick3DSGDirectRenderer *m_directRenderer = nullptr;
207 bool m_renderModeDirty = false;
208 RenderMode m_renderMode = Offscreen;
210 int m_explicitTextureWidth = 0;
211 int m_explicitTextureHeight = 0;
212 QSize m_effectiveTextureSize;
213 float m_widthMultiplier = 1.0f;
214 float m_heightMultiplier = 1.0f;
215 QQuick3DRenderStats *m_renderStats = nullptr;
216 bool m_enableInputProcessing = false;
217 QQuick3DLightmapBaker *m_lightmapBaker = nullptr;
218 QList<QQuick3DObject *> m_extensions;
219 bool m_extensionListDirty = false;
220
221 struct TouchState {
222 QQuickItem *target = nullptr;
224 bool isPressed = false;
225 };
226 QPointingDevice *m_syntheticTouchDevice = nullptr;
227 QVarLengthArray<TouchState, 2> m_touchState{2};
228
230};
231
233
234#endif // QSSGVIEW3D_H
The QEventPoint class provides information about a point in a QPointerEvent.
Definition qeventpoint.h:20
\inmodule QtCore
Definition qcoreevent.h:45
The QJSValue class acts as a container for Qt/JavaScript data types.
Definition qjsvalue.h:31
Definition qlist.h:75
\inmodule QtCore\reentrant
Definition qpoint.h:217
A base class for pointer events.
Definition qevent.h:73
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
Definition qqmllist.h:24
\qmltype Object3D \inqmlmodule QtQuick3D \instantiates QQuick3DObject \inherits QtObject
const QList< QQuick3DObject * > & extensionList() const
Q_REVISION(6, 7) Q_INVOKABLE void rebuildExtensionList()
QQmlListProperty< QObject > data()
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
Definition qquickitem.h:144
\inmodule QtCore\reentrant
Definition qrect.h:484
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
Definition qsgnode.h:37
The QSGTextureProvider class encapsulates texture based entities in QML.
\inmodule QtCore
Definition qsize.h:25
The QVector3D class represents a vector or vertex in 3D space.
Definition qvectornd.h:171
Format
Definition ddsheader.h:14
QCamera * camera
Definition camera.cpp:19
direction
Combined button and popup list for selecting options.
static int pick(bool vertical, const QSize &size)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLint GLint GLint GLint GLint x
[0]
GLenum mode
GLint GLsizei GLsizei height
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLsizei width
GLenum target
GLint GLsizei GLsizei GLenum format
GLint y
struct _cl_event * event
GLhandleARB obj
[2]
#define QML_NAMED_ELEMENT(NAME)
#define Q_QUICK3D_PROFILE_ID
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_REVISION(...)
#define Q_CLASSINFO(name, value)
#define Q_INVOKABLE
#define Q_SLOTS
#define Q_SIGNALS
QSqlQueryModel * model
[16]
QGraphicsScene scene
[0]
QNetworkAccessManager manager
QSvgRenderer * renderer
[0]
\inmodule QtQuick
Definition qquickitem.h:159