|
Hi Nian,
I’m also having trouble getting KFbxTrimNurbsSurfaces save to my file. Here’s the function I’m using and a snippet of the code that calls it.
KFbxTrimNurbsSurface* CFBXExporter::ConvertTrimmedNurbsSurface(KFbxNode* pRootNode, const ON_Brep* pBrep, const int& faceidx)
{
if (0 == pBrep || 0 > faceidx || pBrep->m_F.Count() <= faceidx)
return 0;
KFbxTrimNurbsSurface* pFBXtrimsurf = KFbxTrimNurbsSurface::Create(m_pSdkManager, “");
if (0 == pFBXtrimsurf)
return 0;
const ON_BrepFace& face = pBrep->m_F[faceidx];
ON_NurbsSurface surf;
if (0 == pBrep->m_F[faceidx].GetNurbForm(surf))
return 0;
KFbxNurbsSurface* pFBXSurf = ConvertNurbsSurface(surf);
if (0 == pFBXSurf)
return 0;
ON_String surfname;
surfname.Format("Test_Surf");
KFbxNode* pFbxNode = KFbxNode::Create(m_pSdkManager, surfname.Array());
if (0 == pFbxNode)
return 0;
pFbxNode->AddNodeAttribute(pFBXSurf);
pRootNode->AddChild(pFbxNode);
pFBXtrimsurf->SetNurbsSurface(pFBXSurf);
int l, loopct = face.LoopCount();
int t, trimct;
ON_SimpleArray <KFbxBoundary*> FBXboundaryArray;
for (l=0; loopct > l; l++)
{
KFbxBoundary* pFBXboundary = KFbxBoundary::Create(m_pSdkManager, “");
if (0 == pFBXboundary)
return 0;
const ON_BrepLoop& loop = pBrep->m_L[l];
if (ON_BrepLoop::outer == loop.m_type)
pFBXboundary->OuterFlag.Set(true);
else
pFBXboundary->OuterFlag.Set(false);
trimct = loop.TrimCount();
for(t=0; trimct > t; t++)
{
ON_NurbsCurve trimcurve;
if (0 != pBrep->m_T[loop.m_ti[t]].ProxyCurve())
pBrep->m_T[loop.m_ti[t]].ProxyCurve()->GetNurbForm(trimcurve, 0.0, &pBrep->m_T[loop.m_ti[t]].ProxyCurveDomain());
KFbxNurbsCurve* pFBXCrv = ConvertNurbsCurve(trimcurve);
if (0 == pFBXCrv)
return 0;
ON_String crvname;
crvname.Format("Test_Loop_%d_Curve_%d", l, t);
pFbxNode = KFbxNode::Create(m_pSdkManager, crvname.Array());
if (0 == pFbxNode)
return 0;
pFbxNode->AddNodeAttribute(pFBXCrv);
pRootNode->AddChild(pFbxNode);
pFBXboundary->AddCurve(pFBXCrv);
}
pFbxNode = KFbxNode::Create(m_pSdkManager, 0);
if (0 == pFbxNode)
return 0;
ON_String loopname;
loopname.Format("Test_Loop_%d", l);
pFbxNode->AddNodeAttribute(pFBXboundary);
FBXboundaryArray.Append(pFBXboundary);
pRootNode->AddChild(pFbxNode);
}
pFBXtrimsurf->BeginTrimRegion();
loopct = FBXboundaryArray.Count();
for (l=0; loopct > l; l++)
pFBXtrimsurf->AddBoundary(FBXboundaryArray[l]);
pFBXtrimsurf->EndTrimRegion();
return pFBXtrimsurf;
}
KFbxTrimNurbsSurface* pFBXTrimSurf = ConvertTrimmedNurbsSurface(pRootNode, pBrep, i);
if (0 == pFBXTrimSurf)
return false;
ON_String trimsrfname;
trimsrfname.Format("Test_TrimSrf");
KFbxNode* pFbxNode = KFbxNode::Create(m_pSdkManager, trimsrfname.Array());
if (0 == pFbxNode)
return false;
pFbxNode->AddNodeAttribute(pFBXTrimSurf);
pRootNode->AddChild(pFbxNode);
The functions that create the KFbxNurbsSurface and the KFbxNurbsCurve work fine (I get good curves and surfaces in the file, I can post the code to those if you think it makes a difference. I see the surface, trim curves and boundary(ies) in the file but the node labeled Test_TrimSrf shows up as a null node and it only shows up in the connections linking it to the root node. Can you help me figure out what I might be doing wrong. Thanks.
Tim
Author: TimHemmelman
|