From Wang Rui, new native binary/ascii format infrastructure and wrappers.
From Robert Osfield, refactor of Wang Rui's original osg2 into 3 parts - parts placed into osgDB, the ReaderWriter placed into src/osg/Plugin/osg and wrappers into src/osgWrappers/serializers/osg
This commit is contained in:
41
src/osgWrappers/serializers/osg/Geode.cpp
Executable file
41
src/osgWrappers/serializers/osg/Geode.cpp
Executable file
@@ -0,0 +1,41 @@
|
||||
#include <osg/Geode>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
static bool checkDrawables( const osg::Geode& node )
|
||||
{
|
||||
return node.getNumDrawables()>0;
|
||||
}
|
||||
|
||||
static bool readDrawables( osgDB::InputStream& is, osg::Geode& node )
|
||||
{
|
||||
unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET;
|
||||
for ( unsigned int i=0; i<size; ++i )
|
||||
{
|
||||
osg::Drawable* drawable = dynamic_cast<osg::Drawable*>( is.readObject() );
|
||||
if ( drawable ) node.addDrawable( drawable );
|
||||
}
|
||||
is >> osgDB::END_BRACKET;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool writeDrawables( osgDB::OutputStream& os, const osg::Geode& node )
|
||||
{
|
||||
unsigned int size = node.getNumDrawables();
|
||||
os << size << osgDB::BEGIN_BRACKET << std::endl;
|
||||
for ( unsigned int i=0; i<size; ++i )
|
||||
{
|
||||
os << node.getDrawable(i);
|
||||
}
|
||||
os << osgDB::END_BRACKET << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( Geode,
|
||||
new osg::Geode,
|
||||
osg::Geode,
|
||||
"osg::Object osg::Node osg::Geode" )
|
||||
{
|
||||
ADD_USER_SERIALIZER( Drawables ); // _drawables
|
||||
}
|
||||
Reference in New Issue
Block a user