OpenSceneGraph icon indicating copy to clipboard operation
OpenSceneGraph copied to clipboard

osg2/osgt serializer issues

Open dstephan1 opened this issue 9 years ago • 5 comments

I've been trying to follow the serialization guide http://trac.openscenegraph.org/projects/osg//wiki/Support/KnowledgeBase/SerializationSupport and have been having a few issues.

I'm using OSG 3.4.0 built on Visual Studio 2015 64-bit. I've been testing with the cow.osg model.

This export doesn't seem to work. The output is equivalent to the .osgb export.

osgDB::ReaderWriter* rw = osgDB::Registry::instance()->getReaderWriterForExtension("osgt");
if (rw)
{
    rw->writeNode(*node, ostream, new osgDB::Options("Ascii"));
}

This works

osgDB::writeNodeFile(*node, "cow.osgt");

This also works

osgconv cow.osg cow.osgt

However, both .osgt files have buggy indentation.

dstephan1 avatar Apr 04 '17 18:04 dstephan1

The ReaderWriterOSG2.cpp checks against osgDB::Options::getPluginStringata("fileType") so to select the ascii variant the following would be appropriate.

osgDB::Options* options = new osgDB::Options; options->setPluginStringData("fileType", "Ascii");

It looks like code might also support using, osgDB::Options("fileType=Ascii")) but don't recall testing this approach. We are talking usage cases that aren't used too often.

What do you mean buggy indentation? Indentation is purely cosmetic in the .osg* formats.

robertosfield avatar Apr 04 '17 19:04 robertosfield

osgDB::Options* options = new osgDB::Options;
options->setPluginStringData("fileType", "Ascii");

This works great! Thanks. Perhaps update the guide?

About the indentation - sample results of osgconv cow.osg cow.osgt. Some lines are indented, some are not

#Ascii Scene 
#Version 130 
#Generator OpenSceneGraph 3.4.0 

osg::Group {
  UniqueID 1 
  Name "cow.osg" 
DataVariance STATIC 
Children 1 {
osg::Geode {
      UniqueID 2 
      Name "cow.osg" 
DataVariance DYNAMIC 
Drawables 1 {
osg::Geometry {
          UniqueID 3 
          DataVariance DYNAMIC 
StateSet TRUE {
osg::StateSet {
              UniqueID 4 
              DataVariance STATIC 
ModeList 2 {
GL_CULL_FACE OFF 
GL_LIGHTING ON 
}
...
}
}
          }
}
      }
}
  }
}

dstephan1 avatar Apr 04 '17 19:04 dstephan1

Update "the guide", there are lots of OSG resources, could you be specific, i.e url?

I haven't see indentation issues like you describe before. Curious. It might be worth you trying out the OSG-3.4 branch or OSG master as both have lots of fixes over 3.4.0.

As a general note, for support issues the official avenue is the OSG mailing list/forum, the github Issues actively viewed by many in the community.

robertosfield avatar Apr 04 '17 20:04 robertosfield

http://trac.openscenegraph.org/projects/osg//wiki/Support/KnowledgeBase/SerializationSupport

Thanks again

dstephan1 avatar Apr 04 '17 20:04 dstephan1

That's the old website we've kept around in case we missed parts when moving it across to the new website. This was all done a number of years back so it's time we just removed the old website.

I've checked the new website and the same content was wrong as well so I've updated this.

robertosfield avatar Apr 05 '17 06:04 robertosfield