Пример #1
0
    public static AdjacentBlocks GetAdjacentBlocks(int x, int y, int z)
    {
        AdjacentBlocks blocks = new AdjacentBlocks();

        blocks.left   = GetBlockSafe(x - 1, y, z);
        blocks.right  = GetBlockSafe(x + 1, y, z);
        blocks.back   = GetBlockSafe(x, y, z - 1);
        blocks.front  = GetBlockSafe(x, y, z + 1);
        blocks.bottom = GetBlockSafe(x, y - 1, z);
        blocks.top    = GetBlockSafe(x, y + 1, z);

        return(blocks);
    }
Пример #2
0
    public void BuildFluid(Block block, int x, int y, int z, MeshData meshData)
    {
        Vector3i local    = Map.ToLocalPos(x, y, z);
        Vector3i worldPos = new Vector3i(x, y, z);

        AdjacentBlocks neighbors = Map.GetAdjacentBlocks(x, y, z);

        int   curLevel = block.FluidLevel;
        float offset   = FluidSimulator.GetOffset(curLevel);

        if (IsFluidFaceVisible(curLevel, x, y, z + 1, neighbors.front, Direction.Back))
        {
            BuildFrontFluid(block, local.x, local.y, local.z, meshData, Direction.Front, offset, neighbors.front);
            BuildSquareLight(Axis.Z, worldPos, meshData, squareOffsetFront);
        }

        if (IsFluidFaceVisible(curLevel, x, y, z - 1, neighbors.back, Direction.Front))
        {
            BuildBackFluid(block, local.x, local.y, local.z, meshData, Direction.Back, offset, neighbors.back);
            BuildSquareLight(Axis.Z, worldPos, meshData, squareOffsetBack);
        }

        if (IsFluidFaceVisible(curLevel, x + 1, y, z, neighbors.right, Direction.Left))
        {
            BuildRightFluid(block, local.x, local.y, local.z, meshData, Direction.Right, offset, neighbors.right);
            BuildSquareLight(Axis.X, worldPos, meshData, squareOffsetRight);
        }

        if (IsFluidFaceVisible(curLevel, x - 1, y, z, neighbors.left, Direction.Right))
        {
            BuildLeftFluid(block, local.x, local.y, local.z, meshData, Direction.Left, offset, neighbors.left);
            BuildSquareLight(Axis.X, worldPos, meshData, squareOffsetLeft);
        }

        if (IsFluidFaceVisible(curLevel, x, y + 1, z, neighbors.top, Direction.Down))
        {
            BuildTopFluid(block, local.x, local.y, local.z, meshData, Direction.Up, offset);
            BuildSquareLight(Axis.Y, worldPos, meshData, squareOffsetTop);
        }

        if (IsFluidFaceVisible(curLevel, x, y - 1, z, neighbors.bottom, Direction.Up))
        {
            BuildBottomFluid(block, local.x, local.y, local.z, meshData, Direction.Down);
            BuildSquareLight(Axis.Y, worldPos, meshData, squareOffsetBottom);
        }
    }
Пример #3
0
        public override IEnumerable <BlockVertex> CreateMesh(AdjacentBlocks neighborhood)
        {
            Vector3            color    = this.Color;
            List <BlockVertex> vertices = new List <BlockVertex>();

            if (neighborhood.Top)
            {
                vertices.AddRange(CreateInstance(topSideTemplate, color));
            }

            if (neighborhood.Bottom)
            {
                vertices.AddRange(CreateInstance(bottomSideTemplate, color));
            }

            if (neighborhood.NegativeX)
            {
                vertices.AddRange(CreateInstance(negativeXSideTemplate, color));
            }

            if (neighborhood.PositiveX)
            {
                vertices.AddRange(CreateInstance(positiveXSideTemplate, color));
            }

            if (neighborhood.NegativeZ)
            {
                vertices.AddRange(CreateInstance(negativeZSideTemplate, color));
            }

            if (neighborhood.PositiveZ)
            {
                vertices.AddRange(CreateInstance(positiveZSideTemplate, color));
            }

            return(vertices.Select(v => { v.uv.Z = this.texture; return v; }));
        }
Пример #4
0
 public abstract IEnumerable<BlockVertex> CreateMesh(AdjacentBlocks neighborhood);
Пример #5
0
 public override IEnumerable <BlockVertex> CreateMesh(AdjacentBlocks neighborhood)
 {
     return(this.mesh);
 }
Пример #6
0
 public override IEnumerable<BlockVertex> CreateMesh(AdjacentBlocks neighborhood)
 {
     return this.mesh;
 }
Пример #7
0
 public abstract IEnumerable <BlockVertex> CreateMesh(AdjacentBlocks neighborhood);