void MakeBox(Vector3Int start, Vector3Int end) { for (int x = start.x; x <= end.x; x++) { for (int y = start.y; y <= end.y; y++) { for (int z = start.z; z <= end.z; z++) { VoxelData voxel = voxelMesh.GetVoxel(x, y, z); if (voxel != null) { bool isVisible = voxel.IsVisible; voxel.Copy(voxelMesh.voxelTemplate); if (mode == ToolMode.Sub) { isVisible = false; } else if (mode == ToolMode.Add) { isVisible = true; } voxelMesh.SetVoxelVisible(voxel.Position, isVisible); } } } } }
void SetVoxel(VoxelData voxel) { if (voxel != null) { voxel.Copy(voxelMesh.voxelTemplate); voxelMesh.SetVoxelVisible(voxel.Position, mode != ToolMode.Sub); } }
void MakeSphere(Vector3Int start, Vector3Int end) { Vector3Int size = end - start + Vector3Int.one; Vector3Int normalInt = new Vector3Int( Mathf.Abs(Mathf.RoundToInt(normal.x)), Mathf.Abs(Mathf.RoundToInt(normal.y)), Mathf.Abs(Mathf.RoundToInt(normal.z))); VoxelMesh.Direction dir = VoxelMesh.Direction.MAX; List <Vector3Int> points = null; if (normalInt.x != 0) { dir = VoxelMesh.Direction.Right; points = GetSphere(size.z, size.y, size.x); } else if (normalInt.y != 0) { dir = VoxelMesh.Direction.Up; points = GetSphere(size.x, size.z, size.y); } else if (normalInt.z != 0) { dir = VoxelMesh.Direction.Front; points = GetSphere(size.x, size.y, size.z); } foreach (var item in points) { VoxelData voxel = null; if (dir == VoxelMesh.Direction.Right) { voxel = voxelMesh.GetVoxel(start.x + item.z, start.y + item.y, start.z + item.x); } else if (dir == VoxelMesh.Direction.Up) { voxel = voxelMesh.GetVoxel(start.x + item.x, start.y + item.z, start.z + item.y); } else if (dir == VoxelMesh.Direction.Front) { voxel = voxelMesh.GetVoxel(start.x + item.x, start.y + item.y, start.z + item.z); } if (voxel != null) { voxel.Copy(voxelMesh.voxelTemplate); voxelMesh.SetVoxelVisible(voxel.Position, mode != ToolMode.Sub); } } }