diff --git a/src/osgPlugins/ac/Geode.cpp b/src/osgPlugins/ac/Geode.cpp index 974d05aef..5a1953391 100644 --- a/src/osgPlugins/ac/Geode.cpp +++ b/src/osgPlugins/ac/Geode.cpp @@ -162,6 +162,28 @@ void Geode::OutputPolygon(const int iCurrentMaterial, const unsigned int surface } } //======= draw array length cases +void Geode::OutputLineDARR(const int iCurrentMaterial, const unsigned int surfaceFlags, + const osg::IndexArray *pVertexIndices, const osg::Vec2 *pTexCoords, const osg::IndexArray *pTexIndices,const osg::DrawArrayLengths* drawArrayLengths, ostream& fout) +{ + unsigned int vindex = drawArrayLengths->getFirst(); + for(osg::DrawArrayLengths::const_iterator primItr = drawArrayLengths->begin(); primItr end(); ++primItr) + { + unsigned int localPrimLength; + localPrimLength = 2; + + for(GLsizei primCount = 0; primCount < *primItr; ++primCount) + { + if ((primCount%localPrimLength)==0) + { + OutputSurfHead(iCurrentMaterial,surfaceFlags,localPrimLength, fout); + } + OutputVertex(vindex, pVertexIndices, pTexCoords, pTexIndices, fout); + ++vindex; + } + + } +} + void Geode::OutputTriangleDARR(const int iCurrentMaterial, const unsigned int surfaceFlags, const osg::IndexArray *pVertexIndices, const osg::Vec2 *pTexCoords, const osg::IndexArray *pTexIndices,const osg::DrawArrayLengths* drawArrayLengths, ostream& fout) { @@ -183,6 +205,7 @@ void Geode::OutputTriangleDARR(const int iCurrentMaterial, const unsigned int su } } + void Geode::OutputQuadsDARR(const int iCurrentMaterial, const unsigned int surfaceFlags, const osg::IndexArray *pVertexIndices, const osg::Vec2 *pTexCoords, const osg::IndexArray *pTexIndices,const osg::DrawArrayLengths* drawArrayLengths, ostream& fout) { @@ -980,6 +1003,9 @@ void Geode::ProcessGeometry(ostream& fout, const unsigned int ioffset) const osg::DrawArrayLengths* drawArrayLengths = static_cast(primitiveset); switch(mode) { + case(osg::PrimitiveSet::LINES): + OutputLineDARR(iCurrentMaterial,surfaceFlags, pVertexIndices, pTexCoords, pTexIndices, drawArrayLengths, fout); + break; case(osg::PrimitiveSet::TRIANGLES): OutputTriangleDARR(iCurrentMaterial,surfaceFlags, pVertexIndices, pTexCoords, pTexIndices, drawArrayLengths, fout); break; diff --git a/src/osgPlugins/ac/Geode.h b/src/osgPlugins/ac/Geode.h index f080f0c47..acf86744a 100644 --- a/src/osgPlugins/ac/Geode.h +++ b/src/osgPlugins/ac/Geode.h @@ -31,6 +31,8 @@ namespace ac3d void OutputPolygon(const int iCurrentMaterial,const unsigned int surfaceFlags, const osg::IndexArray *pVertexIndices, const osg::Vec2 *pTexCoords, const osg::IndexArray *pTexIndices,const osg::DrawArrays* drawArray, std::ostream& fout); //== output for prims with draw array lengths + void OutputLineDARR(const int iCurrentMaterial,const unsigned int surfaceFlags, + const osg::IndexArray *pVertexIndices, const osg::Vec2 *pTexCoords, const osg::IndexArray *pTexIndices,const osg::DrawArrayLengths* drawArrayLengths, std::ostream& fout); void OutputTriangleDARR(const int iCurrentMaterial,const unsigned int surfaceFlags, const osg::IndexArray *pVertexIndices, const osg::Vec2 *pTexCoords, const osg::IndexArray *pTexIndices,const osg::DrawArrayLengths* drawArrayLengths, std::ostream& fout); void OutputTriangleStripDARR(const int iCurrentMaterial,const unsigned int surfaceFlags, diff --git a/src/osgPlugins/ac/ac3d.cpp b/src/osgPlugins/ac/ac3d.cpp index 1d727e1bd..de6a6e884 100644 --- a/src/osgPlugins/ac/ac3d.cpp +++ b/src/osgPlugins/ac/ac3d.cpp @@ -127,13 +127,30 @@ class ReaderWriterAC : public osgDB::ReaderWriter std::vector::iterator itr; fout << "AC3Db" << std::endl; // output the Materials - for (itr=glist.begin();itr!= glist.end();itr++) { + int iNumGeodesWithGeometry = 0; + for (itr=glist.begin();itr!= glist.end();itr++) + { iNumMaterials.push_back(const_cast(static_cast(*itr))->ProcessMaterial(fout,itr-glist.begin())); + unsigned int iNumDrawables = (*itr)->getNumDrawables(); + int iNumGeometries = 0; + for (unsigned int i = 0; i < iNumDrawables; i++) + { + const osg::Drawable* pDrawable = (*itr)->getDrawable(i); + if (NULL != pDrawable) + { + const osg::Geometry *pGeometry = pDrawable->asGeometry(); + if (NULL != pGeometry) + iNumGeometries++; + } + if (iNumGeometries > 0) + iNumGeodesWithGeometry++; + } } // output the Geometry unsigned int nfirstmat=0; fout << "OBJECT world" << std::endl; - fout << "kids " << (glist.end()-glist.begin()) << std::endl; + + fout << "kids " << iNumGeodesWithGeometry << std::endl; for (itr=glist.begin();itr!= glist.end();itr++) { const_cast(static_cast(*itr))->ProcessGeometry(fout,nfirstmat); nfirstmat+=iNumMaterials[itr-glist.begin()];