Jump to content


Notice about Feature Requests & Bug Reports

The bug reporting and feature request forums (except for the Urgent Help section) are going away soon! Please use Mantis to report any bugs and feature requests. the link to Mantis is:
3d-coat.com/mantis/

Read more about it HERE.

Photo

3B file format specification


  • Please log in to reply
24 replies to this topic

#1 Andrew Shpagin

Andrew Shpagin

    3DC creator & admin

  • 3D-Coat Developer
  • PipPipPipPipPipPip
  • 6,585 posts

  • Gender:Male

Posted 29 July 2009 - 12:44 PM

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

Attached File  3B_file_format_specification-changed2.doc   39.5KB   50 downloads

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

Attached File  VoxelsSDK.zip   3.39MB   26 downloads

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

cells_description.png

#2 haikalle

haikalle

    Journeymen

  • Contributor
  • PipPipPipPip
  • 1,360 posts
  • Gender:Male
  • Location:Finland

Posted 24 May 2010 - 12:27 PM

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.

#3 ggaliens

ggaliens

    Novice

  • Member
  • PipPip
  • 371 posts
  • Gender:Male
  • Location:Upstate New York, USA

Posted 30 November 2010 - 02:58 AM

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

#4 Andrew Shpagin

Andrew Shpagin

    3DC creator & admin

  • 3D-Coat Developer
  • PipPipPipPipPipPip
  • 6,585 posts

  • Gender:Male

Posted 30 November 2010 - 07:39 AM

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.

#5 noirgel

noirgel

    Newbie

  • Member
  • 5 posts

Posted 06 January 2011 - 11:44 PM

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 don’t 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

#6 noirgel

noirgel

    Newbie

  • Member
  • 5 posts

Posted 07 January 2011 - 01:38 AM

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

#7 dulo

dulo

    Neophyte

  • Member
  • Pip
  • 34 posts

Posted 09 January 2011 - 04:20 PM

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.

Attached Files


Posted Image
www.woogieworks.at

martin dulovits
technical director

#8 noirgel

noirgel

    Newbie

  • Member
  • 5 posts

Posted 09 January 2011 - 05:06 PM

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

Attached Files



#9 dulo

dulo

    Neophyte

  • Member
  • Pip
  • 34 posts

Posted 10 January 2011 - 12:39 PM

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 ...
Posted Image
www.woogieworks.at

martin dulovits
technical director

#10 noirgel

noirgel

    Newbie

  • Member
  • 5 posts

Posted 10 January 2011 - 02:17 PM

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!

#11 Andrew Shpagin

Andrew Shpagin

    3DC creator & admin

  • 3D-Coat Developer
  • PipPipPipPipPipPip
  • 6,585 posts

  • Gender:Male

Posted 10 January 2011 - 02:52 PM

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.

#12 dulo

dulo

    Neophyte

  • Member
  • Pip
  • 34 posts

Posted 10 January 2011 - 04:13 PM

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
Posted Image
www.woogieworks.at

martin dulovits
technical director

#13 dulo

dulo

    Neophyte

  • Member
  • Pip
  • 34 posts

Posted 10 January 2011 - 07:59 PM

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

Attached Files


Posted Image
www.woogieworks.at

martin dulovits
technical director

#14 Andrew Shpagin

Andrew Shpagin

    3DC creator & admin

  • 3D-Coat Developer
  • PipPipPipPipPipPip
  • 6,585 posts

  • Gender:Male

Posted 10 January 2011 - 08:48 PM

I will post 3B writer sample tomorrow.

#15 noirgel

noirgel

    Newbie

  • Member
  • 5 posts

Posted 11 January 2011 - 12:37 AM

Thanks a lot!!

:)


Best regards

#16 Andrew Shpagin

Andrew Shpagin

    3DC creator & admin

  • 3D-Coat Developer
  • PipPipPipPipPipPip
  • 6,585 posts

  • Gender:Male

Posted 11 January 2011 - 01:36 PM

I posted Voxels SDK there

http://www.3d-coat.c...?showtopic=7333

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

#17 dulo

dulo

    Neophyte

  • Member
  • Pip
  • 34 posts

Posted 12 January 2011 - 04:32 PM

I posted Voxels SDK there

http://www.3d-coat.c...?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;
}
}
Posted Image
www.woogieworks.at

martin dulovits
technical director

#18 Andrew Shpagin

Andrew Shpagin

    3DC creator & admin

  • 3D-Coat Developer
  • PipPipPipPipPipPip
  • 6,585 posts

  • Gender:Male

Posted 12 January 2011 - 04:55 PM

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.

#19 dulo

dulo

    Neophyte

  • Member
  • Pip
  • 34 posts

Posted 19 January 2011 - 05:26 PM

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 ?
Posted Image
www.woogieworks.at

martin dulovits
technical director

#20 Andrew Shpagin

Andrew Shpagin

    3DC creator & admin

  • 3D-Coat Developer
  • PipPipPipPipPipPip
  • 6,585 posts

  • Gender:Male

Posted 19 January 2011 - 05:55 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users