Example #1
0
    private void GetRandomMap()
    {
        // Dont run another mesh if another render is still running
        renderDone = false;

        // Map dimensions
        width  = mapDimensions.width;
        height = mapDimensions.height;

        // ProcGen settings
        fillPercent     = proceduralGeneration.randomFill;
        resolution      = proceduralGeneration.resolution;
        smoothingPasses = proceduralGeneration.smoothing;
        seed            = proceduralGeneration.seed;
        useRandom       = proceduralGeneration.randomSeed;
        threadCount     = proceduralGeneration.threads;

        // Inversely proportional to resolution; same size but more complex meshes
        squareSize = 1 / (float)resolution;

        // Generates random 2d array of booleans
        randomMap = new CellularAutomata(fillPercent, resolution, smoothingPasses, width, height, seed, useRandom);
        map       = randomMap.GenerateMap();

        // Creates contoured mesh from bool array
        meshGenerator = new ThreadedContourMesh(RecieveMeshData, threadCount, map, squareSize, meshSettings.drawContours, meshSettings.drawSimple, meshSettings.uniqueVertcies);
        meshGenerator.StartThreads();
    }