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,48 @@
/*
* 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/Cgf/CgfExportContexts.h>
namespace AZ
{
namespace RC
{
CgfGroupExportContext::CgfGroupExportContext(SceneAPI::Events::ExportEventContext& parent,
const SceneAPI::DataTypes::IMeshGroup& group, Phase phase)
: m_products(parent.GetProductList())
, m_scene(parent.GetScene())
, m_outputDirectory(parent.GetOutputDirectory())
, m_group(group)
, m_phase(phase)
{
}
CgfGroupExportContext::CgfGroupExportContext(SceneAPI::Events::ExportProductList& products, const SceneAPI::Containers::Scene& scene,
const AZStd::string& outputDirectory, const SceneAPI::DataTypes::IMeshGroup& group, Phase phase)
: m_products(products)
, m_scene(scene)
, m_outputDirectory(outputDirectory)
, m_group(group)
, m_phase(phase)
{
}
CgfGroupExportContext::CgfGroupExportContext(const CgfGroupExportContext& 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)
{
}
} // RC
} // AZ
@@ -0,0 +1,65 @@
#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 <AzCore/std/string/string.h>
#include <SceneAPI/SceneCore/Events/CallProcessorBus.h>
#include <SceneAPI/SceneCore/Events/ExportEventContext.h>
#include <RC/ResourceCompilerScene/Common/ExportContextGlobal.h>
#include <CryHeaders.h>
class CContentCGF;
struct CNodeCGF;
class CMesh;
namespace AZ
{
namespace SceneAPI
{
namespace DataTypes
{
class IGroup;
class IMeshGroup;
}
namespace Events
{
class ExportProductList;
}
}
namespace RC
{
// Called to export a specific Mesh (Cgf) Group.
struct CgfGroupExportContext
: public SceneAPI::Events::ICallContext
{
AZ_RTTI(CgfGroupExportContext, "{974FF54E-9724-4E8B-A2A1-D360C3B3DA80}", SceneAPI::Events::ICallContext);
CgfGroupExportContext(SceneAPI::Events::ExportEventContext& parent,
const SceneAPI::DataTypes::IMeshGroup& group, Phase phase);
CgfGroupExportContext(SceneAPI::Events::ExportProductList& products, const SceneAPI::Containers::Scene& scene, const AZStd::string& outputDirectory,
const SceneAPI::DataTypes::IMeshGroup& group, Phase phase);
CgfGroupExportContext(const CgfGroupExportContext& copyContext, Phase phase);
CgfGroupExportContext(const CgfGroupExportContext& copyContext) = delete;
~CgfGroupExportContext() override = default;
CgfGroupExportContext& operator=(const CgfGroupExportContext& other) = delete;
SceneAPI::Events::ExportProductList& m_products;
const SceneAPI::Containers::Scene& m_scene;
const AZStd::string& m_outputDirectory;
const SceneAPI::DataTypes::IMeshGroup& m_group;
const Phase m_phase;
};
} // RC
} // AZ
@@ -0,0 +1,63 @@
/*
* 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/Cgf/CgfExporter.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/IMeshGroup.h>
#include <SceneAPI/SceneCore/Events/ExportEventContext.h>
#include <RC/ResourceCompilerScene/Cgf/CgfExportContexts.h>
namespace AZ
{
namespace RC
{
namespace SceneContainers = AZ::SceneAPI::Containers;
namespace SceneDataTypes = AZ::SceneAPI::DataTypes;
CgfExporter::CgfExporter(IConvertContext* convertContext)
: m_convertContext(convertContext)
{
BindToCall(&CgfExporter::ProcessContext);
ActivateBindings();
}
SceneEvents::ProcessingResult CgfExporter::ProcessContext(SceneEvents::ExportEventContext& context)
{
AZ_TraceContext("Scene name", context.GetScene().GetName());
AZ_TraceContext("Source file", context.GetScene().GetSourceFilename());
AZ_TraceContext("Output path", context.GetOutputDirectory());
const SceneContainers::SceneManifest& manifest = context.GetScene().GetManifest();
auto valueStorage = manifest.GetValueStorage();
auto view = SceneContainers::MakeDerivedFilterView<SceneDataTypes::IMeshGroup>(valueStorage);
SceneEvents::ProcessingResultCombiner result;
for (const SceneDataTypes::IMeshGroup& meshGroup : view)
{
AZ_TraceContext("Mesh group", meshGroup.GetName());
result += SceneEvents::Process<CgfGroupExportContext>(context, meshGroup, Phase::Construction);
result += SceneEvents::Process<CgfGroupExportContext>(context, meshGroup, Phase::Filling);
result += SceneEvents::Process<CgfGroupExportContext>(context, meshGroup, Phase::Finalizing);
}
return result.GetResult();
}
} // namespace RC
} // namespace AZ
@@ -0,0 +1,46 @@
/*
* 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 CgfExporter
: public SceneEvents::CallProcessorBinder
{
public:
CgfExporter(IConvertContext* convertContext);
~CgfExporter() override = default;
SceneEvents::ProcessingResult ProcessContext(SceneEvents::ExportEventContext& context);
private:
IConvertContext* m_convertContext;
};
} // namespace RC
} // namespace AZ
@@ -0,0 +1,117 @@
/*
* 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/IO/SystemFile.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <RC/ResourceCompilerScene/Common/CommonExportContexts.h>
#include <RC/ResourceCompilerScene/Cgf/CgfExportContexts.h>
#include <RC/ResourceCompilerScene/Cgf/CgfGroupExporter.h>
#include <RC/ResourceCompilerScene/Cgf/CgfUtils.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Utilities/SceneGraphSelector.h>
#include <SceneAPI/SceneCore/Utilities/FileUtilities.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshData.h>
#include <SceneAPI/SceneCore/DataTypes/ManifestBase/ISceneNodeSelectionList.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/IMeshGroup.h>
#include <SceneAPI/SceneCore/DataTypes/Rules/IMaterialRule.h>
#include <SceneAPI/SceneCore/DataTypes/DataTypeUtilities.h>
#include <SceneAPI/SceneCore/Events/ExportProductList.h>
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
namespace AZ
{
namespace RC
{
namespace SceneUtil = AZ::SceneAPI::Utilities;
namespace SceneDataTypes = AZ::SceneAPI::DataTypes;
namespace SceneContainers = AZ::SceneAPI::Containers;
const AZStd::string CgfGroupExporter::s_fileExtension = "cgf";
CgfGroupExporter::CgfGroupExporter(IAssetWriter* writer)
: m_assetWriter(writer)
{
BindToCall(&CgfGroupExporter::ProcessContext);
ActivateBindings();
}
SceneEvents::ProcessingResult CgfGroupExporter::ProcessContext(CgfGroupExportContext& 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("CGF File Name", filename);
if (filename.empty() || !SceneUtil::FileUtilities::EnsureTargetFolderExists(filename))
{
AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "Unable to write CGF file. Filename is empty or target folder does not exist.");
return SceneEvents::ProcessingResult::Failure;
}
SceneEvents::ProcessingResultCombiner result;
CContentCGF cgfContent(filename.c_str());
ConfigureCgfContent(cgfContent);
const SceneContainers::SceneGraph& graph = context.m_scene.GetGraph();
AZStd::vector<AZStd::string> targetNodes = SceneUtil::SceneGraphSelector::GenerateTargetNodes(graph,
context.m_group.GetSceneNodeSelectionList(), SceneUtil::SceneGraphSelector::IsMesh);
result += ProcessMeshes(context, cgfContent, targetNodes);
if (m_assetWriter && cgfContent.GetNodeCount() > 0)
{
if (m_assetWriter->WriteCGF(&cgfContent))
{
static const Data::AssetType staticMeshAssetType("{C2869E3B-DDA0-4E01-8FE3-6770D788866B}"); // from MeshAsset.h
AZ::SceneAPI::Events::ExportProduct& exportProduct = context.m_products.AddProduct(AZStd::move(filename), context.m_group.GetId(), staticMeshAssetType, 0, AZStd::nullopt);
// If the mesh group has a material rule, then add the material path dependency
if (context.m_group.GetRuleContainerConst().FindFirstByType<SceneDataTypes::IMaterialRule>())
{
// All CGFs are assumed to have a single material with their same name in their same folder.
// Add just the material file name as a path dependency for now.
// Note that at this point, the .mtl file may or may not exist, which is fine.
AZStd::string materialName;
AzFramework::StringFunc::Path::GetFullFileName(context.m_scene.GetSourceFilename().c_str(), materialName);
AzFramework::StringFunc::Path::ReplaceExtension(materialName, ".mtl");
exportProduct.m_legacyPathDependencies.push_back(materialName);
}
}
else
{
AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "Unable to write CGF file.");
result += SceneEvents::ProcessingResult::Failure;
}
}
else
{
if (!m_assetWriter)
{
AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "No asset writer found. Unable to write cgf to disk");
}
if (cgfContent.GetNodeCount() == 0 )
{
AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "Empty Cgf file. Cgf not written to disk." );
}
result += SceneEvents::ProcessingResult::Failure;
}
return result.GetResult();
}
} // namespace RC
} // namespace AZ
@@ -0,0 +1,44 @@
/*
* 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>
class CContentCGF;
struct IAssetWriter;
namespace AZ
{
namespace RC
{
struct CgfGroupExportContext;
namespace SceneEvents = AZ::SceneAPI::Events;
class CgfGroupExporter
: public SceneEvents::CallProcessorBinder
{
public:
CgfGroupExporter(IAssetWriter* writer);
~CgfGroupExporter() override = default;
static const AZStd::string s_fileExtension;
SceneEvents::ProcessingResult ProcessContext(CgfGroupExportContext& context) const;
protected:
IAssetWriter* m_assetWriter;
};
} // namespace RC
} // namespace AZ
@@ -0,0 +1,126 @@
/*
* 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/IO/SystemFile.h>
#include <AzCore/std/string/conversions.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <RC/ResourceCompilerScene/Common/CommonExportContexts.h>
#include <RC/ResourceCompilerScene/Cgf/CgfExportContexts.h>
#include <RC/ResourceCompilerScene/Cgf/CgfLodExporter.h>
#include <RC/ResourceCompilerScene/Cgf/CgfUtils.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Utilities/SceneGraphSelector.h>
#include <SceneAPI/SceneCore/Utilities/FileUtilities.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshData.h>
#include <SceneAPI/SceneCore/DataTypes/ManifestBase/ISceneNodeSelectionList.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/IMeshGroup.h>
#include <SceneAPI/SceneCore/DataTypes/Rules/ILodRule.h>
#include <SceneAPI/SceneCore/DataTypes/DataTypeUtilities.h>
#include <SceneAPI/SceneCore/Events/ExportProductList.h>
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
namespace AZ
{
namespace RC
{
namespace SceneUtil = AZ::SceneAPI::Utilities;
namespace SceneDataTypes = AZ::SceneAPI::DataTypes;
namespace SceneContainers = AZ::SceneAPI::Containers;
const AZStd::string CgfLodExporter::s_fileExtension = "cgf";
CgfLodExporter::CgfLodExporter(IAssetWriter* writer)
: m_assetWriter(writer)
{
BindToCall(&CgfLodExporter::ProcessContext);
ActivateBindings();
}
SceneEvents::ProcessingResult CgfLodExporter::ProcessContext(CgfGroupExportContext& 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;
}
// Create the base CGF name
AZStd::string baseCGFfilename = SceneUtil::FileUtilities::CreateOutputFileName(context.m_group.GetName(), context.m_outputDirectory, s_fileExtension);
SceneEvents::ProcessingResultCombiner result;
for (size_t index = 0; index < lodRule->GetLodCount(); ++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("CGF Lod File Name", filename);
if (filename.empty() || !SceneUtil::FileUtilities::EnsureTargetFolderExists(filename))
{
AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "Unable to write CGF Lod file. Filename is empty or target folder does not exist.");
result += SceneEvents::ProcessingResult::Failure;
break;
}
CContentCGF cgfContent(filename.c_str());
ConfigureCgfContent(cgfContent);
const SceneContainers::SceneGraph& graph = context.m_scene.GetGraph();
AZStd::vector<AZStd::string> targetNodes = SceneUtil::SceneGraphSelector::GenerateTargetNodes(graph,
lodRule->GetSceneNodeSelectionList(index), SceneUtil::SceneGraphSelector::IsMesh);
result += ProcessMeshes(context, cgfContent, targetNodes);
if (cgfContent.GetNodeCount() == 0)
{
AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "Empty LoD Detected at level %d.", index);
result += SceneEvents::ProcessingResult::Failure;
break;
}
if (m_assetWriter)
{
if (m_assetWriter->WriteCGF(&cgfContent))
{
static const AZ::Data::AssetType staticMeshLodsAssetType("{9AAE4926-CB6A-4C60-9948-A1A22F51DB23}");
// 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.
AZ::SceneAPI::Events::ExportProduct& lodProduct = context.m_products.AddProduct(AZStd::move(filename), context.m_group.GetId(), staticMeshLodsAssetType, index + 1, AZStd::nullopt);
// Add this LOD as a dependency to the base CGF
context.m_products.AddDependencyToProduct(baseCGFfilename, lodProduct);
}
else
{
AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "Unable to write CGF LoD file at level %d.", index);
result += SceneEvents::ProcessingResult::Failure;
break;
}
}
else
{
AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "No asset writer found. Unable to write cgf to disk");
result += SceneEvents::ProcessingResult::Failure;
break;
}
}
return result.GetResult();
}
} // namespace RC
} // namespace AZ
@@ -0,0 +1,44 @@
/*
* 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>
class CContentCGF;
struct IAssetWriter;
namespace AZ
{
namespace RC
{
struct CgfGroupExportContext;
namespace SceneEvents = AZ::SceneAPI::Events;
class CgfLodExporter
: public SceneEvents::CallProcessorBinder
{
public:
CgfLodExporter(IAssetWriter* writer);
~CgfLodExporter() override = default;
static const AZStd::string s_fileExtension;
SceneEvents::ProcessingResult ProcessContext(CgfGroupExportContext& context) const;
protected:
IAssetWriter* m_assetWriter;
};
} // namespace RC
} // namespace AZ
@@ -0,0 +1,93 @@
/*
* 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 <AzToolsFramework/Debug/TraceContext.h>
#include <RC/ResourceCompilerScene/Common/CommonExportContexts.h>
#include <RC/ResourceCompilerScene/Cgf/CgfExportContexts.h>
#include <RC/ResourceCompilerScene/Cgf/CgfUtils.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/DataTypes/Groups/IMeshGroup.h>
#include <SceneAPI/SceneCore/Utilities/SceneGraphSelector.h>
#include <SceneAPI/SceneCore/Utilities/FileUtilities.h>
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
#include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
namespace AZ
{
namespace RC
{
void ConfigureCgfContent(CContentCGF& content)
{
CExportInfoCGF* exportInfo = content.GetExportInfo();
bool useCustomNormalDefault = true;
AZ::SceneAPI::Events::AssetImportRequestBus::Broadcast(&AZ::SceneAPI::Events::AssetImportRequestBus::Events::AreCustomNormalsUsed, useCustomNormalDefault);
exportInfo->bMergeAllNodes = true;
exportInfo->bUseCustomNormals = useCustomNormalDefault; // This will be overritten by StaticMeshAdvancedRule (if teh rule exists) when calling ContainerSettingsExporter::ProcessContext
exportInfo->bCompiledCGF = false;
exportInfo->bHavePhysicsProxy = false;
exportInfo->bHaveAutoLods = false;
exportInfo->bNoMesh = true;
exportInfo->b8WeightsPerVertex = false;
exportInfo->bWantF32Vertices = false;
exportInfo->authorToolVersion = 1;
}
void ProcessMeshType(ContainerExportContext& context, CContentCGF& content, const AZStd::vector<AZStd::string>& targetNodes, EPhysicsGeomType physicalizeType)
{
const SceneAPI::Containers::SceneGraph& graph = context.m_scene.GetGraph();
for (const AZStd::string& nodeName : targetNodes)
{
AZ_TraceContext("Mesh node", nodeName);
SceneAPI::Containers::SceneGraph::NodeIndex index = graph.Find(nodeName);
if (index.IsValid())
{
CNodeCGF* node = new CNodeCGF(); // will be auto deleted by CContentCGF cgf
SetNodeName(nodeName, *node);
AZStd::string rootBoneName;
SceneAPI::Events::Process<NodeExportContext>(context, *node, nodeName, index, physicalizeType, rootBoneName, Phase::Construction);
SceneAPI::Events::Process<NodeExportContext>(context, *node, nodeName, index, physicalizeType, rootBoneName, Phase::Filling);
content.AddNode(node);
SceneAPI::Events::Process<NodeExportContext>(context, *node, nodeName, index, physicalizeType, rootBoneName, Phase::Finalizing);
}
}
}
void SetNodeName(const AZStd::string& name, CNodeCGF& node)
{
static const size_t nodeNameCount = sizeof(node.name) / sizeof(node.name[0]);
size_t offset = name.length() < nodeNameCount ? 0 : name.length() - nodeNameCount + 1;
azstrcpy(node.name, nodeNameCount, name.c_str() + offset);
}
SceneAPI::Events::ProcessingResult ProcessMeshes(CgfGroupExportContext& context, CContentCGF& content, const AZStd::vector<AZStd::string>& targetNodes)
{
SceneAPI::Events::ProcessingResultCombiner result;
ContainerExportContext containerContext(context.m_scene, context.m_outputDirectory, context.m_group, content, Phase::Construction);
result += SceneAPI::Events::Process(containerContext);
result += SceneAPI::Events::Process<ContainerExportContext>(containerContext, Phase::Filling);
const SceneAPI::Containers::SceneGraph& graph = context.m_scene.GetGraph();
ProcessMeshType(containerContext, content, targetNodes, PHYS_GEOM_TYPE_NONE);
result += SceneAPI::Events::Process<ContainerExportContext>(containerContext, Phase::Finalizing);
return result.GetResult();
}
} // RC
} // AZ
@@ -0,0 +1,32 @@
/*
* 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;
namespace AZ
{
namespace RC
{
struct CgfContainerExportContext;
struct CgfGroupExportContext;
void ConfigureCgfContent(CContentCGF& content);
AZ::SceneAPI::Events::ProcessingResult ProcessMeshes(CgfGroupExportContext& context, CContentCGF& content, const AZStd::vector<AZStd::string>& targetNodes);
void ProcessMeshType(ContainerExportContext& context, CContentCGF& content, const AZStd::vector<AZStd::string>& targetNodes, EPhysicsGeomType physicalizeType);
void SetNodeName(const AZStd::string& name, CNodeCGF& node);
} // namespace RC
} // namespace AZ