コード例 #1
0
    void Start()
    {
        groundNoise = new Noise();
        groundNoise.setPermutations (groundSeed);

        mountainNoise = new Noise();
        mountainNoise.setPermutations (mountainSeed);

        treeNoise = new Noise();
        treeNoise.setPermutations (treeSeed);

        detailNoise = new Noise();
        detailNoise.setPermutations (detailSeed);

        if(!Mathf.IsPowerOfTwo(heightMapSize-1))
        {
            heightMapSize = Mathf.ClosestPowerOfTwo(heightMapSize)+1;
        }

        if(!Mathf.IsPowerOfTwo(alphaMapSize))
        {
            alphaMapSize = Mathf.ClosestPowerOfTwo(alphaMapSize);
        }

        if(!Mathf.IsPowerOfTwo(detailMapSize))
        {
            detailMapSize = Mathf.ClosestPowerOfTwo(detailMapSize);
        }

        if(detailResolutionPerPatch < 8)
        {
            detailResolutionPerPatch = 8;
        }

        //		terrain = new Terrain[tilesX,tilesZ];

        //this will center terrain at origin

        //populate prototypes
        if(splatDataCreated()){
            Debug.Log("Splats Created");
            if (treeDataCreated ()) {
                Debug.Log ("Trees Created");
                if(detailsDataCreated()){
                    Debug.Log("Details Created");
                }
            }
        }

        Terrain[,] terrain = new Terrain[tilesX, tilesZ];

        //		for(int x = 0; x < tilesX; x++)
        //		{
        //			for(int z = 0; z < tilesZ; z++)
        //			{
        //				GenerateTerrains(x, z, terrain[x,z] );
        //			}
        //		}

        // Get Player's initial position
        startPos = Vector3.zero;
        Debug.Log (startPos);

        // Generate 4 terrains at the beginning
        current = GenerateTerrains(x, z, current );

        if(left == null) {
            int leftX = x-1;
            left = GenerateTerrains(leftX, z, left );
        }
        if(right == null) {
            int rightX = x+1;
            right = GenerateTerrains(rightX, z, right );
        }
        if(top == null) {
            int topZ = z+1;
            top = GenerateTerrains(x, topZ, top );
        }
        if(bottom == null) {
            int botZ = z-1;
            bottom = GenerateTerrains(x, botZ, bottom );
        }

        listX.Add (x);
        listZ.Add (z);

        Debug.Log (listX.Contains(x));
    }