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

Revision 11018, 2.1 kB (checked in by robert, 5 years ago)

From Wang Rui, "Changes:

1. Rewrite the reading/writing exception handlers to work like the ive
plugin exceptions.
2. Write a header writing/checking function in ReaderWriterOSG2.cpp,
which may help decide if the stream is ascii or binary. The
readInputIterator() function will return null pointer if the input
file is nither osgb nor osgt format, which indicates that the old .osg
format could be used here, in case we've merged the two plugins
together.
3. Add a new ForceReadingImage? option in the InputStream?, which will
allocate an empty image object with the filename if specifed external
image file is missed. It may be useful for format converting in some
cases.
4. Add new osgParticle wrappers, as well as some modification to the
osgParticle headers, for instance, change isEnabled() to getEnabled().
5. Some fixes to the osg serialization wrappers."

  • 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    osg::Vec3d min, max;
14    is >> osgDB::BEGIN_BRACKET;
15    is >> osgDB::PROPERTY("Minimum") >> min;
16    is >> osgDB::PROPERTY("Maximum") >> max;
17    is >> osgDB::END_BRACKET;
18    drawable.setInitialBound( osg::BoundingBox(min, max) );
19    return true;
20}
21
22static bool writeInitialBound( osgDB::OutputStream& os, const osg::Drawable& drawable )
23{
24    const osg::BoundingBox& bb = drawable.getInitialBound();
25    os << osgDB::BEGIN_BRACKET << std::endl;
26    os << osgDB::PROPERTY("Minimum") << osg::Vec3d(bb._min) << std::endl;
27    os << osgDB::PROPERTY("Maximum") << osg::Vec3d(bb._max) << std::endl;
28    os << osgDB::END_BRACKET;
29    os << std::endl;
30    return true;
31}
32
33REGISTER_OBJECT_WRAPPER( Drawable,
34                         /*new osg::Drawable*/NULL,
35                         osg::Drawable,
36                         "osg::Object osg::Drawable" )
37{
38    ADD_OBJECT_SERIALIZER( StateSet, osg::StateSet, NULL );  // _stateset
39    ADD_USER_SERIALIZER( InitialBound );  // _initialBound
40    ADD_OBJECT_SERIALIZER( ComputeBoundingBoxCallback,
41                           osg::Drawable::ComputeBoundingBoxCallback, NULL );  // _computeBoundCallback
42    ADD_OBJECT_SERIALIZER( Shape, osg::Shape, NULL );  // _shape
43    ADD_BOOL_SERIALIZER( SupportsDisplayList, true );  // _supportsDisplayList
44    ADD_BOOL_SERIALIZER( UseDisplayList, true );  // _useDisplayList
45    ADD_BOOL_SERIALIZER( UseVertexBufferObjects, false );  // _useVertexBufferObjects
46    ADD_OBJECT_SERIALIZER( UpdateCallback, osg::Drawable::UpdateCallback, NULL );  // _updateCallback
47    ADD_OBJECT_SERIALIZER( EventCallback, osg::Drawable::EventCallback, NULL );  // _eventCallback
48    ADD_OBJECT_SERIALIZER( CullCallback, osg::Drawable::CullCallback, NULL );  // _cullCallback
49    ADD_OBJECT_SERIALIZER( DrawCallback, osg::Drawable::DrawCallback, NULL );  // _drawCallback
50}
Note: See TracBrowser for help on using the browser.