public byte GetVoxel(int x, int y, int z) { VoxelCell cell = Cells[x / VoxelCell.SizeX][y / VoxelCell.SizeY][z / VoxelCell.SizeZ]; if (cell == null) { return(0); } return(cell.GetAt(x % VoxelCell.SizeX, y % VoxelCell.SizeY, z % VoxelCell.SizeZ)); }
public void SetVoxel(int x, int y, int z, byte value) { VoxelCell cell = Cells[x / VoxelCell.SizeX][y / VoxelCell.SizeY][z / VoxelCell.SizeZ]; if (cell == null) { cell = new VoxelCell(); Cells[x / VoxelCell.SizeX][y / VoxelCell.SizeY][z / VoxelCell.SizeZ] = cell; } cell.SetAt(x % VoxelCell.SizeX, y % VoxelCell.SizeY, z % VoxelCell.SizeZ, value); }
public VoxelField(VoxelizingOctree tree) { CellSize = new Vector3i( (int)Math.Ceiling((tree.VoxelSize.X + 1) / (double)VoxelCell.SizeX), (int)Math.Ceiling((tree.VoxelSize.Y + 1) / (double)VoxelCell.SizeY), (int)Math.Ceiling((tree.VoxelSize.Z + 1) / (double)VoxelCell.SizeZ)); VoxelSize = tree.VoxelSize; // Initialize the cell tables, but don't actually fill in the arrays with voxel cell instances // until we know those cells will be filled. Cells = new VoxelCell[CellSize.X][][]; for (int x = 0; x < Cells.Length; x++) { Cells[x] = new VoxelCell[CellSize.Y][]; for (int y = 0; y < Cells[x].Length; y++) { Cells[x][y] = new VoxelCell[CellSize.Z]; } } CreateSolidVolume(tree, tree.Root, tree.VoxelSize); }