How Does Blender Voxel Data Work?

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?

• Without looking at the code my first guess would be an ordered list from point one to point xx. If you always increment through x,y,z in the same order then the density values will always correspond to the same position. – sambler Nov 2 '13 at 10:36
• I think that might be a good explanation. But I was looking into the mapping tab on Blender, and found some things on coordinates. What does that do? Can I manipulate it to set my own coordinates? – Lamikins Nov 5 '13 at 1:49
• The only mapping panel in blender I can think of is in the texture settings. This determines what calculation is used to get the colour of a specific point, I don't think it will make a difference for voxel data unless you are using a colour ramp. As for the mapping options in particle textures I don't know what effect it would have. – sambler Nov 10 '13 at 10:10
• Possible duplicate: blender.stackexchange.com/questions/3676/… – gandalf3 Nov 14 '13 at 22:22

First off, that's not ASCII; this is merely a misinterpretation of the raw data. The actual format can be figured out from Blender source files render/intern/include/voxeldata.h and render/intern/source/voxeldata.c together with blenlib/intern/voxel.c. The format is used for 3-dimensional textures.
Within each frame, the order of the voxels is defined in the sampling functions. They use a macro named BLI_VOXEL_INDEX to perform the lookup, defined in blenlib/BLI_voxel.h. It shows that the order is along X axis first, then Y axis, then finally Z axis.