Re: [osg-users] Skipping nodes in serialization
I was pondering this the other day and it occurred to me that the problem boiled down to the fact that some (if not all) serializers do not write via a subclass of NodeVisitor, and hence are unaffected by nodemasks. I wondered if you could simply make your node so it is ONLY visible to NodeVisitor traversal by subclassing the node and overriding the traverse function. e.g. Code: class NonSerializedGroup : public osg::Group { public: UnserializedGroup(osg::Group* unserializedGroup) : _unserializedGroup(unserializedGroup) { } void traverse(osg::NodeVisitor& nv) { _unserializedGroup->traverse(nv); } osg::ref_ptr _unserializedGroup; } graffy wrote: > Hi, > > I have a graph that I serialize with a simple call to osgDB::writeNodeFile(), > but it contains a node that is auto-generated when the application starts. > Is there a way to exclude that node from serialization? I'm familiar with > the setNodeMask() / setTraversalMask() mechanism used in visitor classes, but > wasn't finding something similiar for serialization - nothing jumped out at > me in the ReaderWriter docs, anyway. > > ... > > Thank you! > > Cheers, > Joel -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42491#42491 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Skipping nodes in serialization
On Sat, 2011-09-03 at 13:01 +0200, Joel Graff wrote: > Hi, > > I have a graph that I serialize with a simple call to osgDB::writeNodeFile(), > but it contains a node that is auto-generated when the application starts. > Is there a way to exclude that node from serialization? I'm familiar with > the setNodeMask() / setTraversalMask() mechanism used in visitor classes, but > wasn't finding something similiar for serialization - nothing jumped out at > me in the ReaderWriter docs, anyway. It is really mind-boggling-ly easy to write a serializer wrapper. Here, I'll show you (this file is generally called LibraryWrapper.cpp): -- #include #include extern "C" void wrapper_serializer_library_myLibrary(void) { } REGISTER_OBJECT_WRAPPER( myLibrary_Object, new myLibrary::Object(), myLibrary::Object, "osg::Object osg::MatrixTransform myLibrary::Object" ) { } - As long as your object can be built after construction this will be a suitable workaround. If you want to actually serialize members, well, that's also incredibly easy (depending on what type of data they are). You can find some examples here: http://code.google.com/p/osgpango/source/browse/#svn%2Ftrunk%2Fsrc% 2Fserializers ...or all throughout the code in $OSG/src/osgWrappers/serializers/ > ... > > Thank you! > > Cheers, > Joel > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=42403#42403 > > > > > > ___ > 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
Re: [osg-users] Skipping nodes in serialization
Robert Osfield wrote on 2011-09-05: > There isn't a scheme for missing nodes during serialization. > > On Sat, Sep 3, 2011 at 12:01 PM, Joel Graff > wrote: >> Hi, >> >> I have a graph that I serialize with a simple call to > osgDB::writeNodeFile(), but it contains a node that is auto-generated > when the application starts. Is there a way to exclude that node from > serialization? I'm familiar with the setNodeMask() / > setTraversalMask() mechanism used in visitor classes, but wasn't > finding something similiar for serialization - nothing jumped out at me > in the ReaderWriter docs, anyway. Joel, You could try writing a WriteFileCallback and adding it to the osgDB::Registry which modifies the node mask, serializes the nodes, then restores the mask. This would cause problems if you were using the nodes elsewhere at the same time, though (such as for rendering). -- Bryan Thrall Principal Software Engineer FlightSafety International bryan.thr...@flightsafety.com ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Skipping nodes in serialization
Hi Joel, There isn't a scheme for missing nodes during serialization. Robert. On Sat, Sep 3, 2011 at 12:01 PM, Joel Graff wrote: > Hi, > > I have a graph that I serialize with a simple call to osgDB::writeNodeFile(), > but it contains a node that is auto-generated when the application starts. > Is there a way to exclude that node from serialization? I'm familiar with > the setNodeMask() / setTraversalMask() mechanism used in visitor classes, but > wasn't finding something similiar for serialization - nothing jumped out at > me in the ReaderWriter docs, anyway. > > ... > > Thank you! > > Cheers, > Joel > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=42403#42403 > > > > > > ___ > 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
[osg-users] Skipping nodes in serialization
Hi, I have a graph that I serialize with a simple call to osgDB::writeNodeFile(), but it contains a node that is auto-generated when the application starts. Is there a way to exclude that node from serialization? I'm familiar with the setNodeMask() / setTraversalMask() mechanism used in visitor classes, but wasn't finding something similiar for serialization - nothing jumped out at me in the ReaderWriter docs, anyway. ... Thank you! Cheers, Joel -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42403#42403 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org