diff --git a/src/osgPlugins/flt/CommentRecord.h b/src/osgPlugins/flt/CommentRecord.h index 6cf9d07e0..4b21ea2e6 100644 --- a/src/osgPlugins/flt/CommentRecord.h +++ b/src/osgPlugins/flt/CommentRecord.h @@ -20,8 +20,8 @@ namespace flt { struct SComment { - SRecHeader RecHeader; - // TODO + SRecHeader RecHeader; + char szComment[1]; // (Length - 4) ASCII ID of node }; diff --git a/src/osgPlugins/flt/flt2osg.cpp b/src/osgPlugins/flt/flt2osg.cpp index a8e94a0b7..9bc80bf48 100644 --- a/src/osgPlugins/flt/flt2osg.cpp +++ b/src/osgPlugins/flt/flt2osg.cpp @@ -58,6 +58,7 @@ #include "Input.h" #include "GeoSetBuilder.h" #include "LongIDRecord.h" +#include "CommentRecord.h" #include "InstanceRecords.h" #include "LocalVertexPoolRecord.h" #include "MultiTextureRecord.h" @@ -163,7 +164,7 @@ osg::Group* ConvertFromFLT::visitAncillary(osg::Group& osgParent, osg::Group& os break; case COMMENT_OP: -// visitComment(osgPrimary, (CommentRecord*)child); + visitComment(osgPrimary, (CommentRecord*)child); break; case COLOR_PALETTE_OP: @@ -333,6 +334,30 @@ void ConvertFromFLT::visitLongID(osg::Group& osgParent, LongIDRecord* rec) } +void ConvertFromFLT::visitComment(osg::Group& osgParent, CommentRecord* rec) +{ + SComment *pSComment = (SComment*)rec->getData(); + + //std::cout << "ConvertFromFLT::visitComment '"<szComment,pSComment->RecHeader.length()-4)<<"'"<szComment<<"'"<szComment; + char* eol; + int lineno = 1; + // add all lines followed by \n + while ( commentline && (eol = strchr( commentline, '\n' ) ) ) { + *eol = '\0'; + osgParent.addDescription( commentline ); + //std::cerr << "Line " << lineno << ": " << commentline << "\n"; + ++lineno; + commentline = ++eol; + } + // add the last line + osgParent.addDescription( commentline ); + //std::cerr << "Line " << lineno << ": " << commentline << "\n"; +} + + osg::Group* ConvertFromFLT::visitHeader(HeaderRecord* rec) { SHeader *pSHeader = (SHeader*)rec->getData(); diff --git a/src/osgPlugins/flt/flt2osg.h b/src/osgPlugins/flt/flt2osg.h index 0f3925199..fd88b6333 100644 --- a/src/osgPlugins/flt/flt2osg.h +++ b/src/osgPlugins/flt/flt2osg.h @@ -50,6 +50,7 @@ class LightPointRecord; class VertexListRecord; class LocalVertexPoolRecord; class LongIDRecord; +class CommentRecord; class InstanceDefinitionRecord; class InstanceReferenceRecord; class MultiTextureRecord; @@ -119,6 +120,7 @@ class ConvertFromFLT // Ancillary records osg::Group* visitMatrix(osg::Group& osgParent, const osg::Group& osgPrimary, MatrixRecord* rec); void visitLongID(osg::Group& osgParent, LongIDRecord* rec); + void visitComment(osg::Group& osgParent, CommentRecord* rec); // Palette records void visitColorPalette(osg::Group& osgParent, ColorPaletteRecord* rec);