3D Tiles介绍(二)

来源:互联网 发布:淘宝新百伦旗舰店 编辑:程序博客网 时间:2024/06/08 03:43

原文地址:点击打开链接

Coordinate System and Units 坐标系和单位

3D Tiles use a right-handed Cartesian coordinate system, that is, the cross product of x and y yields z. 3D Tiles define the z axis as up for local Cartesian coordinate systems (see theTile transform section). A tileset's global coordinate system will often be WGS84 coordinates, but it doesn't have to be, e.g., a power plant may be defined fully in its local coordinate system for using with a modeling tool without a geospatial context.

3D Tiles使用右手笛卡尔坐标系,即x和y的叉乘得到z轴。3D Tiles定义本地笛卡尔坐标系z轴向上。瓦片集的世界坐标系常常是WGS84坐标系,但是也不一定,例如,一个发电厂可以在没有地理空间框架的模型工具中,使用局部坐标系创建。

b3dm and i3dm tiles embed glTF. According to the glTF spec glTF uses a right-handed coordinate system and defines the y axis as up. By default embedded models are considered to be y-up, but in order to support a variety of source data, including models defined directly in WGS84 coordinates, embedded glTF models may be defined as x-up, y-up, or z-up with the asset.gltfUpAxis property oftileset.json. In general an implementation should transform glTF assets to z-up at runtime to be consistent with the z-up coordinate system of the bounding volume hierarchy.

b3dm和i3dm瓦片内嵌glTF。根据glTF说明,glTF使用y轴向上的右手坐标系。默认情况下,内嵌模型y轴向上,但是为了支持多种数据源,包括直接在WGS84坐标系定义的模型,内嵌glTF模型也可以通过tileset.json的asset.gltfUpAxis属性定义x轴向上,y轴向上或z轴向上。通常的实现是,在运行时变换glTF资产为z轴向上,以便和包围体层次的z轴向上坐标系保持一致。

The units for all linear distances are meters.

所有线性距离都采用米为单位。

All angles are in radians.

所有角度采用弧度值。

3D Tiles do not explicitly store Cartographic coordinates (longitude, latitude, and height); these values are implicit in WGS84 Cartesian coordinates, which are efficient for the GPU to render since they do not require a non-affine coordinate transformation. A 3D Tiles tileset can include application-specific metadata, such as Cartographic coordinates, but the semantics are not part of the 3D Tiles specification.

3D Tiles 不明确存储制图坐标(经度、纬度和高程);这些值内含在WGS84笛卡尔坐标中,这样有利于GPU高效渲染,因为坐标不需要非仿射坐标变换。3D Tiles 瓦片集可以包含应用程序专用元数据,例如制图坐标,但是语义不包含在3D Tiles规范中。

Tile transform 瓦片变换

To support local coordinate systems, e.g., so a building tileset inside a city tileset can be defined in its own coordinate system, and a point cloud tileset inside the building could, again, be defined in its own coordinate system, each tile has an optionaltransform property.

为了支持局部坐标系,每个瓦片有一个可选的transform属性,这样一个城市瓦片集中的一个建筑物瓦片集才能在它自己的坐标系中定义,一个建筑物中的点云瓦片集能在它自己的坐标系中定义。

The transform property is a 4x4 affine transformation matrix, stored in column-major order, that transforms from the tile's local coordinate system to the parent tile's coordinate system, or tileset's coordinate system in the case of the root tile.

transform属性是一个4X4的仿射变换矩阵,以列主序存储,用来实现从瓦片局部坐标系到父瓦片或根瓦片坐标系的变换。

The transform property applies to:

transform属性应用于:

  • tile.content
    • Each feature's position.
    • Each feature's normal should be transformed by the top-left 3x3 matrix of the inverse-transpose oftransform to account forcorrect vector transforms when scale is used.
    • content.boundingVolume, except when content.boundingVolume.region is defined, which is explicitly inWGS84 / EPSG:4326 coordinates.
  • tile.boundingVolume, except when tile.boundingVolume.region is defined, which is explicitly in WGS84 / EPSG:4326 coordinates.
  • tile.viewerRequestVolume, except when tile.viewerRequestVolume.region is defined, which is explicitly in WGS84 / EPSG:4326 coordinates.

The transform property does not apply to geometricError, i.e., the scale defined bytransform does not scale the geometric error; the geometric error is always defined in meters.

