osgEarth的Earth格式文件說明

Earth 格式文件說明(初學者,請斧正)

地圖 Map

MAP是根節點。

<map name    = "my map"
     type    = "geocentric"
     version = "2" >

    <options>
    <image>
    <elevation>
    <model>
    <mask>
    <libraries>
Property Description
name 名字節點,不影響渲染。
type

座標系類型。

geocentric: 畫一個橢圓球體。
projected: 渲染“平面”投影貼圖。
version 文件版本號。默認爲 “2”,這樣設置可以加載舊版本文件。

地圖選項 Map Options

這些 options選項控制 地圖模型以及整個地圖渲染過程涉及的參數。

<map>
    <options lighting                 = "true"
             elevation_interpolation  = "bilinear"
             overlay_texture_size     = "4096"
             overlay_blending         = "true"
             overlay_resolution_ratio = "3.0" >

        <profile>
        <proxy>
        <cache>
        <cache_policy>
        <terrain>
屬性 描述
lighting 是否允許照明着色器影響貼圖
elevation_interpolation

重採樣高程源數據時要使用的算法:

nearest: 最近相鄰
average: 相鄰值平均值
bilinear: 兩軸線性插值
triangulate: Interp 遵循三角坡度
overlay_texture_size 設置要用於覆蓋的紋理大小(投影紋理)
overlay_blending 覆蓋幾何體是否在覆蓋期間與地形混合(投影紋理)
overlay_resolution_ratio 對於覆蓋幾何體,是指靠近攝影機的投影紋理的分辨率與遠離攝影機的分辨率的比率。增大該值可改善靠近攝影機的外觀,同時犧牲更遠幾何體的外觀。注意:如果你使用一個支持側翻的攝影機操縱器,你可能需要將其設置爲1.0;否則你將得到覆蓋物!這是一個已知的問題。

地形 選項 Terrain Options

這些選項控制地形曲面的渲染。

<map>
    <options>
        <terrain driver                = "rex"
                 lighting              = "true"
                 min_tile_range_factor = "6"
                 first_lod             = "0"
                 blending              = "false"
                 color                 = "#ffffffff"
                 tile_size             = "17"
                 normalize_edges       = "false"
                 compress_normal_maps  = "false"
                 normal_maps           = "true"
                 min_expiry_frames     = "0"
                 min_expiry_time       = "0" >
屬性 說明
driver 要加載的地形引擎插件類型。 默認是“rex”。請參閱“驅動程序”參考指南,瞭解每個插件的特定屬性。
lighting 地形是否接受照明(如果存在)。默認是:true
min_tile_range_factor

最小瓦片範圍因子:對於某個大小的瓦片,想要能看到時候的最小距離。例如某個瓦片半徑是10KM,這個MTRF因子爲7,那麼瓦片在大約70公里時候可見。默認是6.0。

first_lod

地形圖上將會顯示瓦片的最低的級別。如果在更低的 LOD級別上就不會顯示瓦片。

blending

Set this to true to enable GL blending on the terrain’s underlying geometry. This lets you make the globe partially transparent. This is handy for seeing underground objects.

這個值設置爲true可以讓GL渲染地表以下的地理環境,可以讓地球變得部分透明,這樣就可以方便的看到地下的一些物理。

tile_size

The dimensions of each terrain tile. Each terrain tile will have tile_size X tile_size vertices. Default=17

地形瓦片的尺寸。每個瓦片都將有 tile_size * tile_size個頂點。默認是17。

normalize_edges 沿地形瓦片的邊緣計算法線向量,以便從一個瓦片到另一個瓦片的照明會更平滑。默認設置爲false
normal_maps

是否生成和使用法線貼圖代替幾何體法線。法線貼圖與照明一起使用,創建的地形會比單獨使用三角形表示的分辨率更高。默認值取決於引擎。

compress_normal_maps 是否在將法線貼圖發送到GPU之前壓縮法線貼圖。您必須在OpenSceneGraph 庫BUILD時候,內置NVIDIA紋理工具圖像處理器插件。默認值爲false
min_expiry_frames 地形瓦片在可以考慮過期之前沒有看到的幀數。默認值爲0
min_expiry_time 地形瓦片在可以考慮過期之前未被剔除的秒數。默認值爲0

圖層 Image Layer

