Beispiel #1
0
    public void MeshDataThread(MapData mapData, int lod, Action <MeshData> callback)
    {
        MeshData meshData = MeshGen.GenerateMesh(mapData.heightMap, meshHeightMultiplier, meshHeightCurve, lod);

        lock (meshDataThreadInfoQueue)
        {
            meshDataThreadInfoQueue.Enqueue(new MapThreadInfo <MeshData>(callback, meshData));
        }
    }
Beispiel #2
0
    void GenerateMap()
    {
        map = new int[width, height];
        RandomFillMap();

        for (int i = 0; i < 16; i++)
        {
            //SmoothMap();
        }

        MeshGen meshGen = GetComponent <MeshGen>();

        meshGen.GenerateMesh(map, 1);
    }
    public void GenerateTerrain()
    {
        mesh = new Mesh();
        GetComponent <MeshFilter>().mesh = mesh;


        meshGen.GenerateMesh(heightMap);

        Vertices  = meshGen.Vertices;
        Triangles = meshGen.Triangles;


        mesh.Clear();
        mesh.vertices  = Vertices;
        mesh.triangles = Triangles;
        mesh.RecalculateNormals();
    }
Beispiel #4
0
    public void DrawMapInEditor()
    {
        MapData    mapData = GenerateMapData(Vector2.zero);
        MapDisplay display = FindObjectOfType <MapDisplay>();

        if (drawMode == DrawMode.NoiseMap)
        {
            display.DrawTexture(TextureGen.TextureFromHeightMap(mapData.heightMap));
        }
        else if (drawMode == DrawMode.ColorMap)
        {
            display.DrawTexture(TextureGen.TextureFromColorMap(mapData.colorMap, mapChunkSize, mapChunkSize));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            display.DrawMesh(MeshGen.GenerateMesh(mapData.heightMap, meshHeightMultiplier, meshHeightCurve, editorPreviewLOD), TextureGen.TextureFromColorMap(mapData.colorMap, mapChunkSize, mapChunkSize));
        }
    }
Beispiel #5
0
    // generates map using seed
    public void GenerateMap()
    {
        currentBiome    = Biome.forest;
        currentRooms    = new List <Room>();
        roomCoordinates = new List <List <Coord> >();
        hallCoordinates = new List <List <Coord> >();
        // GetComponent<Renderer>().material = walls;
        map = new int[currentBiome.width, currentBiome.height];
        RandomFillMap();

        for (int i = 0; i < currentBiome.smoothingIterations; i++)
        {
            SmoothMap();
        }

        ProcessMap();

        int borderSize = 15;         // sets border THICCness

        int[,] borderedMap = new int[currentBiome.width + borderSize * 2, currentBiome.height + borderSize * 2];

        for (int x = 0; x < borderedMap.GetLength(0); x++)
        {
            for (int y = 0; y < borderedMap.GetLength(1); y++)
            {
                if (x >= borderSize && x < currentBiome.width + borderSize && y >= borderSize && y < currentBiome.height + borderSize)
                {
                    borderedMap[x, y] = map[x - borderSize, y - borderSize];
                }
                else
                {
                    borderedMap[x, y] = 1;
                }
            }
        }

        MeshGen meshGen = GetComponent <MeshGen>();

        meshGen.GenerateMesh(borderedMap, 1);
    }
Beispiel #6
0
    void GenerateMap()
    {
        map = new int[width, height];
        RandomFillMap();

        for (int i = 0; i < smoothingIterations; i++)
        {
            SmoothMap();
        }

        ProcessMap();

        int borderSize = 5;         // sets border THICCness

        int[,] borderedMap = new int[width + borderSize * 2, height + borderSize * 2];

        for (int x = 0; x < borderedMap.GetLength(0); x++)
        {
            for (int y = 0; y < borderedMap.GetLength(1); y++)
            {
                if (x >= borderSize && x < width + borderSize && y >= borderSize && y < height + borderSize)
                {
                    borderedMap[x, y] = map[x - borderSize, y - borderSize];
                }
                else
                {
                    borderedMap[x, y] = 1;
                }
            }
        }

        //GenerateMapObjects(hazards, hazardParent, true);
        GenerateMapObjects(pickUps, pickupParent);
        PlacePlayer();

        MeshGen meshGen = GetComponent <MeshGen>();

        meshGen.GenerateMesh(borderedMap, 1);
    }
Beispiel #7
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            GenerateMap();
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            SmoothMap(4, 5);
            Debug.Log("Smoothening");
            MeshGen meshGen = GetComponent <MeshGen>();
            meshGen.GenerateMesh(map, 1);
        }

        if (Input.GetMouseButton(1))
        {
            SmoothMap();
            Debug.Log("Smoothening");
            MeshGen meshGen = GetComponent <MeshGen>();
            meshGen.GenerateMesh(map, 1);
        }
    }