I'm trying to export the LOD data using FBX SDK(2016.1) from my application. When the exported model is loaded in FBX review I don't see any geometry loaded even though the file has some geometry. When loaded in Unreal, the product structure is not retained, the children of the LOD group are created outside LOD.
In Maya, the file is loaded but the LOD group is not connected to the camera, and with the following Python script, I'm able to overcome it.
from maya import cmds
lodList=cmds.ls(type='lodGroup')
for lod in lodList:
cmds.connectAttr( 'perspShape.worldMatrix', lod + '.cameraMatrix', f = True )
cmds.connectAttr( 'perspShape.focalLength', lod + '.focalLength', f = True )
Following is the C++ export code I'm using
FbxNode *lGroup = FbxNode::Create(pScene, “LOD_01”);
FbxLODGroup *lLodGroupAttr = FbxLODGroup::Create(pScene, “LOD_01”);
lLodGroupAttr->AddDisplayLevel(FbxLODGroup::eUseLOD);
lLodGroupAttr->AddThreshold(FbxDistance(500, FbxSystemUnit::mm));
lLodGroupAttr->AddDisplayLevel(FbxLODGroup::eUseLOD);
lLodGroupAttr->AddThreshold(FbxDistance(1000, FbxSystemUnit::mm));
lLodGroupAttr->AddDisplayLevel(FbxLODGroup::eUseLOD);
lLodGroupAttr->AddThreshold(FbxDistance(1500, FbxSystemUnit::mm));
lLodGroupAttr->AddDisplayLevel(FbxLODGroup::eUseLOD);
lLodGroup->SetNodeAttribute(lLodGroupAttr);
for (int j = 0; j < lChildNodes.GetCount(); j++)
{
lGroup ->AddChild(lChildNodes.GetAt(j));
}
Attached is the exported model.
Can someone kindly let me know what I'm missing here?
Thank you for the help.
Everything looks fine with your code / and the generated FBX file regarding the LOD definitions but I don't know how Unreal handles will actually handle the FbxLODGroup objects!
Based on the comments I found in the Maya code, there is some kind of logic for connecting the LOD group to the camera:
// if there are user perspective camera, we use the first one we find.
// otherwise, we connect the LOD group to the default "persp" camera
I tried to import your scene into Maya and I do see the effects of the LODGroup. However, Maya seems to ignore the units of the FbxDistance and just use the value() component as is. This means that your 500, 1000 and 1500 are interpreted as Maya's current units instead of being "converted" to these units. I will open a ticket to investigate this in Maya and, hopefully, have a better handling of these units in the future! I validated this by simply changing the units in Maya to millimeters.
As for the content of the file not showing in FBXReview, the reason is simple (and complex) at the same time! Because this program can only render triangles, it calls the FbxGeometryConverter::Triangulate() function to make sure that everything become triangulated meshes. This mean that even the NURB surfaces are converted to meshes. However, these is one big assumption made inside the Triangulate() function and it is that any FbxNodeAttribute that need to be converted (typically: FbxMesh, FbxNurbs, FbxNurbsSurface, FbxPatch) is connected to an FbxNode. This way, the result of the conversion can be re-connected to the FbxNode and "belong" to the scene.
In your case, however, you have the FbxNurbsSurface connected to another FbxNodeAttribute (FbxTrimNurbsSurface) and during the conversion, the resulting mesh cannot be connected to the scene. This explains why FbxReview does not show anything! Maya does not have this problem because it supports NURBS as is.
While it is allowed to connect a node attribute to another node attribute (or even more than one node attribute to the same node) in the FBX SDK, there may be programs that do not support these configurations. For this reason I suggest, when possible, that your program stays close to the generic approach that is to attach one single FbxNodeAttribute to an FbxNode only. This way, you are assured that your file(s) are compatible with more applications.
Hope this answer your questions
Regards
Can't find what you're looking for? Ask the community or share your knowledge.