// // ModelBaker.h // libraries/baking/src // // Created by Utkarsh Gautam on 9/29/17. // Copyright 2017 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef hifi_ModelBaker_h #define hifi_ModelBaker_h #include #include #include #include #include "Baker.h" #include "MaterialBaker.h" #include "ModelBakingLoggingCategory.h" #include #include using GetMaterialIDCallback = std::function ; static const QString FST_EXTENSION { ".fst" }; static const QString BAKED_FST_EXTENSION { ".baked.fst" }; static const QString FBX_EXTENSION { ".fbx" }; static const QString BAKED_FBX_EXTENSION { ".baked.fbx" }; static const QString OBJ_EXTENSION { ".obj" }; static const QString GLTF_EXTENSION { ".gltf" }; class ModelBaker : public Baker { Q_OBJECT public: ModelBaker(const QUrl& inputModelURL, const QUrl& destinationPath, const QString& bakedOutputDirectory, const QString& originalOutputDirectory = "", bool hasBeenBaked = false); void setOutputURLSuffix(const QUrl& urlSuffix); void setMappingURL(const QUrl& mappingURL); void setMapping(const hifi::VariantHash& mapping); void initializeOutputDirs(); bool buildDracoMeshNode(FBXNode& dracoMeshNode, const QByteArray& dracoMeshBytes, const std::vector& dracoMaterialList); virtual void setWasAborted(bool wasAborted) override; QUrl getModelURL() const { return _modelURL; } virtual QUrl getFullOutputMappingURL() const; QUrl getBakedModelURL() const { return _bakedModelURL; } signals: void modelLoaded(); public slots: virtual void bake() override; virtual void abort() override; protected: void saveSourceModel(); virtual void bakeProcessedSource(const hfm::Model::Pointer& hfmModel, const std::vector& dracoMeshes, const std::vector>& dracoMaterialLists) = 0; void exportScene(); FBXNode _rootNode; QUrl _modelURL; QUrl _destinationPath; QUrl _outputURLSuffix; QUrl _mappingURL; hifi::VariantHash _mapping; QString _bakedOutputDir; QString _originalOutputDir; QString _originalOutputModelPath; QString _outputMappingURL; QUrl _bakedModelURL; protected slots: void handleModelNetworkReply(); virtual void bakeSourceCopy(); void handleFinishedMaterialBaker(); private: void outputBakedFST(); bool _hasBeenBaked { false }; hfm::Model::Pointer _hfmModel; QSharedPointer _materialBaker; }; #endif // hifi_ModelBaker_h