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
qquick3dinstancing.h
Go to the documentation of this file.
1// Copyright (C) 2020 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 Q_QUICK3D_INSTANCING_H
7#define Q_QUICK3D_INSTANCING_H
8
9#include <QtQuick3D/qquick3dobject.h>
10#include <QtGui/QVector4D>
11#include <QtGui/QQuaternion>
12#include <QtGui/QColor>
13
14QT_BEGIN_NAMESPACE
15
16class QQuick3DInstancingPrivate;
17
18class Q_QUICK3D_EXPORT QQuick3DInstancing : public QQuick3DObject
19{
20 Q_OBJECT
21 Q_DECLARE_PRIVATE(QQuick3DInstancing)
22
23 QML_NAMED_ELEMENT(Instancing)
24 QML_UNCREATABLE("Instancing is Abstract")
25 QML_ADDED_IN_VERSION(6, 2)
26 Q_PROPERTY(int instanceCountOverride READ instanceCountOverride WRITE setInstanceCountOverride NOTIFY instanceCountOverrideChanged)
27 Q_PROPERTY(bool hasTransparency READ hasTransparency WRITE setHasTransparency NOTIFY hasTransparencyChanged)
28 Q_PROPERTY(bool depthSortingEnabled READ depthSortingEnabled WRITE setDepthSortingEnabled NOTIFY depthSortingEnabledChanged)
29 Q_PROPERTY(QVector3D shadowBoundsMinimum READ shadowBoundsMinimum WRITE setShadowBoundsMinimum NOTIFY
30 shadowBoundsMinimumChanged REVISION(6, 9))
31 Q_PROPERTY(QVector3D shadowBoundsMaximum READ shadowBoundsMaximum WRITE setShadowBoundsMaximum NOTIFY
32 shadowBoundsMaximumChanged REVISION(6, 9))
34public:
35 struct Q_QUICK3D_EXPORT InstanceTableEntry {
36 QVector4D row0;
37 QVector4D row1;
38 QVector4D row2;
39 QVector4D color;
40 QVector4D instanceData;
41
42 QVector3D getPosition() const;
43 QVector3D getScale() const;
44 QQuaternion getRotation() const;
45 QColor getColor() const;
46 };
47
48 explicit QQuick3DInstancing(QQuick3DObject *parent = nullptr);
49 ~QQuick3DInstancing() override;
50
51 QByteArray instanceBuffer(int *instanceCount);
52 int instanceCountOverride() const;
53 bool hasTransparency() const;
54 bool depthSortingEnabled() const;
55 Q_REVISION(6, 9) QVector3D shadowBoundsMinimum() const;
56 Q_REVISION(6, 9) QVector3D shadowBoundsMaximum() const;
58 Q_REVISION(6, 3) Q_INVOKABLE QVector3D instancePosition(int index);
59 Q_REVISION(6, 3) Q_INVOKABLE QVector3D instanceScale(int index);
60 Q_REVISION(6, 3) Q_INVOKABLE QQuaternion instanceRotation(int index);
61 Q_REVISION(6, 3) Q_INVOKABLE QColor instanceColor(int index);
62 Q_REVISION(6, 3) Q_INVOKABLE QVector4D instanceCustomData(int index);
63
64public Q_SLOTS:
65 void setInstanceCountOverride(int instanceCountOverride);
66 void setHasTransparency(bool hasTransparency);
67 void setDepthSortingEnabled(bool enabled);
68 Q_REVISION(6, 9) void setShadowBoundsMinimum(const QVector3D &newShadowBoundsMinimum);
69 Q_REVISION(6, 9) void setShadowBoundsMaximum(const QVector3D &newShadowBoundsMinimum);
71Q_SIGNALS:
72 void instanceTableChanged();
73 void instanceNodeDirty();
74 void instanceCountOverrideChanged();
75 void hasTransparencyChanged();
76 void depthSortingEnabledChanged();
77 Q_REVISION(6, 9) void shadowBoundsMinimumChanged();
78 Q_REVISION(6, 9) void shadowBoundsMaximumChanged();
80protected:
81 virtual QByteArray getInstanceBuffer(int *instanceCount) = 0;
82 void markDirty();
83 static InstanceTableEntry calculateTableEntry(const QVector3D &position,
84 const QVector3D &scale, const QVector3D &eulerRotation,
85 const QColor &color, const QVector4D &customData = {});
86 static InstanceTableEntry calculateTableEntryFromQuaternion(const QVector3D &position,
87 const QVector3D &scale, const QQuaternion &rotation,
88 const QColor &color, const QVector4D &customData = {});
89 QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;
90
91private:
92 const InstanceTableEntry *getInstanceEntry(int index);
93};
94
95QT_END_NAMESPACE
96
97#endif // Q_QUICK3D_INSTANCING_H
\qmlproperty vector3d Instancing::shadowBoundsMaximum