Introduction
Qubicle Binary is the exchange format of the voxel editor Qubicle by Minddesk. A file holds any number of named voxel boxes, called matrices, each with its own size and position, in which every voxel carries its own colour. There is no palette. Other voxel tools read and write it.
There is no signature. A file begins with the version number 1.1.0.0, the bytes
01 01 00 00.
Structure
Numbers are little-endian. A 24-byte header is followed by the matrices, one after another.
0Header six 32-bit numbers24 bytes24Matrix 1 name, size, position, voxelsvaries…Further matrices as many as the header countsvaries
Header
| Offset | Size | Name | Meaning |
|---|---|---|---|
| 0 | 4 | version | Four bytes: major, minor, release, build. The current version is 1.1.0.0 |
| 4 | 4 | color format | 0: voxels are RGBA. 1: BGRA |
| 8 | 4 | z-axis orientation | 0: left handed. 1: right handed |
| 12 | 4 | compression | 0: none. 1: run-length encoded |
| 16 | 4 | visibility mask | 0: the alpha byte is 0 or 255. 1: it is a mask of visible sides |
| 20 | 4 | matrix count | Number of matrices |
Matrix
| Field | Size | Meaning |
|---|---|---|
| name length | 1 | Unsigned byte |
| name | name length | Characters, no terminating zero |
| size x, y, z | 4 each | Unsigned, in voxels |
| position x, y, z | 4 each | Signed: where the matrix’s grid starts in the model |
| voxels | varies | Raw or compressed, as the header says |
The vengi reader, which sets limits of its own, refuses more than 16384 matrices, a size of 0, or a size of 2048 or more on any axis.
Voxel data
A voxel is four bytes: three colour channels in the order chosen by the color format, then the alpha byte. An alpha of 0 means there is no voxel.
Uncompressed
All size x × size y × size z voxels follow, with x changing fastest, then y, then z. The voxel at (x, y, z) is number:
x + y * sizeX + z * sizeX * sizeY
Run-length encoded
The data is coded slice by slice, one slice for each z. Within a slice the reader takes 32-bit words:
| Next word | What follows | Effect |
|---|---|---|
2 (code flag) | uint32 count, then one voxel | The voxel repeats count times |
6 (next slice flag) | Nothing | The slice is finished |
| Anything else | Nothing | The word is itself one voxel |
Each voxel produced takes the next place in the slice: with a running index from 0, x = index mod sizeX and y = index ÷ sizeX (whole-number division). The index starts again at 0 in each slice.
Visibility mask
With the header flag set, the alpha byte records which faces of the voxel are exposed, so a renderer can skip the others. A value of 0 is still an absent voxel.
| Bit value | Visible side |
|---|---|
| 2 | Left |
| 4 | Right |
| 8 | Top |
| 16 | Bottom |
| 32 | Front |
| 64 | Back |
The description of QB gives no side for the values 1 and 128. The vendor’s description of its other voxel format, Qubicle Binary Tree (QBT), also stores a visibility mask byte. It says that there a mask above 0 is a solid voxel, and that a mask of exactly 1 is a core voxel: solid, but surrounded by six other voxels and so not visible. It does not say that the same holds for the alpha byte of a QB file, and does not mention 128.
Axis orientation
The header says which handedness the coordinates are in. The vengi converter, which works left handed, exchanges the x and z sizes of a right-handed file when it builds the volume, and when writing one it stores size and position in the order z, y, x.
Worked example
An uncompressed RGBA file with one matrix named a, 2 × 1 × 1, holding a
red voxel and an empty one: 58 bytes.
| Offset | Bytes | Meaning |
|---|---|---|
| 0 | 01 01 00 00 | Version 1.1.0.0 |
| 4 | 00 00 00 00 00 00 00 00 | RGBA, left handed |
| 12 | 00 00 00 00 00 00 00 00 | Not compressed, no mask |
| 20 | 01 00 00 00 | One matrix |
| 24 | 01 61 | Name of length 1: a |
| 26 | 02 00 00 00 01 00 00 00 01 00 00 00 | Size 2, 1, 1 |
| 38 | 00 00 00 00 00 00 00 00 00 00 00 00 | Position 0, 0, 0 |
| 50 | FF 00 00 FF | Red voxel at x 0 |
| 54 | 00 00 00 00 | Nothing at x 1 |
In compressed form, a slice of five red voxels would be
02 00 00 00 05 00 00 00 FF 00 00 FF 06 00 00 00.
Divergence from the specification
- The pseudo code for compressed data in the vendor’s description adds 1 to the slice number before using it and to x and y, while its uncompressed branch counts from 0. The vengi reader counts all of them from 0.
- The mask tests are written there with the logical operator
&&; a bit test is meant.
In the explorer
A dropped .qb file is read as a Qubicle Binary model.
- 3D view: every matrix at its position, in the voxels’ own colours, with the handedness the header gives. A face between two voxels of one matrix is left out. A view holds 250,000 solid voxels; the rest of a larger model is in further parts, where faces between parts are drawn.
- Tables: the matrices with name, size, position and voxel count; each opens its own view and a table of its solid voxels with colour and alpha, or with the visibility mask and the sides it names.
- Structure: the header, and for every matrix its name, size, position and every voxel word, run and end of slice.
- Checks: header values outside 0 and 1, cut-off matrices, runs past the end of a slice, empty runs and bytes after the last matrix.
Not described
Known, not yet covered
- Viewer: the visibility mask is listed and not used for drawing; the faces shown are worked out from the neighbouring voxels. A matrix with y downwards or exchanged axes by another program’s convention is drawn as stored.
Unknown
- Reference: whether a QB visibility mask of 1 marks a core voxel as it does in QBT, and the meaning of the bit value 128.
Links
Software
Developers
- QBFormat.cpp – the reader and writer in vengi (C++)
Reference
- Qubicle Binary file specifications – Minddesk’s documentation, archived
- Qubicle Binary format article – the earlier version of the same description, archived
- Qubicle Binary Tree description – the vendor’s text on the visibility mask of QBT, archived