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
qquick3dresourceloader_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
7#ifndef QQUICK3DRESOURCELOADER_H
8#define QQUICK3DRESOURCELOADER_H
9
10//
11// W A R N I N G
12// -------------
13//
14// This file is not part of the Qt API. It exists purely as an
15// implementation detail. This header file may change from version to
16// version without notice, or even be removed.
17//
18// We mean it.
19//
20
21#include <QtQuick3D/private/qquick3dnode_p.h>
22#include <QtQuick3D/private/qquick3dgeometry_p.h>
23#include <QtQuick3D/private/qquick3dtexture_p.h>
24#include <QtQml/QQmlListProperty>
25
27
28class Q_QUICK3D_EXPORT QQuick3DResourceLoader : public QQuick3DObject
29{
30 Q_OBJECT
31 Q_PROPERTY(QList<QUrl> meshSources READ meshSources WRITE setMeshSources NOTIFY meshSourcesChanged)
32 Q_PROPERTY(QQmlListProperty<QQuick3DTexture> textures READ textures)
33 Q_PROPERTY(QQmlListProperty<QQuick3DGeometry> geometries READ geometries)
34 QML_NAMED_ELEMENT(ResourceLoader)
35 QML_ADDED_IN_VERSION(6, 3)
36public:
37 QQuick3DResourceLoader(QQuick3DObject *parent = nullptr);
38
39 const QList<QUrl> &meshSources() const;
40 void setMeshSources(const QList<QUrl> &newMeshSources);
41 QQmlListProperty<QQuick3DGeometry> geometries();
42 QQmlListProperty<QQuick3DTexture> textures();
43Q_SIGNALS:
44 void meshSourcesChanged();
45
46private Q_SLOTS:
47 void onGeometryDestroyed(QObject *object);
48 void onTextureDestroyed(QObject *object);
49protected:
50 QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;
51 void markAllDirty() override;
52 void itemChange(ItemChange change, const ItemChangeData &value) override;
53
54private:
55 static void qmlAppendGeometry(QQmlListProperty<QQuick3DGeometry> *list, QQuick3DGeometry *geometry);
56 static QQuick3DGeometry *qmlGeometryAt(QQmlListProperty<QQuick3DGeometry> *list, qsizetype index);
57 static qsizetype qmlGeometriesCount(QQmlListProperty<QQuick3DGeometry> *list);
58 static void qmlClearGeometries(QQmlListProperty<QQuick3DGeometry> *list);
59
60 static void qmlAppendTexture(QQmlListProperty<QQuick3DTexture> *list, QQuick3DTexture *texture);
61 static QQuick3DTexture *qmlTextureAt(QQmlListProperty<QQuick3DTexture> *list, qsizetype index);
62 static qsizetype qmlTexturesCount(QQmlListProperty<QQuick3DTexture> *list);
63 static void qmlClearTextures(QQmlListProperty<QQuick3DTexture> *list);
64
65 enum ResourceLoaderDirtyType {
66 MeshesDirty = 0x00000001,
67 TexturesDirty = 0x00000002,
68 GeometriesDirty = 0x00000004
69 };
70
71
72 quint32 m_dirtyAttributes = 0xffffffff; // all dirty by default
73 void markDirty(ResourceLoaderDirtyType type);
74 void updateSceneManager(QQuick3DSceneManager *sceneManager);
75
76 QList<QUrl> m_meshSources;
77 QList<QQuick3DGeometry *> m_geometries;
78 QList<QQuick3DTexture *> m_textures;
79};
80
81QT_END_NAMESPACE
82
83#endif // QQUICK3DRESOURCELOADER_H