public VoxelData CreatePalette() { var colors = new List <Color>() { Color.Transparent }; var voxelData = new VoxelData(this.size, new Color[256]); foreach (var v in this) { var c = ColorOf(v); var i = colors.IndexOf(c); if (i == -1) { i = colors.Count; colors.Add(c); } voxelData[v] = new Voxel((uint)i); } for (var i = 0; i < 256; i++) { voxelData.Colors[i] = i < colors.Count ? colors[i] : MagicaVoxel.GetDefaultColor(i); } return(voxelData); }
public static VoxelData Read(Stream stream) { var voxelData = MagicaVoxel.Read(stream); if (voxelData == null) { stream.Seek(0, SeekOrigin.Begin); voxelData = Voxlap.Read(stream); } return(voxelData); }