root/OpenSceneGraph/trunk/src/osgPlugins/osgTerrain/Terrain.cpp @ 9934

Revision 9934, 1.2 kB (checked in by robert, 6 years ago)

Added osgTerrain::Terrain support to the .osg format

Line 
1#include "osgTerrain/Terrain"
2
3#include "osgDB/Registry"
4#include "osgDB/Input"
5#include "osgDB/Output"
6
7// forward declare functions to use later.
8bool Terrain_readLocalData(osg::Object& obj, osgDB::Input& fr);
9bool Terrain_writeLocalData(const osg::Object& obj, osgDB::Output& fw);
10
11// register the read and write functions with the osgDB::Registry.
12REGISTER_DOTOSGWRAPPER(Terrain)
13(
14    new osgTerrain::Terrain,
15    "Terrain",
16    "Object Node Terrain Group",
17    &Terrain_readLocalData,
18    &Terrain_writeLocalData
19);
20
21bool Terrain_readLocalData(osg::Object& obj, osgDB::Input& fr)
22{
23    bool iteratorAdvanced = false;
24
25    osgTerrain::Terrain& terrain = static_cast<osgTerrain::Terrain&>(obj);
26
27    float value;
28    if (fr.read("SampleRatio",value)) terrain.setSampleRatio(value);
29    if (fr.read("VerticalScale",value)) terrain.setVerticalScale(value);
30
31    return iteratorAdvanced;
32}
33
34
35bool Terrain_writeLocalData(const osg::Object& obj, osgDB::Output& fw)
36{
37    const osgTerrain::Terrain& terrain = static_cast<const osgTerrain::Terrain&>(obj);
38    fw.indent()<<"SampleRatio "<<terrain.getSampleRatio()<<std::endl;
39    fw.indent()<<"VerticalScale "<<terrain.getVerticalScale()<<std::endl;
40
41    return true;
42}
Note: See TracBrowser for help on using the browser.