Files
OpenSceneGraph/examples/osgterrain/osgterrain.cpp
Robert Osfield 541c3f13e9 Added GeometryTechinque to osgTerrain. Added usage of GeometryTechnique into osgterrain example
Added --width and --height command line options to osgdistortion to allow users
to control the window size.
2007-03-21 16:34:04 +00:00

76 lines
1.9 KiB
C++

#include <osgViewer/Viewer>
#include <osg/Group>
#include <osg/Geode>
#include <osg/ShapeDrawable>
#include <osg/Texture2D>
#include <osg/PositionAttitudeTransform>
#include <osg/MatrixTransform>
#include <osg/CoordinateSystemNode>
#include <osg/ClusterCullingCallback>
#include <osg/ArgumentParser>
#include <osgDB/FileUtils>
#include <osgDB/ReadFile>
#include <osgText/FadeText>
#include <osgTerrain/TerrainNode>
#include <osgTerrain/GeometryTechnique>
#include <osgTerrain/Layer>
#include <iostream>
int main(int argc, char** argv)
{
osg::ArgumentParser arguments(&argc, argv);
// construct the viewer.
osgViewer::Viewer viewer;
double x = 0.0;
double y = 0.0;
double w = 1.0;
double h = 1.0;
osg::ref_ptr<osgTerrain::TerrainNode> terrain = new osgTerrain::TerrainNode;
bool readParameter = false;
do
{
readParameter = false;
std::string filename;
if (arguments.read("-x",x)) readParameter = true;
if (arguments.read("-y",y)) readParameter = true;
if (arguments.read("-w",w)) readParameter = true;
if (arguments.read("-h",h)) readParameter = true;
if (arguments.read("--dem",filename))
{
readParameter = true;
osg::notify(osg::NOTICE)<<"--dem "<<filename<<" x="<<x<<" y="<<y<<" w="<<w<<" h="<<h<<std::endl;
}
if (arguments.read("--image",filename))
{
readParameter = true;
osg::notify(osg::NOTICE)<<"--image "<<filename<<" x="<<x<<" y="<<y<<" w="<<w<<" h="<<h<<std::endl;
}
} while (readParameter);
osg::ref_ptr<osgTerrain::GeometryTechnique> geometryTechnique = new osgTerrain::GeometryTechnique;
terrain->setTerrainTechnique(geometryTechnique.get());
if (!terrain) return 0;
// add a viewport to the viewer and attach the scene graph.
viewer.setSceneData(terrain.get());
return viewer.run();
}