// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. #pragma once #if COMPILE_WITH_ASSETS_IMPORTER #include "Types.h" /// /// Assets Importing service allows to import or create new assets /// class FLAXENGINE_API AssetsImportingManager { public: /// /// The asset importers. /// static Array Importers; /// /// The asset creators. /// static Array Creators; /// /// If true store asset import path relative to the current workspace, otherwise will store absolute path. /// static bool UseImportPathRelative; public: /// /// The create texture tag (using internal import pipeline to crate texture asset from custom image source). /// static const String CreateTextureTag; /// /// The create texture from raw data. Argument must be TextureData*. /// static const String CreateTextureAsTextureDataTag; /// /// The create texture from raw data. Argument must be TextureBase::InitData*. /// static const String CreateTextureAsInitDataTag; /// /// The create material tag. /// static const String CreateMaterialTag; /// /// The create material tag. /// static const String CreateMaterialInstanceTag; /// /// The create cube texture tag. Argument must be TextureData*. /// static const String CreateCubeTextureTag; /// /// The create model tag. Argument must be ModelData*. /// static const String CreateModelTag; /// /// The create raw data asset tag. Argument must be BytesContainer*. /// static const String CreateRawDataTag; /// /// The create collision data asset tag. /// static const String CreateCollisionDataTag; /// /// The create animation graph asset tag. /// static const String CreateAnimationGraphTag; /// /// The create skeleton mask asset tag. /// static const String CreateSkeletonMaskTag; /// /// The create particle emitter asset tag. /// static const String CreateParticleEmitterTag; /// /// The create particle system asset tag. /// static const String CreateParticleSystemTag; /// /// The create scene animation asset tag. /// static const String CreateSceneAnimationTag; /// /// The create material function asset tag. /// static const String CreateMaterialFunctionTag; /// /// The create particle graph function asset tag. /// static const String CreateParticleEmitterFunctionTag; /// /// The create animation graph function asset tag. /// static const String CreateAnimationGraphFunctionTag; /// /// The create animation asset tag. /// static const String CreateAnimationTag; /// /// The create visual script asset tag. /// static const String CreateVisualScriptTag; public: /// /// Gets the asset importer by file extension. /// /// The file extension. /// Importer or null if not found. static const AssetImporter* GetImporter(const String& extension); /// /// Gets the asset creator by tag. /// /// The tag. /// Creator or null if not found. static const AssetCreator* GetCreator(const String& tag); public: /// /// Creates new asset. /// /// The import function. /// The output path. /// The asset identifier. If valid then used as new asset id. Set to the actual asset id after import. /// The custom argument. /// True if fails, otherwise false. static bool Create(const CreateAssetFunction& importFunc, const StringView& outputPath, Guid& assetId, void* arg = nullptr); /// /// Creates new asset. /// /// The import function. /// The output path. /// The custom argument. /// True if fails, otherwise false. static bool Create(const CreateAssetFunction& importFunc, const StringView& outputPath, void* arg = nullptr) { Guid id = Guid::Empty; return Create(importFunc, outputPath, id, arg); } /// /// Creates new asset. /// /// The asset type tag. /// The output path. /// The asset identifier. /// The custom argument. /// True if fails, otherwise false. static bool Create(const String& tag, const StringView& outputPath, Guid& assetId, void* arg = nullptr); /// /// Creates new asset. /// /// The asset type tag. /// The output path. /// The custom argument. /// True if fails, otherwise false. static bool Create(const String& tag, const StringView& outputPath, void* arg = nullptr) { Guid id = Guid::Empty; return Create(tag, outputPath, id, arg); } /// /// Imports file and creates asset. If asset already exists overwrites it's contents. /// /// The input path. /// The output path. /// The asset identifier. If valid then used as new asset id. Set to the actual asset id after import. /// The custom argument. /// True if fails, otherwise false. static bool Import(const StringView& inputPath, const StringView& outputPath, Guid& assetId, void* arg = nullptr); /// /// Imports file and creates asset. If asset already exists overwrites it's contents. /// /// The input path. /// The output path. /// The custom argument. /// True if fails, otherwise false. static bool Import(const StringView& inputPath, const StringView& outputPath, void* arg = nullptr) { Guid id = Guid::Empty; return Import(inputPath, outputPath, id, arg); } /// /// Imports file and creates asset only if source file has been modified. If asset already exists overwrites it's contents. /// /// The input path. /// The output path. /// The asset identifier. If valid then used as new asset id. Set to the actual asset id after import. /// The custom argument. /// True if fails, otherwise false. static bool ImportIfEdited(const StringView& inputPath, const StringView& outputPath, Guid& assetId, void* arg = nullptr); /// /// Imports file and creates asset only if source file has been modified. If asset already exists overwrites it's contents. /// /// The input path. /// The output path. /// The custom argument. /// True if fails, otherwise false. static bool ImportIfEdited(const StringView& inputPath, const StringView& outputPath, void* arg = nullptr) { Guid id = Guid::Empty; return ImportIfEdited(inputPath, outputPath, id, arg); } private: static bool Create(const CreateAssetFunction& callback, const StringView& inputPath, const StringView& outputPath, Guid& assetId, void* arg); }; #endif