# Setting Voxel Coordinates

I've been looking online for a long time, searching for documentation on the subject of Blender Voxel Data. So far, I know that Blender uses many file types, including the .bvox file type. For the .bvox file type, I have found that it uses ASCII characters to load in density values, starting with the dimensions. For example, a data set with dimensions 64,64,64 would save into the .bvox file as:

@@@

However, only the density values are saved. The data set I have is formatted as follows, where dd is a density value:

xx yy zz dd
xx yy zz dd


My python code strips each line and takes only the density values and uses pythons pack struct to pack the values into a .bvox file. This works fine, but I am wondering how Blender knows where to put the coordinates of the densities? Each density value has to be at a specific point, and how does Blender know where that point is? And also, is it possible to specify my own coordinates for each value?

In the Blender wiki article it says

The voxels are stored in a flat z/y/x grid of floats.

That means that the coordinates of every density is defined by its position in the file. I guess that your original data set is sorted that way too. For example:

xx yy zz dd
-----------
12 20 00 dd
12 20 01 dd
12 20 02 dd
...
12 21 00 dd
12 21 01 dd
...


In this case the coordinates are redundant because they can be easily deduced from the position in the list. Thus the coordinates can be omitted.

Also the file format doesn't use ASCII characters. It is a binary file and simply stores numbers. Every number can be interpreted as an ASCII character. The character for 64 is @. But in this case this is irrelevant.

• Thank you for your reply! Also, I forgot to note that at the bvox file is headed by the dimensions. Does that have something to do with is too? The data file I have has dimensions 64-64-64, and so the bvox file starts with @@@ . – Lamikins Nov 8 '13 at 2:41
• Yes that is what I mean with the last paragraph in my answer – Maccesch Nov 8 '13 at 12:48
• One more thing, is it possible to manually set the voxel coordinates? Some of my data sets are not in the pattern specified above, so the coordinates cannot be omitted. – Lamikins Nov 17 '13 at 21:39
• You could fill in the blanks with 0 densities and/or reoder the data. – Maccesch Nov 19 '13 at 11:32
• I don't know about the possibilities of RAW voxel files mentioned in blender wiki. But if you don't have uniformly spaced data you could resample it: For each point in a grid calculate the density based on points of the original file that are near the grid point. – Maccesch Nov 21 '13 at 11:34