Currently I'm trying to add possibility to cancel importing big files during import via FBX SDK.
If I'm understand correctly I can cancel import operation via FbxProgress::Cancel. But there is no possibility to set up progress for FbxImporter - in public interface I see only a method for setting FbxProgressCallback.
But from the other hand I see that FbxReader has both methods (for setting progress and setting progress callback). Am I right that similar method for setting FbxProgress to FbxImporter should be available too?
Or I should user appropriate FbxReaders if I want to have possibility to cancel operation?
If I remember correctly, you just need to set the ProgressCallback function. The Importer have an internal FbxProgress class and will "hook" the callback to it. Your callback then need to return false when you want to 'Abort'. In the example below, the ProgressCallback instructs the importer to stop reading the incoming Fbx file when the pPercent value hits 50% (or above):
FbxImporter* importer = FbxImporter::Create(manager, "");
importer->SetProgressCallback(ProgressCallback);
bool ProgressCallback(void* pArgs, float pPercent, const char* pStatus)
{
FBX_UNUSED(pArgs);
FBXSDK_printf(pStatus && strlen(pStatus) > 0 ? "\r%0.2f%% (%s)" : "\r%0.2f%%%s", pPercent, pStatus);
return (pPercent < 50.0f) ? true : false;
}
At first I thought in the same way - but even if I will always return false import will succeed
With next callback method import won't be cancelled and everything from the file will be imported:
bool progress_callback(void*, const float, const char*)
{
return false;
}
I think I see what is going on.
The "cancel" functionality via the progress callback have been implemented for the FBX version 7.x. Previous versions (6.x and 5.x) have a much too old internal data structure to correctly interrupt the reading process. Even with version 7.x, you can still read some data until the return value of the progress is examined. At that moment, though, I guarantee that the reading process returns without any further processing.
Can't find what you're looking for? Ask the community or share your knowledge.