|
楼主 |
发表于 2015-12-31 23:48:14
|
显示全部楼层
我的代码如下:
osgEarth::Map *map = new osgEarth::Map();
createImageLayers(map);
_mapNode = new osgEarth::MapNode(map);
_viewer->setCameraManipulator(new EarthMultiTouchManipulator());
EarthMultiTouchManipulator* manip = dynamic_cast<EarthMultiTouchManipulator*>(_viewer->getCameraManipulator());
osgEarth::Util::EarthManipulator::ActionOptions options;
manip->getSettings()->setMouseSensitivity(0.30);
manip->getSettings()->setThrowingEnabled(true);
manip->getSettings()->setThrowDecayRate(0.1);
manip->getSettings()->setLockAzimuthWhilePanning(false);
manip->getSettings()->setArcViewpointTransitions(false);
manip->getSettings()->bindTwist(osgEarth::Util::EarthManipulator::ACTION_NULL, options);
manip->getSettings()->bindMultiDrag(osgEarth::Util::EarthManipulator::ACTION_NULL, options);
manip->getSettings()->setMinMaxPitch(-90.0, -90.0);
osgEarth::Util::SkyOptions sOptions;
sOptions.ambient() = 1.0;
osg::ref_ptr<osgEarth::Util::SkyNode> sky = osgEarth::Util::SkyNode::create(sOptions, _mapNode);
sky->setDateTime( osgEarth:ateTime(2011, 3, 6, 12.0) );
sky->attach(_viewer, 0);
if ( _mapNode->getNumParents() > 0 )
{
osgEarth::insertGroup(sky.get(), _mapNode->getParent(0));
}
else
{
sky->addChild( _mapNode );
}
osg::Group* root = new osg::Group();
root->addChild(sky);
osg::Material* material = new osg::Material();
material->setAmbient(osg::Material::FRONT, osg::Vec4(0.4,0.4,0.4,1.0));
material->setDiffuse(osg::Material::FRONT, osg::Vec4(0.9,0.9,0.9,1.0));
material->setSpecular(osg::Material::FRONT, osg::Vec4(0.4,0.4,0.4,1.0));
root->getOrCreateStateSet()->setAttribute(material);
root->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE);
root->getOrCreateStateSet()->setAttribute(_viewer->getLight());
_viewer->setSceneData(root);
_viewer->realize(); |
|