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:
56
src/osgWrappers/serializers/osg/Drawable.cpp
Executable file
56
src/osgWrappers/serializers/osg/Drawable.cpp
Executable file
@@ -0,0 +1,56 @@
|
||||
#include <osg/Drawable>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
static bool checkInitialBound( const osg::Drawable& drawable )
|
||||
{
|
||||
return drawable.getInitialBound().valid();
|
||||
}
|
||||
|
||||
static bool readInitialBound( osgDB::InputStream& is, osg::Drawable& drawable )
|
||||
{
|
||||
bool valid = false; is >> valid;
|
||||
if ( valid )
|
||||
{
|
||||
osg::Vec3d min, max;
|
||||
is >> osgDB::BEGIN_BRACKET >> osgDB::PROPERTY("Minimum") >> min;
|
||||
is >> osgDB::PROPERTY("Maximum") >> max >> osgDB::END_BRACKET;
|
||||
drawable.setInitialBound( osg::BoundingBox(min, max) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool writeInitialBound( osgDB::OutputStream& os, const osg::Drawable& drawable )
|
||||
{
|
||||
const osg::BoundingBox& bb = drawable.getInitialBound();
|
||||
os << bb.valid();
|
||||
if ( bb.valid() )
|
||||
{
|
||||
os << osgDB::BEGIN_BRACKET << std::endl;
|
||||
os << osgDB::PROPERTY("Minimum") << osg::Vec3d(bb._min) << std::endl;
|
||||
os << osgDB::PROPERTY("Maximum") << osg::Vec3d(bb._max) << std::endl;
|
||||
os << osgDB::END_BRACKET;
|
||||
}
|
||||
os << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( Drawable,
|
||||
/*new osg::Drawable*/NULL,
|
||||
osg::Drawable,
|
||||
"osg::Object osg::Drawable" )
|
||||
{
|
||||
ADD_OBJECT_SERIALIZER( StateSet, osg::StateSet, NULL ); // _stateset
|
||||
ADD_USER_SERIALIZER( InitialBound ); // _initialBound
|
||||
ADD_OBJECT_SERIALIZER( ComputeBoundingBoxCallback,
|
||||
osg::Drawable::ComputeBoundingBoxCallback, NULL ); // _computeBoundCallback
|
||||
ADD_OBJECT_SERIALIZER( Shape, osg::Shape, NULL ); // _shape
|
||||
ADD_BOOL_SERIALIZER( SupportsDisplayList, true ); // _supportsDisplayList
|
||||
ADD_BOOL_SERIALIZER( UseDisplayList, true ); // _useDisplayList
|
||||
ADD_BOOL_SERIALIZER( UseVertexBufferObjects, false ); // _useVertexBufferObjects
|
||||
ADD_OBJECT_SERIALIZER( UpdateCallback, osg::Drawable::UpdateCallback, NULL ); // _updateCallback
|
||||
ADD_OBJECT_SERIALIZER( EventCallback, osg::Drawable::EventCallback, NULL ); // _eventCallback
|
||||
ADD_OBJECT_SERIALIZER( CullCallback, osg::Drawable::CullCallback, NULL ); // _cullCallback
|
||||
ADD_OBJECT_SERIALIZER( DrawCallback, osg::Drawable::DrawCallback, NULL ); // _drawCallback
|
||||
}
|
||||
Reference in New Issue
Block a user