3dTile技术研究-概念详述(10)Instanced 3D Model

上篇:

3dTile技术研究-概念详述(7)Batched 3D Model

下篇:

3dTile技术研究-概念详述(8)Feature Table

3dTile技术研究-概念详述(9)Batch Table

 

1. 内容(Contents)

2. 概述(Overview)

Instanced 3D Model是高效传输和渲染大量对象(也叫实例)的tile格式,有一点变化。最简单的场景,比如,一个相同的树对象可能被放在(或者叫实例化在)几个地方。每个实例引用了相同的对象(树),且有各自实例的属性,比如位置。用核心的的3D Tiles格式语言来说,每个实例是一个对象。

除了表达tree对象之外,Instanced 3D Model对于消防栓、下水道帽、灯具和交通灯等外部功能,以及用于内部CAD功能,如螺栓、阀门和电源插座也是有用的。

一个Instanced 3D Model tile是以小端方式存储的二进制数据流。

实现注意项:可以用一个Composite tile来创建有不同类型的instanced models的tiles,比如,合并trees和交通灯两个Instanced 3D Model tiles。

实现注意项: Instanced 3D Model可以很好的映射到ANGLE_instanced_arrays扩展,以高效的使用WebGL渲染。

3. 布局(Layout)

tile由标头部分和紧随其后的二进制体构成。下面的图片展示了Instanced 3D Model的布局(虚线标记的是可选的字段):

header layout

布局和b3dm基本一致

3.1 填充(Padding)

tile的byteLength必须是8字节边界对齐的。包含的Feature TableBatch Table必须遵守它们各自的填充要求。

binary glTF(如果出现的话)必须开始和结束语8字节的边界,这样glTF的字节对齐要求可以得到保障。这可以通过填充Feature Table或Batch Table。

另外,如果glTF字段(glTF field)是UTF-8字符串,必须在它的后面填充空格字符串(0x20)以满足tile的字节对齐要求,而在运行时请求glTF资源之前必须被去掉。

glTF字段(glTF field),其实翻译成字段不准确,原意表示的是glTF领域,也就是内容,具体请参考下面的第6章。

4. 标头(Header)

32字节的标头含有下面的字段:

Field nameData typeDescription
magic4-byte ANSI string"i3dm". This can be used to identify the content as an Instanced 3D Model tile.
versionuint32The version of the Instanced 3D Model format. It is currently 1.
byteLengthuint32The length of the entire tile, including the header, in bytes.
featureTableJSONByteLengthuint32The length of the Feature Table JSON section in bytes.
featureTableBinaryByteLengthuint32The length of the Feature Table binary section in bytes.
batchTableJSONByteLengthuint32The length of the Batch Table JSON section in bytes. Zero indicates that there is no Batch Table.
batchTableBinaryByteLengthuint32The length of the Batch Table binary section in bytes. If batchTableJSONByteLength is zero, this will also be zero.
gltfFormatuint32Indicates the format of the glTF field of the body. 0 indicates it is a uri, 1 indicates it is embedded binary glTF. See the glTF section below.

二进制体紧随在标头部分之后,并且由三部分构成:Feature TableBatch Table, 和 glTF

5. Feature Table

Feature Table含有用来创建实例化对象(instanced models)的i3dm语义值。更多的有用信息请参考Feature Table specification

See Property reference for the i3dm feature table schema reference. The full JSON schema can be found in i3dm.featureTable.schema.json.

5.1 语义(Semantics)

5.1.1 实例语义(Instance semantics)

这些语义映射到用来创建实例的一个对象属性值数组。这些数组的长度对于所有的语义必须一样,且等于实例的数量。每个实例语义的值必须引用指向Feature Table的二进制体;它们不能嵌入到Feature Table的JSON标头中。

如果一个语义依赖另一个语义,那后者必须是定义的。如果一个实例的SCALESCALE_NON_UNIFORM都定义了,那么这两个缩放操作都要被应用。如果一个实例的POSITIONPOSITION_QUANTIZED都定义了,这个更高精度的POSITION将会被使用。如果一个实例的NORMAL_UPNORMAL_RIGHTNORMAL_UP_OCT32P, 和 NORMAL_RIGHT_OCT32P都定义了,那么较高精度的NORMAL_UPNORMAL_RIGHT将被使用。

SemanticData TypeDescriptionRequired
POSITIONfloat32[3]

A 3-component array of numbers containing xy, and z Cartesian coordinates for the position of the instance.

一个包含实例的x,y,z笛卡尔坐标位置的3个数值元素的数组。

✅ Yes, unless POSITION_QUANTIZED is defined.
POSITION_QUANTIZEDuint16[3]

A 3-component array of numbers containing xy, and z in quantized Cartesian coordinates for the position of the instance.

 

一个包含实例的x,y,z量化的笛卡尔坐标位置的3个数值元素的数组。

✅ Yes, unless POSITION is defined.
NORMAL_UPfloat32[3]

A unit vector defining the up direction for the orientation of the instance.

一个定义了实例的旋转(绕)的up方向的单位向量。

🔴 No, unless NORMAL_RIGHT is defined.
NORMAL_RIGHTfloat32[3]

