예제 #1
0
    //creates (instantiates) a terrain chunk (but does not render it yet)
    public void CreateChunk(LODPos pos, bool render)
    {
        //if the chunk has aready been created, dont build it again!
        if (chunks.ContainsKey(pos))
        {
            return;
        }

        totalChunks++;

        //build the terrainobject and add its gameobject to the chunks list(may remove this last thing later)
        //TerrainObject chunk = Build.buildObject<TerrainObject>(pos.toVector3(), Quaternion.identity);
        GameObject terrainGO = Pool.getTerrain();

        terrainGO.name = "Terrain Chunk " + pos.ToString();
        TerrainObject chunk = terrainGO.GetComponent <TerrainObject>();

        chunk.init(pos, planet);
        chunks.Add(pos, chunk);
        //Debug.Log("chunks added key :" + pos.ToString());
        visChunks.Add(pos);

        if (render)
        {
            chunk.calculateNoise();
            chunk.Render();            //renders the chunk immediately
        }
        //RequestSystem.terrainToRender.Add(chunk);
    }