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

Revision 13041, 2.3 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1#include <osg/LOD>
2#include <osgDB/ObjectWrapper>
3#include <osgDB/InputStream>
4#include <osgDB/OutputStream>
5
6// _userDefinedCenter, _radius
7static bool checkUserCenter( const osg::LOD& node )
8{
9    return (node.getCenterMode()==osg::LOD::USER_DEFINED_CENTER)||(node.getCenterMode()==osg::LOD::UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED);
10}
11
12static bool readUserCenter( osgDB::InputStream& is, osg::LOD& node )
13{
14    osg::Vec3d center; double radius;
15    is >> center >> radius;
16    node.setCenter( center ); node.setRadius( radius );
17    return true;
18}
19
20static bool writeUserCenter( osgDB::OutputStream& os, const osg::LOD& node )
21{
22    os << osg::Vec3d(node.getCenter()) << (double)node.getRadius() << std::endl;
23    return true;
24}
25
26// _rangeList
27static bool checkRangeList( const osg::LOD& node )
28{
29    return node.getNumRanges()>0;
30}
31
32static bool readRangeList( osgDB::InputStream& is, osg::LOD& node )
33{
34    unsigned int size = is.readSize(); is >> osgDB::BEGIN_BRACKET;
35    for ( unsigned int i=0; i<size; ++i )
36    {
37        float min, max;
38        is >> min >> max;
39        node.setRange( i, min, max );
40    }
41    is >> osgDB::END_BRACKET;
42    return true;
43}
44
45static bool writeRangeList( osgDB::OutputStream& os, const osg::LOD& node )
46{
47    const osg::LOD::RangeList& ranges = node.getRangeList();
48    os.writeSize(ranges.size()); os << osgDB::BEGIN_BRACKET << std::endl;
49    for ( osg::LOD::RangeList::const_iterator itr=ranges.begin();
50          itr!=ranges.end(); ++itr )
51    {
52        os << itr->first << itr->second << std::endl;
53    }
54    os << osgDB::END_BRACKET << std::endl;
55    return true;
56}
57
58REGISTER_OBJECT_WRAPPER( LOD,
59                         new osg::LOD,
60                         osg::LOD,
61                         "osg::Object osg::Node osg::Group osg::LOD" )
62{
63    BEGIN_ENUM_SERIALIZER( CenterMode, USE_BOUNDING_SPHERE_CENTER );
64        ADD_ENUM_VALUE( USE_BOUNDING_SPHERE_CENTER );
65        ADD_ENUM_VALUE( USER_DEFINED_CENTER );
66        ADD_ENUM_VALUE( UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED );
67    END_ENUM_SERIALIZER();  // _centerMode
68
69    ADD_USER_SERIALIZER( UserCenter );  // _userDefinedCenter, _radius
70
71    BEGIN_ENUM_SERIALIZER( RangeMode, DISTANCE_FROM_EYE_POINT );
72        ADD_ENUM_VALUE( DISTANCE_FROM_EYE_POINT );
73        ADD_ENUM_VALUE( PIXEL_SIZE_ON_SCREEN );
74    END_ENUM_SERIALIZER();  // _rangeMode
75
76    ADD_USER_SERIALIZER( RangeList );  // _rangeList
77}
Note: See TracBrowser for help on using the browser.