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

Revision 13041, 1.4 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
6#include <osgTerrain/TerrainTile>
7
8
9static bool checkImage( const osgTerrain::ImageLayer& im )
10{ return im.getImage() != NULL; }
11
12static bool readImage( osgDB::InputStream& is, osgTerrain::ImageLayer& il )
13{
14
15    if(!is.isBinary()) is >> osgDB::BEGIN_BRACKET;
16
17    bool deferExternalLayerLoading = osgTerrain::TerrainTile::getTileLoadedCallback().valid() ?
18            osgTerrain::TerrainTile::getTileLoadedCallback()->deferExternalLayerLoading() : false;
19
20
21    osg::ref_ptr<osg::Image> image = is.readImage(!deferExternalLayerLoading);
22    if (image.valid())
23    {
24        if(image->valid())
25        {
26            il.setImage(image.get());
27        }
28    }
29    if(!is.isBinary()) is >> osgDB::END_BRACKET;
30
31   return true;
32}
33
34static bool writeImage( osgDB::OutputStream& os, const osgTerrain::ImageLayer& il )
35{
36    const osg::Image* image = il.getImage();
37
38    if(!os.isBinary()) os << osgDB::BEGIN_BRACKET << std::endl;
39    os.writeImage(image);
40    if(!os.isBinary()) os << osgDB::END_BRACKET << std::endl;
41
42    return true;
43}
44
45REGISTER_OBJECT_WRAPPER( osgTerrain_ImageLayer,
46                         new osgTerrain::ImageLayer,
47                         osgTerrain::ImageLayer,
48                         "osg::Object osgTerrain::Layer osgTerrain::ImageLayer" )
49{
50   ADD_USER_SERIALIZER( Image );
51}
Note: See TracBrowser for help on using the browser.