参考:http://docs.osgearth.org/en/latest/faq.html
Common Usage
How do I place a 3D model on the map?
The
osgEarth::GeoTransform
class inherits fromosg::Transform
and will convert map coordinates into OSG world coordinates for you:GeoTransform* xform = new GeoTransform(); ... xform->setTerrain( mapNode->getTerrain() ); ... GeoPoint point(srs, -121.0, 34.0); xform->setPosition(point);
I added a node, but it has no texture/lighting/etc. in osgEarth. Why?
Everything under an osgEarth scene graph is rendered with shaders. So, when using your own models (or creating geometry by hand) you need to create shader components in order for them to render properly.
一切在osgEarth场景图呈现着色器。因此,当使用您自己的模型(或手工创建几何)您需要创建材质组件为了正确地呈现。
osgEarth has a built-in shader generator for this purpose. Run the shader generator on your node like so:
为此osgEarth有一个内置的着色器生成器。在节点上运行着色器生成器:
osgEarth::Registry::shaderGenerator().run( myNode );After that, your node will contain shader snippets that allows osgEarth to render it properly and for it to work with other osgEarth features like sky lighting.
之后,节点将包含材质片段,允许osgEarth渲染它正确,工作与其他osgEarth天空照明等功能
How do make the terrain transparent?
By default, the globe will be opaque white when there are no image layers, or when all the image layers have their opacities set to zero. To make the underlying globe transparent, set the base color of the terrain to a transparent color like so:
<map> <options> <terrain color="#ffffff00" ...In code, this option is found in the
MPTerrainEngineOptions
class:#include <osgEarthDrivers/engine_mp/MPTerrainEngineOptions> using namespace osgEarth::Drivers::MPTerrainEngine; ... MPTerrainEngineOptions options; options.color() = osg::Vec4(1,1,1,0);
How do I set the resolution of terrain tiles?
Each tile is a grid of vertices. The number of vertices can vary depending on source data and settings. By default (when you have no elevation data) it is an 17x17 grid, tessellated into triangles.
You can expressly set the terrain’s tile size by using the Map options. osgEarth will then resample all elevation data to the size you specify:
每个瓦是一个网格的顶点。顶点的数量取决于源数据和设置。在默认情况下(当你没有高程数据)这是一个17 x17网格,完全嵌合成三角形。
<map> <options> <terrain> <tile_size>65</tile_size> ...
Other Terrain Formats
Does osgEarth work with VirtualPlanetBuilder?
VirtualPlanetBuilder (VPB) is a command-line terrain generation tool. Before osgEarth came along, VPB was probably the most-used open source tool for building terrains for OSG appliations. We mention is here because many people ask questions about loading VPB models or transitioning from VPB to osgEarth.
osgEarth differs from VPB in that:
- VPB builds static terrain models and saves them to disk. osgEarth generates terrain on demand as your application runs; you do not (and cannot) save a model to disk.
- Changing a VPB terrain generally requires that you rebuild the model. osgEarth does not require a preprocessing step since it builds the terrain at run time.
- osgEarth and VPB both use GDAL to read many types of imagery and elevation data from the local file system. osgEarth also supports network-based data sources through its plug-in framework.
osgEarth has a VPB driver for “scraping” elevation and imagery tiles from a VPB model.
翻译:1VPB构建静态地形模型和保存到磁盘。osgEarth生成地形在您的应用程序运行时需求;你不会(也不能)模型保存到磁盘。
2改变一个VPB地形一般要求你重建模型。osgEarth不需要预处理步骤,因为它在运行时构建地形。
3osgEarth和VPB都使用GDAL阅读许多类型的图像和高程数据从本地文件系统。osgEarth通过其插件框架还支持基于网络的数据源。Confiugration of this driver is quite tricky and requires you to understand the details of how VPB models are organized. You’re on your own.
Please Note that this driver only exists as a last resort for people that have a VPB model but no longer have access to the source data from which it was built. If at all possible you should feed your source data directly into osgEarth instead of using the VPB driver.
Can osgEarth load TerraPage or MetaFlight?
osgEarth cannot load TerraPage (TXP) or MetaFlight. However, osgEarth does have a “bring your own terrain” plugin that allows you to load an external model and use it as your terrain. The caveat is that since osgEarth doesn’t know anything about your terrain model, you will not be able to use some of the features of osgEarth (like being able to add or remove layers).
For usage formation, please refer to the
byo.earth
example in the repo.