// Copyright (C) 2021 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QQUICK3DRESOURCELOADER_H #define QQUICK3DRESOURCELOADER_H // // W A R N I N G // ------------- // // This file is not part of the Qt API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // #include #include #include #include QT_BEGIN_NAMESPACE class Q_QUICK3D_EXPORT QQuick3DResourceLoader : public QQuick3DObject { Q_OBJECT Q_PROPERTY(QList meshSources READ meshSources WRITE setMeshSources NOTIFY meshSourcesChanged) Q_PROPERTY(QQmlListProperty textures READ textures) Q_PROPERTY(QQmlListProperty geometries READ geometries) QML_NAMED_ELEMENT(ResourceLoader) QML_ADDED_IN_VERSION(6, 3) public: QQuick3DResourceLoader(QQuick3DObject *parent = nullptr); const QList &meshSources() const; void setMeshSources(const QList &newMeshSources); QQmlListProperty geometries(); QQmlListProperty textures(); Q_SIGNALS: void meshSourcesChanged(); private Q_SLOTS: void onGeometryDestroyed(QObject *object); void onTextureDestroyed(QObject *object); protected: QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override; void markAllDirty() override; void itemChange(ItemChange change, const ItemChangeData &value) override; private: static void qmlAppendGeometry(QQmlListProperty *list, QQuick3DGeometry *geometry); static QQuick3DGeometry *qmlGeometryAt(QQmlListProperty *list, qsizetype index); static qsizetype qmlGeometriesCount(QQmlListProperty *list); static void qmlClearGeometries(QQmlListProperty *list); static void qmlAppendTexture(QQmlListProperty *list, QQuick3DTexture *texture); static QQuick3DTexture *qmlTextureAt(QQmlListProperty *list, qsizetype index); static qsizetype qmlTexturesCount(QQmlListProperty *list); static void qmlClearTextures(QQmlListProperty *list); enum ResourceLoaderDirtyType { MeshesDirty = 0x00000001, TexturesDirty = 0x00000002, GeometriesDirty = 0x00000004 }; quint32 m_dirtyAttributes = 0xffffffff; // all dirty by default void markDirty(ResourceLoaderDirtyType type); void updateSceneManager(QQuick3DSceneManager *sceneManager); QList m_meshSources; QList m_geometries; QList m_textures; }; QT_END_NAMESPACE #endif // QQUICK3DRESOURCELOADER_H