root/OpenSceneGraph/trunk/src/osgWrappers/serializers/osg/Drawable.cpp @ 10976

Revision 10976, 2.2 kB (checked in by robert, 5 years ago)

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

  • Property svn:executable set to *
Line 
1#include <osg/Drawable>
2#include <osgDB/ObjectWrapper>
3#include <osgDB/InputStream>
4#include <osgDB/OutputStream>
5
6static bool checkInitialBound( const osg::Drawable& drawable )
7{
8    return drawable.getInitialBound().valid();
9}
10
11static bool readInitialBound( osgDB::InputStream& is, osg::Drawable& drawable )
12{
13    bool valid = false; is >> valid;
14    if ( valid )
15    {
16        osg::Vec3d min, max;
17        is >> osgDB::BEGIN_BRACKET >> osgDB::PROPERTY("Minimum") >> min;
18        is >> osgDB::PROPERTY("Maximum") >> max >> osgDB::END_BRACKET;
19        drawable.setInitialBound( osg::BoundingBox(min, max) );
20    }
21    return true;
22}
23
24static bool writeInitialBound( osgDB::OutputStream& os, const osg::Drawable& drawable )
25{
26    const osg::BoundingBox& bb = drawable.getInitialBound();
27    os << bb.valid();
28    if ( bb.valid() )
29    {
30        os << osgDB::BEGIN_BRACKET << std::endl;
31        os << osgDB::PROPERTY("Minimum") << osg::Vec3d(bb._min) << std::endl;
32        os << osgDB::PROPERTY("Maximum") << osg::Vec3d(bb._max) << std::endl;
33        os << osgDB::END_BRACKET;
34    }
35    os << std::endl;
36    return true;
37}
38
39REGISTER_OBJECT_WRAPPER( Drawable,
40                         /*new osg::Drawable*/NULL,
41                         osg::Drawable,
42                         "osg::Object osg::Drawable" )
43{
44    ADD_OBJECT_SERIALIZER( StateSet, osg::StateSet, NULL );  // _stateset
45    ADD_USER_SERIALIZER( InitialBound );  // _initialBound
46    ADD_OBJECT_SERIALIZER( ComputeBoundingBoxCallback,
47                           osg::Drawable::ComputeBoundingBoxCallback, NULL );  // _computeBoundCallback
48    ADD_OBJECT_SERIALIZER( Shape, osg::Shape, NULL );  // _shape
49    ADD_BOOL_SERIALIZER( SupportsDisplayList, true );  // _supportsDisplayList
50    ADD_BOOL_SERIALIZER( UseDisplayList, true );  // _useDisplayList
51    ADD_BOOL_SERIALIZER( UseVertexBufferObjects, false );  // _useVertexBufferObjects
52    ADD_OBJECT_SERIALIZER( UpdateCallback, osg::Drawable::UpdateCallback, NULL );  // _updateCallback
53    ADD_OBJECT_SERIALIZER( EventCallback, osg::Drawable::EventCallback, NULL );  // _eventCallback
54    ADD_OBJECT_SERIALIZER( CullCallback, osg::Drawable::CullCallback, NULL );  // _cullCallback
55    ADD_OBJECT_SERIALIZER( DrawCallback, osg::Drawable::DrawCallback, NULL );  // _drawCallback
56}
Note: See TracBrowser for help on using the browser.