protected override LC_Cell CreateCell(int chunkX, int chunkZ, LC_Chunk <LC_Cell> chunk)
    {
        LC_Cell cell = new LC_Cell(new Vector2Int(chunk.CellsOffset.x + chunkX, chunk.CellsOffset.y + chunkZ),
                                   chunk.HeightsMap[chunkX + 1, chunkZ + 1]); // +1 to compensate the offset for normals computation

        cell.Height = Mathf.RoundToInt(cell.Height);
        return(cell);
    }
Esempio n. 2
0
    protected override void SplitAndMergeMesh(LC_Chunk <WorldCell> chunk)
    {
        List <LC_Math.QuadTreeSector> sectors = LC_Math.SplitAndMerge(
            (x, z) => { return(chunk.Cells[x, z].RealHeight); },
            (x, y) => { return(x == y); },
            ChunkSize, true);

        foreach (LC_Math.QuadTreeSector sector in sectors)
        {
            CreateElementMesh(sector.Initial, sector.Final, chunk);
        }
    }
Esempio n. 3
0
    protected virtual void InstanceWorldObjects(LC_Chunk <WorldCell> chunk)
    {
        for (int x = 0; x < ChunkSize; x++)
        {
            for (int y = 0; y < ChunkSize; y++)
            {
                WorldCell cell = chunk.Cells[x, y];

                if (cell.IsFree())
                {
                    World.CreateWorldObject(chunk, cell);
                }
            }
        }
    }
Esempio n. 4
0
    protected override Vector2Int GetTexPos(WorldCell cell, LC_Chunk <WorldCell> chunk)
    {
        float      value;
        Vector2Int texPos = Vector2Int.zero;

        if (cell.IsWater)
        {
            texPos.y = 0;
            value    = Mathf.InverseLerp(0, WaterHeight, cell.RealHeight);
        }
        else
        {
            texPos.y = 1;
            value    = Mathf.InverseLerp(WaterHeight, MaxHeight, cell.Height);
        }
        texPos.x = Mathf.RoundToInt(value * (TextureColumnsAndRows.x - 1));

        return(texPos);
    }
Esempio n. 5
0
 protected override void BuildChunk(LC_Chunk <WorldCell> chunk)
 {
     base.BuildChunk(chunk);
     InstanceWorldObjects(chunk);
 }
Esempio n. 6
0
 protected override WorldCell CreateCell(int chunkX, int chunkZ, LC_Chunk <WorldCell> chunk)
 {
     return(World.CreateCell(chunkX, chunkZ, chunk));
 }
Esempio n. 7
0
 /// <summary>
 /// Create a cell of a chunk using the coordinates and the chunk.HeightsMap.
 /// </summary>
 protected override LC_Cell CreateCell(int chunkX, int chunkZ, LC_Chunk <LC_Cell> chunk)
 {
     return(new LC_Cell(new Vector2Int(chunk.CellsOffset.x + chunkX, chunk.CellsOffset.y + chunkZ),
                        chunk.HeightsMap[chunkX + 1, chunkZ + 1])); // +1 to compensate the offset for normals computation
 }