Пример #1
0
        public AbstractPostProcessor(string rootPath, XElement xml, int offsetX, int offsetZ, int sizeX, int sizeZ)
        {
            worldOriginOffsetX = offsetX;
            worldOriginOffsetZ = offsetZ;
            var maskElem = xml.Element("mask");

            if (maskElem != null)
            {
                string       maskPath    = Path.Combine(rootPath, maskElem.Value);
                var          channelAttr = maskElem.Attribute("channel");
                ColorChannel channel;
                string       attr = channelAttr?.Value.ToLower();
                switch (attr)
                {
                case "r":
                case "red": channel = ColorChannel.Red; break;

                case "g":
                case "green": channel = ColorChannel.Green; break;

                case "b":
                case "blue": channel = ColorChannel.Blue; break;

                case "a":
                case "alpha": channel = ColorChannel.Alpha; break;

                default: channel = ColorChannel.Red; break;
                }
                mask = SplatmapImporter.GetMask(maskPath, channel, 0, 0, sizeX, sizeZ);
            }
        }
Пример #2
0
        public SplatmappedGenerator(SplatmappedSurfacePostProcessor post, XElement xml, string rootPath, int ditherLimit, int offsetX, int offsetZ, int sizeX, int sizeZ)
            : base(rootPath, xml, offsetX, offsetZ, sizeX, sizeZ)
        {
            postProcessor = post;
            string mapFileName = Path.Combine(rootPath, xml.Attribute("file").Value);

            foreach (var layer in xml.Elements("layer"))
            {
                XAttribute colorAttr = layer.Attribute("color");
                if (colorAttr == null)
                {
                    ConsoleOutput.WriteError("layer is missing required attribute 'color': " + layer.ToString().Trim());
                    continue;
                }
                var color        = ParseColor(colorAttr.Value);
                var surfaceLayer = new SurfaceLayer(color, layer.Attribute("name")?.Value);
                layers.Add(surfaceLayer);
                foreach (var elem in layer.Elements())
                {
                    if (elem.Name.LocalName == "surface")
                    {
                        surfaceLayer.AddSurfaceGenerator(elem);
                    }
                    else if (elem.Name.LocalName == "gen")
                    {
                        surfaceLayer.AddSchematicGenerator(this, elem);
                    }
                    else if (elem.Name.LocalName == "biome")
                    {
                        surfaceLayer.AddBiomeGenerator(elem);
                    }
                }
            }

            Color[] mappedColors = new Color[layers.Count];
            for (int i = 0; i < layers.Count; i++)
            {
                mappedColors[i] = layers[i].layerColor;
            }

            map = SplatmapImporter.GetFixedSplatmap(mapFileName, mappedColors, ditherLimit, 0, 0, sizeX, sizeZ);
        }
Пример #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");
            }
        }
        public SplatmappedBiomePostProcessor(string filepath, int ditherLimit, int localRegionX, int localRegionZ)
        {
            var desc = new SplatmapDescriptorReader(filepath, false);

            biomes = desc.biomes;
            foreach (string k in desc.maps.Keys)
            {
                string path = Path.GetDirectoryName(filepath);
                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(path + "\\" + desc.maps[k], mappings.ToArray(), ditherLimit, localRegionX, localRegionZ));
            }

            /*foreach(var sm in desc.layers.Keys) {
             *      layers.Add((byte)sm.value, desc.layers[sm].Split(','));
             * }*/
        }