本文通过代码的介绍,讲解在osgEarth中,由.earth文件到地球的创建流程,展现osgEarth中概念,如Map、Layer以及MapNode。
内容
osg::Node* node = MapNodeHelper().load(arguments, &viewer);
分析osgEarth中地球的创建,从如上代码开始,其中arguments变量为osg::ArgumentParser对象,其路径中包含一.earth文件,viewer为osgViewer::Viewer对象,上述代码中创建的osg::Node对象,可直接设置为viewer对象的场景节点,实现渲染,结果如下图所示:
接下来分析load函数的内容:
osg::ref_ptr<osg::Node> node = osgDB::readNodeFiles(args, myReadOptions.get());
// fallback in case none is specified:
if (!node.valid()