Jump to content
3DCoat Forums

3B file format specification


Andrew Shpagin
 Share

Recommended Posts

There is DOC file that describes 3B file format. For now only voxel part is described - it is most interesting part of 3B.

3B_file_format_specification-changed2.doc

Sample console Visual Studion 2008 project to read 3B files:

VoxelsSDK.zip

This picture explans internal format of cells in 3D-Coat

post-1-1248867851_thumb.png

Link to comment
https://3dcoat.com/forum/index.php?/topic/3227-3b-file-format-specification/
Share on other sites

  • 9 months later...
  • 6 months later...
  • Advanced Member

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 ???

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.

  • 1 month later...
  • Member

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

  • Member

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

  • Member

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

  • Member

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

  • Member

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 ...

  • Member

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!

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.

  • Member

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

  • Member

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...