Пример #1
0
        public void DecorateTerrain(MCWorldExporter exporter)
        {
            int processorIndex = 0;

            foreach (var post in generators)
            {
                for (int pass = 0; pass < post.NumberOfPasses; pass++)
                {
                    string name = post.GetType().Name;
                    if (post.PostProcessorType == PostProcessType.Block || post.PostProcessorType == PostProcessType.Both)
                    {
                        //Iterate the postprocessors over every block
                        for (int x = 0; x < exporter.heightmapLengthX; x++)
                        {
                            for (int z = 0; z < exporter.heightmapLengthZ; z++)
                            {
                                for (int y = post.BlockProcessYMin; y <= post.BlockProcessYMax; y++)
                                {
                                    post.ProcessBlock(exporter.world, x + exporter.regionOffsetX * 512, y, z + exporter.regionOffsetZ * 512, pass);
                                }
                            }
                            UpdateProgressBar(processorIndex, "Decorating terrain", name, (x + 1) / (float)exporter.heightmapLengthX, pass, post.NumberOfPasses);
                        }
                    }

                    if (post.PostProcessorType == PostProcessType.Surface || post.PostProcessorType == PostProcessType.Both)
                    {
                        //Iterate the postprocessors over every surface block
                        for (int x = 0; x < exporter.heightmapLengthX; x++)
                        {
                            for (int z = 0; z < exporter.heightmapLengthZ; z++)
                            {
                                post.ProcessSurface(exporter.world, x + exporter.regionOffsetX * 512, exporter.heightmap[x, z], z + exporter.regionOffsetZ * 512, pass);
                            }
                            UpdateProgressBar(processorIndex, "Decorating surface", name, (x + 1) / (float)exporter.heightmapLengthX, pass, post.NumberOfPasses);
                        }
                    }

                    //Run every postprocessor once for every region (rarely used)
                    Parallel.ForEach(exporter.world.regions.Values, (MCUtils.Region reg) =>
                    {
                        post.ProcessRegion(exporter.world, reg, reg.regionPosX, reg.regionPosZ, pass);
                    });
                }
                processorIndex++;
            }
            foreach (var post in generators)
            {
                post.OnFinish(exporter.world);
            }
        }
Пример #2
0
        public OverviewmapExporter(MCWorldExporter world, bool mcMapStyle, HeightmapType type = HeightmapType.SolidBlocks)
        {
            var        heightmap  = world.GetHeightmap(type, true);
            HeightData heightData = new HeightData(ArrayConverter.ToFloatMap(ArrayConverter.Flip(heightmap)), 1)
            {
                lowPoint  = 0,
                highPoint = 256
            };

            map = world.world.GetSurfaceMap(world.worldBounds.xMin, world.worldBounds.yMin, heightmap, mcMapStyle);
            if (!mcMapStyle)
            {
                map = GenerateShadedMap(heightData, map);
            }
        }