Can't embed texture in output FBX file with fbxsdk

ivan6857
Community Visitor
Community Visitor

Can't embed texture in output FBX file with fbxsdk

ivan6857
Community Visitor
Community Visitor

I'm creating an FBX file and write it with texture. But when I want to move it on another PC the texture isn't loading because filepath for it has been obviously changed. I've decided to embed texture in FBX file. How can I do it? 

 

Now it works so:

auto aPhongSurface = fbxsdk::FbxSurfacePhong::Create (&theScene, "");

fbxsdk::FbxFileTexture* aFBXTexture = fbxsdk::FbxFileTexture::Create (&theScene, "");

aFBXTexture->SetTextureUse (fbxsdk::FbxTexture::eStandard);
aFBXTexture->SetSwapUV (false);
aFBXTexture->SetMaterialUse (fbxsdk::FbxFileTexture::eModelMaterial);
aFBXTexture->SetAlphaSource (fbxsdk::FbxTexture::eNone);

aPhongSurface .Diffuse.ConnectSrcObject (a);

theNode.AddMaterial (aPhongSurface);

 

Also during writing I use

theTarget.SetBoolProp (EXP_FBX_TEXTURE, true);

 

But output model still contained only path references without embedded texture image.

 

0 Likes
Reply
373 Views
5 Replies
Replies (5)

J450NP13
Advisor
Advisor
 fbxManager.GetIOSettings().SetBoolProp(Globals.EXP_FBX_EMBEDDED, true);
0 Likes

matcarbo838P8
Explorer
Explorer

Hello,

I tried exporting a model with non embedded texture using one of the examples (in particular ExportScene03) 

with those options above, but no media were embedded in the output file.

I modified the example using this call in order to try embedding the texture:

SaveScene(pManager, pScene, filepath, pFileFormat=0, pEmbedMedia=true)
It did not work. Any suggestions?
Thanks.
0 Likes

regalir
Autodesk
Autodesk

The ExportScene03 sample worked for me when I set pEmbedMedia=true. You just need to be sure that the image files can be resolved. In this example, the file names of the textures being specified as: "scene03.jpg", "gradient.jpg" and "spotty.jpg", the FBX SDK will try to find them from the current executable directory (you can see it as "./scene03.jpg"). Depending on how you are setup when building  & executing the sample, it is possible that the jpg files are not in the "working" directory. For example, if you are inside VisualStudio, make sure that the "Working Directory" in the "Debug" tab of the project is set to the same value as the "Output Directory" in the "General" tab.

J450NP13
Advisor
Advisor

I am using this in Unity, so it is a little different, but same concept.  I am iterating through the models being exported and grabbing all the materials and texture files.   Obviously they have to be specific and the path needs to be correct to them.

0 Likes

matcarbo838P8
Explorer
Explorer

Ok thanks I found that my images were in a wrong absolute file path.

I put them in the correct file path and now external media are embedded.