Hi J-S, The dotosg wrapper / serializer recognizes classes from there class names. These should be defined with the className() method (or META_Node macro) and the writing processor in osgDB will try to find a wrapper corresponding to the name. If found, the node will be written to files; otherwise the unknown node and its subgraph will be skipped. It can't decide if the OceanScene is derived from osg::Group without a name-wrapper map recorded in the Registry object.
The ive plugin is not limited in this way, because it implements read()/write() virtual functions for all common scene elements, but it must have all the libraries as dependencies and is hard to extend. Adding and implementing read()/write() virtual methods for all OSG classes may be better for serialization IO, but it will certainly cause changes to almost all source files and be completely a pain for future debugging and compatibility tests. Do you mind if I could have time to help finish the serializers of the osgOcean project someday? :-) Cheers, Wang Rui 2010/12/1 Jean-Sébastien Guay <jean-sebastien.g...@cm-labs.com>: > Hello all, > > I noticed when doing osgDB::writeNodeFile to .osg file with an > osgOcean::OceanScene in the graph, the written graph stops at that node, > i.e. that node and all its children (it is a subclass of osg::Group) are not > in the file. > > I would think that even if no wrapper / serializer exists for this node > type, it should be writable as its base class type (osg::Group)... Is this > not what's supposed to happen? > > Initially, the OceanScene class didn't use the META_Node(library, class) > macro, and I thought that was why it couldn't be saved even as its base > class type (or any node type). But I changed the header to use the macro, > and it still isn't written. > > I know the best thing would be to provide a serializer / osgdb_osgOcean > plugin to be able to write and read the exact type and its members from .osg > files (and other types). But what is the minimum I need to do so that at > least, the writeNodeFile() traversal will traverse it as an osg::Group and > write its children? > > Is there a way to write a callback that would be called for unknown node > types, and from which I could static_cast<osg::Group*> and then traverse > that, which would resolve the base class type correctly? > > I even checked the OceanScene::traverse() method, and it is written as: > > void OceanScene::traverse( osg::NodeVisitor& nv ) > { > if( nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR ) > { > //... > } > else if (nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR) > { > //... > } > else > osg::Group::traverse(nv); > } > > So I would have thought that would let the writeNodeFile() do its work as if > it were an osg::Group... > > Thanks in advance, > > J-S > -- > ______________________________________________________ > Jean-Sebastien Guay jean-sebastien.g...@cm-labs.com > http://www.cm-labs.com/ > http://whitestar02.webhop.org/ > _______________________________________________ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org