Example #1
0
        bool CheckAdjacent(int x, int y, int z, Direction direction, Transparency transparency)
        {
            // returns true if a face should be spawned
            Index  idx           = _chunk.GetAdjacentIndex(x, y, z, direction);
            ushort adjacentVoxel = _chunk.GetVoxel(idx);

            if (adjacentVoxel == ushort.MaxValue)
            {
                bool neighborChunkIsMissing = Engine.ShowBorderFaces || direction == Direction.up;
                return(neighborChunkIsMissing);
            }

            Transparency result = Engine.GetVoxelType(adjacentVoxel).VTransparency; // get the transparency of the adjacent voxel

            // parse the result (taking into account the transparency of the adjacent block as well as the one doing this check)
            if (transparency == Transparency.transparent)
            {
                return(result != Transparency.transparent);
                // don't draw a transparent block next to another transparent block
                // draw a transparent block next to a solid or semi-transparent
            }
            else
            {
                return(result != Transparency.solid);
                // don't draw a solid block or a semi-transparent block next to a solid block
                // draw a solid block or a semi-transparent block next to both transparent and semi-transparent
            }
        }
Example #2
0
        private bool CheckAdjacent(int x, int y, int z, Direction direction, Transparency transparency)      // returns true if a face should be spawned
        {
            Index  index         = chunk.GetAdjacentIndex(x, y, z, direction);
            ushort adjacentVoxel = chunk.GetVoxel(index.x, index.y, index.z);

            if (adjacentVoxel == ushort.MaxValue)       // if the neighbor chunk is missing

            {
                if (Engine.ShowBorderFaces || direction == Direction.up)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            Transparency result = Engine.GetVoxelType(adjacentVoxel).VTransparency;             // get the transparency of the adjacent voxel

            // parse the result (taking into account the transparency of the adjacent block as well as the one doing this check)
            if (transparency == Transparency.transparent)
            {
                if (result == Transparency.transparent)
                {
                    return(false);            // don't draw a transparent block next to another transparent block
                }
                else
                {
                    return(true);            // draw a transparent block next to a solid or semi-transparent
                }
            }
            else
            {
                if (result == Transparency.solid)
                {
                    return(false);            // don't draw a solid block or a semi-transparent block next to a solid block
                }
                else
                {
                    return(true);            // draw a solid block or a semi-transparent block next to both transparent and semi-transparent
                }
            }
        }