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
qquick3druntimeloader_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// Qt-Security score:significant reason:default
4
5
6#ifndef QQUICK3DRUNTIMELOADER_H
7#define QQUICK3DRUNTIMELOADER_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#include <QtQuick3D/private/qquick3dmodel_p.h>
21#include <QtQuick3D/private/qquick3dinstancing_p.h>
22
24
25#include <QtCore/qpointer.h>
26#include <QtCore/qlist.h>
27#if QT_CONFIG(mimetype)
28#include <QtCore/qmimetype.h>
29#endif
30#include <QtCore/qhash.h>
31
33
34class Q_QUICK3DASSETUTILS_EXPORT QQuick3DRuntimeLoader : public QQuick3DNode
35{
36 Q_OBJECT
37
38 QML_NAMED_ELEMENT(RuntimeLoader)
39 QML_ADDED_IN_VERSION(6, 2)
40
41 Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
42 Q_PROPERTY(Status status READ status NOTIFY statusChanged)
43 Q_PROPERTY(QString errorString READ errorString NOTIFY errorStringChanged)
44 Q_PROPERTY(QQuick3DBounds3 bounds READ bounds NOTIFY boundsChanged)
45 Q_PROPERTY(QQuick3DInstancing *instancing READ instancing WRITE setInstancing NOTIFY instancingChanged)
46 Q_PROPERTY(QStringList supportedExtensions READ supportedExtensions CONSTANT REVISION(6, 7))
47 Q_PROPERTY(QStringList materialVariants READ materialVariants NOTIFY materialVariantsChanged REVISION(6, 13))
48 Q_PROPERTY(QString materialVariant READ materialVariant WRITE setMaterialVariant NOTIFY materialVariantChanged
49 REVISION(6, 13))
50#if QT_CONFIG(mimetype)
51 Q_PROPERTY(QList<QMimeType> supportedMimeTypes READ supportedMimeTypes CONSTANT REVISION(6, 7))
52#endif
53
54public:
55 explicit QQuick3DRuntimeLoader(QQuick3DNode *parent = nullptr);
56
57 enum class QueryFilter
58 {
59 Textures,
60 Materials,
61 Nodes,
62 Cameras,
63 Lights,
64 Models,
65 };
66 Q_ENUM(QueryFilter)
67
68 QUrl source() const;
69 void setSource(const QUrl &newSource);
70 void componentComplete() override;
71 Q_REVISION(6, 7) static QStringList supportedExtensions();
72#if QT_CONFIG(mimetype)
73 Q_REVISION(6, 7) static QList<QMimeType> supportedMimeTypes();
74#endif
75
76 enum class Status { Empty, Success, Error };
77 Q_ENUM(Status)
78 Status status() const;
79 QString errorString() const;
80 const QQuick3DBounds3 &bounds() const;
81
82 QQuick3DInstancing *instancing() const;
83 void setInstancing(QQuick3DInstancing *newInstancing);
84
85 Q_REVISION(6, 13) QStringList materialVariants() const;
86 Q_REVISION(6, 13) QString materialVariant() const;
87 Q_REVISION(6, 13) void setMaterialVariant(const QString &variant);
88
89 Q_REVISION(6, 12) Q_INVOKABLE QQuick3DObject *query(const QString &name) const;
90 Q_REVISION(6, 12) Q_INVOKABLE QList<QQuick3DObject *> queryAll(QueryFilter filter) const;
91
92Q_SIGNALS:
93 void sourceChanged();
94 void statusChanged();
95 void errorStringChanged();
96 void boundsChanged();
97 void instancingChanged();
98 Q_REVISION(6, 13) void materialVariantsChanged();
99 Q_REVISION(6, 13) void materialVariantChanged();
100
101protected:
102 QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;
103
104private:
105 void calculateBounds();
106 void loadSource();
107 void updateModels();
108
109 QSSGRuntimeObjectNameMap m_objects;
110 QSSGRuntimeObjectTypeMap m_objectsByType;
111
112 QPointer<QQuick3DNode> m_root;
113 QPointer<QQuick3DNode> m_imported;
114 QString m_assetId; // Used to release runtime assets in the buffer manager.
115 QUrl m_source;
116 Status m_status = Status::Empty;
117 QString m_errorString;
118 bool m_boundsDirty = false;
119 QQuick3DBounds3 m_bounds;
120 QQuick3DInstancing *m_instancing = nullptr;
121 bool m_instancingChanged = false;
122
123 void applyMaterialVariant();
124 struct ModelVariantMaterials
125 {
126 QPointer<QQuick3DModel> model;
127 QList<QList<QQuick3DMaterial *>> perVariant;
128 QList<QQuick3DMaterial *> defaults;
129 };
130 QList<ModelVariantMaterials> m_variantModels;
131 QStringList m_materialVariants;
132 QString m_materialVariant;
133};
134
135QT_END_NAMESPACE
136
137#endif // QQUICK3DRUNTIMELOADER_H
Combined button and popup list for selecting options.
static void boxBoundsRecursive(const QQuick3DNode *baseNode, const QQuick3DNode *node, QQuick3DBounds3 &accBounds)
static void applyToModels(QQuick3DObject *obj, Func &&lambda)
static QSSGRenderGraphObject::BaseType queryFilterToBaseType(QQuick3DRuntimeLoader::QueryFilter filter)