/* * 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 // Needed for CGFContent.h #include #include #include #include #include #include #include #include #include #include #include #include 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, AZStd::vector& 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(context, *node, nodeName, index, physicalizeType, rootBoneName, Phase::Construction); SceneAPI::Events::Process(context, *node, nodeName, index, physicalizeType, rootBoneName, Phase::Filling); content.AddNode(node); SceneAPI::Events::Process(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, AZStd::vector& targetNodes, AZStd::vector& physTargetNodes) { 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(containerContext, Phase::Filling); const SceneAPI::Containers::SceneGraph& graph = context.m_scene.GetGraph(); ProcessMeshType(containerContext, content, physTargetNodes, PHYS_GEOM_TYPE_DEFAULT_PROXY); ProcessMeshType(containerContext, content, targetNodes, PHYS_GEOM_TYPE_NONE); result += SceneAPI::Events::Process(containerContext, Phase::Finalizing); return result.GetResult(); } } // RC } // AZ