分析Rex引擎的起点,要从下面代码开始(或者其它类似)。
osg::Node* node = MapNodeHelper().load(arguments, &viewer);
它会解析earth文件,搭建起地球的四梁八柱框架,接下来的帧循环会围绕这个框架进行影像、高程瓦片的调度。
这个函数会启动一个读取调用链条(中间省略一些不重要的链条节点)
osgDB::readRefNodeFile
osgDB::Registry::read
osgDB::Registry::ReadNodeFunctor::doRead
ReaderWriterEarth::readNode
osgEarth_osgearth::EarthFileSerializer2::deserialize
至此读取链条就以结束,接下来就是osgEarth_osgearth::EarthFileSerializer2::deserialize的操作了,这里主要做两件事
1、构建地图图层
osgEarthDrivers/earth/EarthFileSerialize2.cpp
osg::Node*
EarthFileSerializer2::deserialize( const Config& conf, const std::string& referrer ) const
{
osg::ref_ptr< Map > map = new Map( mapOptions );
map->beginUpdate();
...
map->endUpdate();
}
2、构建地图节点