I have a file with a list of (x,y,z) coordinates of points which I am attempting to convert into a voxel file format readable by viewvox. I have come across the binvox file format which seems like it should be relatively simple but I just can't get my head around it. In particular when it mentions the use of a value byte and a count byte I must have misunderstood because it is unclear to me why the range for count must be 1<=count<=255.

Hopefully somebody can do one or more of the following: explain the format to me like I am five years old, provide a working example of a binvox file for a small model or suggest a better way of converting my coordinate data to a voxelised format.

Thanks in advance for any advice.

EDIT: After thinking some more I've understood the range of the count byte - 1 is the minimum because a count of 0 would be uninformative and the maximum is 255 because that is the maximum value of a byte.

有帮助吗?

解决方案

Sorted it out in my head now. For anyone else who has similar comprehension issues here is the .binvox file format explained:

  • Header goes first and must contain
    • Version number
    • Dimensions of voxel grid
    • Translation and scale factors to go from model coordinates to unit cube.
    • The word "data" before the actual data begins

An example header would be:

#binvox 1
dim 512 512 512
translate 0 0 0
scale 1
data

Then the rest of the file after this is composed of pairs of bytes giving the voxel value (1 for presence and 0 for absence) and the count of voxels (e.g. this byte would be 2 if there was a run of 2 coordinates with the same value). There are no separators between byte pairs. The order of these byte pairs is determined by running through your model coordinates; with y changing fastest, then z, then x.

Now I understand it, I can see that the documentation is actually already good and all I have done here is summarised it. Actual documentation can be found here.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top