Andrew Shpagin

3B file format specification

25 posts in this topic

I try to study .3b files. But they are just a big mess. You can't read them at all. Is this normal or is this encoding issue.

Share this post


Link to post
Share on other sites

I assume you got your answer. Looks like a binary file format specification to me.

I might even try to write a read/write/parser for it. Looks detailed enough spec.

Certainly won't look nice in a text editor.

How uptodate is this document ??? Anyone ???

Share this post


Link to post
Share on other sites

I assume you got your answer. Looks like a binary file format specification to me.

I might even try to write a read/write/parser for it. Looks detailed enough spec.

Certainly won't look nice in a text editor.

How uptodate is this document ??? Anyone ???

It is up to date, but only voxels are described there.

Share this post


Link to post
Share on other sites

It is up to date, but only voxels are described there.

Hi,

I'm trying to read the voxel format, and I managed to parse some of it but I'm stuck at one point:

After it says:

DWORD Number of voxel cells. Every cell is a volume 8x8x8 that contains WORDS (16 bits). 0 means that cell is empty, 65535 filled, 32767.5 position of the surface.

(Question 1) cells directly come in an array at this point, after the "DWORD number of voxel cells"?

doing so I get these values:

Number of voxel cells: 20303

x position: 2

y position: -786429

z position: 17432564

cell side: 1

but cell side is supposed to be 9! besides, the y and z position seem to be totally wrong. I'm sure I parse properly up until the name of the shader, however it says there:

"In general this set of characters consists of 2 parts 2 zero-terminated strings. First one is name of the shader, second XML data with shaders parameters. Every shader variable has own tag in this XML. If you dont need shader parameters just read all this as a single string."

(Question 2) does that mean that even though I get the number of characters of the shader from the previous serialized variable, there is still another null-terminated string after that one?

Anyway, I have scanned the binary file for the value 00 00 00 09 in hex, representing the 32-bits integer 9, and only a few occurences, so obviously the "cell side" variable that should be 9 is not there.

(Question 3) Or is it a 16-bit integer?

Thanks a lot for your time, I think what I'm doing could be useful for 3d coat users :)

Best regards

Share this post


Link to post
Share on other sites

Hi!

I apologize for posting again without waiting for an answer, but I'm pretty confused with this binary format...

I'm trying several combinations, and trying to reverse-engineer from files, but from the point:

DWORD Number of voxel cells. Every cell is a volume 8x8x8 that contains WORDS (16 bits). 0 means that cell is empty, 65535 filled, 32767.5 position of the surface.

...it's described in an ambiguous manner, that I can't match with the actual binary format.

Could you please explain that part of the specification "For every cell" and what comes just before, please?

I would really appreciate,

Thank you very much

Best regards

Share this post


Link to post
Share on other sites

Hi!

I apologize for posting again without waiting for an answer, but I'm pretty confused with this binary format...

I'm trying several combinations, and trying to reverse-engineer from files, but from the point:

DWORD Number of voxel cells. Every cell is a volume 8x8x8 that contains WORDS (16 bits). 0 means that cell is empty, 65535 filled, 32767.5 position of the surface.

...it's described in an ambiguous manner, that I can't match with the actual binary format.

Could you please explain that part of the specification "For every cell" and what comes just before, please?

I would really appreciate,

Thank you very much

Best regards

I have quite the same problem.

I have attached the VS2010 Solution of my little 3b file reader.

I find a lot of data Chunks in the file until i reach the voxel Chunk

Found chunk RNDR with the length 8

Found chunk NSYZ with the length 0

Found chunk NBLN with the length 0

Found chunk MSSK with the length 20

Found chunk SYPL with the length 20

Found chunk SSPC with the length 0

Found chunk LR01 with the length 626

Found chunk MTLS with the length 55

Found chunk MTEX with the length 4

Found chunk OBJS with the length 57

Found chunk RNTS with the length 59

Found chunk UVST with the length 47

Found chunk SUBD with the length 0

Found chunk VMAP with the length 4

Found chunk VMTP with the length 49

Found chunk POS0 with the length 0

Found chunk UVS0 with the length 8

Found chunk SAR7 with the length 32

Found chunk with the length 0

Found chunk CMSC with the length 61

Found chunk RTP1 with the length 160699

Found chunk SYMM with the length 8

Found chunk UVM1 with the length 122

Volume found !!!!

VolumeName: Ball1m.lwo

