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
qquick3dinstancing_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 Q_QUICK3D_INSTANCING_P_H
5#define Q_QUICK3D_INSTANCING_P_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/qquick3dinstancing.h>
19#include <QtQuick3D/private/qquick3dobject_p.h>
20
21#include <QtGui/qvector3d.h>
22
24
36
37class Q_QUICK3D_EXPORT QQuick3DInstanceListEntry : public QQuick3DObject
38{
40
42 Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged)
43 Q_PROPERTY(QVector3D scale READ scale WRITE setScale NOTIFY scaleChanged)
44 Q_PROPERTY(QVector3D eulerRotation READ eulerRotation WRITE setEulerRotation NOTIFY eulerRotationChanged)
45 Q_PROPERTY(QQuaternion rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
47 Q_PROPERTY(QVector4D customData READ customData WRITE setCustomData NOTIFY customDataChanged)
48 QML_NAMED_ELEMENT(InstanceListEntry)
49
50public:
53
55 {
56 return m_position;
57 }
59 {
60 return m_scale;
61 }
62
64 {
65 return m_eulerRotation;
66 }
67
69 {
70 return m_rotation;
71 }
72
73 QColor color() const
74 {
75 return m_color;
76 }
77
79 {
80 return m_customData;
81 }
82
83public Q_SLOTS:
85 void setScale(QVector3D scale);
86 void setEulerRotation(QVector3D eulerRotation);
87 void setRotation(QQuaternion rotation);
88 void setColor(QColor color);
89 void setCustomData(QVector4D customData);
90
98 void changed();
99
100protected:
102 {
103 return nullptr;
104 }
105
106private:
107 QVector3D m_position;
108 QVector3D m_scale = {1, 1, 1};
109 QVector3D m_eulerRotation;
110 QQuaternion m_rotation;
111 QColor m_color = Qt::white;
112 QVector4D m_customData;
113 bool m_useEulerRotation = true;
115};
116
117class Q_QUICK3D_EXPORT QQuick3DInstanceList : public QQuick3DInstancing
118{
120 Q_PROPERTY(QQmlListProperty<QQuick3DInstanceListEntry> instances READ instances)
121 Q_PROPERTY(int instanceCount READ instanceCount NOTIFY instanceCountChanged)
122 QML_NAMED_ELEMENT(InstanceList)
124
125public:
127 ~QQuick3DInstanceList() override;
128
129 QByteArray getInstanceBuffer(int *instanceCount) override;
131 int instanceCount() const;
132
134 void instanceCountChanged();
135
137 void handleInstanceChange();
138 void onInstanceDestroyed(QObject *object);
139
140private:
141 void generateInstanceData();
142
143 static void qmlAppendInstanceListEntry(QQmlListProperty<QQuick3DInstanceListEntry> *list, QQuick3DInstanceListEntry *material);
145 static qsizetype qmlInstanceListEntriesCount(QQmlListProperty<QQuick3DInstanceListEntry> *list);
146 static void qmlClearInstanceListEntries(QQmlListProperty<QQuick3DInstanceListEntry> *list);
147
148 bool m_dirty = true;
149 QByteArray m_instanceData;
150 QList<QQuick3DInstanceListEntry *> m_instances;
151};
152
153class Q_QUICK3D_EXPORT QQuick3DFileInstancing : public QQuick3DInstancing
154{
156 QML_NAMED_ELEMENT(FileInstancing)
158 Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
159 Q_PROPERTY(int instanceCount READ instanceCount NOTIFY instanceCountChanged)
160
161public:
163 ~QQuick3DFileInstancing() override;
164
165 const QUrl &source() const;
166 void setSource(const QUrl &newSource);
167
168 bool loadFromBinaryFile(const QString &filename);
169 bool loadFromXmlFile(const QString &filename);
170 int writeToBinaryFile(QIODevice *out);
171
172 int instanceCount() const;
173
175 void instanceCountChanged();
176 void sourceChanged();
177
178protected:
179 QByteArray getInstanceBuffer(int *instanceCount) override;
180
181private:
182 bool loadFromFile(const QUrl &source);
183
184private:
185 int m_instanceCount = 0;
186 QByteArray m_instanceData;
187 QFile *m_dataFile = nullptr;
188 bool m_dirty = true;
189 QUrl m_source;
190};
191
193
194#endif
\inmodule QtCore
Definition qbytearray.h:57
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore
Definition qfile.h:93
\inmodule QtCore \reentrant
Definition qiodevice.h:34
Definition qlist.h:75
\inmodule QtCore
Definition qobject.h:103
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
Definition qqmllist.h:24
The QQuaternion class represents a quaternion consisting of a vector and scalar.
QSSGRenderGraphObject * updateSpatialNode(QSSGRenderGraphObject *) override
\inmodule QtQuick3D \inherits QQuick3DObject
\qmltype Object3D \inqmlmodule QtQuick3D \instantiates QQuick3DObject \inherits QtObject
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
The QVector3D class represents a vector or vertex in 3D space.
Definition qvectornd.h:171
The QVector4D class represents a vector or vertex in 4D space.
Definition qvectornd.h:330
void colorChanged()
Combined button and popup list for selecting options.
@ white
Definition qnamespace.h:31
static int instanceCount
n void setPosition(void) \n\
GLuint index
[2]
GLuint color
[2]
GLsizei GLsizei GLchar * source
GLenum GLenum GLenum GLenum GLenum scale
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SLOTS
#define Q_SIGNALS
ptrdiff_t qsizetype
Definition qtypes.h:165
#define explicit
QList< int > list
[14]
QTextStream out(stdout)
[7]
myFilter setColor(QColor(128, 0, 0))