private void Awake()
 {
     _wfc = GetComponent <WFC>();
     _wfc._islandGrid.x = Random.Range(IslandSizeMin.x, IslandSizeMax.x);
     _wfc._islandGrid.y = Random.Range(IslandSizeMin.y, IslandSizeMax.y);
     _wfc._islandGrid.z = Random.Range(IslandSizeMin.z, IslandSizeMax.z);
 }
Exemplo n.º 2
0
 public void OnEnable()
 {
     wfc                    = (WFC)target;
     p_UpConnectors         = serializedObject.FindProperty("UpConnector");
     p_DownConnectors       = serializedObject.FindProperty("DownConnector");
     p_HorizontalConnectors = serializedObject.FindProperty("HorizontalConnector");
 }
Exemplo n.º 3
0
    static void Main(string[] args)
    {
        ReadSettings();

        int scaling        = 10;
        int tiling         = 10;
        int upscaledTiling = 2;

        if (args[1] == "true") //arg 0 is "WaveFunctionCollapse.csproj" so we look at arg[1]
        {
            usingAutoWriter = true;
            Writer.CreateSamplesFile();
        }
        else
        {
            usingAutoWriter = false;
        }

        Stopwatch sw = Stopwatch.StartNew();

        WFC.Run(); // Runs the WFC


        if (saveRegularSize)
        {
            foreach (KeyValuePair <string, Bitmap> kvp in regularbitmaps)
            {
                kvp.Value.Save(kvp.Key + ".png");
            }
        }

        if (saveUpscaleds || saveUpscaledCombined)
        {
            Console.WriteLine("Beginning Upscaling...");

            foreach (string name in listofNames)
            {
                Bitmap image = regularbitmaps[name];

                Bitmap upscaledImage = new Bitmap(image.Width * scaling, image.Height * scaling);

                int height = upscaledImage.Height;
                int width  = upscaledImage.Width;

                for (int y = 0; y < height; y++)
                {
                    for (int x = 0; x < width; x++)
                    {
                        upscaledImage.SetPixel(x, y, image.GetPixel(x / scaling, y / scaling));
                    }
                }

                if (saveUpscaleds)
                {
                    upscaledImage.Save("upscaled " + name + ".png");
                }
                upscaleds.Add(upscaledImage);
            }

            Console.WriteLine("Upscales Done!");
        }

        if (saveRegularCombined)
        {
            Console.WriteLine("Beginning Combineds...");
            foreach (string name in listofNames)
            {
                Bitmap image = regularbitmaps[name];

                Bitmap combinedImage = new Bitmap(image.Width * tiling, image.Height * tiling);

                int height = combinedImage.Height;
                int width  = combinedImage.Width;

                int orgX = 0;
                int orgY = 0;

                for (int y = 0; y < height; y++)
                {
                    for (int x = 0; x < width; x++)
                    {
                        combinedImage.SetPixel(x, y, image.GetPixel(orgX, orgY));

                        orgX++;

                        if (orgX >= image.Height)
                        {
                            orgX = 0;
                        }
                    }
                    orgY++;
                    if (orgY >= image.Width)
                    {
                        orgY = 0;
                    }
                }

                combinedImage.Save("combined " + name + ".png");
            }

            Console.WriteLine("Combined Done!");
        }

        if (saveUpscaledCombined)
        {
            Console.WriteLine("Beginning Upscaled Combineds...");
            int count = 0;
            foreach (string name in listofNames)
            {
                Bitmap combinedImage = new Bitmap(upscaleds[count].Width * (tiling / 4), upscaleds[count].Height * (tiling / 4));

                int height = combinedImage.Height;
                int width  = combinedImage.Width;

                int orgX = 0;
                int orgY = 0;

                for (int y = 0; y < height; y++)
                {
                    for (int x = 0; x < width; x++)
                    {
                        combinedImage.SetPixel(x, y, upscaleds[count].GetPixel(orgX, orgY));

                        orgX++;

                        if (orgX >= upscaleds[count].Width)
                        {
                            orgX = 0;
                        }
                    }
                    orgY++;
                    if (orgY >= upscaleds[count].Height)
                    {
                        orgY = 0;
                    }
                }

                combinedImage.Save("BIGcombined " + name + ".png");
                count++;
            }
            Console.WriteLine("Upscaled Combineds Done!");
        }

        if (saveflipped)
        {
            Console.WriteLine("Beginning Flipped...");
            int count = 0;
            foreach (string name in listofNames)
            {
                Bitmap flippedImage = new Bitmap(upscaleds[count].Width * upscaledTiling, upscaleds[count].Height * upscaledTiling);

                int height = flippedImage.Height - 1; //is one pixel less because the resulting image won't have pixel 0 in height and width twice
                int width  = flippedImage.Width - 1;

                int orgX = -upscaleds[count].Width + 1;
                int orgY = -upscaleds[count].Height + 1;

                for (int y = 0; y < height; y++)
                {
                    orgX = -upscaleds[count].Width + 1;
                    for (int x = 0; x < width; x++)
                    {
                        flippedImage.SetPixel(x, y, upscaleds[count].GetPixel(Math.Abs(orgX), Math.Abs(orgY)));

                        orgX++;
                    }
                    orgY++;
                }

                flippedImage.Save("FLIPPEDcombined " + name + ".png");
                count++;
            }
            Console.WriteLine("Flipped Done!");
        }



        Console.WriteLine($"time = {sw.ElapsedMilliseconds}");
    }