c++ – Is it possible to create a camera when exporting with fbx sdk (2020)?

I tried writing the code as below, but I can’t create a camera successfully. Is it possible to create a new camera when exporting?

#include <fbxsdk.h>
#include <fbxfilesdk/fbxio/fbxiosettings.h>

// Create the FBX SDK manager
FbxManager* lSdkManager = FbxManager::Create();

// Create an IOSettings object.
FbxIOSettings * ios = FbxIOSettings::Create(lSdkManager, IOSROOT );
lSdkManager->SetIOSettings(ios);

// ... Configure the FbxIOSettings object here ...

// Create an exporter.
FbxExporter* lExporter = FbxExporter::Create(lSdkManager, "");

// Declare the path and filename of the file to which the scene will be exported.
// In this case, the file will be in the same directory as the executable.
const char* lFilename = "file.fbx";

// Initialize the exporter.
bool lExportStatus = lExporter->Initialize(lFilename, -1, lSdkManager->GetIOSettings());


if(!lExportStatus) {
    printf("Call to FbxExporter::Initialize() failed.\n");
    printf("Error returned: %s\n\n", lExporter->GetStatus().GetErrorString());
    return false;
}

// Create a new scene so it can be populated by the imported file.
FbxScene* lScene = FbxScene::Create(lSdkManager,"myScene");

Here is the code that declares the creation of a new camera.

// Create a new Camera
FbxCamera* testCamera = FbxCamera::Create(lScene, "");
testCamera->SetFormat(FbxCamera::eHD);
FbxNode* myCameraNode = FbxNode::Create(lScene,"");
myCameraNode->SetNodeAttribute(testCamera);
FbxNode* myRootnode = lScene->GetRootNode();
myRootnode->AddChild(myCameraNode);

Then run the export as is.

// Export the scene to the file.
lExporter->Export(lScene);

Read more here: Source link