我尝试编写如下代码,但我无法成功创建相机。导出时是否可以创建新相机?
#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");
这里是声明创建新相机的代码。
// Create a new Camera
FbxCamera* testCamera = FbxCamera::Create(lScene, "");
testCamera->SetFormat(FbxCamera::eHD);
FbxNode* myCameraNode = FbxNode::Create(lScene,"");
myCameraNode->SetNodeAttribute(testCamera);
FbxNode* myRootnode = cScene->GetRootNode();
myRootnode->AddChild(myCameraNode);
然后按原样运行导出。
// Export the scene to the file.
lExporter->Export(lScene);