圖層:覆蓋在地球幾何體上的光柵圖像。

<map>
    <image name              = "my image layer"
           driver            = "gdal"
           nodata_image      = "http://readymap.org/nodata.png"
           opacity           = "1.0"
           min_range         = "0"
           max_range         = "100000000"
           attenuation_range = "0"
           min_level         = "0"
           max_level         = "23"
           min_resolution    = "100.0"
           max_resolution    = "0.0"
           max_data_level    = "23"
           enabled           = "true"
           visible           = "true"
           shared            = "false"
           shared_sampler    = "string"
           shared_matrix     = "string"
           coverage          = "false"
           min_filter        = "LINEAR"
           mag_filter        = "LINEAR"
           blend             = "interpolate"
           altitude          = "0"
           texture_compression = "none" >

        <cache_policy>
        <proxy>
屬性 說明
name 名字。引擎用不到。
driver 用於爲此層創建瓦片的插件。請參閱驅動程序參考指南,瞭解每個插件的特定屬性。
nodata_image

如果數據源沒有數據,則用此URI地址的圖片。如果osgEarth使用了此圖像,則說明數據源沒有找到數據。

opacity 圖層的不透明度: [0..1].
min_range

到攝像機的最小可見距離(米),如果距離太小了,則不可見。

max_range 到攝像機的最大可見距離(米),如果距離太大了,則不可見。
attenuation_range 向最小範圍或最大範圍渲染的距離。(文本或圖標不支持,僅支持幾何圖形)
min_level 細節的最小可見級別。
max_level 細節的最大可見級別。
min_resolution 繪製瓦片的最小源數據分辨率。源數據是幾個單位,這裏每像素就是幾個單位。
max_resolution 繪製平鋪的最大源數據分辨率。源數據是幾個單位,這裏每像素就是幾個單位。
max_data_level

此圖像層可以使用新源數據的最大詳細級別。通常驅動會報告這些信息。但你可能回希望自己限制一下。這對於一些沒有分辨率限制的驅動程序來說尤其如此,例如光柵化驅動程序(聚集體)。

enabled 是否在地圖中包含此圖層。您只能在加載時設置它;這只是在地球文件中“註釋掉”圖層的一種簡單方法。
visible 圖層是否可見。
shared 爲該層生成輔助的專用採樣器,以便自定義着色器可以全局訪問它。
shared_sampler 對於共享圖層,將在GLSL代碼中使用的採樣器統一名稱。
shared_matrix 對於共享圖層,將在GLSL代碼中使用的紋理矩陣的統一名稱,您可以使用該名稱訪問上面shared_sampler的正確紋理座標。
coverage

指示這是一個覆蓋層,即,用特定語義傳遞離散值的層。例如,“土地利用”層,其中每個像素都有一個值,該值指示該區域是否爲草地、沙漠等。將一個層標記爲覆蓋將禁用任何插值、濾波或壓縮,因爲這些將損壞GPU上的採樣數據值。

min_filter 用於此層的OpenGL紋理縮小過濾器。選項包括:NEAREST, LINEAR, NEAREST_MIPMAP_NEAREST, NEAREST_MIPMIP_LINEAR, LINEAR_MIPMAP_NEAREST, LINEAR_MIPMAP_LINEAR
mag_filter 用於此層的OpenGL紋理放大過濾器。選項同上
texture_compression “auto” 表示自動在GPU上壓縮紋理; “none” 禁用. “fastdxt” 使用 FastDXT 算法實時DXT 壓縮器
blend

“modulate”將像素與幀緩衝區相乘;“interpolate”基於alpha(def)與幀緩衝區混合

altitude 渲染圖層的海拔。可以使用這個參數在地面以上渲染天氣或者雲層,再比如, 一個視覺助手. 默認是0

高程層 Elevation Layer

高程圖層爲地形引擎提供高度地圖柵格。osgEarth引擎將把所有的高程數據合成一個單一的高度圖,並使用它來構建地形圖塊。

<map>
    <elevation name            = "text"
               driver          = "gdal"
               min_level       = "0"
               max_level       = "23"
               min_resolution  = "100.0"
               max_resolution  = "0.0"
               enabled         = "true"
               offset          = "false"
               nodata_value    = "-32768"
               min_valid_value = "-32768"
               max_valid_value = "32768"
               nodata_policy   = "interpolate" >
