Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,108 @@
/*
* 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.
*
*/
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/IO/SystemFile.h>
#include <AzCore/IO/GenericStreams.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <AzFramework/API/ApplicationAPI.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <SceneAPI/SceneCore/Import/ManifestImportRequestHandler.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Containers/SceneManifest.h>
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
namespace AZ
{
namespace SceneAPI
{
namespace Import
{
const char* ManifestImportRequestHandler::s_extension = ".assetinfo";
const char* ManifestImportRequestHandler::s_generated = ".generated"; // support for foo.fbx.assetinfo.generated
void ManifestImportRequestHandler::Activate()
{
BusConnect();
}
void ManifestImportRequestHandler::Deactivate()
{
BusDisconnect();
}
void ManifestImportRequestHandler::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<ManifestImportRequestHandler, BehaviorComponent>()->Version(1);
}
}
void ManifestImportRequestHandler::GetManifestExtension(AZStd::string& result)
{
result = s_extension;
}
Events::LoadingResult ManifestImportRequestHandler::LoadAsset(Containers::Scene& scene, const AZStd::string& path,
const Uuid& /*guid*/, RequestingApplication /*requester*/)
{
AZStd::string manifestPath = path + s_extension;
scene.SetManifestFilename(manifestPath);
if (!AZ::IO::FileIOBase::GetInstance()->Exists(manifestPath.c_str()))
{
AZ::SettingsRegistryInterface::FixedValueString assetCacheRoot;
AZ::SettingsRegistry::Get()->Get(assetCacheRoot, AZ::SettingsRegistryMergeUtils::FilePathKey_CacheRootFolder);
if (assetCacheRoot.empty())
{
// If there's no cache root folder, the default settings will do.
return Events::LoadingResult::Ignored;
}
// looking for filename in the pattern of sourceFileName.extension.assetinfo.generated in the cache
AZStd::string filename = path;
AZ::StringFunc::Path::GetFullFileName(filename.c_str(), filename);
filename += s_extension;
filename += s_generated;
AZStd::string altManifestPath = path;
AzFramework::ApplicationRequests::Bus::Broadcast(
&AzFramework::ApplicationRequests::Bus::Events::MakePathRootRelative,
altManifestPath);
AZ::StringFunc::Path::GetFolderPath(altManifestPath.c_str(), altManifestPath);
AZStd::string generatedAssetInfoPath;
AZ::StringFunc::Path::Join(assetCacheRoot.c_str(), altManifestPath.c_str(), generatedAssetInfoPath);
AZ::StringFunc::Path::ConstructFull(generatedAssetInfoPath.c_str(), filename.c_str(), generatedAssetInfoPath);
if (!AZ::IO::FileIOBase::GetInstance()->Exists(generatedAssetInfoPath.c_str()))
{
// If there's no manifest file, the default settings will do.
return Events::LoadingResult::Ignored;
}
manifestPath = generatedAssetInfoPath;
scene.SetManifestFilename(AZStd::move(generatedAssetInfoPath));
}
return scene.GetManifest().LoadFromFile(manifestPath) ? Events::LoadingResult::ManifestLoaded : Events::LoadingResult::ManifestFailure;
}
} // namespace Import
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,47 @@
/*
* 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 <SceneAPI/SceneCore/Components/BehaviorComponent.h>
#include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
namespace AZ
{
namespace SceneAPI
{
namespace Import
{
class ManifestImportRequestHandler
: public SceneCore::BehaviorComponent
, public Events::AssetImportRequestBus::Handler
{
public:
AZ_COMPONENT(ManifestImportRequestHandler, "{6CF0520E-D5A9-4003-81A5-F20D62010E6F}", SceneCore::BehaviorComponent);
~ManifestImportRequestHandler() override = default;
void Activate() override;
void Deactivate() override;
static void Reflect(ReflectContext* context);
void GetManifestExtension(AZStd::string& result) override;
Events::LoadingResult LoadAsset(Containers::Scene& scene, const AZStd::string& path, const Uuid& guid,
RequestingApplication requester) override;
private:
static const char* s_extension;
static const char* s_generated;
};
} // namespace Import
} // namespace SceneAPI
} // namespace AZ