| 1 | #include <osg/Drawable> |
|---|
| 2 | #include <osgDB/ObjectWrapper> |
|---|
| 3 | #include <osgDB/InputStream> |
|---|
| 4 | #include <osgDB/OutputStream> |
|---|
| 5 | |
|---|
| 6 | static bool checkInitialBound( const osg::Drawable& drawable ) |
|---|
| 7 | { |
|---|
| 8 | return drawable.getInitialBound().valid(); |
|---|
| 9 | } |
|---|
| 10 | |
|---|
| 11 | static 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 | |
|---|
| 24 | static 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 | |
|---|
| 39 | REGISTER_OBJECT_WRAPPER( Drawable, |
|---|
| 40 | NULL, |
|---|
| 41 | osg::Drawable, |
|---|
| 42 | "osg::Object osg::Drawable" ) |
|---|
| 43 | { |
|---|
| 44 | ADD_OBJECT_SERIALIZER( StateSet, osg::StateSet, NULL ); |
|---|
| 45 | ADD_USER_SERIALIZER( InitialBound ); |
|---|
| 46 | ADD_OBJECT_SERIALIZER( ComputeBoundingBoxCallback, |
|---|
| 47 | osg::Drawable::ComputeBoundingBoxCallback, NULL ); |
|---|
| 48 | ADD_OBJECT_SERIALIZER( Shape, osg::Shape, NULL ); |
|---|
| 49 | ADD_BOOL_SERIALIZER( SupportsDisplayList, true ); |
|---|
| 50 | ADD_BOOL_SERIALIZER( UseDisplayList, true ); |
|---|
| 51 | ADD_BOOL_SERIALIZER( UseVertexBufferObjects, false ); |
|---|
| 52 | ADD_OBJECT_SERIALIZER( UpdateCallback, osg::Drawable::UpdateCallback, NULL ); |
|---|
| 53 | ADD_OBJECT_SERIALIZER( EventCallback, osg::Drawable::EventCallback, NULL ); |
|---|
| 54 | ADD_OBJECT_SERIALIZER( CullCallback, osg::Drawable::CullCallback, NULL ); |
|---|
| 55 | ADD_OBJECT_SERIALIZER( DrawCallback, osg::Drawable::DrawCallback, NULL ); |
|---|
| 56 | } |
|---|