| 11 | |
| 12 | |
| 13 | def sample_grid_points_aabb(aabb, resolution): |
| 14 | # aabb: (6, ) |
| 15 | # resolution: int |
| 16 | # return: (Nx, Ny, Nz, 3) |
| 17 | aabb_min, aabb_max = torch.split(aabb, 3, dim=-1) |
| 18 | aabb_size = aabb_max - aabb_min |
| 19 | resolutions = (resolution * aabb_size / aabb_size.max()).long() |
| 20 | |
| 21 | xs = torch.linspace(0.5, resolutions[0] - 0.5, resolutions[0], device=aabb.device) / resolutions[0] * aabb_size[0] + aabb_min[0] |
| 22 | ys = torch.linspace(0.5, resolutions[1] - 0.5, resolutions[1], device=aabb.device) / resolutions[1] * aabb_size[1] + aabb_min[1] |
| 23 | zs = torch.linspace(0.5, resolutions[2] - 0.5, resolutions[2], device=aabb.device) / resolutions[2] * aabb_size[2] + aabb_min[2] |
| 24 | grid_points = torch.stack(torch.meshgrid(xs, ys, zs, indexing='ij'), dim=-1) |
| 25 | return grid_points |
| 26 | |
| 27 | |
| 28 | def read_metarial_params_from_mtl(path): |