Page History
...
Byte Index | Byte Count | Content Description |
---|---|---|
0 | 1 | The binary magic number indicating cgeo file 0x43 |
1 | 4 | The size of the header H that follows represented as a binary 4 byte integer |
5 | H | The header itself in human readable form (see the following description) |
5 + H | Determined by the header | The data section |
Header
...
Let's start with a sample…sample:
Code Block |
---|
Corona Renderer CGeo file.
This file contains an animated Mesh object.
This file is BINARY.
Version: 4
Date created: 2016-01-05/14:10:17
Number of faces: 12
Number of vertices: 8
Number of mapping channels: 2
Number of normals: 24
Bounding box size (original units) : 21.0804 26.3839 33.2031
Bounding box size (millimeters) : 210.804 263.839 332.031
Original material name: [none]
Original object name: Box001
Animation snapshot count: 1
Time per animation snapshot [microseconds]: 33333
Animation time start: 0
Scale: 0.1
Compressed: True |
The header is in plain text, so that it is possible to easily inspect CGeo file in a text editor. It contains properties describing the data stored in the form:
Code Block |
---|
PropertyName: PropertyValue |
Every property shall be on it's own line with line separator being \n
. The header can contain arbitrary number of properties, but there are properties that are mandatory (listed bellow). Beside properties the header can contain arbitrary text. It's a good idea to at least state the origin of the file.
List of mandatory properties
...
Name | Description |
---|---|
“Version” | Currently 7 for Corona v2 |
“Animation snapshot count” | The number of animation snapshots stored in the data section |
“Time per animation snapshot [microseconds]” | As the name suggests |
“Animation time start” | In microseconds. Can be used to place the object correctly on the time line upon loading |
“Scale” | The scale of the data stored relative to millimeter (e.g. 10 if data are stored in centimeters). 0 if unknown |
“Original material name” | As the name suggests |
“Original object name” | As the name suggests |
“Compressed” | Can be one of {'True', 'False'}. The comparison is done case insensitive. If 'False' is specified then no section of the CGeo file is compressed. In other case sections of all snapshots in data section are compressed (see bellow). This property was added in version 5 and if it is missing then 'True' shall be assumed. If at any point in the documentation something is said to be compressed then it is only if the value of this property is 'True'. |
...
Tags are used to identify certain events within the data section. Every tag is a 4 byte integer. Following is the table of currently used tags and the rest of the documentation will be referencing them by their ids.
Tag Id | Tag Value |
---|---|
TAG_ANIMATION_SNAPHOT_START | 0xA3CDEF00 |
TAG_ANIMATION_SNAPHOT_END | 0xFED3BA11 |
TAG_ANIM_TABLE_START | 0xFAD0CCA1 |
TAG_ANIM_TABLE_END | 0xE580AC23 |
TAG_BOUNDING_BOX | 0x2F89A8B5 |
TAG_MESH_DATA | 0x35F71EA8 |
TAG_MESH_VERTICES_END | 0x42C342CC |
TAG_MESH_NORMALS_END | 0xB00B06B0 |
TAG_MESH_MAP_COORDS_END | 0xCAAC04CA |
TAG_POINTCLOUD | 0x1387EBEB |
Layout
...
Following is the description of the layout of the data section.
Item | Description |
---|---|
Flags | An uncompressed 4 byte integer described later. |
TAG_ANIM_TABLE_START | |
Offset Table | Uncompressed offset table. There is an entry for every animation snapshot and every entry is the 8 byte offset from the beginning of the file to the beginning of the snapshot's data |
TAG_ANIM_TABLE_END | |
TAG_ANIMATION_SNAPSHOT_START | Tag indicating the beginning of an animation snapshot. |
Sections | Individual sections containing the data for the snapshot. Described later. |
TAG_ANIMATION_SNAPSHOT_END | Tag indicating the end of an animation snapshot. |
...
Please note that the pair (TAG_ANIMATION_SNAPSHOT_START, TAG_ANIMATION_SNAPSHOT_END) will appear as many times as there are animation snapshots.
Flags
...
Bit | Name | Description |
---|---|---|
1 | Changing Topology | Flag indicates that every animation snapshot is stored compressed on it's own as the topology can change from snapshot to snapshot. In case this flag is not specified then it's expected that only the first snapshot contains topological information and all subsequent snapshots are only stored as compressed differences of positions, normals and texcoords from the first snapshot. |
...
Following is the decription of the section's content when the snapshot is stored completely.
Item | Description |
---|---|
0x1 | 1 byte of value 0x1 indicating that this is a complete snapshot |
Vertex Count | 4 byte integer |
Normal Count | 4 byte integer |
Map Channel Count | 4 byte integer indicating the number of mapping channels |
Triangle Count | 4 byte integer |
Vertices | Every vertex is represented by 3 IEEE754 single precision floating point numbers corresponding to X,Y,Z |
TAG_MESH_VERTICES_END | |
Normals | Every normal is represented by 3 IEEE754 single precision floating point numbers corresponding to X,Y,Z |
TAG_MESH_NORMALS_END | |
Texture Coordinates | Data for all mapping channels. The number of mapping channels is idicated by Map Coord Count. Every mapping channel data are given as 4 byte integer storing the number of texture coordinates followed by the coordinates itself. Each coordinate is represented by 3 IEEE754 single precision floating point numbers corresponding to U,V,W. |
TAG_MESH_MAP_COORDS_END | |
Triangle Data | Described bellow. |
Following table describes how a single triangle is stored in CGEO version 7 and newer (Corona v2 and newer).
Item | Description |
---|---|
Vertex Indices | 3 vertex indices. Every index is represented as a 4 byte integer. |
Normal Indices | 3 normal indices. Every index is represented as a 4 byte integer. |
Map Coordinates Indices | 3 indices are stored for each mapping channel and every index is represented as 4 byte integer. |
Material ID | 2 byte material id. |
Edge Visibility | 1 byte bitset. Bits 0, 1, 2 represents edges AB, BC, CA. When the corresponding bit for an edge is set the edge is visible. |
...
Following is the decription of the section's content when the snapshot is stored as the difference from the first.
Item | Description |
---|---|
0x0 | 1 byte of value 0x0 indicating that this is a difference from the first snapshot |
Vertex Differences | Every difference is represented by 3 IEEE754 single precision floating point numbers corresponding to X,Y,Z |
TAG_MESH_VERTICES_END | |
Normal Differences | Every difference is represented by 3 IEEE754 single precision floating point numbers corresponding to X,Y,Z |
TAG_MESH_NORMALS_END | |
Texture Coordinate Differences | Every difference is represented by 3 IEEE754 single precision floating point numbers corresponding to U,V,W. The differences for all map channels are stored subsequently. The number of differences for each channel are given by the first snapshot which is stored completely. |
TAG_MESH_MAP_COORDS_END |
Bounding Box - TAG_BOUNDING_BOX
...
Compressed 6 IEEE754 single precision floating point numbers describing the bounding box of the snapshot. The order is: MinX, MinY, MinZ, MaxX, MaxY, MaxZ.
...
This section contains the point cloud that can be used to visualize the animation snapshot in the viewport. The whole section is compressed and contains following:
Item | Description |
---|---|
Point Count | 8 byte unsigned integer telling the number of points that follow. |
Points | Every point is represented by 3 IEEE754 single precision floating point numbers corresponding to X,Y,Z coordinates in that order. |