root/OpenSceneGraph/trunk/src/osgWrappers/serializers/osgTerrain/Layer.cpp @ 13041

Revision 13041, 2.2 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 <osgTerrain/Layer>
2#include <osgDB/ObjectWrapper>
3#include <osgDB/InputStream>
4#include <osgDB/OutputStream>
5
6static bool checkValidDataOperator( const osgTerrain::Layer& layer )
7{
8    return layer.getValidDataOperator()!=NULL;
9}
10
11static bool readValidDataOperator( osgDB::InputStream& is, osgTerrain::Layer& layer )
12{
13    unsigned int type; is >> type;
14    switch ( type )
15    {
16    case 1:
17        {
18            float value; is >> value;
19            layer.setValidDataOperator( new osgTerrain::NoDataValue(value) );
20        }
21        break;
22    case 2:
23        {
24            float min, max; is >> min >> max;
25            layer.setValidDataOperator( new osgTerrain::ValidRange(min, max) );
26        }
27        break;
28    default:
29        break;
30    }
31    return true;
32}
33
34static bool writeValidDataOperator( osgDB::OutputStream& os, const osgTerrain::Layer& layer )
35{
36    const osgTerrain::NoDataValue* ndv = dynamic_cast<const osgTerrain::NoDataValue*>( layer.getValidDataOperator() );
37    if ( ndv )
38    {
39        os << (unsigned int)1 << ndv->getValue() << std::endl;
40        return true;
41    }
42
43    const osgTerrain::ValidRange* vr = dynamic_cast<const osgTerrain::ValidRange*>( layer.getValidDataOperator() );
44    if ( vr )
45    {
46        os << (unsigned int)2 << vr->getMinValue() << vr->getMaxValue() << std::endl;
47        return true;
48    }
49
50    os << (unsigned int)0 << std::endl;
51    return true;
52}
53
54REGISTER_OBJECT_WRAPPER( osgTerrain_Layer,
55                         new osgTerrain::Layer,
56                         osgTerrain::Layer,
57                         "osg::Object osgTerrain::Layer" )
58{
59    ADD_STRING_SERIALIZER( FileName, "" );  // _filename
60    ADD_OBJECT_SERIALIZER( Locator, osgTerrain::Locator, NULL );  // _locator
61    ADD_UINT_SERIALIZER( MinLevel, 0 );  // _minLevel
62    ADD_UINT_SERIALIZER( MaxLevel, MAXIMUM_NUMBER_OF_LEVELS );  // _maxLevel
63    ADD_USER_SERIALIZER( ValidDataOperator );  // _validDataOperator
64    ADD_VEC4_SERIALIZER( DefaultValue, osg::Vec4() );  // _defaultValue
65    ADD_GLENUM_SERIALIZER( MinFilter, osg::Texture::FilterMode, osg::Texture::LINEAR_MIPMAP_LINEAR );  // _minFilter
66    ADD_GLENUM_SERIALIZER( MagFilter, osg::Texture::FilterMode, osg::Texture::LINEAR );  // _magFilter
67}
Note: See TracBrowser for help on using the browser.