Does FBX exporter support utf-8 encoding when exporting to .obj?

Does FBX exporter support utf-8 encoding when exporting to .obj?

Anonymous
Not applicable
1,604 Views
3 Replies
Message 1 of 4

Does FBX exporter support utf-8 encoding when exporting to .obj?

Anonymous
Not applicable

Using the same piece of code to export the same piece of geometry as both .fbx and .obj, I encountered a problem where the geometry name (UTF-8 encoded, partially in Russian: "Basicстена") does not get exported properly and all non-ASCII characters become '_'. All documentation points to FBX supporting UTF-8 encoded strings (link). What I'm uncertain about is whether this applies to exporting a .obj file. Has anyone encountered the same problem and am I missing something here?

 

Very modified code snippet below:

 

    #include <string>
    #include <sstream>
    #include <codecvt>
    #include <fbxsdk.h>

    void main()
    {
        std::string zFilename = "test.obj";
    	std::wstring wzNodeName = L"Basicстена";
	std::stringstream oss;
        std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> convert;
        oss << convert.to_bytes( wzNodeName );
	std::string zNodeName = oss.str();

        fbxsdk::FbxManager fbxManager = fbxsdk::FbxManager::Create();
        if ( !fbxManager ) return;

	fbxsdk::FbxIOSettings* pIOSettings = fbxsdk::FbxIOSettings::Create( fbxManager, IOSROOT );
	if ( !pIOSettings ) return;
	fbxManager->SetIOSettings( pIOSettings );

	fbxsdk::FbxExporter* pExporterTest = fbxsdk::FbxExporter::Create( fbxManager, "" );

	pExporterTest->SetFileExportVersion( FBX_2016_00_COMPATIBLE );
	
        // Create dummy scene with geometry to export
	fbxsdk::FbxScene* pSceneTest = fbxsdk::FbxScene::Create( fbxManager, "testscene" );
	fbxsdk::FbxNode * pNodeTest = fbxsdk::FbxNode::Create( pSceneTest, zNodeName.c_str() );
	fbxsdk::FbxMesh* pMeshTest = fbxsdk::FbxMesh::Create( pSceneTest, "testmesh" );
	pNodeTest->SetNodeAttribute( pMeshTest );
	fbxsdk::FbxNode* pRootNodeTest = pSceneTest->GetRootNode();
	pRootNodeTest->AddChild( pNodeTest );

        // Initialize to export as .fbx file:
	pExporterTest->Initialize( zFilename.c_str(), 1, fbxManager->GetIOSettings() );
	pExporterTest->Export( pSceneTest );

        // Initialize to export based on detected extension (.obj file):
	pExporterTest->Initialize( zFilename.c_str(), -1, fbxManager->GetIOSettings() );
	pExporterTest->Export( pSceneTest );

        // Clean-up
    	pSceneTest->Destroy( true );
	pExporterTest->Destroy( true );
        fbxManager->Destroy();
        return;
    }

 

In the .fbx file I see this near the bottom of the file:

 

    Objects:  {
    	Geometry: 2212458999648, "Geometry::testmesh", "Mesh" {
    	}
    	Model: 2212447434112, "Model::Basicстена", "Mesh" {
    		Version: 232
    		Properties70:  {
    			P: "ScalingMax", "Vector3D", "Vector", "",0,0,0
    			P: "DefaultAttributeIndex", "int", "Integer", "",0
    		}
    		Shading: Y
    		Culling: "CullingOff"
    	}
    }
    
    ; Object connections

 

and in the .obj file I see:

 

# 
# Wavefront OBJ file
# Created with Kaydara FBX
# 
g Basic__________

 

0 Likes
Accepted solutions (1)
1,605 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

I do not know the official OBJ spec (if it exists), but OBJ is a really old format. There is a good chance FBX replaces every non-ASCII letter with an underscore for compatibility reasons towards other software.

Message 3 of 4

regalir
Autodesk
Autodesk
Accepted solution

The OBJ specification does not provide a mechanism to identify the encoding of the strings (Wavefront OBJ specification: http://www.martinreddy.net/gfx/3d/OBJ.spec) therefore, as Loebl wrote, for compatibility reasons, all non ascii characters are replaced with the underscore.

 

if the FBX was just writing the string as UTF8, any program that would read the OBJ file would not know that the received strings need to be interpreted as UTF8 so it would be impossible to figure out if the word A_éàîç is the actual string defined with these characters or if, instead, would represent the word: A_éàîç

 

 

 

 

0 Likes
Message 4 of 4

Anonymous
Not applicable

Thank you for your responses! That clears things up for me. Will this be something that is going to or needs to be changed?

0 Likes