| 1 | // Copyright (C) 2022 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QSSGLIGHTMAPPER_P_H |
| 5 | #define QSSGLIGHTMAPPER_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 <QtQuick3DRuntimeRender/private/qtquick3druntimerenderglobal_p.h> |
| 19 | #include <ssg/qssglightmapper.h> |
| 20 | |
| 21 | #include <QString> |
| 22 | |
| 23 | QT_BEGIN_NAMESPACE |
| 24 | |
| 25 | struct QSSGLightmapperPrivate; |
| 26 | struct QSSGBakedLightingModel; |
| 27 | class QSSGRhiContext; |
| 28 | class QSSGRenderer; |
| 29 | struct QSSGRenderModel; |
| 30 | |
| 31 | class QSSGLightmapper |
| 32 | { |
| 33 | public: |
| 34 | enum class BakingStatus { |
| 35 | None, |
| 36 | Progress, |
| 37 | Warning, |
| 38 | Error, |
| 39 | Cancelled, |
| 40 | Complete |
| 41 | }; |
| 42 | |
| 43 | struct BakingControl { |
| 44 | bool cancelled = false; |
| 45 | }; |
| 46 | |
| 47 | typedef std::function<void(BakingStatus, std::optional<QString>, BakingControl*)> Callback; |
| 48 | |
| 49 | QSSGLightmapper(QSSGRhiContext *rhiCtx, QSSGRenderer *renderer); |
| 50 | ~QSSGLightmapper(); |
| 51 | void reset(); |
| 52 | void setOptions(const QSSGLightmapperOptions &options); |
| 53 | void setOutputCallback(Callback callback); |
| 54 | qsizetype add(const QSSGBakedLightingModel &model); |
| 55 | bool bake(); |
| 56 | |
| 57 | enum class LightmapAsset { |
| 58 | LightmapImage, |
| 59 | MeshWithLightmapUV, |
| 60 | LightmapImageList |
| 61 | }; |
| 62 | static QString lightmapAssetPathForLoad(const QSSGRenderModel &model, LightmapAsset asset); |
| 63 | static QString lightmapAssetPathForSave(const QSSGRenderModel &model, LightmapAsset asset, const QString& outputFolder = {}); |
| 64 | static QString lightmapAssetPathForSave(LightmapAsset asset, const QString& outputFolder = {}); |
| 65 | |
| 66 | private: |
| 67 | #ifdef QT_QUICK3D_HAS_LIGHTMAPPER |
| 68 | QSSGLightmapperPrivate *d = nullptr; |
| 69 | #endif |
| 70 | }; |
| 71 | |
| 72 | QT_END_NAMESPACE |
| 73 | |
| 74 | #endif |
| 75 | |