Added osgTerrain::Terrain support to the .osg format
This commit is contained in:
parent
e9d4f99409
commit
1b3b69721f
@ -8,6 +8,7 @@ SET(TARGET_SRC
|
|||||||
CompositeLayer.cpp
|
CompositeLayer.cpp
|
||||||
SwitchLayer.cpp
|
SwitchLayer.cpp
|
||||||
Layer.cpp
|
Layer.cpp
|
||||||
|
Terrain.cpp
|
||||||
TerrainTile.cpp
|
TerrainTile.cpp
|
||||||
GeometryTechnique.cpp
|
GeometryTechnique.cpp
|
||||||
ReaderWriterOsgTerrain.cpp
|
ReaderWriterOsgTerrain.cpp
|
||||||
|
42
src/osgPlugins/osgTerrain/Terrain.cpp
Normal file
42
src/osgPlugins/osgTerrain/Terrain.cpp
Normal file
@ -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<osgTerrain::Terrain&>(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<const osgTerrain::Terrain&>(obj);
|
||||||
|
fw.indent()<<"SampleRatio "<<terrain.getSampleRatio()<<std::endl;
|
||||||
|
fw.indent()<<"VerticalScale "<<terrain.getVerticalScale()<<std::endl;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user