コード例 #1
0
    public TerrainGenerator(Terrain terrain)
    {
        td = terrain.terrainData;
        terrain.detailObjectDistance = 2000;
        //Creates a new 2D array, the same size resolution as the heightmap.
        HeightMap = new float[td.heightmapWidth, td.heightmapHeight];
        //Sets the renderer as the texture
        //renderer.material.mainTexture = texture;


        td.splatPrototypes = initialiseSplatPrototypes();
        initialiseHills();
        Average(45, td.heightmapWidth, td.heightmapHeight);


        int[][] patchcoords = Cliff.setCliffPatch(200, 200, 240, 270, 0.7f, 0.71f);
        Cliff.setHillPatch(500, 700, -0.3f, 100);
        setPondPatch(800, 400, 0.3f, 100);
        //cliffCircleCutout (patchcoords, 25);

        int[] circlecoords = Cliff.setCircularCliffPatch(700, 400, 100, 2048, 0.75f, 0.74f);
        TERRAIN_HEIGHT = HeightMap[1, 1];

        //setQuadraticCliffPatch(400,300,350,450);

        Cliff.quadraticCliffPatchController(400, 300, 370, 430, 88, 0.1f, 0.9f, 15, -1 * 0.005f);

        //createPathToCliff (700,400,120,Mathf.PI,HeightMap[5,5],true);
        //createPathToCliff (700,400,100,Mathf.PI*2,HeightMap[5,5],true);
        Average(4, td.heightmapWidth, td.heightmapHeight);

        // Sets the heightmap of the terrain equal to the height map we just generated.
        td.SetHeights(0, 0, HeightMap);
    }
コード例 #2
0
    // Use this for initialization


    /*
     * Sets a patch of terrain to a different height to the rest of the terrain. Useful for creating mountains and valleys.
     * The core code is to be used for splitting up the terrain into segments, so that different terrain details
     * can be applied to different parts of the map
     * LIMITATION: Only allows for squares or rectangles.
     * */



    void setPondPatch(int x, int z, float depth, int spread)
    {
        Vector3 waterVector = new Vector3(x, z, 0);

        Cliff.setHillPatch(x, z, depth, spread);

        Vector3    position = new Vector3(x + 530, 281, z + 520);
        GameObject pond     = (GameObject)Instantiate(Resources.Load("waterPond"), position, Quaternion.identity);
    }