File Formats
This page describes the proprietary binary file formats that are used by the Tinman 3D SDK.
Basic Data Types
In the following descriptions, the type names int8
, int16
, int32
, int64
refer to signed integer types and the types uint8
, uint16
, uint32
refer to unsigned integer types.
Floating-point types are indicated by float32
and float64
(IEEE 754).
Unless stated otherwise in the description, multi-byte values use little-endian encoding.
In specific cases, big-endian may be indicated by the type suffix _be
and _little-endian_ may be indicated by _le
.
The type bool
is an 8-bit integer which represents either true (0
) or false (~0
).
Fixed-length array types have a []
suffix.
Array elements are stored sequentially, without padding.
The type varint
refers to the variable-length integer type, see SystemUtil.VarIntRead and SystemUtil.VarIntWrite.
The special type suffix
maps to different basic data types, depending on the name suffix of the enclosing type:
Name Suffix | Maps to… | Example |
---|---|---|
…D |
float64 |
|
…F |
float32 |
|
…I |
int32 |
|
…L |
int64 |
enum
The ordinal values of the items of an enumeration type that is annotated with SemanticEnumAttribute may be used in binary file formats.
In such a case, the documented type will be int32
, int16
or int8
and the description will point to the enumeration type.
For other enumerations, the persistent values of the enumeration items are documented in-place.
string
A nullable sequence of ISO-8859-1 or UTF-16 characters.
Field | Type | Count | Description |
---|---|---|---|
length |
int32 |
1 |
The string length, in characters |
if length == -1 |
The |
||
else-if length < 0 |
Use |
||
chars |
uint16 |
length |
The string characters in UTF-16 encoding |
else |
|||
chars |
uint8 |
length |
The string characters in ISO-8859-1 encoding |
end-if |
Compiled Model Hierarchy (CMH)
This is a self-contained file format for 3D models, which aggregates all model data in a single file, while allowing lazy-loading of specific data at runtime; for example vertex buffers, index buffers and textures.
This file format is backward compatible, i.e. files in an older format can always be loaded with the current SDK version.
When writing a file, the smallest file version is chosen that is capable of carrying all information, which makes it possible to generate files that may be consumed by an older SDK version.
- See
History
Changed | Released [1] | Preview [2] | Version | Description |
---|---|---|---|---|
2023/03/07 |
2023/03/07 |
2023/03/07 |
v5 |
Added new material properties to IMaterial, to support the glTF 2.0 specification. The IMaterial.BaseColor, IMaterial.Emissive, IMaterial.Reflectivity and IMaterial.Translucency properties may now carry HDR color values. Added base vertex for indexed geometry to PrimitiveBatch. Added the ModelFlags.Terrain, ModelPartFlags.Opaque and ModelVertexFormat.TextureCoordsExtra flags. Added support for re-using IModel and IModelPart objects at multiple places in the model hierarchy. Replaced ModelFlags.Lighting with ModelPartFlags.NoLighting. |
2023/02/10 |
2023/02/10 |
2023/02/10 |
v4 |
Added level-of-detail control, see IModel.FadeIn / IModel.FadeOut. |
2023/02/06 |
- |
- |
v3 |
Added surface layers, see IModelPart.Layer. |
2021/05/24 |
2021/09/10 |
2021/09/10 |
v3 |
Added embedded spatial acceleration structures, see ModelFlags.ComplexGeometry. |
2020/07/28 |
2021/01/10 |
2021/01/10 |
v2 |
Added model parts, see IModelPart. Added 64-bit precision for child-to-parent transforms, see IModel.ChildTransformAt. |
2020/07/06 |
- |
- |
v2 |
|
2019/12/21 |
- |
- |
v1 |
Removed model animation frames. |
2017/03/23 |
2017/04/28 |
2017/04/28 |
v1 |
Added unit of measure, see IModel.Unit. |
2017/03/21 |
- |
- |
- |
Initial version (unreleased). |
Specification
This is the binary file format specification of the CMH file format.
Byte offsets are always interpreted relative to the beginning of the file.
Header
Field | Type | Count | Description |
---|---|---|---|
magic |
int64 |
1 |
The magic value |
version |
varint |
1 |
The file version number; file format features that depend on specific version numbers are annotated with @ version <> N. |
root |
int64 |
1 |
Byte offset of root Model block |
Model
This block encodes the data of IModel objects.
Field | Type | Count | Description |
---|---|---|---|
name_length |
varint |
1 |
Length of name field, in array elements |
name |
uint8[] |
1 |
The UTF-8 byte sequence of the model name |
parts |
varint |
1 |
Number of subsequent ModelPart blocks |
if parts >= 0 |
A bitmask that carries the following information:
|
||
geometry |
int64 |
1 |
Byte offset to the Geometry block for IModelPart.Geometry |
material |
int64 |
1 |
Byte offset to the Material block for IModelPart.Material |
unit |
object |
1 |
Serialized UnitOfMeasure object for IModel.Unit |
batch |
1 |
Embedded Batch block for IModelPart.Batch |
|
- |
int8 |
1 |
Not used, should be |
else-if parts < 0 |
Number of subsequent embedded ModelPart blocks, encoded as: |
||
flags |
varint |
1 |
A bitmask that carries the following information:
|
unit |
object |
1 |
Serialized UnitOfMeasure object for IModel.Unit |
part |
count |
Embedded ModelPart blocks for IModel.PartAt. |
|
end-if |
|||
collider |
1 |
The pre-computed spatial acceleration structure @ version > 2 |
|
fade |
object |
2 |
Serialized Fade values for IModel.FadeIn and IModel.FadeOut, in that order @ version > 3 |
children |
varint |
1 |
Number of subsequent Model blocks. |
if children >= 0 |
Number of child models with 32-bit floating-point transformations, encoded as |
||
repeat count times |
|||
child |
int64 |
1 |
Byte offset of index-th child Model block |
matrix |
1 |
The affine matrix that transforms from child to parent |
|
end-repeat |
|||
else-if children < 0 |
Number of child models with 64-bit floating-point transformations, encoded as |
||
repeat count times |
|||
child |
int64 |
1 |
Byte offset of index-th child Model block |
translation |
1 |
Translation from child to parent |
|
rotation |
1 |
Rotation from child to parent (may include axis flip) |
|
scaling |
float64 |
1 |
The uniform scale factor from child to parent |
end-repeat |
|||
end-if |
ModelPart
This block encodes the data of IModelPart objects.
Field | Type | Count | Description |
---|---|---|---|
part |
varint |
1 |
The part flags or byte offset. |
if part < 0 |
Byte offset of known ModelPart block to reference, encoded as |
||
else |
A bitmask that carries the following information:
|
||
geometry |
int64 |
1 |
Byte offset of Geometry block. |
material |
int64 |
1 |
Byte offset of Material block. |
batch |
1 |
Embedded Batch block. |
|
end-if |
Pixel Pyramid Cache (PYC)
See: PyramidFileCache
Serialized Object (SER)
The ISerializable interface is implemented by classes that support compact binary serialization, for example JsonValue. The implementations of the ITypeSerializer interface may be used to serialize non-object values, for example Vec3D.Serializer.
The binary format of every ISerializable object begins with a common preamble block, which defines the serial type ID and version.
Field | Type | Count | Description |
---|---|---|---|
length |
int32 |
1 |
The type identifier length / format version |
if length == -1 |
The deserialized object is |
||
else-if length == 36 |
|||
guid |
1 |
The serial type ID, see GUID.From |
|
version |
int32 |
1 |
The serial version number |
payload |
… |
1 |
The serialized data of the object |
else-if length > 36 |
Use |
||
guid |
int64 |
2 |
The parts of the serial type ID, see GUID.GUID |
payload |
… |
1 |
The serialized data of the object |
else |
Use the value Each deserialized non-null object is assigned a positive identifier, which begins at zero and is incremented for each object. |
||
end-if |
The serial type ID is used to lookup the serial type via SerialTypeInfos.Get, a new object instance is created with ISerialTypeInfo.CreateInstance and the object state is deserialized by calling ISerializable.Deserialize, passing the serial version number.
The common type name prefix "Tinman." is omitted in the following sections. |
Core.Math
Cuboid
Field | Type | Count | Description |
---|---|---|---|
origin |
1 |
||
orientation |
1 |
Fraction
Field | Type | Count | Description |
---|---|---|---|
numerator |
int32 |
1 |
|
denominator |
int32 |
1 |
Gauss
Field | Type | Count | Description |
---|---|---|---|
expected |
float64 |
1 |
The expected value of the distribution |
deviation |
float64 |
1 |
The deviation value of the distribution |
scale |
float64 |
1 |
The scale value of the distribution |
Plane
Field | Type | Count | Description |
---|---|---|---|
normal |
1 |
||
distance |
float64 |
1 |
QuatD
Field | Type | Count | Description |
---|---|---|---|
x |
float64 |
1 |
|
y |
float64 |
1 |
|
z |
float64 |
1 |
|
w |
float64 |
1 |
Range(DF)
Field | Type | Count | Description |
---|---|---|---|
start |
suffix |
1 |
|
end |
suffix |
1 |
Range(IL)
Field | Type | Count | Description |
---|---|---|---|
start |
suffix |
1 |
|
last |
suffix |
1 |
Ray
Field | Type | Count | Description |
---|---|---|---|
origin |
1 |
||
direction |
1 |
Sphere
Field | Type | Count | Description |
---|---|---|---|
center |
1 |
||
radius |
float64 |
1 |
Core.Math.Vectors
Mat2(DF)
Field | Type | Count | Description |
---|---|---|---|
element |
suffix |
4 |
The matrix elements, in row-major order |
Mat3(DF)
Field | Type | Count | Description |
---|---|---|---|
element |
suffix |
9 |
The matrix elements, in row-major order |
Mat4(DF)
Field | Type | Count | Description |
---|---|---|---|
element |
suffix |
16 |
The matrix elements, in row-major order |
Vec2(DFIL)
Field | Type | Count | Description |
---|---|---|---|
x |
suffix |
1 |
|
y |
suffix |
1 |
Vec3(DFIL)
Field | Type | Count | Description |
---|---|---|---|
x |
suffix |
1 |
|
y |
suffix |
1 |
|
z |
suffix |
1 |
Vec4(DFIL)
Field | Type | Count | Description |
---|---|---|---|
x |
suffix |
1 |
|
y |
suffix |
1 |
|
z |
suffix |
1 |
|
z |
suffix |
1 |
Core.Util
ColorF
Field | Type | Count | Description |
---|---|---|---|
r |
float32 |
1 |
|
g |
float32 |
1 |
|
b |
float32 |
1 |
|
a |
float32 |
1 |
GUID
Field | Type | Count | Description |
---|---|---|---|
first |
int64 |
1 |
|
second |
int64 |
1 |
LUID
Field | Type | Count | Description |
---|---|---|---|
value |
int32 |
1 |
Terrain.Georef
LatLon
Field | Type | Count | Description |
---|---|---|---|
longitude |
float64 |
1 |
|
latitude |
float64 |
1 |
LatLonHeight
Field | Type | Count | Description |
---|---|---|---|
coords |
1 |
||
height |
float64 |
1 |
|
vertical |
int32 |
1 |
LatLonRange
Field | Type | Count | Description |
---|---|---|---|
start |
1 |
||
end |
1 |
UnitOfMeasure
Field | Type | Count | Description |
---|---|---|---|
name |
1 |
||
- |
int8 |
8 |
Not used, should be |
one |
float64 |
1 |
|
type |
int32 |
1 |
Terrain.Heightmaps
HeightmapSample
Field | Type | Count | Description |
---|---|---|---|
values |
int8 |
1 |
|
if values has Coverage |
|||
coverage |
int32 |
1 |
|
end-if |
|||
if values has Elevation |
|||
elevation |
int32 |
1 |
|
end-if |
|||
if values has Texture |
|||
texture |
int64 |
1 |
|
end-if |
|||
if values has Material |
|||
material |
int64 |
1 |
|
end-if |
|||
if values has Displacement |
|||
displacement |
int32 |
1 |
|
end-if |
VerticalRange
Field | Type | Count | Description |
---|---|---|---|
minimum |
float64 |
1 |
|
maximum |
float64 |
1 |
Terrain.Mapping
CubemapFaceCoordsI
Field | Type | Count | Description |
---|---|---|---|
x |
int32 |
1 |
|
y |
int32 |
1 |
|
face |
int32 |
1 |
Terrain.Util
Box2(DIL)
Field | Type | Count | Description |
---|---|---|---|
x1 |
suffix |
1 |
|
y1 |
suffix |
1 |
|
x2 |
suffix |
1 |
|
y2 |
suffix |
1 |
Box3(DI)
Field | Type | Count | Description |
---|---|---|---|
x1 |
suffix |
1 |
|
y1 |
suffix |
1 |
|
x2 |
suffix |
1 |
|
y2 |
suffix |
1 |
Fade
Field | Type | Count | Description |
---|---|---|---|
scale |
float64 |
1 |
The scale factor |
offset |
float64 |
1 |
The offset value |
The return value of Fade.Compute is defined as result = value * scale + offset
, clamped to the range [0..1].