예제 #1
0
        private void AddBlock(int x, int y, int z)
        {
            const int air = 0;

            if (chunk.Map[x, y, z] == air)
            {
                return;
            }
            var blockTexture = storage[chunk.Map[x, y, z]];
            var offset       = new Vector3(x + 0.5f, y + 0.5f, z + 0.5f);
            var toSee        = new HashSet <BlockEdge>();

            if (!HasNeighbourOn(x, y, z, BlockEdge.Right))
            {
                toSee.Add(BlockEdge.Right);
            }
            if (!HasNeighbourOn(x, y, z, BlockEdge.Left))
            {
                toSee.Add(BlockEdge.Left);
            }
            if (!HasNeighbourOn(x, y, z, BlockEdge.Top))
            {
                toSee.Add(BlockEdge.Top);
            }
            if (!HasNeighbourOn(x, y, z, BlockEdge.Bottom))
            {
                toSee.Add(BlockEdge.Bottom);
            }
            if (!HasNeighbourOn(x, y, z, BlockEdge.Front))
            {
                toSee.Add(BlockEdge.Front);
            }
            if (!HasNeighbourOn(x, y, z, BlockEdge.Back))
            {
                toSee.Add(BlockEdge.Back);
            }

            foreach (var edge in toSee)
            {
                AddFace(BlockModel.GetEdge(edge), offset);
                textureCoords.AddRange(blockTexture.GetEdge(edge));
                AddIndices();
            }
        }