Shadername: mcubes

Number of VoxelCells: 3720

Processing Cell number : 0

xpos: 2

ypos: 0

zpos: -3

cellside: -4

bitmask: 247

dataflag: 255

But the code fails with the rle decompression of the first voxelcell.

The cellside and the data flag do not look very reasonable.

I try to convert 3dcoat volumes to image slices and imageslices to 3dcoat volumes.

My little .net program is the first step to convert 3b files to imageslices.

The goat is to edit MRT Scans with 3d Coat.

Endian.zip

Share this post


Link to post
Share on other sites

Your code looks nicer to me than mine, and you've tackled the endianness problem in a cleaner way. But in essence, we are doing the same.

By the way, in:

DWORD Number of voxel cells. Every cell is a volume 8x8x8 that contains WORDS (16 bits). 0 means that cell is empty, 65535 filled, 32767.5 position of the surface.

That last sentence refers to the voxels, once the cells are read, right?

Besides, in the specification it is mentiones that the value "INT side" is always 9, but there is no pattern in the binary file that resembles an INT 0x00000009 anywhere.

The specification is wrong, misleading or expressed really confusingly.

Best regards

read3b.zip

Share this post


Link to post
Share on other sites

By the way, in:

DWORD Number of voxel cells. Every cell is a volume 8x8x8 that contains WORDS (16 bits). 0 means that cell is empty, 65535 – filled, 32767.5 – position of the surface.

That last sentence refers to the voxels, once the cells are read, right?

I read it as following: In the decompressed Matrix of WORDs ( 8x8x8 ) the values of the matrix are to be interpreted as 0 is empty cell, 65535 is a filled Cell in the Voxel matrix. But the rest i dont understand. First how can an integer have decimals ??? 32767.5 ?? If the value is just the length of a surface normal offset how is the direction of the offset defined ? I have no idea how to interpret the values from 1-65534 ...

Share this post


Link to post
Share on other sites

I read it as following: In the decompressed Matrix of WORDs ( 8x8x8 ) the values of the matrix are to be interpreted as 0 is empty cell, 65535 is a filled Cell in the Voxel matrix. But the rest i dont understand. First how can an integer have decimals ??? 32767.5 ?? If the value is just the length of a surface normal offset how is the direction of the offset defined ? I have no idea how to interpret the values from 1-65534 ...

Exactly, an integer with decimals?! wtf.

I believe it is meant hexadecimals 0x0000, 0x0011 and 0x1111 (SHORTS not INTS!!!)

If there is only these three options (empty, filled and a hint to "in the surface") it would have been enough with 2 bits, compressing the data automatically by a factor of 8 in case of shorts or 16 in case of ints. I don't think any normals are encoded here, because surface representation is in another chunk.

People from 3dcoat, could you answer some of this?

Thank you!

Share this post


Link to post
Share on other sites

Excuse for providing specification with errors. I fixed errorы (marked with yelloew in document). Also I provided VS2008 project that performs reading of 3D-file (as example).

I have add some additional description to the document regarding interpretation of voxel values.

Every voxel is integer value 0..65535. All this looks like 3D-field in volume. She surface separates values that less or equal than 32767 and values that are more or equal to 32768.

It is essentially not enough just 2 values for voxels (0 and 65535) becuase in this case surface will be very blocky. So 3D-Coat operates over smooth field of values 0..65535 to provide surface of very good smoothness.

Also - is your purpose only to read 3B files, or you need to write them too? Writing is a bit more complex brcause you need to fill XML part too, but if need, I may help with code snippets.

Share this post


Link to post
Share on other sites

Excuse for providing specification with errors. I fixed errorы (marked with yelloew in document). Also I provided VS2008 project that performs reading of 3D-file (as example).

I have add some additional description to the document regarding interpretation of voxel values.

It is essentially not enough just 2 values for voxels (0 and 65535) becuase in this case surface will be very blocky. So 3D-Coat operates over smooth field of values 0..65535 to provide surface of very good smoothness.

Also - is your purpose only to read 3B files, or you need to write them too? Writing is a bit more complex brcause you need to fill XML part too, but if need, I may help with code snippets.

Thanks a lot for your response.

Yes i need to write 3b files too.

I am writing an converter for Dicom files to 3b to create a surface for the dicom volumes with nice topology ..

The reading of files was just a first test if i understand the file format well enough to write it later ..

