Beispiel #1
0
        private VertexPositionTextureShade BuildVertex(Vector3 position, Vector2 textureCoordinate, float shade)
        {
            VertexPositionTextureShade vertex = new VertexPositionTextureShade();

            vertex.Position          = position;
            vertex.TextureCoordinate = textureCoordinate;
            vertex.Shade             = shade;
            return(vertex);
        }
Beispiel #2
0
        private void BuildFaceVertices(int x, int y, int z, Buffer buffer, ref VertexPositionTextureShade[] vertexArray, BlockFaceDirection faceDir, BlockTexture texture)
        {
            int faceIndex = 0;

            switch (faceDir)
            {
            case BlockFaceDirection.XIncreasing:
                faceIndex = 0;
                break;

            case BlockFaceDirection.XDecreasing:
                faceIndex = 1;
                break;

            case BlockFaceDirection.YIncreasing:
                faceIndex = 2;
                break;

            case BlockFaceDirection.YDecreasing:
                faceIndex = 3;
                break;

            case BlockFaceDirection.ZIncreasing:
                faceIndex = 4;
                break;

            case BlockFaceDirection.ZDecreasing:
                faceIndex = 5;
                break;
            }
            Vector2[] UVList = UVMappings[(int)texture * 6 + faceIndex];
            int       index  = 0;

            switch (buffer)
            {
            case Buffer.Model:
                index = _modelIndex;
                break;

            case Buffer.Solid:
                index = _solidIndex;
                break;

            case Buffer.Water:
                index = _waterIndex;
                break;
            }

            switch (faceDir)
            {
            case BlockFaceDirection.XIncreasing:
            {
                vertexArray[index]     = new VertexPositionTextureShade(new Vector3(x + 1, y + 1, z + 1), UVList[0], _world.Lighting.GetLight(x + 1, y, z) + WorldSettings.SIDESHADOWS);
                vertexArray[index + 1] = new VertexPositionTextureShade(new Vector3(x + 1, y + 1, z), UVList[1], _world.Lighting.GetLight(x + 1, y, z) + WorldSettings.SIDESHADOWS);
                vertexArray[index + 2] = new VertexPositionTextureShade(new Vector3(x + 1, y, z + 1), UVList[2], _world.Lighting.GetLight(x + 1, y, z) + WorldSettings.SIDESHADOWS);
                vertexArray[index + 3] = new VertexPositionTextureShade(new Vector3(x + 1, y, z + 1), UVList[3], _world.Lighting.GetLight(x + 1, y, z) + WorldSettings.SIDESHADOWS);
                vertexArray[index + 4] = new VertexPositionTextureShade(new Vector3(x + 1, y + 1, z), UVList[4], _world.Lighting.GetLight(x + 1, y, z) + WorldSettings.SIDESHADOWS);
                vertexArray[index + 5] = new VertexPositionTextureShade(new Vector3(x + 1, y, z), UVList[5], _world.Lighting.GetLight(x + 1, y, z) + WorldSettings.SIDESHADOWS);
            }
            break;

            case BlockFaceDirection.XDecreasing:
            {
                vertexArray[index]     = new VertexPositionTextureShade(new Vector3(x, y + 1, z), UVList[0], _world.Lighting.GetLight(x - 1, y, z) + WorldSettings.SIDESHADOWS);
                vertexArray[index + 1] = new VertexPositionTextureShade(new Vector3(x, y + 1, z + 1), UVList[1], _world.Lighting.GetLight(x - 1, y, z) + WorldSettings.SIDESHADOWS);
                vertexArray[index + 2] = new VertexPositionTextureShade(new Vector3(x, y, z + 1), UVList[2], _world.Lighting.GetLight(x - 1, y, z) + WorldSettings.SIDESHADOWS);
                vertexArray[index + 3] = new VertexPositionTextureShade(new Vector3(x, y + 1, z), UVList[3], _world.Lighting.GetLight(x - 1, y, z) + WorldSettings.SIDESHADOWS);
                vertexArray[index + 4] = new VertexPositionTextureShade(new Vector3(x, y, z + 1), UVList[4], _world.Lighting.GetLight(x - 1, y, z) + WorldSettings.SIDESHADOWS);
                vertexArray[index + 5] = new VertexPositionTextureShade(new Vector3(x, y, z), UVList[5], _world.Lighting.GetLight(x - 1, y, z) + WorldSettings.SIDESHADOWS);
            }
            break;

            case BlockFaceDirection.YIncreasing:
            {
                vertexArray[index]     = new VertexPositionTextureShade(new Vector3(x, y + 1, z), UVList[0], _world.Lighting.GetLight(x, y + 1, z));
                vertexArray[index + 1] = new VertexPositionTextureShade(new Vector3(x + 1, y + 1, z), UVList[1], _world.Lighting.GetLight(x, y + 1, z));
                vertexArray[index + 2] = new VertexPositionTextureShade(new Vector3(x + 1, y + 1, z + 1), UVList[2], _world.Lighting.GetLight(x, y + 1, z));
                vertexArray[index + 3] = new VertexPositionTextureShade(new Vector3(x, y + 1, z), UVList[3], _world.Lighting.GetLight(x, y + 1, z));
                vertexArray[index + 4] = new VertexPositionTextureShade(new Vector3(x + 1, y + 1, z + 1), UVList[4], _world.Lighting.GetLight(x, y + 1, z));
                vertexArray[index + 5] = new VertexPositionTextureShade(new Vector3(x, y + 1, z + 1), UVList[5], _world.Lighting.GetLight(x, y + 1, z));
            }
            break;

            case BlockFaceDirection.YDecreasing:
            {
                vertexArray[index]     = new VertexPositionTextureShade(new Vector3(x + 1, y, z + 1), UVList[0], _world.Lighting.GetLight(x, y - 1, z) + WorldSettings.SIDESHADOWS);
                vertexArray[index + 1] = new VertexPositionTextureShade(new Vector3(x + 1, y, z), UVList[1], _world.Lighting.GetLight(x, y - 1, z) + WorldSettings.SIDESHADOWS);
                vertexArray[index + 2] = new VertexPositionTextureShade(new Vector3(x, y, z + 1), UVList[2], _world.Lighting.GetLight(x, y - 1, z) + WorldSettings.SIDESHADOWS);
                vertexArray[index + 3] = new VertexPositionTextureShade(new Vector3(x, y, z + 1), UVList[3], _world.Lighting.GetLight(x, y - 1, z) + WorldSettings.SIDESHADOWS);
                vertexArray[index + 4] = new VertexPositionTextureShade(new Vector3(x + 1, y, z), UVList[4], _world.Lighting.GetLight(x, y - 1, z) + WorldSettings.SIDESHADOWS);
                vertexArray[index + 5] = new VertexPositionTextureShade(new Vector3(x, y, z), UVList[5], _world.Lighting.GetLight(x, y - 1, z) + WorldSettings.SIDESHADOWS);
            }
            break;

            case BlockFaceDirection.ZIncreasing:
            {
                vertexArray[index]     = new VertexPositionTextureShade(new Vector3(x, y + 1, z + 1), UVList[0], _world.Lighting.GetLight(x, y, z + 1));
                vertexArray[index + 1] = new VertexPositionTextureShade(new Vector3(x + 1, y + 1, z + 1), UVList[1], _world.Lighting.GetLight(x, y, z + 1));
                vertexArray[index + 2] = new VertexPositionTextureShade(new Vector3(x + 1, y, z + 1), UVList[2], _world.Lighting.GetLight(x, y, z + 1));
                vertexArray[index + 3] = new VertexPositionTextureShade(new Vector3(x, y + 1, z + 1), UVList[3], _world.Lighting.GetLight(x, y, z + 1));
                vertexArray[index + 4] = new VertexPositionTextureShade(new Vector3(x + 1, y, z + 1), UVList[4], _world.Lighting.GetLight(x, y, z + 1));
                vertexArray[index + 5] = new VertexPositionTextureShade(new Vector3(x, y, z + 1), UVList[5], _world.Lighting.GetLight(x, y, z + 1));
            }
            break;

            case BlockFaceDirection.ZDecreasing:
            {
                vertexArray[index]     = new VertexPositionTextureShade(new Vector3(x + 1, y + 1, z), UVList[0], _world.Lighting.GetLight(x, y, z - 1));
                vertexArray[index + 1] = new VertexPositionTextureShade(new Vector3(x, y + 1, z), UVList[1], _world.Lighting.GetLight(x, y, z - 1));
                vertexArray[index + 2] = new VertexPositionTextureShade(new Vector3(x + 1, y, z), UVList[2], _world.Lighting.GetLight(x, y, z - 1));
                vertexArray[index + 3] = new VertexPositionTextureShade(new Vector3(x + 1, y, z), UVList[3], _world.Lighting.GetLight(x, y, z - 1));
                vertexArray[index + 4] = new VertexPositionTextureShade(new Vector3(x, y + 1, z), UVList[4], _world.Lighting.GetLight(x, y, z - 1));
                vertexArray[index + 5] = new VertexPositionTextureShade(new Vector3(x, y, z), UVList[5], _world.Lighting.GetLight(x, y, z - 1));
            }
            break;
            }
            index += 6;
            switch (buffer)
            {
            case Buffer.Model:
                _modelIndex = index;
                break;

            case Buffer.Solid:
                _solidIndex = index;
                break;

            case Buffer.Water:
                _waterIndex = index;
                break;
            }
        }