root/OpenSceneGraph/trunk/src/osgWrappers/serializers/osg/Node.cpp @ 13041

Revision 13041, 2.9 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1#include <osg/Node>
2#include <osgDB/ObjectWrapper>
3#include <osgDB/InputStream>
4#include <osgDB/OutputStream>
5
6// _initialBound
7static bool checkInitialBound( const osg::Node& node )
8{
9    return node.getInitialBound().valid();
10}
11
12static bool readInitialBound( osgDB::InputStream& is, osg::Node& node )
13{
14    osg::Vec3d center;
15    double radius;
16    is >> osgDB::BEGIN_BRACKET;
17    is >> osgDB::PROPERTY("Center") >> center;
18    is >> osgDB::PROPERTY("Radius") >> radius;
19    is >> osgDB::END_BRACKET;
20    node.setInitialBound( osg::BoundingSphere(center, radius) );
21    return true;
22}
23
24static bool writeInitialBound( osgDB::OutputStream& os, const osg::Node& node )
25{
26    const osg::BoundingSphere& bs = node.getInitialBound();
27    os << osgDB::BEGIN_BRACKET << std::endl;
28    os << osgDB::PROPERTY("Center") << osg::Vec3d(bs.center()) << std::endl;
29    os << osgDB::PROPERTY("Radius") << double(bs.radius()) << std::endl;
30    os << osgDB::END_BRACKET << std::endl;
31    return true;
32}
33
34// _descriptions
35static bool checkDescriptions( const osg::Node& node )
36{
37    return node.getDescriptions().size()>0;
38}
39
40static bool readDescriptions( osgDB::InputStream& is, osg::Node& node )
41{
42    unsigned int size = is.readSize(); is >> osgDB::BEGIN_BRACKET;
43    for ( unsigned int i=0; i<size; ++i )
44    {
45        std::string value;
46        is.readWrappedString( value );
47        node.addDescription( value );
48    }
49    is >> osgDB::END_BRACKET;
50    return true;
51}
52
53static bool writeDescriptions( osgDB::OutputStream& os, const osg::Node& node )
54{
55    const osg::Node::DescriptionList& slist = node.getDescriptions();
56    os.writeSize(slist.size()); os << osgDB::BEGIN_BRACKET << std::endl;
57    for ( osg::Node::DescriptionList::const_iterator itr=slist.begin();
58          itr!=slist.end(); ++itr )
59    {
60        os.writeWrappedString( *itr );
61        os << std::endl;
62    }
63    os << osgDB::END_BRACKET << std::endl;
64    return true;
65}
66
67REGISTER_OBJECT_WRAPPER( Node,
68                         new osg::Node,
69                         osg::Node,
70                         "osg::Object osg::Node" )
71{
72    ADD_USER_SERIALIZER( InitialBound );  // _initialBound
73    ADD_OBJECT_SERIALIZER( ComputeBoundingSphereCallback,
74                           osg::Node::ComputeBoundingSphereCallback, NULL );  // _computeBoundCallback
75    ADD_OBJECT_SERIALIZER( UpdateCallback, osg::NodeCallback, NULL );  // _updateCallback
76    ADD_OBJECT_SERIALIZER( EventCallback, osg::NodeCallback, NULL );  // _eventCallback
77    ADD_OBJECT_SERIALIZER( CullCallback, osg::NodeCallback, NULL );  // _cullCallback
78    ADD_BOOL_SERIALIZER( CullingActive, true );  // _cullingActive
79    ADD_HEXINT_SERIALIZER( NodeMask, 0xffffffff );  // _nodeMask
80
81    ADD_USER_SERIALIZER( Descriptions );  // _descriptions, deprecated
82    UPDATE_TO_VERSION( 77 )
83    {
84        REMOVE_SERIALIZER( Descriptions );
85    }
86
87    ADD_OBJECT_SERIALIZER( StateSet, osg::StateSet, NULL );  // _stateset
88}
Note: See TracBrowser for help on using the browser.