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
qquick3dreflectionprobe_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QSSGREFLECTIONPROBE_H
5#define QSSGREFLECTIONPROBE_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 <QtQuick3D/private/qquick3dnode_p.h>
19#include <QtQuick3D/private/qquick3dgeometry_p.h>
20#include <QtQuick3D/private/qquick3dmodel_p.h>
21#include <QtQuick3D/private/qquick3ddefaultmaterial_p.h>
22#include <QtQuick3D/private/qquick3dviewport_p.h>
23#include <QtQuick3D/private/qquick3dcubemaptexture_p.h>
24#include <QColor>
25
27
28class Q_QUICK3D_EXPORT QQuick3DReflectionProbe : public QQuick3DNode
29{
31 Q_PROPERTY(ReflectionQuality quality READ quality WRITE setQuality NOTIFY qualityChanged)
32 Q_PROPERTY(QColor clearColor READ clearColor WRITE setClearColor NOTIFY clearColorChanged)
33 Q_PROPERTY(ReflectionRefreshMode refreshMode READ refreshMode WRITE setRefreshMode NOTIFY refreshModeChanged)
34 Q_PROPERTY(ReflectionTimeSlicing timeSlicing READ timeSlicing WRITE setTimeSlicing NOTIFY timeSlicingChanged)
35 Q_PROPERTY(bool parallaxCorrection READ parallaxCorrection WRITE setParallaxCorrection NOTIFY parallaxCorrectionChanged)
36 Q_PROPERTY(QVector3D boxSize READ boxSize WRITE setBoxSize NOTIFY boxSizeChanged)
37 Q_PROPERTY(QVector3D boxOffset READ boxOffset WRITE setBoxOffset NOTIFY boxOffsetChanged REVISION(6, 4))
38 Q_PROPERTY(bool debugView READ debugView WRITE setDebugView NOTIFY debugViewChanged REVISION(6, 4))
39 Q_PROPERTY(QQuick3DCubeMapTexture *texture READ texture WRITE setTexture NOTIFY textureChanged REVISION(6, 5))
40 QML_NAMED_ELEMENT(ReflectionProbe)
42
43public:
44 enum class ReflectionQuality {
45 VeryLow,
46 Low,
47 Medium,
48 High,
49 VeryHigh
50 };
51 Q_ENUM(ReflectionQuality)
52
54 FirstFrame,
55 EveryFrame
56 };
57 Q_ENUM(ReflectionRefreshMode)
58
60 None,
61 AllFacesAtOnce,
62 IndividualFaces,
63 };
64 Q_ENUM(ReflectionTimeSlicing)
65
66 explicit QQuick3DReflectionProbe(QQuick3DNode *parent = nullptr);
68
69 ReflectionQuality quality() const;
70 QColor clearColor() const;
71 ReflectionRefreshMode refreshMode() const;
72 ReflectionTimeSlicing timeSlicing() const;
73 bool parallaxCorrection() const;
74 QVector3D boxSize() const;
75 Q_REVISION(6, 4) bool debugView() const;
76 Q_REVISION(6, 4) QVector3D boxOffset() const;
77
78 Q_REVISION(6, 4) Q_INVOKABLE void scheduleUpdate();
80
81public Q_SLOTS:
82 void setQuality(ReflectionQuality reflectionQuality);
83 void setClearColor(const QColor &clearColor);
84 void setRefreshMode(ReflectionRefreshMode newRefreshMode);
85 void setTimeSlicing(ReflectionTimeSlicing newTimeSlicing);
86 void setParallaxCorrection(bool parallaxCorrection);
87 void setBoxSize(const QVector3D &newBoxSize);
88 Q_REVISION(6, 4) void setDebugView(bool debugView);
89 Q_REVISION(6, 4) void setBoxOffset(const QVector3D &boxOffset);
90 Q_REVISION(6, 5) void setTexture(QQuick3DCubeMapTexture *newTexture);
91
93 void qualityChanged();
94 void clearColorChanged();
95 void refreshModeChanged();
96 void timeSlicingChanged();
97 void parallaxCorrectionChanged();
98
99 void boxSizeChanged();
100 Q_REVISION(6, 4) void debugViewChanged();
101 Q_REVISION(6, 4) void boxOffsetChanged();
102 Q_REVISION(6, 5) void textureChanged();
103
104protected:
105 QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;
106 void markAllDirty() override;
107 void itemChange(ItemChange, const ItemChangeData &) override;
108
109 enum class DirtyFlag {
110 QualityDirty = (1 << 0),
111 ClearColorDirty = (1 << 1),
112 RefreshModeDirty = (1 << 2),
113 ParallaxCorrectionDirty = (1 << 3),
114 BoxDirty = (1 << 4),
115 TimeSlicingDirty = (1 << 5),
116 TextureDirty = (1 << 6)
117 };
118 Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag)
119
120 DirtyFlags m_dirtyFlags = DirtyFlags(DirtyFlag::QualityDirty)
121 | DirtyFlags(DirtyFlag::ClearColorDirty)
122 | DirtyFlags(DirtyFlag::RefreshModeDirty)
123 | DirtyFlags(DirtyFlag::ParallaxCorrectionDirty)
124 | DirtyFlags(DirtyFlag::BoxDirty)
125 | DirtyFlags(DirtyFlag::TimeSlicingDirty)
126 | DirtyFlags(DirtyFlag::TextureDirty);
127
128private:
129 quint32 mapToReflectionResolution(ReflectionQuality quality);
130 void findSceneView();
131 void createDebugView();
132 void updateDebugView();
133 void updateSceneManager(QQuick3DSceneManager *window);
134 ReflectionQuality m_quality = ReflectionQuality::Low;
135 QColor m_clearColor = Qt::transparent;
136 ReflectionRefreshMode m_refreshMode = ReflectionRefreshMode::EveryFrame;
137 bool m_parallaxCorrection = false;
138 QVector3D m_boxSize = QVector3D(0, 0, 0);
140 bool m_debugView = false;
141 // These objects are used to visualize the reflection probe box.
142 QQuick3DGeometry *m_debugViewGeometry = nullptr;
143 QQuick3DModel *m_debugViewModel = nullptr;
144 QQuick3DDefaultMaterial *m_debugViewMaterial = nullptr;
145 QVector3D m_boxOffset;
146 QQuick3DViewport* m_sceneView = nullptr;
147 QQuick3DCubeMapTexture *m_texture = nullptr;
148};
149
151
152#endif // QSSGREFLECTIONPROBE_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\qmltype Geometry \inherits Object3D \inqmlmodule QtQuick3D \instantiates QQuick3DGeometry
Q_REVISION(6, 4) bool debugView() const
The QVector3D class represents a vector or vertex in 3D space.
Definition qvectornd.h:171
Combined button and popup list for selecting options.
Definition qcompare.h:63
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
@ None
Definition qhash.cpp:531
GLenum GLuint texture
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
@ Medium
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_REVISION(...)
#define Q_INVOKABLE
#define Q_SLOTS
#define Q_SIGNALS
unsigned int quint32
Definition qtypes.h:50
aWidget window() -> setWindowTitle("New Window Title")
[2]