Community
FBX Forum
Welcome to Autodesk’s FBX Forums. Share your knowledge, ask questions, and explore popular FBX topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Big issue of FBX comverter when convert FBX to DAE.

1 REPLY 1
SOLVED
Reply
Message 1 of 2
42634690
1057 Views, 1 Reply

Big issue of FBX comverter when convert FBX to DAE.

In following circumstance:

* You want to convert a FBX model which contains animations to COLLADA format

* The scene graph node representing skeleton joint contains spaces

the issue occurs.

 

As above, when construct COLLADA element

<souce id="jointnamesource"....>

Name1 Name2 Name3 ......

</source>

<input source="jointnamesource" semantic="JOINT"/>

of vertex weights description,

current FBX converter will export spaces splitted name into such element.

for example:

given

<node type="JOINT" sid="left hand"/>

There will be

<source .....>

left      hand ......

</source>

 

It causes that when another collada parser parse this element, it cannot recognize the right joints list.

 

---------

 

My temporary solution is:

* Parse the scene graph first, take care of all node id/sid

* everytime read an item from such source, see if what current read is a prefix of any node, if so, continue read.

 

This solution is ineffective and exists problems.

 

---------

 

If you have any questions or  you have fixed this issue, please contact me: leslieleigh@outlook.com

 

1 REPLY 1
Message 2 of 2
regalir
in reply to: 42634690

Hi,

 

thank you for reporting this! We confirm that our DAE writer does not fully comply with the XML NCName schema that the Collada specifications is following (non alphanumeric & space characters unsupported - except the '_', '-' and '.'). We will investigate to see how we could deliver a global solution to this issue.

 

In the mean time, as a work around, may I suggest you write your converter and apply the FbxRenamingStrategyUtils::EncodeNonAlpha() to all the objects in the FBX scene prior to writing to DAE. The code below will do just that.

 

The code is a very simplified version of the ConvertScene sample that ships with the FBX SDK.

const char* lFileTypes[] = { "_dae.dae", "Collada DAE (*.dae)" };
int main(int argc, char** argv)
{
    FbxManager* lSdkManager = NULL;
    FbxScene* baseScene = NULL; // scene were we merge stuff into
    bool lResult = true;

    FbxString lFilePath = argv[1];

    // Prepare the FBX SDK.
    InitializeSdkObjects(lSdkManager, baseScene);
	
    FbxStatus mStatus;
    if (lResult && !lFilePath.IsEmpty())
	lResult = LoadScene(lSdkManager, baseScene, lFilePath.Buffer());

    if (lResult)
    {
	// replace all unsupported characters in object names
	FbxString permitted("-_.");
	for (int i = 0; i < baseScene->GetSrcObjectCount(); i++)
	{
	    FbxObject* o = baseScene->GetSrcObject(i);
	    FbxString name(o->GetName());
	    FbxRenamingStrategyUtils::EncodeNonAlpha(name, true, permitted, false);
	    o->SetName(name.Buffer());
	}

	// Retrieve the writer ID according to the description of file format.
	int lFormat = lSdkManager->GetIOPluginRegistry()->FindWriterIDByDescription(lFileTypes[1]);

	// Construct the output file name.
	const size_t lFileNameLength = strlen(lFilePath.Buffer());
	char* lNewFileName = new char[lFileNameLength + 64];
	FBXSDK_strcpy(lNewFileName, lFileNameLength + 64, lFilePath.Buffer());
	FBXSDK_strcpy(lNewFileName + lFileNameLength - 4, 60, lFileTypes[0]);

	lResult = SaveScene(lSdkManager, baseScene, lNewFileName, lFormat, true);
    }

    if(lResult == false)
    {
        FBXSDK_printf("\n\nAn error occurred ...\n");
        DestroySdkObjects(lSdkManager, lResult);
        return 0;
    }

    // Destroy all objects created by the FBX SDK.
    DestroySdkObjects(lSdkManager, lResult);

	return 0;	
}

The last argument to the EncodeNonAlpha() function allows to support wide chars as well as the 8 bit character.

The string: "Model::p Plane!1" will be converted to "pFBXCHR00020PlaneFBXCHR000211" if the wide char support is enabled and to "pFBXASC032PlaneFBXASC0331" with the 8 bit characters.

 

Because the names are all changed before calling the DAE writer, all the Collada scene will use the new names everywhere and you do not need to parse the Collada data to remove the spaces in the object names

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report