#include <string>
#include <iostream>
#include <osgViewer/Viewer>
#include <osg/Node>
#include <osg/Geode>
#include <osg/Group>
#include <osg/CoordinateSystemNode>
#include <osg/ShapeDrawable>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgUtil/Optimizer>
using namespace std;
osg::ref_ptr<osg::Node> createEarth()
{
osg::ref_ptr<osg::ShapeDrawable> sd =
new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0.0, 0.0, 0.0), osg::WGS_84_RADIUS_POLAR));
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
geode->addDrawable(sd.get());
std::string filename("/home/zhaogang/work/thirdparty/OpenSceneGraph-3.2.1/data/Images/land_shallow_topo_2048.jpg");
geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, new osg::Texture2D(osgDB::readImageFile(filename)));
osg::ref_ptr<osg::CoordinateSystemNode> csn = new osg::CoordinateSystemNode;
csn->setEllipsoidModel(new osg::EllipsoidModel());
csn->addChild(geode.get());
return csn.get();
}
int main()
{
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();
osg::ref_ptr<osg::Group> root = new osg::Group();
root->addChild(createEarth());
osgUtil::Optimizer optimizer;
optimizer.optimize(root.get());
viewer->setSceneData(root.get());
viewer->realize();
viewer->run();
return 0;
}
#include <iostream>
#include <osgViewer/Viewer>
#include <osg/Node>
#include <osg/Geode>
#include <osg/Group>
#include <osg/CoordinateSystemNode>
#include <osg/ShapeDrawable>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgUtil/Optimizer>
using namespace std;
osg::ref_ptr<osg::Node> createEarth()
{
osg::ref_ptr<osg::ShapeDrawable> sd =
new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0.0, 0.0, 0.0), osg::WGS_84_RADIUS_POLAR));
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
geode->addDrawable(sd.get());
std::string filename("/home/zhaogang/work/thirdparty/OpenSceneGraph-3.2.1/data/Images/land_shallow_topo_2048.jpg");
geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, new osg::Texture2D(osgDB::readImageFile(filename)));
osg::ref_ptr<osg::CoordinateSystemNode> csn = new osg::CoordinateSystemNode;
csn->setEllipsoidModel(new osg::EllipsoidModel());
csn->addChild(geode.get());
return csn.get();
}
int main()
{
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();
osg::ref_ptr<osg::Group> root = new osg::Group();
root->addChild(createEarth());
osgUtil::Optimizer optimizer;
optimizer.optimize(root.get());
viewer->setSceneData(root.get());
viewer->realize();
viewer->run();
return 0;
}
----
LIBS += -L/usr/local/lib/
LIBS += -lOpenThreads
LIBS += -losg
LIBS += -losgDB
LIBS += -losgFX
LIBS += -losgGA
LIBS += -losgManipulator
LIBS += -losgParticle
LIBS += -losgShadow
LIBS += -losgSim
LIBS += -losgTerrain
LIBS += -losgText
LIBS += -losgUtil
LIBS += -losgViewer
----