Quantied-mesh-1.0 地形格式


一个地形瓦片在quantied-mesh-1.0格式是简单的根据瓦片地图服务器(Tile Map Service (TMS))和全球大数据的多分辨率四叉树。所有的瓦片都有延伸地形,所以,瓦片的URL是:

 

http://assets.agi.com/stk-terrain/world/tiles

 

然后在这些URL种找到金智塔的两个根文件:

(-180 deg, -90 deg) - (0 deg, 90 deg) - http://assets.agi.com/stk-terrain/world/tiles/0/0/0.terrain

(0 deg, -90 deg) - (180 deg, 90 deg) - http://assets.agi.com/stk-terrain/world/tiles/0/1/0.terrain

 

下一层的八块瓦片在这些URL中:

(-180 deg, -90 deg) - (-90 deg, 0 deg) - http://assets.agi.com/stk-terrain/world/tiles/1/0/0.terrain

(-90 deg, -90 deg) - (0 deg, 0 deg) - http://assets.agi.com/stk-terrain/world/tiles/1/1/0.terrain

(0 deg, -90 deg) - (90 deg, 0 deg) - http://assets.agi.com/stk-terrain/world/tiles/1/2/0.terrain

(90 deg, -90 deg) - (180 deg, 0 deg) - http://assets.agi.com/stk-terrain/world/tiles/1/3/0.terrain

(-180 deg, 0 deg) - (-90 deg, 90 deg) - http://assets.agi.com/stk-terrain/world/tiles/1/0/1.terrain

(-90 deg, 0 deg) - (0 deg, 90 deg) - http://assets.agi.com/stk-terrain/world/tiles/1/1/1.terrain

(0 deg, 0 deg) - (90 deg, 90 deg) - http://assets.agi.com/stk-terrain/world/tiles/1/2/1.terrain

(90 deg, 0 deg) - (180 deg, 90 deg) - http://assets.agi.com/stk-terrain/world/tiles/1/3/1.terrain

 

在请求瓦片时,轻确保在亲贵中包含以下HTTP头:

Accept: application/vnd.quantized-mesh,application/octet-stream;q=0.9

 

否则,一些服务器可能返回一个不同的瓦片表示,而不少这里描述的。

 

每个瓦片的网片边缘重叠的顶点是特别编码三角网格的。换句话说,实际上,在西边瓦片中最东边的顶点和东边瓦片最西边的顶点在同一个经度上。

 

地形瓦片是压缩保存的。一旦提取,瓦片是 little-endian,二进制数据。文件的第一部分后具有一些格式的标题。Doubles的是IEEE 75464为浮点数,和FloatsIEEE 754 32位浮点数。

struct QuantizedMeshHeader

{

    // The center of the tile in Earth-centered Fixed coordinates.

    double CenterX;

    double CenterY;

    double CenterZ;

 

    // The minimum and maximum heights in the area covered by this tile.

    // The minimum may be lower and the maximum may be higher than

    // the height of any vertex in this tile in the case that the min/max vertex

    // was removed during mesh simplification, but these are the appropriate

    // values to use for analysis or visualization.

    float MinimumHeight;

    float MaximumHeight;

 

    // The tile’s bounding sphere.  The X,Y,Z coordinates are again expressed

    // in Earth-centered Fixed coordinates, and the radius is in meters.

    double BoundingSphereCenterX;

    double BoundingSphereCenterY;

    double BoundingSphereCenterZ;

    double BoundingSphereRadius;

 

    // The horizon occlusion point, expressed in the ellipsoid-scaled Earth-centered Fixed frame.

    // If this point is below the horizon, the entire tile is below the horizon.

    // See http://cesiumjs.org/2013/04/25/Horizon-culling/ for more information.

    double HorizonOcclusionPointX;

    double HorizonOcclusionPointY;

    double HorizonOcclusionPointZ;

};

 

在头文件后面是定点数据。Unsigned interesting32位无符号整数和unsgned short是一个16位无符号整型。

 

struct VertexData

{

    unsigned int vertexCount;

    unsigned short u[vertexCount];

    unsigned short v[vertexCount];

    unsigned short height[vertexCount];

};

这个vertexCount在这个三个数组中使用。这三个数组包含先前得到的delta,然后用zig-zag编码来生成小整数,不管它们的符号是什么都是使用少量的bit

解码这个值也是很简单的:

var u = 0;var v = 0;var height = 0;

function zigZagDecode(value) {

    return (value >> 1) ^ (-(value & 1));

}

for (i = 0; i < vertexCount; ++i) {

    u += zigZagDecode(uBuffer[i]);

    v += zigZagDecode(vBuffer[i]);

    height += zigZagDecode(heightBuffer[i]);

 

    uBuffer[i] = u;

    vBuffer[i] = v;

    heightBuffer[i] = height;

}

 

一旦解码,每个阵列的值的含义如下:

名称

意义

 

u

在瓦片中顶点的水平坐标。当u值是0,顶点是瓦片的西边缘。当值是32767,顶点是在瓦片东边。是其他的值时,顶点的经度是瓦片东边和西边经度的线性插值。

 

v

这个是顶点的垂直坐标。当这个v值是0时,顶点在瓦片的南边,当这个值是32767,顶点在瓦片的北边。其他值时,顶点的纬度是瓦片你南边和北边纬度的线性插值。

 

height

在瓦片顶点的高度值。当高度值是0,顶点高度相当于瓦片的最小高度,正如在瓦片标题中指定的。当值是32767,顶点高度相当于瓦片最大高度值。如果是其他值,顶点的高度值是最大和最小的高度值的线性插值。

 

 

紧跟着顶点数据是索引数据。索引指定顶点如何连接成三角形。当瓦片有多余65536个顶点,瓦片使用IndexData32结构来编码索引。否则,使用IndexData16结构。

 

执行适当的字节对齐,在IndexData之前添加填充物,以确保IndexData162个字节和IndexData324个字节对齐。

struct IndexData16

{

    unsigned int triangleCount;

    unsigned short indices[triangleCount * 3];

}

struct IndexData32

{

    unsigned int triangleCount;

    unsigned int indices[triangleCount * 3];

}

 

索引使用来自webgl-loader的高水平标记编码,索引北解码如下:

var highest = 0;for (var i = 0; i < indices.length; ++i) {

    var code = indices[i];

    indices[i] = highest - code;

    if (code === 0) {

        ++highest;

    }

}

 

每一个索引值构成一个三角形,使用逆时针绕序。下面的三角形索引是四个指标列表:

struct EdgeIndices16

{

    unsigned int westVertexCount;

    unsigned short westIndices[westVertexCount];

 

    unsigned int southVertexCount;

    unsigned short southIndices[southVertexCount];

 

    unsigned int eastVertexCount;

    unsigned short eastIndices[eastVertexCount];

 

    unsigned int northVertexCount;

    unsigned short northIndices[northVertexCount];

}

struct EdgeIndices32

{

    unsigned int westVertexCount;

    unsigned int westIndices[westVertexCount];

 

    unsigned int southVertexCount;

    unsigned int southIndices[southVertexCount];

 

    unsigned int eastVertexCount;

    unsigned int eastIndices[eastVertexCount];

 

    unsigned int northVertexCount;

    unsigned int northIndices[northVertexCount];

}

 

这些索引列表列举了瓦片边缘的顶点。指定哪些顶点在边缘很有帮助的,这样就可以在相邻的细节层之间添加裙子来隐藏裂缝。

 

 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值