屬性 說明
name 名字,引擎用不到。
driver 繪圖驅動的名字。
min_level 最小可見級別
max_level 最大可見級別
min_resolution 最小分辨率。Minimum source data resolution at which to draw tiles. Value is units per pixel, in the native units of the source data.
max_resolution 最大分辨率。Maximum source data resolution at which to draw tiles. Value is units per pixel, in the native units of the source data.
enabled 是否顯示這一層。
offset Indicates that the height values in this layer are relative offsets rather than true terrain height samples.
nodata_policy What to do with “no data” values. Default is “interpolate” which will interpolate neighboring values to fill holes. Set it to “msl” to replace “no data” samples with the current sea level value.
nodata_value 看到這個值就是沒有數據。
min_valid_value 如果任何小於此值的,都視爲無數據。
max_valid_value 如果任何大於此值的,都視爲無數據。

模型層 Model Layer

把3維的模型也作爲一個圖層來渲染繪製。

<map>
    <model name    = "my model layer"
           driver  = "simple" >
Property Description
name 名字
driver 驅動

模型層還允許您定義剪切蒙版(cut-out mask)。地形引擎將在地形表面上切割一個孔,並與您提供的邊界幾何圖形相匹配。可以使用工具osgearth_boundarygen創建這樣的幾何體。

如果您有一個外部地形模型,並且希望將其插入到osgEarth地形中,這將非常有用。

模型必須與地形處於同一座標系中。

<map>
    <model ...>
        <mask driver="feature">
            <features driver="ogr">
                ...

蒙版可以接受任何多邊形特徵作爲輸入,可以使用內嵌幾何圖形指定遮罩幾何圖形:

<features ...>
    <geometry>POLYGON((120 42 0, 121 41 0, 121 40 0))</geometry>

或者,你可以使用shapefile或其他特徵數據,這時會使用指定的驅動加載。

請參考 mask.earth 例子。

簡況  Profile

告訴osgEarth空間參考系統、地理空間範圍和它應該用於渲染瓦片的平鋪方案。

<profile srs    = "+proj=utm +zone=17 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"
         vdatum = "egm96"
         xmin   = "560725.500"
         xmax   = "573866.500"
         ymin   = "4385762.500"
         ymax   = "4400705.500"
         num_tiles_wide_at_lod_0 = "1"
         num_tiles_high_at_lod_0 = "1">
Property Description
srs Spatial reference system of the map. This can be a WKT string, an EPSG code, a PROJ4 initialization string, or a stock profile name. Please refer to Spatial References for details.
vdatum Vertical datum of the profile, which describes how to treat Z values. Please refer to Spatial References for details.
xmin, xmax, ymin, ymax Geospatial extent of the map. The units are those defined by the SRS above (usually meters for a projected map, degrees for a geocentric map).
num_tiles_*_at_lod_0 Size of the tile hierarchy’s top-most level. Default is “1” in both directions. (optional)

Cache

爲瓦片數據設置緩存.

<cache driver = "filesystem"
       path   = "c:/osgearth_cache" >
Property Description
driver 緩存使用的驅動方式, filesystem 或者 leveldb.
path 相對路徑,或者絕對路徑,緩存目錄或者文件。

CachePolicy

確定“給定元素”與“配置的緩存”交互的策略.

<cache_policy usage="no_cache">
Property Description
usage

緩存策略

read_write: 如果配置就使用。默認值是這個
cache_only: 僅僅從緩存讀數據,忽略數據源數據;離線渲染時候有用。
no_cache: 忽略緩存,僅僅從數據源加載。
max_age 單位是秒,早於此值 的緩存都視爲超時過期了。

Proxy Settings

Proxy 設置可以讓大家設置數據的代理服務器,比如科學上網。

<proxy host     = "hostname"
       port     = "8080"
       username = "jason"
       password = "helloworld" >

這些屬性根據字面意思,大家都理解。

Libraries

預先加載某些庫.

<libraries>a</libraries>

多個庫可以使用分號 ‘;’ 來分隔。

<libraries>a;b;c;d;e</libraries>

在osg庫路徑中搜索庫,庫名需要遵循osg nodekit庫名約定(後綴加上osg庫版本號)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章