Exemplo n.º 1
0
        public SampleSet Load(string filename)
        {
            var vox    = VoxUtils.Load(filename);
            var sample = VoxUtils.ToTopoArray(vox).ToTiles();

            return(new SampleSet
            {
                Directions = sample.Topology.Directions,
                Samples = new[] { sample },
                ExportOptions = new VoxExportOptions {
                    Template = vox
                },
            });
        }
Exemplo n.º 2
0
        private SampleSet LoadFileSet()
        {
            if (config.Tiles == null)
            {
                throw new ConfigurationException($"You must specify tile data when using SrcType {config.SrcType}.");
            }

            var filenames = new Dictionary <Tile, string>();

            foreach (var tile in config.Tiles)
            {
                if (tile.Value == null)
                {
                    tile.Value = new Guid().ToString();
                }
                if (tile.Src == null)
                {
                    throw new ConfigurationException($"All tiles must have a src set when using SrcType {config.SrcType}.");
                }
                filenames[Parse(tile.Value)] = tile.Src;
            }

            if (filenames.Count == 0)
            {
                throw new ConfigurationException($"Must supply at least one tile when using SrcType {config.SrcType}.");
            }

            if (config.SrcType == SrcType.BitmapSet)
            {
                var bitmaps = filenames.ToDictionary(x => x.Key, x => Image.Load(Path.Combine(config.BaseDirectory, x.Value)));
                var first   = bitmaps.First().Value;
                return(new SampleSet
                {
                    Directions = DirectionSet.Cartesian2d,
                    Samples = new ITopoArray <Tile> [0],
                    ExportOptions = new BitmapSetExportOptions
                    {
                        Bitmaps = bitmaps,
                        TileWidth = first.Width,
                        TileHeight = first.Height,
                    }
                });
            }
            else if (config.SrcType == SrcType.VoxSet)
            {
                var subtiles = filenames.ToDictionary(x => x.Key, x => VoxUtils.Load(Path.Combine(config.BaseDirectory, x.Value)));
                var first    = VoxUtils.ToTopoArray(subtiles.First().Value);
                return(new SampleSet
                {
                    Directions = DirectionSet.Cartesian3d,
                    Samples = new ITopoArray <Tile> [0],
                    ExportOptions = new VoxSetExportOptions
                    {
                        Template = subtiles.First().Value,
                        SubTiles = subtiles,
                        TileWidth = first.Topology.Width,
                        TileHeight = first.Topology.Height,
                        TileDepth = first.Topology.Depth,
                    }
                });
            }
            else
            {
                throw new NotImplementedException($"Unrecognized src type {config.SrcType}");
            }
        }