You can create properties directly to the FbxScene object (see code snippet) . Just be aware that an FBX reader that does not know about your custom properties will ignore them. Also, if you plan to write ASCII files, I strongly suggest you write your strings into an FbxBlob because the ascii parser has a limited string length that it can support (I believe around 4000 characters). Sure it is a little bit more of work and the strings are not readable until extracted, but you save yourself from creating corrupted FBX files 😉
FbxPropertyT<FbxString> lP = FbxProperty::Create(lScene, FbxStringDT, "PropOnScene");
lP.Set("a dynamic property directly on the scene");
The above code snipped will produce the following data in the FBX file:
; Documents Description
;------------------------------------------------------------------
Documents: {
Count: 1
Document: 1400889389744, "My Scene", "Scene" {
Properties70: {
P: "SourceObject", "object", "", ""
P: "ActiveAnimStackName", "KString", "", "", ""
P: "PropOnScene", "KString", "", "", "a dynamic property directly on the scene"
}
RootNode: 0
}
}
To get the property back, you can call FindProperty:
FbxProperty p = lScene->FindProperty("PropOnScene");
if (p.IsValid())
FBXSDK_printf("PropOnScene=%s\n", p.Get <FbxString>().Buffer());
Maybe, however, it may be more appropriate to add them to the FbxDocumentInfo object (it really depend on your goals). If you have more than one property, I also suggest that you attach them under a parent property. Something like this should work:
FbxDocumentInfo* lDocInfo = lScene->GetDocumentInfo();
if (lDocInfo)
{
FbxProperty lMyCustomPropertyGroup = FbxProperty::Create(lDocInfo, FbxCompoundDT, "MyCustomProperties");
FbxPropertyT<FbxString> lProp = FbxProperty::Create(lMyCustomPropertyGroup, FbxStringDT, "PropA");
lProp.Set("This is my first custom property string value");
lProp = FbxProperty::Create(lMyCustomPropertyGroup, FbxStringDT, "PropN");
lProp.Set("and a second string property");
}
and will produce:
SceneInfo: "SceneInfo::GlobalInfo", "UserData" {
Type: "UserData"
Version: 100
MetaData: {
Version: 100
Title: ""
Subject: ""
Author: ""
Keywords: ""
Revision: ""
Comment: ""
}
Properties70: {
P: "DocumentUrl", "KString", "Url", "", "c:\temp\customProp.fbx"
P: "SrcDocumentUrl", "KString", "Url", "", "c:\temp\customProp.fbx"
P: "Original", "Compound", "", ""
P: "Original|ApplicationVendor", "KString", "", "", ""
P: "Original|ApplicationName", "KString", "", "", ""
P: "Original|ApplicationVersion", "KString", "", "", ""
P: "Original|DateTime_GMT", "DateTime", "", "", ""
P: "Original|FileName", "KString", "", "", ""
P: "LastSaved", "Compound", "", ""
P: "LastSaved|ApplicationVendor", "KString", "", "", ""
P: "LastSaved|ApplicationName", "KString", "", "", ""
P: "LastSaved|ApplicationVersion", "KString", "", "", ""
P: "LastSaved|DateTime_GMT", "DateTime", "", "", ""
P: "MyCustomProperties", "Compound", "", ""
P: "MyCustomProperties|PropA", "KString", "", "", "This is my first custom property string value"
P: "MyCustomProperties|PropN", "KString", "", "", "and a second string property"
}
}
}