#include #include using namespace std; extern "C" { // 定义给Rust调用的接口函数 void fbx_parse(const char* fbx_path) { std::printf("%s\n", fbx_path); FbxManager* lSdkManager = FbxManager::Create(); if (lSdkManager){ std::printf("FbxManager created successfully.\n"); } else{ std::printf("FbxManager creation failed.\n"); } FbxScene* lScene = FbxScene::Create(lSdkManager, "myScene"); if (lScene){ std::printf("FbxScene created successfully.\n"); } else{ std::printf("FbxScene creation failed.\n"); } FbxImporter* lImporter = FbxImporter::Create(lSdkManager, ""); bool s = lImporter->Initialize(fbx_path, -1, lSdkManager->GetIOSettings()); if (s){ std::printf("FbxImporter initialized successfully.\n"); } else{ std::printf("FbxImporter initialization failed.\n"); } lImporter->Import(lScene); lImporter->Destroy(); FbxNode* lRootNode = lScene->GetRootNode(); if (lRootNode) { std::printf("Root node found. Node name: %s\n", lRootNode->GetName()); int childCount = lRootNode->GetChildCount(); std::printf("Number of child nodes: %d\n", childCount); for (int i = 0; i < childCount; ++i) { FbxNode* childNode = lRootNode->GetChild(i); std::printf("Child node %d name: %s\n", i, childNode->GetName()); } } else { std::printf("No root node found in the scene.\n"); } if (lRootNode && lRootNode->GetNodeAttribute() && lRootNode->GetNodeAttribute()->GetAttributeType() == FbxNodeAttribute::eMesh) { FbxMesh* lMesh = static_cast(lRootNode->GetNodeAttribute()); int materialCount = lMesh->GetElementMaterialCount(); std::printf("Number of materials in the mesh: %d\n", materialCount); for (int i = 0; i < materialCount; ++i) { FbxSurfaceMaterial* lMaterial = nullptr; std::printf("Material name: %s\n", lMaterial->GetName()); // lMesh->GetElementMaterial(0)->eMaterial(i, lMaterial); // if (lMaterial) { // std::printf("Material %d name: %s\n", i, lMaterial->GetName()); // } } int controlPointCount = lMesh->GetControlPointsCount(); std::printf("Number of vertices in the mesh: %d\n", controlPointCount); } } }