vault backup: 2025-01-17 16:11:56
This commit is contained in:
parent
19ddb1837e
commit
a345b73a1e
@ -31,9 +31,82 @@
|
|||||||
|
|
||||||
|
|
||||||
# FaceSet
|
# FaceSet
|
||||||
https://groups.google.com/g/alembic-discussion/c/hICfVMzRV2U?pli=1
|
https://github.com/zenustech/zeno/blob/b4ed8740810f20cf0612d615d9505468b2d2a4d1/projects/FBX/FBXSDK.cpp#L477
|
||||||
|
|
||||||
FbxSelectionSet Class
|
```c++
|
||||||
https://help.autodesk.com/view/FBX/2015/ENU/?guid=__cpp_ref_class_fbx_selection_set_html
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
GetPolygonGroup?
|
UE中相关逻辑位于FbxMesh.cpp
|
||||||
|
```c++
|
||||||
|
void ExtractMeshMaterials(FFbxParser& Parser, FbxMesh* Mesh, FbxNode* MeshNode, TFunction<void(const FString& MaterialName, const FString& MaterialUid, const int32 MeshMaterialIndex)> CollectMaterial)
|
||||||
|
{
|
||||||
|
if (!Mesh || !MeshNode)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Grab all Material indexes use by the mesh
|
||||||
|
TArray<int32> MaterialIndexes;
|
||||||
|
int32 PolygonCount = Mesh->GetPolygonCount();
|
||||||
|
if (FbxGeometryElementMaterial* GeometryElementMaterial = Mesh->GetElementMaterial())
|
||||||
|
{
|
||||||
|
FbxLayerElementArrayTemplate<int32>& IndexArray = GeometryElementMaterial->GetIndexArray();
|
||||||
|
switch (GeometryElementMaterial->GetMappingMode())
|
||||||
|
{
|
||||||
|
case FbxGeometryElement::eByPolygon:
|
||||||
|
{
|
||||||
|
if (IndexArray.GetCount() == PolygonCount)
|
||||||
|
{
|
||||||
|
for (int32 PolygonIndex = 0; PolygonIndex < PolygonCount; ++PolygonIndex)
|
||||||
|
{
|
||||||
|
MaterialIndexes.AddUnique(IndexArray.GetAt(PolygonIndex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FbxGeometryElement::eAllSame:
|
||||||
|
{
|
||||||
|
if (IndexArray.GetCount() > 0)
|
||||||
|
{
|
||||||
|
MaterialIndexes.AddUnique(IndexArray.GetAt(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const int32 MaterialCount = MeshNode->GetMaterialCount();
|
||||||
|
TMap<FbxSurfaceMaterial*, int32> UniqueSlotNames;
|
||||||
|
UniqueSlotNames.Reserve(MaterialCount);
|
||||||
|
bool bAddAllNodeMaterials = (MaterialIndexes.Num() == 0);
|
||||||
|
for (int32 MaterialIndex = 0; MaterialIndex < MaterialCount; ++MaterialIndex)
|
||||||
|
{
|
||||||
|
if (FbxSurfaceMaterial* FbxMaterial = MeshNode->GetMaterial(MaterialIndex))
|
||||||
|
{
|
||||||
|
int32& SlotMaterialCount = UniqueSlotNames.FindOrAdd(FbxMaterial);
|
||||||
|
FString MaterialName = Parser.GetFbxHelper()->GetFbxObjectName(FbxMaterial);
|
||||||
|
FString MaterialUid = TEXT("\\Material\\") + MaterialName;
|
||||||
|
if (bAddAllNodeMaterials || MaterialIndexes.Contains(MaterialIndex))
|
||||||
|
{
|
||||||
|
if (SlotMaterialCount > 0)
|
||||||
|
{
|
||||||
|
MaterialName += TEXT("_Section") + FString::FromInt(SlotMaterialCount);
|
||||||
|
}
|
||||||
|
SlotMaterialCount++;
|
||||||
|
CollectMaterial(MaterialName, MaterialUid, MaterialIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
Loading…
x
Reference in New Issue
Block a user