From 7c1d97b2c3249f9a9c1be8407123ffff74053702 Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Tue, 3 Sep 2024 15:40:00 +0800 Subject: [PATCH] fbx faceset --- projects/FBX/FBXSDK.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/projects/FBX/FBXSDK.cpp b/projects/FBX/FBXSDK.cpp index 9f3b68b301..75cfe5adee 100644 --- a/projects/FBX/FBXSDK.cpp +++ b/projects/FBX/FBXSDK.cpp @@ -593,6 +593,20 @@ static std::shared_ptr GetMesh(FbxNode* pNode) { if (pMesh->GetElementTangentCount() > 0) { getAttr(pMesh->GetElementTangent(0), "tang", prim); } + auto &faceset = prim->polys.add_attr("faceset"); + std::fill(faceset.begin(), faceset.end(), -1); + int mat_count = 0; + if (pMesh->GetElementMaterialCount() > 0) { + for (auto i = 0; i < numPolygons; ++i) { + faceset[i] = pMesh->GetElementMaterial()->GetIndexArray().GetAt(i); + } + mat_count = pNode->GetMaterialCount(); + for (auto i = 0; i < mat_count; i++) { + FbxSurfaceMaterial* material = pNode->GetMaterial(i); + ud.set2(format("faceset_{}", i), material->GetName()); + } + } + ud.set2("faceset_count", mat_count); prim_set_abcpath(prim.get(), format("/ABC/{}", nodeName)); return prim; }