Witaj!
tBane dodał nowy post w wątku: Wczytanie Modelu *.fbx
Witam. Chciałbym wczytać animowany model zapisany w formacie .fbx Mam kod na pobranie wierzchołków, ale nie jestem pewien czy zapisywanie wszystkich wierzchołków dla danej klatki będzie dobrym rozwiązaniem. Co o tym sądzicie ?
Kopiuj
#include <fbxsdk.h> #include <iostream> void LoadFBX(const char* filename) { // 1. Inicjalizacja menadżera FBX FbxManager* manager = FbxManager::Create(); FbxIOSettings* ios = FbxIOSettings::Create(manager, IOSROOT); manager->SetIOSettings(ios); // 2. Importer FbxImporter* importer = FbxImporter::Create(manager, ""); if (!importer->Initialize(filename, -1, manager->GetIOSettings())) { std::cerr << "Nie udało się wczytać pliku FBX: " << importer->GetStatus().GetErrorString() << std::endl; return; } // 3. Załaduj scenę FbxScene* scene = FbxScene::Create(manager, "scene"); importer->Import(scene); importer->Destroy(); // 4. Odwiedź węzły sceny FbxNode* root = scene->GetRootNode(); if (root) { for (int i = 0; i < root->GetChildCount(); i++) { FbxNode* child = root->GetChild(i); if (child->GetNodeAttribute() && child->GetNodeAttribute()->GetAttributeType() == FbxNodeAttribute::eMesh) { FbxMesh* mesh = (FbxMesh*)child->GetNodeAttribute(); std::cout << "Mesh: " << child->GetName() << std::endl; int vertexCount = mesh->GetControlPointsCount(); FbxVector4* vertices = mesh->GetControlPoints(); for (int v = 0; v < vertexCount; v++) { std::cout << "Vertex[" << v << "] = (" << vertices[v][0] << ", " << vertices[v][1] << ", " << vertices[v][2] << ")" << std::endl; } } } } // 5. Zwolnij pamięć manager->Destroy(); }
Z poważaniem, 4programmers.net
|