fix fbx hierarchy issue

This commit is contained in:
Wei Lisi 2019-03-26 21:01:24 +08:00 committed by Robert Osfield
parent 6767ff540b
commit 82cae6daf4
2 changed files with 28 additions and 14 deletions

View File

@ -652,10 +652,10 @@ void WriterNodeVisitor::apply(osg::Geometry& geometry)
// retrieved from the geometry.
// create fbx node to contain the single geometry
FbxNode* parent = _curFbxNode;
FbxNode* nodeFBX = FbxNode::Create(_pSdkManager, geometry.getName().empty() ? "Geometry" : geometry.getName().c_str());
_curFbxNode->AddChild(nodeFBX);
_curFbxNode = nodeFBX;
//FbxNode* parent = _curFbxNode;
//FbxNode* nodeFBX = FbxNode::Create(_pSdkManager, geometry.getName().empty() ? "Geometry" : geometry.getName().c_str());
//_curFbxNode->AddChild(nodeFBX);
//_curFbxNode = nodeFBX;
_geometryList.push_back(&geometry);
@ -669,23 +669,33 @@ void WriterNodeVisitor::apply(osg::Geometry& geometry)
buildFaces(geometry.getName(), _geometryList, _listTriangles, _texcoords);
// return to parent fbx node
_curFbxNode = parent;
//_curFbxNode = parent;
}
void WriterNodeVisitor::apply(osg::Group& node)
{
FbxNode* parent = _curFbxNode;
if (_firstNodeProcessed)
{
FbxNode* parent = _curFbxNode;
FbxNode* nodeFBX = FbxNode::Create(_pSdkManager, node.getName().empty() ? "DefaultName" : node.getName().c_str());
_curFbxNode->AddChild(nodeFBX);
_curFbxNode = nodeFBX;
FbxNode* nodeFBX = FbxNode::Create(_pSdkManager, node.getName().empty() ? "DefaultName" : node.getName().c_str());
_curFbxNode->AddChild(nodeFBX);
_curFbxNode = nodeFBX;
traverse(node);
traverse(node);
if (_listTriangles.size() > 0)
buildFaces(node.getName(), _geometryList, _listTriangles, _texcoords);
if (_listTriangles.size() > 0)
buildFaces(node.getName(), _geometryList, _listTriangles, _texcoords);
_curFbxNode = parent;
_curFbxNode = parent;
}
else
{
_firstNodeProcessed = true;
traverse(node);
}
}
void WriterNodeVisitor::apply(osg::MatrixTransform& node)

View File

@ -86,7 +86,8 @@ class WriterNodeVisitor: public osg::NodeVisitor
_options(options),
_externalWriter(srcDirectory, osgDB::getFilePath(fileName), true, 0),
_texcoords(false),
_drawableNum(0)
_drawableNum(0),
_firstNodeProcessed(false)
{}
virtual void apply(osg::Geometry& node);
@ -234,6 +235,9 @@ class WriterNodeVisitor: public osg::NodeVisitor
///Tell us if the last apply succeed, useful to stop going through the graph.
bool _succeedLastApply;
///Marks if the first node is processed.
bool _firstNodeProcessed;
///The current directory.
std::string _directory;