A unit vector defining the right direction for the orientation of the instance. Must be orthogonal to up.

一个定义了实例旋转的right方向的单位向量,它必须正交于up方向。

🔴 No, unless NORMAL_UP is defined.
NORMAL_UP_OCT32Puint16[2]

An oct-encoded unit vector with 32-bits of precision defining the up direction for the orientation of the instance.

具有32位精度的八进制编码的单位向量,定义了实例旋转的up的方向。

🔴 No, unless NORMAL_RIGHT_OCT32P is defined.
NORMAL_RIGHT_OCT32Puint16[2]

An oct-encoded unit vector with 32-bits of precision defining the right direction for the orientation of the instance. Must be orthogonal to up.

具有32位精度的八进制编码的单位向量,定义实例旋转的right方向。必须与up正交。

🔴 No, unless NORMAL_UP_OCT32P is defined.
SCALEfloat32

A number defining a scale to apply to all axes of the instance.

一个定义了需要应用于实例的所有轴的缩放值。

🔴 No.
SCALE_NON_UNIFORMfloat32[3]

A 3-component array of numbers defining the scale to apply to the xy, and z axes of the instance.

一个定义了实例的x,y,z轴对应缩放的3元素数值数组。

🔴 No.
BATCH_IDuint8uint16 (default), or uint32

The batchId of the instance that can be used to retrieve metadata from the Batch Table.

实例的batchId,可以用来从Batch Table中获取元数据。

🔴 No.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

5.1.2 全局语义(Global semantics)

这些语义定义了针对于所有实例的全局属性。

SemanticData TypeDescriptionRequired
INSTANCES_LENGTHuint32

The number of instances to generate. The length of each array value for an instance semantic should be equal to this.

需要创建的实例的数量。实例语义的每个数组长度值需要和这个数量相等。

✅ Yes.
RTC_CENTERfloat32[3]

A 3-component array of numbers defining the center position when instance positions are defined relative-to-center.

定义了中心位置的3元素数值数组,当实例的位置被定义为相对于中心(relative-to-center)的时候有效。

🔴 No.
QUANTIZED_VOLUME_OFFSETfloat32[3]

A 3-component array of numbers defining the offset for the quantized volume.

定义了量化的volume的偏移的3元素数值数组。

🔴 No, unless POSITION_QUANTIZED is defined.
QUANTIZED_VOLUME_SCALEfloat32[3]

A 3-component array of numbers defining the scale for the quantized volume.

定义了量化的volume的缩放的3元素数值数组。

🔴 No, unless POSITION_QUANTIZED is defined.
EAST_NORTH_UPboolean

When true and per-instance orientation is not defined, each instance will default to the east/north/up reference frame's orientation on the WGS84 ellipsoid.

当值是true并且每个实例的旋转没有定义时,每个实例将会默认的为WGS84椭球体的east/north/up参考框架方向。

 

🔴 No.

可以在examples section中找到使用了这些语义的例子。

5.2 实例方向(Instance orientation)

实例的方向被upright向量生成的正交坐标轴定义。这个方向需要被 tile transform作用。

标准坐标系中的x轴对应于转换后的right向量,y轴对应于up向量。z轴应该对应于up向量,但是这常常被忽略,因为它总是由rightup叉乘所得。

在标准坐标系中的一个盒子:

 box standard basis

盒子被转换了,它的方向被旋转了:

 box rotated basis

5.2.1 八进制编码的法向向量(Oct-encoded normal vectors)

如果没有为实例定义NORMAL_UPNORMAL_RIGHT,则其方向可以作为八进制编码的法向存储在NORMAL_UP_OCT32P和中NORMAL_RIGHT_OCT32P。它们使用在独立单位向量的有效表示法调查中描述的八进制编码定义了upright。八进制编码的值存储在无符号的非规范化范围([0, 65535])中,然后在运行时映射到有符号的规范化范围([-1.0, 1.0])。

在CesiumJS的AttributeCompression 模块中可以找到对这些单位矢量进行编码和解码的实现。

5.2.2 默认方向(Default orientation)

如果不存在NORMAL_UPNORMAL_RIGHTNORMAL_UP_OCT32PNORMAL_RIGHT_OCT32P,则实例没有自定义方向。如果EAST_NORTH_UPtrue,则假定该实例在WGS84椭圆体上,并且其方向将默认为其制图位置处的参考框架的east/north/up。这适用于诸如树木之类的实例模型,其方向始终从其在椭球表面上的位置朝上。

5.2.3 实例位置(Instance position)

POSITION定义了实例的位置,该位置还没有被tile的转换矩阵作用。

RTC_CENTER

(实例的)位置可能会定义为相对于中心的(relative-to-center),以进行高精度的渲染,参考Precisions, Precisions。如果这样定义了,RTC_CENTER指定了所有实例位置相对于的中心位置的值。

Quantized positions

如果实例的POSITION未定义,则其位置可以存储在中POSITION_QUANTIZED,后者定义相对于量化体积的实例位置。如果没有POSITIONPOSITION_QUANTIZED定义,实例将不会被创建。

