Пример #1
0
        public TerrainChunk(TerraTerrain terrain, TerrainChunk parent, Vector3 start, Vector3 right, Vector3 forward, int resolution, int layer)
        {
            this.parent     = parent;
            this.start      = start;
            this.right      = right;
            this.forward    = forward;
            this.resolution = resolution;
            this.layer      = layer;

            go           = new GameObject("TerrainChunkLOD" + layer);
            meshFilter   = go.AddComponent <MeshFilter>();
            meshRenderer = go.AddComponent <MeshRenderer>();

            if (parent == null)
            {
                go.transform.parent = terrain.transform;
            }
            else
            {
                go.transform.parent = parent.go.transform;
            }

            mesh            = new Mesh();
            meshFilter.mesh = mesh;
        }
Пример #2
0
        private void Regenerate()
        {
            Graph.RebuildConnections();
            Base = gameObject;
            Graph.ActiveTerrain = this;

            if (Chunk == null)
            {
                Chunk = new TerrainChunk(this, null, new Vector3(-0.5f, 0, -0.5f), Vector3.right, Vector3.forward, 255, 0);
            }

            Chunk.Generate(this);
        }