Missing Example? How to parse Qubical Binary (QB) Matrix data?


#1

I am building an importer for the QB file specification. Following the guide at http://minddesk.com/learn/article.php?id=22

I have followed the pseudocode code example but think either I am overlooking something, or the guide is missing a detail.

Following the pseudocode I can successfully build an array of the matrix data. However, the matrix entries are unsigned 32 bit integers. The example doesn’t explain how they are encoded. I’m assuming they would contain vertex data like x,y,z coords and RBGA color. I am unsure how to expand them…

The point in the pseudocode I am referencing is:

Uncompressed example:

 if (compressed == 0) // if uncompressd
 {
   for(z = 0; z < sizeZ; z++)
     for(y = 0; y < sizeY; y++)
       for(x = 0; x < sizeX; x++)
         matrix[x + y*sizeX + z*sizeX*sizeY] = fread_uint32(file);
 }

Compressed example:

 data = fread_uint32(file);
   
 for(j = 0; j < count; j++) 
 {
   x = index mod sizeX + 1; // mod = modulo e.g. 12 mod 8 = 4
   y = index div sizeX + 1; // div = integer division e.g. 12 div 8 = 1
   index++;
   matrix[x + y*sizeX + z*sizeX*sizeY] = data;
 }
   }
   else 
   {
 x = index mod sizex + 1;
 y = index div sizex + 1;
 index++;
 matrix[x + y*sizeX + z*sizeX*sizeY] = data;

This gives me output of

0,
0,
0,
892377340,
825268476,
825268476,
825268476,
825268476,
858822908,
0,

The 0’s being empty space and the other ints being the encoded values


#2

The voxels are encoded R,G,B,Mask
Mask is explained in the docu
The position is determined by the bounding box and not encoded per voxel