transform属性不应用在geometricError上,即transform定义的scale不缩放geometric error;geometric error总是以米为单位定义。

When transform is not defined, it defaults to the identity matrix:

transform未定义时,默认为单位矩阵:

[1.0, 0.0, 0.0, 0.0,0.0, 1.0, 0.0, 0.0,0.0, 0.0, 1.0, 0.0,0.0, 0.0, 0.0, 1.0]

The transformation from each tile's local coordinate to the tileset's global coordinate system is computed by a top-down traversal of the tileset and post-multiplying a child'stransform with its parent'stransform like a traditional scene graph or node hierarchy in computer graphics.

从每个瓦片的局部坐标到瓦片集的世界坐标系变换,是通过从上到下遍历瓦片集,用子瓦片的transform右乘父瓦片的transform计算的,就像计算机图形学中传统的场景图或节点层级。

The following JavaScript code shows how to compute this using Cesium's Matrix4 and Matrix3 types.

下面的JavaScript代码展示了如何用Cesium的Matrix4和Matrix3类型进行坐标变换计算。

function computeTransforms(tileset) {    var t = tileset.root;    var transformToRoot = defined(t.transform) ? Matrix4.fromArray(t.transform) : Matrix4.IDENTITY;    computeTransform(t, transformToRoot);}function computeTransform(tile, transformToRoot) {    // Apply 4x4 transformToRoot to this tile's positions and bounding volumes    var inverseTransform = Matrix4.inverse(transformToRoot, new Matrix4());    var normalTransform = Matrix4.getRotation(inverseTransform, new Matrix3());    normalTransform = Matrix3.transpose(normalTransform, normalTransform);    // Apply 3x3 normalTransform to this tile's normals    var children = tile.children;    var length = children.length;    for (var k = 0; k < length; ++k) {        var child = children[k];http://write.blog.csdn.net/postedit/75007514        var childToRoot = defined(child.transform) ? Matrix4.fromArray(child.transform) : Matrix4.clone(Matrix4.IDENTITY);        childToRoot = Matrix4.multiplyTransformation(transformToRoot, childToRoot, childToRoot);        computeTransform(child, childToRoot);    }}

For an example of the computed transforms (transformToRoot in the code above) for a tileset, consider:

例如计算下面这个瓦片集的变换矩阵(上述代码中的transformToRoot):

The computed transform for each tile is:

每个瓦片的变换矩阵这么计算:

  • TO: [T0]
  • T1: [T0][T1]
  • T2: [T0][T2]
  • T3: [T0][T1][T3]
  • T4: [T0][T1][T4]

The positions and normals in a tile's content may also have tile-specific transformations applied to thembefore the tile'stransform (before indicates post-multiplying for affine transformations). Some examples are:

在瓦片的变换矩阵之前(在仿射变换右乘之前),一个瓦片content中可能设置了位置和法线的变换矩阵。例如:

  • b3dm and i3dm tiles embed glTF, which defines its own node hierarchy, where each node has a transform. These are applied beforetile.transform.                       
  • b3dm和i3dm瓦片内嵌glTF,glTF中定义自己的节点层次,每个节点有一个变换矩阵,这些变换矩阵应用在tile.transform之前。
  • i3dm's Feature Table defines per-instance position, normals, and scales. These are used to create per-instance 4x4 affine transform matrices that are applied to each instance beforetile.transform.                                                                                                                                                                                                              
  •  i3dm的Feature Table定义每个实例的位置、法线和比例,用于创建每个实例的4X4仿射变换矩阵,这些矩阵在tile.transform之前应用于每个实例。
  • Compressed attributes, such as POSITION_QUANTIZED in the Feature Tables fori3dm,pnts, and vctr, and NORMAL_OCT16P inpnts should be decompressed before any other transforms.
  • 压缩属性,例如i3dm、pnts和vctr的Feature Tables中的POSITION_QUANTIZED以及pnts中的NORMAL_OCT16P,应该在任何其他转换之前解压缩。

Therefore, the full computed transforms for the above example are:

因此,上例中完整的矩阵变换计算是:

  • TO: [T0]
  • T1: [T0][T1]
  • T2: [T0][T2][pnts-specific Feature Table properties-derived transform]
  • T3: [T0][T1][T3][b3dm-specific transform, including the glTF node hierarchy]
  • T4: [T0][T1][T4][i3dm-specific transform, including per-instance Feature Table properties-derived transform and the glTF node hierarchy]




原创粉丝点击