/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #pragma once #include #include #include #include #include #include #include namespace AZ { namespace SceneAPI { namespace Containers { class Scene; } namespace Events { enum class LoadingResult { Ignored, AssetLoaded, ManifestLoaded, AssetFailure, ManifestFailure }; class LoadingResultCombiner { public: LoadingResultCombiner(); void operator= (LoadingResult rhs); ProcessingResult GetManifestResult() const; ProcessingResult GetAssetResult() const; private: ProcessingResult m_manifestResult; ProcessingResult m_assetResult; }; class SCENE_CORE_API AssetImportRequest : public AZ::EBusTraits { public: enum RequestingApplication { Generic, Editor, AssetProcessor }; enum ManifestAction { Update, ConstructDefault }; static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple; using MutexType = AZStd::recursive_mutex; virtual ~AssetImportRequest() = 0; //! Fills the given list with all available file extensions, excluding the extension for the manifest. virtual void GetSupportedFileExtensions(AZStd::unordered_set& extensions); //! Gets the file extension for the manifest. virtual void GetManifestExtension(AZStd::string& result); //! Before asset loading starts this is called to allow for any required initialization. virtual ProcessingResult PrepareForAssetLoading(Containers::Scene& scene, RequestingApplication requester); //! Starts the loading of the asset at the given path in the given scene. Loading optimizations can be applied based on //! the calling application. virtual LoadingResult LoadAsset(Containers::Scene& scene, const AZStd::string& path, const Uuid& guid, RequestingApplication requester); //! FinalizeAssetLoading can be used to do any work to complete loading, such as complete asynchronous loading //! or adjust the loaded content in the the SceneGraph. While manifest changes can be done here as well, it's //! recommended to wait for the UpdateManifest call. virtual void FinalizeAssetLoading(Containers::Scene& scene, RequestingApplication requester); //! After all loading has completed, this call can be used to make adjustments to the manifest. Based on the given //! action this can mean constructing a new manifest or updating an existing manifest. This call is intended //! to deal with any default behavior of the manifest. virtual ProcessingResult UpdateManifest(Containers::Scene& scene, ManifestAction action, RequestingApplication requester); // Get scene processing project setting: UseCustomNormal virtual void AreCustomNormalsUsed(bool & value); //! Utility function to load an asset and manifest from file by using the EBus functions above. //! @param assetFilePath The absolute path to the source file (not the manifest). //! @param sourceGuid The guid assigned to the source file (not the manifest). //! @param requester The application making the request to load the file. This can be used to optimize the type and amount of data //! to load. static AZStd::shared_ptr LoadSceneFromVerifiedPath(const AZStd::string& assetFilePath, const Uuid&sourceGuid, RequestingApplication requester); //! Utility function to determine if a given file path points to a scene manifest file (.assetinfo). //! @param filePath A relative or absolute path to the file to check. static bool IsManifestExtension(const char* filePath); //! Utility function to determine if a given file path points to a scene file (for instance .fbx). //! @param filePath A relative or absolute path to the file to check. static bool IsSceneFileExtension(const char* filePath); }; using AssetImportRequestBus = AZ::EBus; inline AssetImportRequest::~AssetImportRequest() = default; } // namespace Events } // namespace SceneAPI } // namespace AZ