Hi Robert, First, happy new year to everyone in the OSG community! :)
I'd like to announce the latest progress of the new extensible
ascii/binary native format, which is named osgdb_bin temporarily at
present. At the end of last year, I spent some time studying the
serialization mechanism of VPB and modified my code day and night, and
finally implemented the third version of this plugin, which should be
more readable and robust than the last one, which uses the >> and <<
operators for I/O directly.
The plugin now uses a series of serialization classes for
reading/writing ascii and binary streams. For example, the Object and
Node class wrappers could be written like this:
REGISTER_OBJECT_WRAPPER( Object, // Marker name
/*new osg::Object*/NULL, // Proto
osg::Object, // Class name
"osg::Object" ) // Class associates
{
ADD_STRING_SERIALIZER( Name, "" ); // _name
BEGIN_ENUM_SERIALIZER( DataVariance, UNSPECIFIED );
ADD_ENUM_VALUE( STATIC );
ADD_ENUM_VALUE( DYNAMIC );
ADD_ENUM_VALUE( UNSPECIFIED );
END_ENUM_SERIALIZER(); // _dataVariance
}
REGISTER_OBJECT_WRAPPER( Node,
new osg::Node,
osg::Node,
"osg::Object osg::Node" )
{
ADD_USER_SERIALIZER( InitialBound ); // _initialBound
ADD_OBJECT_SERIALIZER( UpdateCallback, osg::NodeCallback, NULL );
// _updateCallback
ADD_OBJECT_SERIALIZER( EventCallback, osg::NodeCallback, NULL );
// _eventCallback
ADD_OBJECT_SERIALIZER( CullCallback, osg::NodeCallback, NULL );
// _cullCallback
ADD_BOOL_SERIALIZER( CullingActive, true ); // _cullingActive
ADD_UINT_SERIALIZER( NodeMask, 0xffffffff ); // _nodeMask
ADD_USER_SERIALIZER( Descriptions ); // _descriptions
ADD_OBJECT_SERIALIZER( StateSet, osg::StateSet, NULL ); // _stateset
}
A lot of macros are used to quickly add serializers to the wrapper,
which helps realize I/O operations of strings, booleans, integers,
enumerations, objects and user defined variables. It should make
wrappers clear to read and easy to write, which is already done in the
VPB::BuildOptionsIO class.
But for the whole OSG functionalities, common serializers are
certainly not enough. I define a ADD_USER_SERIALIZER macro to accept
user-defined checker, reader and writer functions. For instance,
ADD_USER_SERIALIZER(InitialBound) means to save the address of
checkInitialBound(), readInitialBound() and writeInitialBound()
entries and use them at the right time. This is much more complex than
common ones, but should be able to handle all kinds of OSG classes.
Another important modification is a initial support of the class'
properties schema, that is, record the writing sequence of methods of
each wrapped classes, and use it as a reference while reading. It will
help improve the backward-compatibility and forward-compatibility of
the plugin in the future.
I also make the plugin try to load external libraries to find
unrecognizable wrapper names, like osgdb_osgText for the wrapper name
"osgText::Text".
Last but not least, I've done a simple performance test of current
osgdb_ive plugin, which includes only a few wrapper classes but could
work well with some existing models. I got a .ive file and a .bin
binary file converted from the original dumptruck.osg, and read them
for 1000 times on an Intel Core2 E6550 and GeForce 8600 GTS computer:
The IVE: an average of 1232.24ms; and the BIN: 1239.54ms. The
difference seems acceptable, but needs more public tests.
To output a binary scene file (with or without writing schema):
./osgconv dumptruck.osg dumptruck.bin
./osgconv dumptruck.osg dumptruck.bin -O SchemaFile=test_schema.txt
And an ascii one:
./osgconv dumptruck.bin -O Ascii
I will automatically check the ascii/binary format now while viewing
the model (with or without schema).
./osgviewer dumptruck.bin
./osgviewer dumptruck.bin -O SchemaFile=test_schema.txt
Next, I'd like to go on finishing all the core classes and be ready to
submit it to osg-submissions. I'm also thinking of having it support
xml later. So what's your opinion? Do you have a better name for the
new format? :)
Cheers,
Wang Rui
osgdb_bin.tar.gz
Description: GNU Zip compressed data
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

