示例#1
0
    void GenerateMap()
    {
        map = new int[width, height];
        RandomFillMap();

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

        ProcessMap();

        int borderSize = 1;

        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;
                }
            }
        }

        MeshGeneration meshGen = GetComponent <MeshGeneration>();

        meshGen.GenerateMesh(borderedMap, 1);
    }
示例#2
0
    void MeshDataThread(MapData mapData, Action <MeshData> callback, int LOD)
    {
        MeshData meshData = MeshGeneration.GenerateMesh(mapData.heightMap, terrainData.meshHeightMultiplier, terrainData.meshHeightCurve, LOD);

        lock (meshDataThreadInfoQueue)
        {
            meshDataThreadInfoQueue.Enqueue(new MapThreadInfo <MeshData>(callback, meshData));
        }
    }
示例#3
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        MeshGeneration myScript = (MeshGeneration)target;

        if (GUILayout.Button("Generate"))
        {
            myScript.GenerateMesh();
        }
    }
示例#4
0
    public void DrawMap()
    {
        MapData mapData = GenerateChunkData(Vector2.zero);

        MapDisplay display = FindObjectOfType <MapDisplay>(); //gets MapDisplay object

        if (drawMode == DrawMode.NoiseMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(mapData.heightMap)); //draws the noisemap
        }
        else if (drawMode == DrawMode.ColourMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromColourMap(mapData.colourMap, chunkSize, chunkSize)); //draws the colourmap
        }
        else if (drawMode == DrawMode.Mesh)
        {
            display.DrawMesh(MeshGeneration.GenerateMesh(mapData.heightMap, terrainData.meshHeightMultiplier, terrainData.meshHeightCurve, editorLevelOfDetail), TextureGenerator.TextureFromColourMap(mapData.colourMap, chunkSize, chunkSize));
        }
    }