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 FbxVector4s, not nodes.

• You forgot to mention what library you're using. – Pharap Apr 23 '17 at 16:56
• @Pharap I am using the official FBX SDK available here: help.autodesk.com/view/FBX/2017/ENU/… – Eutherpy Apr 23 '17 at 16:58

It seems materials can be obtained from the node by FbxNode::GetMaterial(int pIndex) and FbxNode::GetMaterialIndex(const char *pName).
This data should be stored in the node you are reading, alongside the vector information, i.e. it is stored in the node and not bound to the vectors themselves.