Пример #1
0
        public void TestMCAAccuracy()
        {
            var        heights = HeightmapImporter.ImportHeightmapRaw(Path.Combine(inputPath, sampleHeightmapFile), 0, 0, 512, 512);
            HeightData data    = new HeightData(512, 512, null)
            {
                lowPoint  = 0,
                highPoint = 255
            };

            for (int i = 0; i < 512; i++)
            {
                for (int j = 0; j < 512; j++)
                {
                    data.SetHeight(i, j, heights[i, j]);
                }
            }
            var    sampleLocations = GetSampleLocations(data.GridWidth, data.GridHeight);
            var    sourceSamples   = GetHeightSamples(data, sampleLocations);
            string mcaname         = "accuracy-test-r.0.0.mca";

            AssertExport(data, "MCR-RAW", mcaname);
            var reimported  = ImportManager.ImportFile(Path.Combine(outputPath, mcaname));
            var convSamples = GetHeightSamples(reimported, sampleLocations);

            AssertExport(data, "IMG_PNG-HM", "reconstructed_mca.png");
            Assert.AreEqual(sourceSamples, convSamples);
        }
Пример #2
0
        public WatermappedGenerator(string rootPath, XElement xml, int offsetX, int offsetZ, int sizeX, int sizeZ) : base(rootPath, xml, offsetX, offsetZ, sizeX, sizeZ)
        {
            worldOriginOffsetX = offsetX;
            worldOriginOffsetZ = offsetZ;
            var fileXml = xml.Element("file");

            if (fileXml != null)
            {
                string path = Path.Combine(rootPath, xml.Element("file").Value);
                waterSurfaceMap = ArrayConverter.Flip(HeightmapImporter.ImportHeightmapRaw(path, 0, 0, sizeX, sizeZ));
            }
            if (xml.Element("waterlevel") != null)
            {
                waterLevel = short.Parse(xml.Element("waterlevel").Value);
            }
            if (xml.Element("waterblock") != null)
            {
                waterBlock = xml.Element("waterblock").Value;
            }
            ConsoleOutput.WriteLine("Water mapping enabled");
        }
Пример #3
0
        public SplatmappedSurfacePostProcessor(string importedFilePath, int ditherLimit, int localRegionX, int localRegionZ)
        {
            var    desc = new SplatmapDescriptorReader(importedFilePath + ".splat", true);
            string root = Path.GetDirectoryName(importedFilePath);

            foreach (string k in desc.maps.Keys)
            {
                List <SplatmapMapping> mappings = new List <SplatmapMapping>();
                foreach (var sm in desc.layers.Keys)
                {
                    if (sm.mapName == k)
                    {
                        mappings.Add(sm);
                    }
                }
                mappings.Add(new SplatmapMapping(k, Color.Black, 0));
                maps.Add(k, SplatmapImporter.GetFixedSplatmap(root + "\\" + desc.maps[k], mappings.ToArray(), ditherLimit, localRegionX, localRegionZ));
            }
            foreach (var sm in desc.layers.Keys)
            {
                layers.Add((byte)sm.value, desc.layers[sm].Split(','));
            }
            Program.WriteLine("Splatmapping enabled");
            if (!string.IsNullOrWhiteSpace(desc.watermapPath))
            {
                waterSurfaceMap = HeightmapImporter.ImportHeightmapRaw(root + "\\" + desc.watermapPath, localRegionX * 512, localRegionZ * 512, 512, 512);
                waterLevel      = desc.waterLevel;
                waterBlock      = desc.waterBlock;
                Program.WriteLine("Water mapping enabled");
            }
            if (!string.IsNullOrWhiteSpace(desc.biomeMapperPath))
            {
                biomePostProcessor = new SplatmappedBiomePostProcessor(root + "\\" + desc.biomeMapperPath, 0, localRegionX, localRegionZ);
                Program.WriteLine("Biome mapping & decoration enabled");
            }
        }