diff --git a/src/osgPlugins/osgTerrain/CMakeLists.txt b/src/osgPlugins/osgTerrain/CMakeLists.txt index f5c3bd3da..6fc278e61 100644 --- a/src/osgPlugins/osgTerrain/CMakeLists.txt +++ b/src/osgPlugins/osgTerrain/CMakeLists.txt @@ -8,6 +8,7 @@ SET(TARGET_SRC CompositeLayer.cpp SwitchLayer.cpp Layer.cpp + Terrain.cpp TerrainTile.cpp GeometryTechnique.cpp ReaderWriterOsgTerrain.cpp diff --git a/src/osgPlugins/osgTerrain/Terrain.cpp b/src/osgPlugins/osgTerrain/Terrain.cpp new file mode 100644 index 000000000..5fb6932c3 --- /dev/null +++ b/src/osgPlugins/osgTerrain/Terrain.cpp @@ -0,0 +1,42 @@ +#include "osgTerrain/Terrain" + +#include "osgDB/Registry" +#include "osgDB/Input" +#include "osgDB/Output" + +// forward declare functions to use later. +bool Terrain_readLocalData(osg::Object& obj, osgDB::Input& fr); +bool Terrain_writeLocalData(const osg::Object& obj, osgDB::Output& fw); + +// register the read and write functions with the osgDB::Registry. +REGISTER_DOTOSGWRAPPER(Terrain) +( + new osgTerrain::Terrain, + "Terrain", + "Object Node Terrain Group", + &Terrain_readLocalData, + &Terrain_writeLocalData +); + +bool Terrain_readLocalData(osg::Object& obj, osgDB::Input& fr) +{ + bool iteratorAdvanced = false; + + osgTerrain::Terrain& terrain = static_cast(obj); + + float value; + if (fr.read("SampleRatio",value)) terrain.setSampleRatio(value); + if (fr.read("VerticalScale",value)) terrain.setVerticalScale(value); + + return iteratorAdvanced; +} + + +bool Terrain_writeLocalData(const osg::Object& obj, osgDB::Output& fw) +{ + const osgTerrain::Terrain& terrain = static_cast(obj); + fw.indent()<<"SampleRatio "<