diff --git a/src/osgPlugins/fbx/WriterNodeVisitor.cpp b/src/osgPlugins/fbx/WriterNodeVisitor.cpp index 203b6fc2f..ce159b623 100644 --- a/src/osgPlugins/fbx/WriterNodeVisitor.cpp +++ b/src/osgPlugins/fbx/WriterNodeVisitor.cpp @@ -13,20 +13,16 @@ */ #include -#include -#include #include -#include #include #include #include #include #include #include "WriterNodeVisitor.h" -#include -// Use namespace qualification to avoid static-link symbol collitions +// Use namespace qualification to avoid static-link symbol collisions // from multiply defined symbols. namespace pluginfbx { @@ -585,6 +581,7 @@ WriterNodeVisitor::setControlPointAndNormalsAndUV(const osg::Geode& geo, const osg::Array * basenormals = pGeometry->getNormalArray(); + if (basenormals && basenormals->getNumElements()>0) { KFbxVector4 normal; @@ -734,6 +731,9 @@ void WriterNodeVisitor::apply(osg::Geode& node) for (MaterialMap::iterator it = _materialMap.begin(); it != _materialMap.end(); ++it) it->second.setIndex(-1); _lastMaterialIndex = 0; + if(node.getStateSet()){ + pushStateSet(node.getStateSet()); + } for (unsigned int i = 0; i < count; ++i) { const osg::Geometry* g = node.getDrawable(i)->asGeometry(); @@ -743,7 +743,10 @@ void WriterNodeVisitor::apply(osg::Geode& node) createListTriangle(g, listTriangles, texcoords, i); popStateSet(g->getStateSet()); } - } + } + if(node.getStateSet()){ + popStateSet(node.getStateSet()); + } if (count > 0) { buildFaces(node, listTriangles, texcoords);