I have the following piece of C++ code which I use to load triangle vertices from an FBX file:
FbxNode *node = scene->GetRootNode()->GetChild(0);
FbxGeometryConverter fbx_converter(node->GetFbxManager());
fbx_converter.Triangulate(node->GetNodeAttribute(), true);
mesh = node->GetMesh();
int num_vertices = mesh->GetPolygonVertexCount();
FbxVector4 *fbx_vertices = mesh->GetControlPoints();
int *fbx_triangle_vertices = mesh->GetPolygonVertices();
double x, y, z;
vector<vertex> vertices;
for (int vertex_index = 0; vertex_index < num_vertices; ++vertex_index)
{
int index = fbx_triangle_vertices[vertex_index];
x = (double)fbx_vertices[index][0];
y = (double)fbx_vertices[index][1];
z = (double)fbx_vertices[index][2];
vertices.push_back(vertex(vector3(x, y, z), material(color(1, 0.5, 0.5), 0, 0, 0, 0, 1, 0)));
}
Currently, I am only loading vertex coordinates from the file. Now I want to load the vertex's material data (instead of assigning it manually like I did in the code snippet using material(color(1, 0.5, 0.5)...
).
I see that an FbxNode
object has a GetMaterial()
method, but I don't know how to obtain this data since I am working with fbx vertices which are FbxVector4
s, not nodes.