ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

.binvox格式解析

2021-11-09 16:00:09  阅读:234  来源: 互联网

标签:index scale voxel binvox coordinates int 格式 解析


.binvox格式解析

.binvox file has a short ASCII header, followed by binary data.

The ASCII header

//版本信息
#binvox 1
//specifies the depth, width, and height of the voxel grid
//grid纬度信息
dim 256 256 256
//normalization transformation 归一化变换
translate -0.0947055 0.0322891 -0.079402
scale 0.15573
data

Normalization and Mesh Correspondence

Before voxelizing, binvox normalizes the mesh such that it fits inside a 1.0×1.0×1.0 cube with its origin at (0.0, 0.0, 0.0). This is done with a translation and a uniform scale.

The unit cube is then voxelized. Three normalization transformation steps are printed to the terminal when you run binvox, e.g.:

  • bounding box: [-4.26774, -4.46283, -3.51203, 1] - [3.73801, 4.85995, 3.53327, 1]
  • normalization transform:
    • (1) translate [4.26774, 4.46283, 3.51203, 1]
    • (2) scale 0.107264
    • (3) translate [0, 0, 0]
      • Note that the third one can be ignored (it used to be relevant when normalization was not to the unit cube).

As a consequence, each voxel in the voxel model has coordinates inside the unit cube, which can be obtained as follows:

  • given a voxel at (i, j, k) (with voxel index coordinates starting at (0, 0, 0), and voxel model dimension d, these coordinates are:

    (x_n, y_n, z_n) = ((i + 0.5) / d,(j + 0.5) / d,(k + 0.5) / d)

    (the 0.5 is added to get the coordinates of the center of the voxel cell).

Next, there are two methods to compute the corresponding mesh coordinates from (x_n, y_n, z_n):

  1. first method:
    binvox now includes two extra lines in the header (which may be omitted, viewvox and thinvox don't need them):
    translate <t_x> <t_y> <t_z>
    scale <scale factor>
    First scale (x_n, y_n, z_n) by the scale factor, then translate them by (t_x, t_y, t_z)
  2. second method:
    Note the normalization transformation steps from the output of binvox, and apply these in reverse to (x_n, y_n, z_n)

Voxel ordering

The y-coordinate runs fastest, then the z-coordinate, then the x-coordinate.

To illustrate, here is the get_index function that computes the index in the 1D array of voxels of a voxel with indices (x, y, z):

int
Voxels::get_index(int x, int y, int z)
{
  int index = x * wxh + z * width + y;  // wxh = width * height = d * d
  return index;

}  // Voxels::get_index

The binary voxel data

The binary data consists of pairs of bytes.

The first byte of each pair is the value byte and is either 0 or 1 (1 signifies the presence of a voxel).

The second byte is the count byte and specifies how many times the preceding voxel value should be repeated (so obviously the minimum count is 1, and the maximum is 255).

标签:index,scale,voxel,binvox,coordinates,int,格式,解析
来源: https://www.cnblogs.com/fusheng-rextimmy/p/15529380.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有