我的C ++应用程序能够导出FbxMesh对象。网格显示在几个不同的查看器中(MS 3D Viewer,AutoDesk的FBX Review,SAP 3D Viewer)。我正在导出一个FbxLine对象,该对象在代码中没有错误,但是在任何这些查看器中都没有出现。
我能够在查看器的对象列表中看到“线”节点,但看不到实际的线。我给该行添加了一种颜色(红色),以为它已设置为背景色,但无济于事。
如果我导出到基于文本的FBX文件,则可以看到该行的定义。
在AutoDesk帮助论坛(http://help.autodesk.com/view/FBX/2019/ENU/?caas=caas/discussion/t5/FBX-Forum/How-to-Export-FbxLine-structure-/td-p/7749696.html)上只有一篇帖子,但是我的代码正在执行所有这些步骤。
//This is the important calls I make to try and export a FbxLine object
m_fbxSdkManager = FbxManager::Create();
FbxIOSettings *theIOSettings = FbxIOSettings::Create( m_fbxSdkManager, IOSROOT );
m_fbxSdkManager->SetIOSettings(theIOSettings);
m_fbxScene = FbxScene::Create( m_fbxSdkManager, "ExportScene" );
FbxNode* theRootNode = m_fbxScene->GetRootNode();
FbxNode* fbxNode = FbxNode::Create( m_fbxSdkManager, "LineNode");
if(fbxNode)
{
for ( const auto& theLine : aLineList )
{
FbxLine* fbxLine = FbxLine::Create( m_fbxScene, "Line" );
if(fbxLine)
{
//which call to use???
//FbxNodeAttribute* OldNode = fbxNode->SetNodeAttribute(fbxLine);
//or this one, as shown in the sdk documentation
FbxStatus pStatus;
bool OK = fbxNode->AddNodeAttribute( fbxLine, &pStatus );
//Always returns ok == true
uint32 NumPoints = theLine.size();
fbxLine->InitControlPoints(NumPoints);
fbxLine->SetIndexArraySize(NumPoints);
fbxLine->Color = FbxDouble3(1.0, 0.0, 0.0);
for ( uint32 kk = 0; kk < NumPoints; ++kk )
{
FbxVector4 pCtrlPoint =
ToFbxPoint(theLine.getVertex(kk));
//ToFbxPointadds vetrices base on Z-UP or Y-UP orientation
fbxLine->SetControlPointAt(pCtrlPoint , kk);
fbxLine->SetPointIndexAt(kk, kk, kk == (NumPoints-1) );
//last point is marked as an end point by sending TRUE
}
}
}
}
theRootNode->AddChild(fbxNode);
///....snip
// Create an exporter.
theExporter = FbxExporter::Create( m_fbxSdkManager, "" );
// Set any IO settings that may need to be adjusted.
FbxIOSettings* ios = m_fbxSdkManager->GetIOSettings();
if (nullptr != ios)
{
ios->SetBoolProp( EXP_FBX_EMBEDDED, aOpts.m_embedTexture );
}
// Initialize the exporter by providing a filename.
if ( theExporter->Initialize( mFilename, aOpts.m_exportFormat, ios ) )
{
isOK = theExporter->Export( m_fbxScene );
}
我希望在FBX查看器中看到该行,但是它们不会显示。我导出的网格显示得很好。作为一种变通方法,我可以将线导出为网格,但是不必这样做!