void KML_Feature::build( xml_node<>* node, KMLContext& cx, osg::Node* working ) { KML_Object::build(node, cx, working); // subclass feature is built; now add feature level data if available if ( working ) { // parse the visibility to show/hide the item by default: std::string visibility = getValue(node, "visibility"); if ( !visibility.empty() ) working->setNodeMask( as<int>(visibility, 1) == 1 ? ~0 : 0 ); // parse a "LookAt" element (stores a viewpoint) AnnotationData* anno = getOrCreateAnnotationData(working); anno->setName( getValue(node, "name") ); anno->setDescription( getValue(node, "description") ); xml_node<>* lookat = node->first_node("lookat", 0, false); if ( lookat ) { Viewpoint vp; vp.focalPoint() = GeoPoint( cx._srs.get(), as<double>(getValue(lookat, "longitude"), 0.0), as<double>(getValue(lookat, "latitude"), 0.0), as<double>(getValue(lookat, "altitude"), 0.0), ALTMODE_ABSOLUTE ); vp.heading() = as<double>(getValue(lookat, "heading"), 0.0); vp.pitch() = -as<double>(getValue(lookat, "tilt"), 45.0), vp.range() = as<double>(getValue(lookat, "range"), 10000.0); anno->setViewpoint( vp ); } xml_node<>* extdata = node->first_node("extendeddata", 0, false); if ( extdata ) { xml_node<>* data = extdata->first_node("data", 0, false); if ( data ) { for (xml_node<>* n = data->first_node(); n; n = n->next_sibling()) { working->setUserValue(getValue(n, "name"), getValue(n, "value")); } } } } }
int main(int argc, char** argv) { osg::ArgumentParser arguments(&argc,argv); // help? if ( arguments.read("--help") ) return usage(argv[0]); osg::Node* model = 0L; std::string filename; if (arguments.read("--model", filename)) { model = osgDB::readRefNodeFile(filename).release(); Registry::shaderGenerator().run(model); } // create a viewer: osgViewer::Viewer viewer(arguments); // Tell the database pager to not modify the unref settings viewer.getDatabasePager()->setUnrefImageDataAfterApplyPolicy( false, false ); // install our default manipulator (do this before calling load) EarthManipulator* manip = new EarthManipulator(); viewer.setCameraManipulator(manip); // load an earth file, and support all or our example command-line options // and earth file <external> tags osg::Group* node = osgEarth::Util::MapNodeHelper().load(arguments, &viewer, createUI()); if ( node ) { viewer.getCamera()->setNearFarRatio(0.00002); viewer.getCamera()->setSmallFeatureCullingPixelSize(-1.0f); viewer.setSceneData( node ); s_app.map = MapNode::get( node )->getMap(); s_app.addTriton(); s_app.addBuoyancyTest(model); // Zoom the camera to our area of interest: Viewpoint vp; vp.heading() = 25.0f; vp.pitch() = -25; vp.range() = 400.0; vp.focalPoint() = s_app.anchor; manip->setViewpoint(vp); while(!viewer.done()) { viewer.frame(); s_app.updateBuoyancyTest(); } } else { return usage(argv[0]); } }