public void Start()     // {{{
 {
     perlinNoise = new PerlinNoise(terrainSeed);
     Random.InitState(terrainSeed);
     settings = new TerrainChunkSettings(terrainChunkLength, terrainChunkHeight, terrainChunkFaceSpacing,
                                         treeDensinity, detailsDensinity, treePrefabs, detailsPrefabs);
 }
Example #2
0
    public TerrainChunk(TerrainChunkSettings settings, PerlinNoise perlinNoise, int seed, Vector2i pos) // {{{
    {
        this.pos         = pos;
        this.settings    = settings;
        this.perlinNoise = perlinNoise;
        this.seed        = seed;
        rand             = new System.Random((pos.x * 10000 + pos.z * 587) * seed);

        stages = new Action[] {
            CreateMesh,
            CreateTerrain,
            AddTrees,
            AddDetails,
        };

        gameObject = new GameObject("Terrain");
        gameObject.transform.position = new Vector3(pos.x * (settings.length - 1) * settings.spacing + (settings.length % 2 == 0 && pos.z % 2 == 0 ? settings.spacing / 2 : 0),
                                                    0,
                                                    pos.z * (settings.length - 1) * settings.spacing);
        worldPosition = gameObject.transform.position;
    }
 public TerrainChunk(TerrainChunkSettings terrainChunkSettings, int x, int z)
 {
     Settings = terrainChunkSettings;
     X = x;
     Z = z;
 }
Example #4
0
 public void Test()
 {
     var settings = new TerrainChunkSettings(129, 129, 100, 20, (NoiseMethodType)1, 3);
     var terrain = new TerrainChunk(settings, 0, 0);
     terrain.CreateTerrain();
 }