量化的体积由offsetscale定义,并将量化的位置映射到局部空间,如下图所示:

quantized volume

offset存储在全局语义QUANTIZED_VOLUME_OFFSET中,并且scale存储在全局语义QUANTIZED_VOLUME_SCALE中。如果未定义这些全局语义,POSITION_QUANTIZED则无法使用。

可以使用以下公式将量化的位置映射到本地空间:

POSITION = POSITION_QUANTIZED * QUANTIZED_VOLUME_SCALE / 65535.0 + QUANTIZED_VOLUME_OFFSET

5.2.4 实例缩放(Instance scaling)

缩放可以使用SCALESCALE_NON_UNIFORM语义应用于实例。 SCALE沿着所有轴施加均匀的缩放,而SCALE_NON_UNIFORM独立地应用缩放到xyz轴。

5.3 例子(Examples)

下面的例子展示了如何生成Feature Table的JSON和二进制数据。

Positions only

在这个最小的例子中,我们把4个实例以默认的方向放到了一个单位长度的正方形的四个角上:

var featureTableJSON = {
    INSTANCES_LENGTH : 4,
    POSITION : {
        byteOffset : 0
    }
};

var featureTableBinary = new Buffer(new Float32Array([
    0.0, 0.0, 0.0,
    1.0, 0.0, 0.0,
    0.0, 0.0, 1.0,
    1.0, 0.0, 1.0
]).buffer);

Quantized positions and oct-encoded normals

在此示例中,四个实例的以八进制格式编码的放置方向为的up[0.0, 1.0, 0.0])、right[1.0, 0.0, 0.0]),并将它们放置在量化体积的角上,该量化体积在xz方向上跨越-250.0到个250.0单位:

VAR  featureTableJSON  =  { 
    INSTANCES_LENGTH:4 ,
    QUANTIZED_VOLUME_OFFSET:[ - 250.0 , 0.0 , - 250.0 ] ,
    QUANTIZED_VOLUME_SCALE:[ 500.0 , 0.0 , 500.0 ] ,
    POSITION_QUANTIZED:{ 
        byteOffset:0 
    } ,
    NORMAL_UP_OCT32P:{ 
        byteOffset:24 
    } ,
    NORMAL_RIGHT_OCT32P:{ 
        byteOffset:40 
    } 
} ; 

VAR  positionQuantizedBinary  = 新 缓冲液(新 Uint16Array ([ 
    0 , 0 , 0 ,
    65535 , 0 , 0 ,
    0 , 0 , 65535 ,
    65535 , 0 , 65535 
] )。缓冲液); 

var  normalUpOct32PBinary  =  new  Buffer (new Uint16Array ([ 
    32768 , 65535 ,
    32768 , 65535 ,
    32768 , 65535 ,
    32768 , 65535 
] )。缓冲); 

VAR  normalRightOct32PBinary  = 新 缓冲液(新 Uint16Array ([ 
    65535 , 32768 ,
    65535 , 32768 ,
    65535 , 32768 ,
    65535 , 32768 
] )。缓冲); 

var  featureTableBinary  =  Buffer 。连续([ positionQuantizedBinary , normalUpOct32PBinary , normalRightOct32PBinary ] );

6. Batch Table

包含以batchId组织的源数据,它可以用于声明式样式。更多信息请参考Batch Table

可以参考该系列博客中关于Batch Table的一篇:3dTile技术研究-概念详述(9)Batch Table

7. glTF

嵌入了包含模型几何和纹理信息的glTF 2.0

要实例化的glTF资源存储在Feature Table 和 Batch Table之后。它可能嵌入了所有的几何、纹理和动画数据,或者可能部分或全部的引用外部资源来存储这些数据。

header.gltfFormat指定了glTF字段的格式:

  • header.gltfFormat的值是0时,glTF字段是一个UTF-8的字符串,其中包含一个glTF的uri或者二进制的glTF内容。
  • header.gltfFormat的值是1时,glTF字段是一个包含了binary glTF的二进制数据。

 glTF字段(glTF field),其实翻译成字段不准确,原意表示的是glTF领域,也就是内容。

7.1 坐标系(Coordinate system)

默认的嵌入的glTFs使用了一个y-up的右手坐标系。为了保持与3D Tiles的z-up坐标系的一致性,在运行时必须对glTFs进行转换。详细参考glTF transforms

 

8. File extension and MIME type

Batched 3D Model tiles使用.i3dm扩展格式和application/octet-stream MIME type。

显示的文件扩展名是可选的。有效的实现可能会忽略高扩展名而在标头的 magic字段标记内容的格式。

参考之前的文章,有示例截图。 

 

传送:

3dTile技术研究-开篇

3dTile技术研究-概述

3dTile技术研究-概念详述(1)

3dTile技术研究-概念详述(2)

3dTile技术研究-概念详述(3)

3dTile技术研究-概念详述(4)

3dTile技术研究-概念详述(5)

3dTile技术研究-概念详述(6)

3dTile技术研究-概念详述(7)Batched 3D Model

3dTile技术研究-概念详述(8)Feature Table

3dTile技术研究-概念详述(9)Batch Table

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值