It would be really great if you could provide the information to write files too.

thx dulo

Share this post


Link to post
Share on other sites

Just succeeded with first version of 3b to image slice converter.

I attached the complete vs 2010 solution. This little program reads a 3b file and writes the volume information to c: in slices.

Still have some problems with weird volume borders as you can see in on attached slice of a simple ball.

I hope i soon get the information on how to write 3b files.

see you soon

dulo

Endian.zip

schicht109.zip

Share this post


Link to post
Share on other sites

I posted Voxels SDK there

http://www.3d-coat.com/forum/index.php?showtopic=7333

It will make operations over 3B files to be very easy.

I have Ported your VoxelSDK to .net c# completely managed.

I will post it here as soon as i get rid of some bugs.

It seems like i am filling the cell matrix in a wrong order which results in the attached image slice of a ball.

Does someone have a clue in which order the values are in the array ??

Here is a sample code in which i am putting one cell into the complete voxelPhantom .. but something seems to be mixed up ..

ushort[, ,] voxelPhantom = new ushort[width * 9, height * 9, depth * 9];

foreach (VolumeCell cell in pos.Cells)

{

int xpos = (cell.Cx + xmin * -1) * 8;

int ypos = (cell.Cy + ymin * -1) * 8;

int zpos = (cell.Cz + zmin * -1) * 8;

int counter = 0;

for (int z = 0; z < 8; z++)

{

for (int y = 0; y < 8; y++)

{

for (int x = 0; x < 8; x++)

{

if (cell.Values.Count == 0)

{

voxelPhantom[xpos + x, ypos + y, zpos + z] = cell.SameValue;

}

else

{

voxelPhantom[xpos + x, ypos + y, zpos + z] = cell.Values[counter];

}

}

counter++;

}

counter += 9;

}

}

Share this post


Link to post
Share on other sites

I am not using 3D-arrays, I prefer using linear arays and index them as

array[x+y*Lx+z*Lx*Ly]

possibly using 3D arrays produced problems, I think x and z axis in array indices are swapped.

Also, don't forget that 3DC scene is Y-up.

Share this post


Link to post
Share on other sites

I am not using 3D-arrays, I prefer using linear arays and index them as

array[x+y*Lx+z*Lx*Ly]

possibly using 3D arrays produced problems, I think x and z axis in array indices are swapped.

Also, don't forget that 3DC scene is Y-up.

My Dicom -> 3b Converter is working so far. I now get segmented MRT-Scans into 3D-Coat.

The plan is so create topology for different organs.

How can i run autoretopology on a 3b voxel file ?

Shouldnt it work ?

Autoretopo creates a voxel object from a mesh and starts the retopo wizard.

I would need to skip the first step and directly work on a voxel object from a 3b file ?

Is there a way ? Do i miss something ?

Share this post


Link to post
Share on other sites

My Dicom -> 3b Converter is working so far. I now get segmented MRT-Scans into 3D-Coat.

The plan is so create topology for different organs.

How can i run autoretopology on a 3b voxel file ?

Shouldnt it work ?

Autoretopo creates a voxel object from a mesh and starts the retopo wizard.

I would need to skip the first step and directly work on a voxel object from a 3b file ?

Is there a way ? Do i miss something ?

VoxTree->RMB->Autopo

Share this post


Link to post
Share on other sites

Hey, I'd be really interested to know how you're handling surface normals...

I'm doing a dissertation involving voxels but haven't been able to find any good information on the web about efficient storing of voxel normals...

Share this post


Link to post
Share on other sites

Hey, I'd be really interested to know how you're handling surface normals...

I'm doing a dissertation involving voxels but haven't been able to find any good information on the web about efficient storing of voxel normals...

We are calculating normals just as gradient of volumetric scalar field.

So normals are stored only in the mesh vertices after triangulation.

Share this post


Link to post
Share on other sites

Is it possible to get the full description of the 3B file format?

Share this post


Link to post
Share on other sites

Complete description is hard to provide because it in in code, not in documentation.

What section of data is interesing for you?

 

Please write to support in responce.

Share this post


Link to post
Share on other sites

I updated documentation and example to be compatible with 4.1

If you want to pass vertex color to coat it is better to avoid maniulation with 3B - it is too complex. I recommend using

File->Import for vertex painting

and pass OBJ file with colors. See attached example to see how colors stored per-vertex

 

vcolor.obj

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now