Exemplo n.º 1
0
 public void SetChunk(Primitives.Chunk chunk)
 {
     if (this.ActiveChunk != chunk)
     {
         this.ActiveChunk = chunk;
         updateRequired   = true;
     }
 }
Exemplo n.º 2
0
        public void SetBlock(Vector3 position, Block block)
        {
            Vector3 chunkIndex = position.FloorDiv(ChunkSize);

            Primitives.Chunk chunk;
            if (!map.TryGetValue(chunkIndex, out chunk))
            {
                chunk = new Primitives.Chunk(chunkIndex, ChunkSize);
                map.Add(chunkIndex, chunk);
            }
            chunk.SetBlock(position.Mod(ChunkSize), block);
        }
Exemplo n.º 3
0
        public void MeshData(Primitives.Chunk chunk, int x, int y, int z, MeshData meshData)
        {
            uint c = 0;

            if (Solid)
            {
                if (!chunk.GetBlock(new Vector3(x, y + 1, z)).Solid)
                {
                    FaceDataUp(x, y, z, meshData);
                    c |= 0x01;
                }
                if (!chunk.GetBlock(new Vector3(x, y - 1, z)).Solid)
                {
                    FaceDataDown(x, y, z, meshData);
                    c |= 0x02;
                }
                if (!chunk.GetBlock(new Vector3(x, y, z + 1)).Solid)
                {
                    FaceDataNorth(x, y, z, meshData);
                    c |= 0x04;
                }
                if (!chunk.GetBlock(new Vector3(x, y, z - 1)).Solid)
                {
                    FaceDataSouth(x, y, z, meshData);
                    c |= 0x08;
                }
                if (!chunk.GetBlock(new Vector3(x + 1, y, z)).Solid)
                {
                    FaceDataEast(x, y, z, meshData);
                    c |= 0x10;
                }
                if (!chunk.GetBlock(new Vector3(x - 1, y, z)).Solid)
                {
                    FaceDataWest(x, y, z, meshData);
                    c |= 0x20;
                }
            }

            if (c > 0 && c < 0x40)
            {
                meshData.AddGeometryInfo(new Vector3(x, y, z), Color, c);
            }
        }