Integrating up through commit 90f050496

This commit is contained in:
alexpete
2021-04-07 14:03:29 -07:00
parent 8f2ed080a9
commit c2cbd430fe
2694 changed files with 285622 additions and 176874 deletions
@@ -1,152 +0,0 @@
<RCJobs>
<!--
DefaultProperties can be overriden from command line
-->
<DefaultProperties
game="SamplesProject"
engine="Engine"
loc="LY_Localization"
src="."
trg="TempRC"
gems="Gems"
pak_root=".\Build"
vertex_index="u16"
streaming="auto"
/>
<Properties
image_types="*.tif;*.png;*.bmp;*.jpg;*.jpe;*.jpeg;*.tga;*.gif"
geometry_types="*.cgf;*.cga"
animation_types="*.i_caf"
xml_types="*.animevents;*.animsettings;*.adb;*.bspace;*.cdf;*.chrparams;*.comb;*.dlg;*.ent;*.fsq;*.fxl;*.ik;*.json;*.lmg;*.mtl;*.setup;*.xml;*.node;*.veg;*.prototype;*.uicanvas;*.uiprefab;*.prefab"
copy_types="${xml_types};*.txt;*.skel;*.skin;*.cfg;*.csv;*.dat;*.ini;*.xls;*.as;*.p;*.chr;*.caf;*.dba;*.ctc;*.lua;*.lut;*.bnk;*.wem;*.cal;*.grd;*.grp;*.ext;*.cfx;*.cfi;*.ttf;*.pak;*.abc;*.cbc;*.bin"
copynooverwrite_types="*.dds;*.dds.*;*.cga;*.cgf"
gems_excludes="*.h;*.c;*.cpp;*.lib;*.dll;*.inl;*.obj"
exclude_types="${gems_excludes};*.$*;*.exportsettings;*.psd;wwise_project*\*;*\ShaderCache\*"
levels_pak_types="Levels\*"
levels_pak_excludes="${exclude_types}"
game_data_pak_types="Config\*.*;Difficulty\*.*;Libs\*.*;Materials\*.*;Prefabs\*.*;Levels\*.*xml;Levels\*.*dds"
game_data_pak_excludes="${exclude_types};*filelist.*"
animation_pak_types="Animations\*.*"
animation_pak_excludes="${exclude_types}"
objects_pak_types="Objects\*.*"
objects_pak_excludes="${exclude_types};Objects\level_specific\*.*;Objects\multiplayer\*.*;Objects\weapons\*.*;Objects\characters\*.*;Objects\props\*.*"
objects_multiplayer_pak_types="Objects\multiplayer\*.*"
objects_multiplayer_pak_excludes="${exclude_types}"
weapons_pak_types="Objects\weapons\*.*"
weapons_pak_excludes="${exclude_types}"
character_pak_types="Objects\characters\*.*;Objects\props\*.*"
character_pak_excludes="${exclude_types}"
level_specific_pak_types="Objects\level_specific\*.*"
level_specific_pak_excludes="${exclude_types}"
textures_pak_types="Textures\*.*"
textures_pak_excludes="{exclude_types}"
sounds_pak_types="Sounds\*.*"
sounds_pak_excludes="${exclude_types}"
videos_pak_types="Videos\*.*"
videos_pak_excludes="${exclude_types}"
scripts_pak_types="Entities\*.*;Scripts\*.*"
scripts_pak_excludes="${exclude_types}"
shader_pak_types="Shaders\*.ext;Shaders\*.cfi;Shaders\*.cfx"
shader_pak_excludes="${exclude_types}"
engine_pak_types="Config\*.*;Fonts\*.*;EngineAssets\*.*;Libs\*.*;Material\*.*"
engine_pak_excludes="${exclude_types}"
gems_pak_types="*"
gems_pak_excludes="${exclude_types}"
src_game="${game}"
src_engine="${src}\${engine}"
src_gems="${src}\${gems}"
src_loc="${src}\${loc}"
trg_game="${trg}\${game}"
trg_engine="${trg}\${engine}"
trg_gems="${trg}\${gems}"
trg_loc="${trg}\${loc}"
pak_game="${pak_root}\${game}"
pak_engine="${pak_root}\${engine}"
vtx_idx="${vertex_index}"
streaming="0"
/>
<ConvertJob>
<!-- process source animation files into staging -->
<Job sourceroot="${src_game}" targetroot="${trg_game}" input="${animation_types}" animConfigFolder="Animations" cafAlignTracks="1" dbaStreamPrepare="1" />
<Job sourceroot="${src_engine}" targetroot="${trg_engine}" input="${animation_types}" animConfigFolder="Animations" cafAlignTracks="1" dbaStreamPrepare="1" />
<Job sourceroot="${src_gems}" targetroot="${trg_gems}" input="${animation_types}" animConfigFolder="Animations" cafAlignTracks="1" dbaStreamPrepare="1" />
<!-- process source geometry files into staging -->
<Job sourceroot="${src_game}" targetroot="${trg_game}" input="${geometry_types}" VertexPositionFormat="exporter" SplitLODs="1" vertexindexformat="${vtx_idx}" />
<Job sourceroot="${src_engine}" targetroot="${trg_engine}" input="${geometry_types}" VertexPositionFormat="exporter" SplitLODs="1" vertexindexformat="${vtx_idx}" />
<Job sourceroot="${src_gems}" targetroot="${trg_gems}" input="${geometry_types}" VertexPositionFormat="exporter" SplitLODs="1" vertexindexformat="${vtx_idx}" />
<!-- process source image files into staging -->
<Job sourceroot="${src_game}" targetroot="${trg_game}" input="${image_types}" imagecompressor="${imagecompressor}" streaming="${streaming}" />
<Job sourceroot="${src_engine}" targetroot="${trg_engine}" input="${image_types}" imagecompressor="${imagecompressor}" streaming="${streaming}" />
<Job sourceroot="${src_gems}" targetroot="${trg_gems}" input="${image_types}" imagecompressor="${imagecompressor}" streaming="${streaming}" />
</ConvertJob>
<CopyJob>
<Job sourceroot="${src_game}" targetroot="${trg_game}" input="${copynooverwrite_types}" copyonlynooverwrite="1" exclude="${exclude_types}" />
<Job sourceroot="${src_engine}" targetroot="${trg_engine}" input="${copynooverwrite_types}" copyonlynooverwrite="1" exclude="${exclude_types}" />
<Job sourceroot="${src_gems}" targetroot="${trg_gems}" input="${copynooverwrite_types}" copyonlynooverwrite="1" exclude="${exclude_types}" />
<Job sourceroot="${src_game}" targetroot="${trg_game}" input="${copy_types}" copyonly="1" exclude="${exclude_types}" />
<Job sourceroot="${src_engine}" targetroot="${trg_engine}" input="${copy_types}" copyonly="1" exclude="${exclude_types}" />
<Job sourceroot="${src_gems}" targetroot="${trg_gems}" input="${copy_types}" copyonly="1" exclude="${exclude_types}" />
</CopyJob>
<PakJob>
<Job sourceroot="${trg_game}" input="${levels_pak_types}" zip="${pak_game}\Levels.pak" exclude="${levels_pak_excludes}" />
<Job sourceroot="${trg_game}" input="${game_data_pak_types}" zip="${pak_game}\GameData.pak" exclude="${game_data_pak_excludes}" />
<Job sourceroot="${trg_game}" input="${animation_pak_types}" zip="${pak_game}\Animations.pak" exclude="${animation_pak_excludes}" />
<Job sourceroot="${trg_game}" input="${objects_pak_types}" zip="${pak_game}\Objects.pak" exclude="${objects_pak_excludes}" />
<Job sourceroot="${trg_game}" input="${objects_multiplayer_pak_types}" zip="${pak_game}\ObjectsMP.pak" exclude="${objects_multiplayer_pak_excludes}" />
<Job sourceroot="${trg_game}" input="${weapons_pak_types}" zip="${pak_game}\Weapons.pak" exclude="${weapons_pak_excludes}" />
<Job sourceroot="${trg_game}" input="${character_pak_types}" zip="${pak_game}\Characters.pak" exclude="${character_pak_excludes}" />
<Job sourceroot="${trg_game}" input="${level_specific_pak_types}" zip="${pak_game}\LevelSpecific.pak" exclude="${level_specific_pak_excludes}" />
<Job sourceroot="${trg_game}" input="${textures_pak_types}" zip="${pak_game}\Textures.pak" exclude="${textures_pak_excludes}" />
<Job sourceroot="${trg_game}" input="${sounds_pak_types}" zip="${pak_game}\Sounds.pak" exclude="${sounds_pak_excludes}" zip_compression="0" />
<Job sourceroot="${trg_game}" input="${videos_pak_types}" zip="${pak_game}\Videos.pak" exclude="${videos_pak_excludes}" zip_compression="0" />
<Job sourceroot="${trg_game}" input="${scripts_pak_types}" zip="${pak_game}\Scripts.pak" exclude="${scripts_pak_excludes}" />
<Job sourceroot="${trg_engine}" input="${shader_pak_types}" zip="${pak_engine}\Shaders.pak" exclude="${shader_pak_excludes}" />
<Job sourceroot="${trg_engine}" input="${engine_pak_types}" zip="${pak_engine}\Engine.pak" exclude="${engine_pak_excludes}" />
<Job sourceroot="${trg_gems}" input="${gems_pak_types}" zip="${pak_game}\${gems}.pak" exclude="${gems_pak_excludes}" />
</PakJob>
<CopyPakJob>
<Job sourceroot="${pak_game}" targetroot="${src_game}" input="*.pak" copyonly="1"/>
<Job sourceroot="${pak_engine}" targetroot="${src_game}" input="*.pak" copyonly="1"/>
</CopyPakJob>
<CleanJob>
<Job input="" targetroot="${trg}" clean_targetroot="1" />
</CleanJob>
<ValidateJob>
<Run Job="ConvertJob"/>
<Job input="" targetroot="${trg}" clean_targetroot="1" refs_scan="1" />
</ValidateJob>
<Run Job="ConvertJob"/>
<Run Job="CopyJob"/>
<Run Job="PakJob"/>
<Run Job="CopyPakJob"/>
<Run Job="CleanJob"/>
<Run Job="ValidateJob"/>
</RCJobs>
@@ -4,7 +4,7 @@
-->
<DefaultProperties
p="pc"
game="samplesproject"
game="automatedtesting"
src="cache\${game}\${p}"
trg="${game}_${p}_paks"
/>
@@ -5,7 +5,7 @@
-->
<DefaultProperties
p="pc"
game="samplesproject"
game="automatedtesting"
src="Cache\${game}\${p}"
trg="${game}_${p}_paks"
@@ -48,6 +48,7 @@
#include "CryLibrary.h"
#include <AzCore/Module/Environment.h>
#include <AzFramework/API/ApplicationAPI.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzFramework/CommandLine/CommandLine.h>
@@ -2407,23 +2408,30 @@ void ResourceCompiler::ScanForAssetReferences(std::vector<string>& outReferences
}
}
std::vector<string> levelPaks;
FileUtil::ScanDirectory(scanRoot, "level.pak", levelPaks, true, string());
for (size_t i = 0; i < levelPaks.size(); ++i)
bool usePrefabSystemForLevels = false;
AzFramework::ApplicationRequests::Bus::BroadcastResult(
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled);
if (!usePrefabSystemForLevels)
{
const string path = PathHelpers::GetDirectory(levelPaks[i].c_str()) + "\\resourcelist.txt";
if (reader.LoadFromPak(GetPakSystem(), path, lines))
std::vector<string> levelPaks;
FileUtil::ScanDirectory(scanRoot, "level.pak", levelPaks, true, string());
for (size_t i = 0; i < levelPaks.size(); ++i)
{
for (size_t j = 0; j < lines.size(); ++j)
const string path = PathHelpers::GetDirectory(levelPaks[i].c_str()) + "\\resourcelist.txt";
if (reader.LoadFromPak(GetPakSystem(), path, lines))
{
const char* const line = lines[j];
if (references.find(line) == references.end())
for (size_t j = 0; j < lines.size(); ++j)
{
strings.push_back(line);
references.insert(strings.back().c_str());
const char* const line = lines[j];
if (references.find(line) == references.end())
{
strings.push_back(line);
references.insert(strings.back().c_str());
}
}
++numSources;
}
++numSources;
}
}
+5 -1
View File
@@ -558,10 +558,14 @@ int rcmain(int argc, char** argv, [[maybe_unused]] char** envp)
RCLog("Initializing System");
{
// Create a local SettingsRegistry to read the bootstrap.cfg settings if the appRoot hasn't been overriden
// Create a local SettingsRegistry to read the bootstrap.cfg settings if the engine root hasn't been overridden
// on the command line
AZ::CommandLine commandLine;
commandLine.Parse(argc, argv);
AZ::SettingsRegistryImpl settingsRegistry;
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_Bootstrap(settingsRegistry);
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_O3deUserRegistry(settingsRegistry, AZ_TRAIT_OS_PLATFORM_CODENAME, {});
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_CommandLine(settingsRegistry, commandLine, false);
string projectPath = config.GetAsString("gameroot", "", "");
if (!projectPath.empty())
@@ -1074,7 +1074,7 @@ bool CStatCGFCompiler::CompileCGF(AssetBuilderSDK::ProcessJobResponse& response,
// Check if our material name is just a name, or if it contains a path
if (strstr(materialName.c_str(), "/") || strstr(materialName.c_str(), "\\"))
{
// The material path is already relative to devroot, for example "samplesproject/materials/foo.mtl"
// The material path is already relative to devroot, for example "automatedtesting/materials/foo.mtl"
// We need to convert this to the cache path AP generates. In this case, cut off the game project name.
AZStd::string materialRelativePath = materialName;
EBUS_EVENT(AzFramework::ApplicationRequests::Bus, NormalizePath, gameFolder);
@@ -212,7 +212,7 @@ TEST_F(CGFBuilderTest, CGF_MaterialInSameFolder)
}
// In this case, we load a basic CGF where the material path is absolute from the dev/ folder,
// for example "samplesproject/materials/test.mtl".
// for example "automatedtesting/materials/test.mtl".
TEST_F(CGFBuilderTest, CGF_MaterialInDifferentFolder)
{
AZStd::string cgfName = "gs_block.cgf";
@@ -1,48 +0,0 @@
/*
* 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 <RC/ResourceCompilerScene/Chr/ChrExportContexts.h>
namespace AZ
{
namespace RC
{
ChrGroupExportContext::ChrGroupExportContext(SceneAPI::Events::ExportEventContext& parent,
const SceneAPI::DataTypes::ISkeletonGroup& group, Phase phase)
: m_products(parent.GetProductList())
, m_scene(parent.GetScene())
, m_outputDirectory(parent.GetOutputDirectory())
, m_group(group)
, m_phase(phase)
{
}
ChrGroupExportContext::ChrGroupExportContext(SceneAPI::Events::ExportProductList& products, const SceneAPI::Containers::Scene& scene,
const AZStd::string& outputDirectory, const SceneAPI::DataTypes::ISkeletonGroup& group, Phase phase)
: m_products(products)
, m_scene(scene)
, m_outputDirectory(outputDirectory)
, m_group(group)
, m_phase(phase)
{
}
ChrGroupExportContext::ChrGroupExportContext(const ChrGroupExportContext& copyContext, Phase phase)
: m_products(copyContext.m_products)
, m_scene(copyContext.m_scene)
, m_outputDirectory(copyContext.m_outputDirectory)
, m_group(copyContext.m_group)
, m_phase(phase)
{
}
}
}
@@ -1,59 +0,0 @@
#pragma once
/*
* 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/RTTI/RTTI.h>
#include <SceneAPI/SceneCore/Events/CallProcessorBus.h>
#include <SceneAPI/SceneCore/Events/ExportEventContext.h>
#include <RC/ResourceCompilerScene/Common/ExportContextGlobal.h>
namespace AZ
{
namespace SceneAPI
{
namespace DataTypes
{
class ISkeletonGroup;
}
namespace Events
{
class ExportProductList;
}
}
namespace RC
{
// Called to export a specific Skeleton (Chr) Group
struct ChrGroupExportContext
: public SceneAPI::Events::ICallContext
{
AZ_RTTI(ChrGroupExportContext, "{294BB98B-DE9D-4B03-B219-A8A94657E81E}", SceneAPI::Events::ICallContext);
ChrGroupExportContext(SceneAPI::Events::ExportEventContext& parent,
const SceneAPI::DataTypes::ISkeletonGroup& group, Phase phase);
ChrGroupExportContext(SceneAPI::Events::ExportProductList& products, const SceneAPI::Containers::Scene& scene,
const AZStd::string& outputDirectory, const SceneAPI::DataTypes::ISkeletonGroup& group, Phase phase);
ChrGroupExportContext(const ChrGroupExportContext& copyContent, Phase phase);
ChrGroupExportContext(const ChrGroupExportContext& copyContent) = delete;
~ChrGroupExportContext() override = default;
ChrGroupExportContext& operator=(const ChrGroupExportContext& other) = delete;
SceneAPI::Events::ExportProductList& m_products;
const SceneAPI::Containers::Scene& m_scene;
const AZStd::string& m_outputDirectory;
const SceneAPI::DataTypes::ISkeletonGroup& m_group;
const Phase m_phase;
};
}
}
@@ -1,58 +0,0 @@
/*
* 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 <RC/ResourceCompilerScene/Chr/ChrExporter.h>
#include <Cry_Geo.h>
#include <ConvertContext.h>
#include <CGFContent.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Containers/SceneManifest.h>
#include <SceneAPI/SceneCore/Containers/Utilities/Filters.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/ISkeletonGroup.h>
#include <SceneAPI/SceneCore/Events/ExportEventContext.h>
#include <RC/ResourceCompilerScene/Chr/ChrExportContexts.h>
namespace AZ
{
namespace RC
{
namespace SceneContainers = AZ::SceneAPI::Containers;
namespace SceneDataTypes = AZ::SceneAPI::DataTypes;
ChrExporter::ChrExporter(IConvertContext* convertContext)
: m_convertContext(convertContext)
{
BindToCall(&ChrExporter::ProcessContext);
ActivateBindings();
}
SceneEvents::ProcessingResult ChrExporter::ProcessContext(SceneEvents::ExportEventContext& context)
{
const SceneContainers::SceneManifest& manifest = context.GetScene().GetManifest();
auto valueStorage = manifest.GetValueStorage();
auto view = SceneContainers::MakeDerivedFilterView<SceneDataTypes::ISkeletonGroup>(valueStorage);
SceneEvents::ProcessingResultCombiner result;
for (const SceneDataTypes::ISkeletonGroup& skeletonGroup : view)
{
AZ_TraceContext("Skeleton Group", skeletonGroup.GetName());
result += SceneEvents::Process<ChrGroupExportContext>(context, skeletonGroup, Phase::Construction);
result += SceneEvents::Process<ChrGroupExportContext>(context, skeletonGroup, Phase::Filling);
result += SceneEvents::Process<ChrGroupExportContext>(context, skeletonGroup, Phase::Finalizing);
}
return result.GetResult();
}
} // namespace RC
} // namespace AZ
@@ -1,46 +0,0 @@
/*
* 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/Events/CallProcessorBinder.h>
struct IConvertContext;
namespace AZ
{
namespace SceneAPI
{
namespace Events
{
class ExportEventContext;
}
}
namespace RC
{
namespace SceneEvents = AZ::SceneAPI::Events;
class ChrExporter
: public SceneEvents::CallProcessorBinder
{
public:
ChrExporter(IConvertContext* convertContext);
~ChrExporter() override = default;
SceneEvents::ProcessingResult ProcessContext(SceneEvents::ExportEventContext& context);
private:
IConvertContext* m_convertContext;
};
} // namespace RC
} // namespace AZ
@@ -1,131 +0,0 @@
/*
* 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 <Cry_Geo.h> // Needed for CGFContent.h
#include <CGFContent.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <RC/ResourceCompilerScene/Common/CommonExportContexts.h>
#include <RC/ResourceCompilerScene/Chr/ChrExportContexts.h>
#include <RC/ResourceCompilerScene/Chr/ChrGroupExporter.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/ISkeletonGroup.h>
#include <SceneAPI/SceneCore/Events/ExportProductList.h>
#include <SceneAPI/SceneCore/Utilities/FileUtilities.h>
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
namespace AZ
{
namespace RC
{
namespace SceneUtil = AZ::SceneAPI::Utilities;
namespace SceneContainer = AZ::SceneAPI::Containers;
namespace SceneDataTypes = AZ::SceneAPI::DataTypes;
const AZStd::string ChrGroupExporter::fileExtension = "chr";
ChrGroupExporter::ChrGroupExporter(IAssetWriter* writer, IConvertContext* convertContext)
: m_assetWriter(writer)
, m_convertContext(convertContext)
{
BindToCall(&ChrGroupExporter::ProcessContext);
ActivateBindings();
}
SceneEvents::ProcessingResult ChrGroupExporter::ProcessContext(ChrGroupExportContext& context) const
{
if (context.m_phase != Phase::Filling)
{
return SceneEvents::ProcessingResult::Ignored;
}
AZStd::string filename = SceneUtil::FileUtilities::CreateOutputFileName(context.m_group.GetName(), context.m_outputDirectory, fileExtension);
if (filename.empty())
{
AZ_TracePrintf(SceneUtil::ErrorWindow, "Invalid filename, can not be an empty value.\n");
return SceneEvents::ProcessingResult::Failure;
}
if (!SceneUtil::FileUtilities::EnsureTargetFolderExists(filename))
{
AZ_TracePrintf(SceneUtil::ErrorWindow, "Invalid filename, target folder does not exist. ('%s')\n", filename.c_str());
return SceneEvents::ProcessingResult::Failure;
}
SceneEvents::ProcessingResultCombiner result;
CContentCGF cgfContent(filename.c_str());
AZStd::unordered_map<AZStd::string, int> boneNameIdMap;
SkeletonExportContext skeletonContextConstruction(context.m_scene, context.m_group.GetSelectedRootBone(), *cgfContent.GetSkinningInfo(), boneNameIdMap, Phase::Construction);
ConfigureChrContent(cgfContent);
result += SceneEvents::Process(skeletonContextConstruction);
result += SceneEvents::Process<SkeletonExportContext>(context.m_scene, context.m_group.GetSelectedRootBone(), *cgfContent.GetSkinningInfo(), boneNameIdMap, Phase::Filling);
result += SceneEvents::Process<SkeletonExportContext>(context.m_scene, context.m_group.GetSelectedRootBone(), *cgfContent.GetSkinningInfo(), boneNameIdMap, Phase::Finalizing);
AZ_Assert(m_assetWriter != nullptr, "Unable to write CHR due to invalid asset writer.");
if (m_assetWriter)
{
if (m_assetWriter->WriteCHR(&cgfContent, m_convertContext))
{
static const AZ::Data::AssetType skeletonAssetType("{60161B46-21F0-4396-A4F0-F2CCF0664CDE}");
auto& list = context.m_products.GetProducts();
bool isFirst = AZStd::find_if(list.begin(), list.end(),
[](const SceneAPI::Events::ExportProduct& it) -> bool
{
return it.m_assetType == skeletonAssetType;
}) == list.end();
SceneAPI::Events::ExportProduct& product = context.m_products.AddProduct(AZStd::move(filename), context.m_group.GetId(), skeletonAssetType,
AZStd::nullopt, AZStd::nullopt);
// Previously only a single skeleton would be exported that was named after the source file. This was changed to exporting all
// skeletons now named after the root node. This means that the first skeleton would previously have been known under
// another name.
if (isFirst)
{
AZStd::string legacyName = product.m_filename;
AzFramework::StringFunc::Path::ReplaceFullName(legacyName, context.m_scene.GetName().c_str(), fileExtension.c_str());
product.m_legacyFileNames.emplace_back(AZStd::move(legacyName));
}
}
else
{
AZ_TracePrintf(SceneUtil::ErrorWindow, "Failed writing CHR file ('%s')\n", filename.c_str());
result += SceneEvents::ProcessingResult::Failure;
}
}
else
{
AZ_TracePrintf(SceneUtil::ErrorWindow, "Failed writing CHR file ('%s')\n", filename.c_str());
result += SceneEvents::ProcessingResult::Failure;
}
return result.GetResult();
}
void ChrGroupExporter::ConfigureChrContent(CContentCGF& content) const
{
CExportInfoCGF* exportInfo = content.GetExportInfo();
AZ_Assert(exportInfo != nullptr, "Invalid export info from %s.", content.GetFilename());
exportInfo->bMergeAllNodes = true;
exportInfo->bUseCustomNormals = false;
exportInfo->bCompiledCGF = false;
exportInfo->bHavePhysicsProxy = false;
exportInfo->bHaveAutoLods = false;
exportInfo->bNoMesh = true;
exportInfo->b8WeightsPerVertex = false;
exportInfo->bWantF32Vertices = false;
exportInfo->authorToolVersion = 1;
}
} // namespace RC
} // namespace AZ
@@ -1,47 +0,0 @@
/*
* 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 <AzCore/std/string/string.h>
#include <SceneAPI/SceneCore/Events/CallProcessorBinder.h>
struct IConvertContext;
class CContentCGF;
namespace AZ
{
namespace RC
{
struct ChrGroupExportContext;
namespace SceneEvents = AZ::SceneAPI::Events;
class ChrGroupExporter
: public SceneEvents::CallProcessorBinder
{
public:
ChrGroupExporter(IAssetWriter* writer, IConvertContext* convertContext);
~ChrGroupExporter() override = default;
SceneEvents::ProcessingResult ProcessContext(ChrGroupExportContext& context) const;
static const AZStd::string fileExtension;
protected:
void ConfigureChrContent(CContentCGF& content) const;
IAssetWriter* m_assetWriter;
IConvertContext* m_convertContext;
};
} // namespace RC
} // namespace AZ
@@ -1,48 +0,0 @@
/*
* 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 <RC/ResourceCompilerScene/Skin/SkinExportContexts.h>
namespace AZ
{
namespace RC
{
SkinGroupExportContext::SkinGroupExportContext(SceneAPI::Events::ExportEventContext& parent,
const SceneAPI::DataTypes::ISkinGroup& group, Phase phase)
: m_products(parent.GetProductList())
, m_scene(parent.GetScene())
, m_outputDirectory(parent.GetOutputDirectory())
, m_group(group)
, m_phase(phase)
{
}
SkinGroupExportContext::SkinGroupExportContext(SceneAPI::Events::ExportProductList& products, const SceneAPI::Containers::Scene& scene,
const AZStd::string& outputDirectory, const SceneAPI::DataTypes::ISkinGroup& group, Phase phase)
: m_products(products)
, m_scene(scene)
, m_outputDirectory(outputDirectory)
, m_group(group)
, m_phase(phase)
{
}
SkinGroupExportContext::SkinGroupExportContext(const SkinGroupExportContext& copyContext, Phase phase)
: m_products(copyContext.m_products)
, m_scene(copyContext.m_scene)
, m_outputDirectory(copyContext.m_outputDirectory)
, m_group(copyContext.m_group)
, m_phase(phase)
{
}
}
}
@@ -1,57 +0,0 @@
#pragma once
/*
* 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/RTTI/RTTI.h>
#include <SceneAPI/SceneCore/Events/CallProcessorBus.h>
#include <SceneAPI/SceneCore/Events/ExportEventContext.h>
#include <RC/ResourceCompilerScene/Common/ExportContextGlobal.h>
struct CSkinningInfo;
namespace AZ
{
namespace SceneAPI
{
namespace DataTypes
{
class ISkinGroup;
}
}
namespace RC
{
// Called to export a specific Skin Group
struct SkinGroupExportContext
: public SceneAPI::Events::ICallContext
{
AZ_RTTI(SkinGroupExportContext, "{F2C0DF6D-84F7-4692-9626-C981FA599755}", SceneAPI::Events::ICallContext);
SkinGroupExportContext(SceneAPI::Events::ExportEventContext& parent,
const SceneAPI::DataTypes::ISkinGroup& group, Phase phase);
SkinGroupExportContext(SceneAPI::Events::ExportProductList& products, const SceneAPI::Containers::Scene& scene,
const AZStd::string& outputDirectory, const SceneAPI::DataTypes::ISkinGroup& group, Phase phase);
SkinGroupExportContext(const SkinGroupExportContext& copyContent, Phase phase);
SkinGroupExportContext(const SkinGroupExportContext& copyContent) = delete;
~SkinGroupExportContext() override = default;
SkinGroupExportContext& operator=(const SkinGroupExportContext& other) = delete;
SceneAPI::Events::ExportProductList& m_products;
const SceneAPI::Containers::Scene& m_scene;
const AZStd::string& m_outputDirectory;
const SceneAPI::DataTypes::ISkinGroup& m_group;
const Phase m_phase;
};
}
}
@@ -1,59 +0,0 @@
/*
* 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 <RC/ResourceCompilerScene/Skin/SkinExporter.h>
#include <Cry_Geo.h>
#include <ConvertContext.h>
#include <CGFContent.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Containers/SceneManifest.h>
#include <SceneAPI/SceneCore/Containers/Utilities/Filters.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/ISkinGroup.h>
#include <SceneAPI/SceneCore/Events/ExportEventContext.h>
#include <RC/ResourceCompilerScene/Skin/SkinExportContexts.h>
namespace AZ
{
namespace RC
{
namespace SceneContainers = AZ::SceneAPI::Containers;
namespace SceneDataTypes = AZ::SceneAPI::DataTypes;
SkinExporter::SkinExporter(IConvertContext* convertContext)
: m_convertContext(convertContext)
{
BindToCall(&SkinExporter::ProcessContext);
ActivateBindings();
}
SceneEvents::ProcessingResult SkinExporter::ProcessContext(SceneEvents::ExportEventContext& context)
{
const SceneContainers::SceneManifest& manifest = context.GetScene().GetManifest();
auto valueStorage = manifest.GetValueStorage();
auto view = SceneContainers::MakeDerivedFilterView<SceneDataTypes::ISkinGroup>(valueStorage);
SceneEvents::ProcessingResultCombiner result;
for (const SceneDataTypes::ISkinGroup& skinGroup : view)
{
AZ_TraceContext("Skin Group", skinGroup.GetName());
result += SceneEvents::Process<SkinGroupExportContext>(context, skinGroup, Phase::Construction);
result += SceneEvents::Process<SkinGroupExportContext>(context, skinGroup, Phase::Filling);
result += SceneEvents::Process<SkinGroupExportContext>(context, skinGroup, Phase::Finalizing);
}
return result.GetResult();
}
} // namespace RC
} // namespace AZ
@@ -1,49 +0,0 @@
/*
* 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/Events/CallProcessorBinder.h>
namespace AZ
{
namespace SceneAPI
{
namespace Events
{
class ExportEventContext;
}
}
}
struct IConvertContext;
namespace AZ
{
namespace RC
{
namespace SceneEvents = AZ::SceneAPI::Events;
class SkinExporter
: public SceneEvents::CallProcessorBinder
{
public:
SkinExporter(IConvertContext* convertContext);
~SkinExporter() override = default;
SceneEvents::ProcessingResult ProcessContext(SceneEvents::ExportEventContext& context);
private:
IConvertContext* m_convertContext;
};
} // namespace RC
} // namespace AZ
@@ -1,93 +0,0 @@
/*
* 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 <Cry_Geo.h> // Needed for CGFContent.h
#include <CGFContent.h>
#include <AzCore/std/containers/map.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <RC/ResourceCompilerScene/Common/CommonExportContexts.h>
#include <RC/ResourceCompilerScene/Skin/SkinExportContexts.h>
#include <RC/ResourceCompilerScene/Skin/SkinGroupExporter.h>
#include <RC/ResourceCompilerScene/Skin/SkinUtils.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Utilities/SceneGraphSelector.h>
#include <SceneAPI/SceneCore/DataTypes/ManifestBase/ISceneNodeSelectionList.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/ISkinGroup.h>
#include <SceneAPI/SceneCore/Events/ExportProductList.h>
#include <SceneAPI/SceneCore/Utilities/FileUtilities.h>
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
namespace AZ
{
namespace RC
{
namespace SceneUtil = AZ::SceneAPI::Utilities;
namespace SceneContainer = AZ::SceneAPI::Containers;
const AZStd::string SkinGroupExporter::s_fileExtension = "skin";
SkinGroupExporter::SkinGroupExporter(IAssetWriter* writer, IConvertContext* convertContext)
: m_assetWriter(writer)
, m_convertContext(convertContext)
{
BindToCall(&SkinGroupExporter::ProcessContext);
ActivateBindings();
}
SceneEvents::ProcessingResult SkinGroupExporter::ProcessContext(SkinGroupExportContext& context) const
{
if (context.m_phase != Phase::Filling)
{
return SceneEvents::ProcessingResult::Ignored;
}
AZStd::string filename = SceneUtil::FileUtilities::CreateOutputFileName(context.m_group.GetName(), context.m_outputDirectory, s_fileExtension);
AZ_TraceContext("Skin filename", filename);
if (filename.empty() || !SceneUtil::FileUtilities::EnsureTargetFolderExists(filename))
{
AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "Invalid file name for skin");
return SceneEvents::ProcessingResult::Failure;
}
SceneEvents::ProcessingResultCombiner result;
CContentCGF cgfContent(filename.c_str());
ConfigureSkinContent(cgfContent);
// Process mesh
// For each selected mesh, find its skinned skeleton's root bone. Make sure the root bone is consistent through all selected skin meshes.
const SceneContainer::SceneGraph& graph = context.m_scene.GetGraph();
AZStd::vector<AZStd::string> targetNodes = SceneUtil::SceneGraphSelector::GenerateTargetNodes(graph,
context.m_group.GetSceneNodeSelectionList(), SceneUtil::SceneGraphSelector::IsMesh);
result += ProcessSkins(context, cgfContent, targetNodes);
if (m_assetWriter)
{
if (m_assetWriter->WriteSKIN(&cgfContent, m_convertContext, true))
{
static const AZ::Data::AssetType skinnedMeshAssetType("{C5D443E1-41FF-4263-8654-9438BC888CB7}"); // from MeshAsset.h
context.m_products.AddProduct(AZStd::move(filename), context.m_group.GetId(), skinnedMeshAssetType, 0, AZStd::nullopt);
}
else
{
AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "Writing Skin has failed.");
result += SceneEvents::ProcessingResult::Failure;
}
}
else
{
AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "No asset writer found. Unable to write skin to disk");
result += SceneEvents::ProcessingResult::Failure;
}
return result.GetResult();
}
} // namespace RC
} // namespace AZ
@@ -1,44 +0,0 @@
/*
* 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 <AzCore/std/string/string.h>
#include <SceneAPI/SceneCore/Events/CallProcessorBinder.h>
struct IConvertContext;
namespace AZ
{
namespace RC
{
struct SkinGroupExportContext;
namespace SceneEvents = AZ::SceneAPI::Events;
class SkinGroupExporter
: public SceneEvents::CallProcessorBinder
{
public:
SkinGroupExporter(IAssetWriter* writer, IConvertContext* convertContext);
~SkinGroupExporter() override = default;
SceneEvents::ProcessingResult ProcessContext(SkinGroupExportContext& context) const;
static const AZStd::string s_fileExtension;
protected:
IAssetWriter* m_assetWriter;
IConvertContext* m_convertContext;
};
} // namespace RC
} // namespace AZ
@@ -1,117 +0,0 @@
/*
* 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 <Cry_Geo.h> // Needed for CGFContent.h
#include <CGFContent.h>
#include <AzCore/std/containers/map.h>
#include <AzCore/std/string/conversions.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <RC/ResourceCompilerScene/Common/CommonExportContexts.h>
#include <RC/ResourceCompilerScene/Cgf/CgfUtils.h>
#include <RC/ResourceCompilerScene/Skin/SkinExportContexts.h>
#include <RC/ResourceCompilerScene/Skin/SkinLodExporter.h>
#include <RC/ResourceCompilerScene/Skin/SkinUtils.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Utilities/SceneGraphSelector.h>
#include <SceneAPI/SceneCore/DataTypes/DataTypeUtilities.h>
#include <SceneAPI/SceneCore/DataTypes/ManifestBase/ISceneNodeSelectionList.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/ISkinGroup.h>
#include <SceneAPI/SceneCore/DataTypes/Rules/ILodRule.h>
#include <SceneAPI/SceneCore/Events/ExportProductList.h>
#include <SceneAPI/SceneCore/Utilities/FileUtilities.h>
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
namespace AZ
{
namespace RC
{
namespace SceneUtil = AZ::SceneAPI::Utilities;
namespace SceneContainer = AZ::SceneAPI::Containers;
namespace SceneDataTypes = AZ::SceneAPI::DataTypes;
const AZStd::string SkinLodExporter::s_fileExtension = "skin";
SkinLodExporter::SkinLodExporter(IAssetWriter* writer, IConvertContext* convertContext)
: m_assetWriter(writer)
, m_convertContext(convertContext)
{
BindToCall(&SkinLodExporter::ProcessContext);
ActivateBindings();
}
SceneEvents::ProcessingResult SkinLodExporter::ProcessContext(SkinGroupExportContext& context) const
{
if (context.m_phase != Phase::Filling)
{
return SceneEvents::ProcessingResult::Ignored;
}
AZStd::shared_ptr<const SceneDataTypes::ILodRule> lodRule = context.m_group.GetRuleContainerConst().FindFirstByType<SceneDataTypes::ILodRule>();
if (!lodRule)
{
return SceneEvents::ProcessingResult::Ignored;
}
SceneEvents::ProcessingResultCombiner result;
for (size_t index = 0; index < lodRule->GetLodCount(); ++index)
{
AZ_TraceContext("Skin lod level", static_cast<uint64_t>(index));
AZStd::string filename = SceneUtil::FileUtilities::CreateOutputFileName(
context.m_group.GetName() + "_LOD" + AZStd::to_string(static_cast<int>(index + 1)), context.m_outputDirectory, s_fileExtension);
AZ_TraceContext("Skin lod filename", filename);
if (filename.empty() || !SceneUtil::FileUtilities::EnsureTargetFolderExists(filename))
{
AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "Invalid file name for skin");
result += SceneEvents::ProcessingResult::Failure;
break;
}
CContentCGF cgfContent(filename.c_str());
ConfigureSkinContent(cgfContent);
// Process mesh
// For each selected mesh, find its skinned skeleton's root bone. Make sure the root bone is consistent through all selected skin meshes.
const SceneContainer::SceneGraph& graph = context.m_scene.GetGraph();
AZStd::vector<AZStd::string> targetNodes = SceneUtil::SceneGraphSelector::GenerateTargetNodes(graph,
lodRule->GetSceneNodeSelectionList(index), SceneUtil::SceneGraphSelector::IsMesh);
result += ProcessSkins(context, cgfContent, targetNodes);
if (m_assetWriter)
{
if (m_assetWriter->WriteSKIN(&cgfContent, m_convertContext, false))
{
static const AZ::Data::AssetType skinnedMeshLodsAssetType("{58E5824F-C27B-46FD-AD48-865BA41B7A51}");
// Using the same guid as the parent group/cgf as this needs to be a lod of that cgf.
// Setting the lod to index+1 as 0 means the base mesh and 1-6 are lod levels 0-5.
context.m_products.AddProduct(AZStd::move(filename), context.m_group.GetId(), skinnedMeshLodsAssetType, index + 1, AZStd::nullopt);
}
else
{
AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "Writing Skin has failed.");
result += SceneEvents::ProcessingResult::Failure;
break;
}
}
else
{
AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "No asset writer found. Unable to write skin to disk");
result += SceneEvents::ProcessingResult::Failure;
break;
}
}
return result.GetResult();
}
} // namespace RC
} // namespace AZ
@@ -1,45 +0,0 @@
/*
* 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 <AzCore/std/string/string.h>
#include <SceneAPI/SceneCore/Events/CallProcessorBinder.h>
struct IConvertContext;
class CContentCGF;
namespace AZ
{
namespace RC
{
struct SkinGroupExportContext;
namespace SceneEvents = AZ::SceneAPI::Events;
class SkinLodExporter
: public SceneEvents::CallProcessorBinder
{
public:
SkinLodExporter(IAssetWriter* writer, IConvertContext* convertContext);
~SkinLodExporter() override = default;
SceneEvents::ProcessingResult ProcessContext(SkinGroupExportContext& context) const;
static const AZStd::string s_fileExtension;
protected:
IAssetWriter* m_assetWriter;
IConvertContext* m_convertContext;
};
} // namespace RC
} // namespace AZ
@@ -1,194 +0,0 @@
/*
* 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 <Cry_Geo.h> // Needed for CGFContent.h
#include <CGFContent.h>
#include <AzCore/std/containers/map.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <RC/ResourceCompilerScene/Common/CommonExportContexts.h>
#include <RC/ResourceCompilerScene/Skin/SkinExportContexts.h>
#include <RC/ResourceCompilerScene/Skin/SkinGroupExporter.h>
#include <RC/ResourceCompilerScene/Cgf/CgfUtils.h>
#include <RC/ResourceCompilerScene/Skin/SkinUtils.h>
#include <RC/ResourceCompilerScene/Skin/SkinExportContexts.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/ISkinGroup.h>
#include <SceneAPI/SceneCore/Utilities/FileUtilities.h>
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
namespace AZ
{
namespace RC
{
void ConfigureSkinContent(CContentCGF& content)
{
CExportInfoCGF* exportInfo = content.GetExportInfo();
exportInfo->bMergeAllNodes = true;
exportInfo->bUseCustomNormals = false;
exportInfo->bCompiledCGF = false;
exportInfo->bHavePhysicsProxy = false;
exportInfo->bHaveAutoLods = false;
exportInfo->bNoMesh = true;
exportInfo->b8WeightsPerVertex = false;
exportInfo->bWantF32Vertices = false;
exportInfo->authorToolVersion = 1;
}
void MergeToFirstNodeMesh(CContentCGF& content)
{
AZ_Assert(content.GetNodeCount() > 0, "Skin Mesh has no node to merge");
if (content.GetNodeCount() == 0)
{
return;
}
CMesh* mergedMesh = content.GetNode(0)->pMesh;
AZ_Assert(mergedMesh, "Failed to retrieve merged mesh for content root node");
if (!mergedMesh)
{
return;
}
for (size_t nodeIndex = 0; nodeIndex < content.GetNodeCount(); ++nodeIndex)
{
CNodeCGF* node = content.GetNode(nodeIndex);
AZ_Assert(node, "Failed to retrieve node at index %i", nodeIndex);
if (!node)
{
continue;
}
if (!node->bIdentityMatrix)
{
AZ_Assert(node->pMesh, "No mesh node set on CGF node at index %i", nodeIndex);
if (!node->pMesh)
{
continue;
}
for (size_t vertexIndex = 0; vertexIndex < node->pMesh->GetVertexCount(); ++vertexIndex)
{
node->pMesh->m_pPositions[vertexIndex] = node->worldTM.TransformPoint(node->pMesh->m_pPositions[vertexIndex]);
node->pMesh->m_pNorms[vertexIndex].RotateSafelyBy(node->worldTM);
}
}
if (nodeIndex > 0)
{
mergedMesh->Append(*node->pMesh);
// Keep color stream in sync size with vertex/normals stream. Reference to CGFNodeMerger::MergeNodes
if (mergedMesh->m_streamSize[CMesh::COLORS][0] > 0 && mergedMesh->m_streamSize[CMesh::COLORS][0] < mergedMesh->GetVertexCount())
{
int colorCount = mergedMesh->m_streamSize[CMesh::COLORS][0];
mergedMesh->ReallocStream(CMesh::COLORS, 0, mergedMesh->GetVertexCount());
memset(mergedMesh->m_pColor0 + colorCount, 255, (mergedMesh->GetVertexCount() - colorCount) * sizeof(SMeshColor));
}
}
}
// We already used the transform during merge, so clear it out
content.GetNode(0)->worldTM.SetIdentity();
}
void RemoveRedundantNodes(CContentCGF& content)
{
while (content.GetNodeCount() > 1)
{
CNodeCGF* deleteNode = content.GetNode(content.GetNodeCount() - 1);
content.RemoveNode(deleteNode);
}
}
SceneAPI::Events::ProcessingResult ProcessSkins(SkinGroupExportContext& context, CContentCGF& content, AZStd::vector<AZStd::string>& targetNodes)
{
namespace SceneEvents = SceneAPI::Events;
if (targetNodes.empty())
{
AZ_TracePrintf(SceneAPI::Utilities::WarningWindow, "No nodes selected for mesh exporting.");
return SceneEvents::ProcessingResult::Ignored;
}
SceneEvents::ProcessingResultCombiner result;
ContainerExportContext containerContext(context.m_scene, context.m_outputDirectory, context.m_group, content, Phase::Construction);
result += SceneEvents::Process(containerContext);
result += SceneEvents::Process<ContainerExportContext>(containerContext, Phase::Filling);
const EPhysicsGeomType physicalizeType = PHYS_GEOM_TYPE_NONE;
AZStd::string rootBoneName;
const SceneAPI::Containers::SceneGraph& graph = context.m_scene.GetGraph();
AZStd::string currentRootBoneName;
for (const AZStd::string& nodeName : targetNodes)
{
AZ_TraceContext("Skin mesh", nodeName);
SceneAPI::Containers::SceneGraph::NodeIndex index = graph.Find(nodeName.c_str());
if (index.IsValid())
{
// Pick the target skeleton from the first node, then make sure all the remaining meshes are referencing the same skeleton
// as the skins need to merged to a single mesh at the end.
SceneEvents::ProcessingResult rootNameResult = SceneEvents::Process<ResolveRootBoneFromNodeContext>(currentRootBoneName, context.m_scene, index);
if (rootNameResult != SceneEvents::ProcessingResult::Success || currentRootBoneName.empty())
{
AZ_TracePrintf(SceneAPI::Utilities::WarningWindow, "Selected skin has no weight data.");
continue;
}
if (rootBoneName.empty())
{
rootBoneName = currentRootBoneName;
// The skeleton has been established so fill up the skinning information for it as there's still
// a strong link between skin and skeleton.
SceneEvents::ProcessingResult skinInfoResult = SceneEvents::Process<AddBonesToSkinningInfoContext>(
*content.GetSkinningInfo(), context.m_scene, rootBoneName);
if (skinInfoResult != SceneEvents::ProcessingResult::Success)
{
// Without the skinning info further processing will cause a crash so early out here.
AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Unable to link bones to skin.");
return SceneEvents::ProcessingResult::Failure;
}
}
else if (rootBoneName != currentRootBoneName)
{
AZ_TracePrintf(SceneAPI::Utilities::WarningWindow, "Skin doesn't belong to the same skeleton as the rest of the meshes in the group.");
continue;
}
CNodeCGF* node = new CNodeCGF(); // will be auto deleted by CContentCGF cgf
SetNodeName(nodeName, *node);
result += SceneAPI::Events::Process<NodeExportContext>(containerContext, *node, nodeName, index, physicalizeType, rootBoneName, Phase::Construction);
result += SceneAPI::Events::Process<NodeExportContext>(containerContext, *node, nodeName, index, physicalizeType, rootBoneName, Phase::Filling);
content.AddNode(node);
result += SceneAPI::Events::Process<NodeExportContext>(containerContext, *node, nodeName, index, physicalizeType, rootBoneName, Phase::Finalizing);
currentRootBoneName.clear();
}
}
if (content.GetNodeCount() > 0)
{
// CharacterCompiler expects all skin sub-meshes to be merged and stored in a single CNodeCGF
MergeToFirstNodeMesh(content);
result += SceneAPI::Events::Process<ContainerExportContext>(containerContext, Phase::Finalizing);
RemoveRedundantNodes(content);
}
else
{
AZ_TracePrintf(SceneAPI::Utilities::WarningWindow, "No valid skin information found that could be added to this container.");
result += SceneAPI::Events::Process<ContainerExportContext>(containerContext, Phase::Finalizing);
}
return result.GetResult();
}
}
}
@@ -1,31 +0,0 @@
/*
* 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 <AzCore/std/string/string.h>
#include <SceneAPI/SceneCore/Events/ProcessingResult.h>
class CContentCGF;
struct CNodeCGF;
namespace AZ
{
namespace RC
{
struct SkinGroupExportContext;
void ConfigureSkinContent(CContentCGF& content);
void MergeToFirstNodeMesh(CContentCGF& content);
void RemoveRedundantNodes(CContentCGF& content);
AZ::SceneAPI::Events::ProcessingResult ProcessSkins(SkinGroupExportContext& context, CContentCGF& content, AZStd::vector<AZStd::string>& targetNodes);
} // namespace RC
} // namespace AZ
@@ -52,20 +52,4 @@ set(FILES
Cgf/CgfExporter.cpp
Cgf/CgfUtils.h
Cgf/CgfUtils.cpp
Chr/ChrExportContexts.h
Chr/ChrExportContexts.cpp
Chr/ChrGroupExporter.h
Chr/ChrGroupExporter.cpp
Chr/ChrExporter.h
Chr/ChrExporter.cpp
Skin/SkinExportContexts.h
Skin/SkinExportContexts.cpp
Skin/SkinGroupExporter.h
Skin/SkinGroupExporter.cpp
Skin/SkinLodExporter.h
Skin/SkinLodExporter.cpp
Skin/SkinExporter.h
Skin/SkinExporter.cpp
Skin/SkinUtils.h
Skin/SkinUtils.cpp
)