3
$\begingroup$

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?

$\endgroup$
4
  • $\begingroup$ 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. $\endgroup$
    – sambler
    Nov 2 '13 at 10:36
  • $\begingroup$ 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? $\endgroup$
    – Lamikins
    Nov 5 '13 at 1:49
  • $\begingroup$ 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. $\endgroup$
    – sambler
    Nov 10 '13 at 10:10
  • $\begingroup$ Possible duplicate: blender.stackexchange.com/questions/3676/… $\endgroup$
    – gandalf3
    Nov 14 '13 at 22:22
3
$\begingroup$

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.

The header is read by read_voxeldata_header(), and consists of four ints: the X, Y and Z dimensions, as well as the number of frames. There's no code to handle endianness nor size variations, so the files aren't portable across platforms. Most current platforms will store these as 32-bit little endian.

Next come the frames, in order. Each frame is also stored in raw memory format, as X*Y*Z floats; this will typically be IEEE 754 single precision (32 bit) values.

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.

The raw 8-bit format is similar, but has no header, and uses only 8 bit fixed point values; the voxel value is databyte/255.0. This requires the actual dimensions of the voxel to be entered in Blender.

The image sequence format simply uses a layered group of images, along ascending Z axis. The pixel data gets averaged into a grayscale voxel texture.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.