Announcements

Announcement: We’re aware of an issue affecting starting a new topic from category pages and creating new blog posts. New topics can still be started directly from the relevant board. Learn more here.

How to retrieve texture's file name from a FBX file?

How to retrieve texture's file name from a FBX file?

Anonymous
Not applicable
1,849 Views
1 Reply
Message 1 of 2

How to retrieve texture's file name from a FBX file?

Anonymous
Not applicable

I have an graphics engine capable of rendering 3D graphics, until a while ago I was using Blender to build some 3D models and testing some textures, and them exporting them as an OBJ file. I would get two files: the first one was a OBJ file with all the meshes data I would need, and the second one was a MTL file with some additional data which I found very useful, it would handle me the texture's file name that the current model I'm looking at uses, and even multiple texture's file names when I had a OBJ with multiple meshes. But now I've moved on to FBX files because of animations, and I don't know how to retrieve the texture name as I did in OBJ files because Blender only exports one file... If someone can help me find out how can I get the texture name from the FBX file that it's mesh uses it would be very helpful.

0 Likes
1,850 Views
1 Reply
Reply (1)
Message 2 of 2

regalir
Autodesk
Autodesk

Hi,

the information is all inside the FBX file so, you have to read it completely in memory before you can query any data. After you have loaded the FBX file in memory, you are supposed to have an FbxScene object filled with all the data. At this point, if you just want all the textures names. you can do something like:

 

for (int i = 0, txCount = lScene->GetSrcObjectCount<FbxTexture>(); i < txCount; i++)
{
    FbxTexture* lTex = lScene->GetSrcObject<FbxTexture>(i);
    FbxString name = lText->GetName();
}

 

If you want to get the textures associated to a model, I strongly suggest you look at the ImportScene sample that is in the FBX SDK package. The work is slightly more complex because you have to get the material(s) from the geometries, then visit the material properties to find the FbxTexture objects connected.

 

Hope this helps

0 Likes