Esempio n. 1
0
 static void RenderTorch(Chunk chunk, BlocktypeInfo info, int x, int y, int z)
 {
     double x1 = 0, x2 = 0, z1 = 0, z2 = 0, yy = 0;
     byte data = chunk.GetData(x, y, z);
     switch (data) {
         case 1:
             x1 -= 0.125; x2 -= 0.5;
             yy = 3/16.0; break;
         case 2:
             x1 += 0.125; x2 += 0.5;
             yy = 3/16.0; break;
         case 3:
             z1 -= 0.125; z2 -= 0.5;
             yy = 3/16.0; break;
         case 4:
             z1 += 0.125; z2 += 0.5;
             yy = 3/16.0; break;
     }
     Light(chunk, x, y, z);
     GL.Normal3(1.0, 0.0, 0.0);
     GL.TexCoord2(info.Left.Right, info.Left.Top);    GL.Vertex3(x+x1+9/16.0, y+yy+1.0, z+z1);
     GL.TexCoord2(info.Left.Left,  info.Left.Top);    GL.Vertex3(x+x1+9/16.0, y+yy+1.0, z+z1+1.0);
     GL.TexCoord2(info.Left.Left,  info.Left.Bottom); GL.Vertex3(x+x2+9/16.0, y+yy,     z+z2+1.0);
     GL.TexCoord2(info.Left.Right, info.Left.Bottom); GL.Vertex3(x+x2+9/16.0, y+yy,     z+z2);
     GL.TexCoord2(info.Right.Right, info.Right.Top);      GL.Vertex3(x+x1+7/16.0, y+yy+1.0, z+z1+1.0);
     GL.TexCoord2(info.Right.Left,  info.Right.Top);      GL.Vertex3(x+x1+7/16.0, y+yy+1.0, z+z1);
     GL.TexCoord2(info.Right.Left,  info.Right.Bottom);   GL.Vertex3(x+x2+7/16.0, y+yy,     z+z2);
     GL.TexCoord2(info.Right.Right, info.Right.Bottom);   GL.Vertex3(x+x2+7/16.0, y+yy,     z+z2+1.0);
     GL.Normal3(0.0, 0.0, 1.0);
     GL.TexCoord2(info.Front.Right, info.Front.Top);    GL.Vertex3(x+x1+1.0, y+yy+1.0, z+z1+9/16.0);
     GL.TexCoord2(info.Front.Left,  info.Front.Top);    GL.Vertex3(x+x1,     y+yy+1.0, z+z1+9/16.0);
     GL.TexCoord2(info.Front.Left,  info.Front.Bottom); GL.Vertex3(x+x2,     y+yy,     z+z2+9/16.0);
     GL.TexCoord2(info.Front.Right, info.Front.Bottom); GL.Vertex3(x+x2+1.0, y+yy,     z+z2+9/16.0);
     GL.TexCoord2(info.Back.Right, info.Back.Top);      GL.Vertex3(x+x1,     y+yy+1.0, z+z1+7/16.0);
     GL.TexCoord2(info.Back.Left,  info.Back.Top);      GL.Vertex3(x+x1+1.0, y+yy+1.0, z+z1+7/16.0);
     GL.TexCoord2(info.Back.Left,  info.Back.Bottom);   GL.Vertex3(x+x2+1.0, y+yy,     z+z2+7/16.0);
     GL.TexCoord2(info.Back.Right, info.Back.Bottom);   GL.Vertex3(x+x2,     y+yy,     z+z2+7/16.0);
     x1 *= 2.125; z1 *= 2.125;
     GL.Normal3(0.0, 1.0, 0.0);
     GL.TexCoord2(info.Top.Right-7/256.0, info.Top.Top+6/256.0);    GL.Vertex3(x+x1+9/16.0, y+yy+10/16.0, z+z1+7/16.0);
     GL.TexCoord2(info.Top.Left+7/256.0,  info.Top.Top+6/256.0);    GL.Vertex3(x+x1+7/16.0, y+yy+10/16.0, z+z1+7/16.0);
     GL.TexCoord2(info.Top.Left+7/256.0,  info.Top.Bottom-8/256.0); GL.Vertex3(x+x1+7/16.0, y+yy+10/16.0, z+z1+9/16.0);
     GL.TexCoord2(info.Top.Right-7/256.0, info.Top.Bottom-8/256.0); GL.Vertex3(x+x1+9/16.0, y+yy+10/16.0, z+z1+9/16.0);
 }
Esempio n. 2
0
        static void RenderStairs(Chunk chunk, BlocktypeInfo info, int x, int y, int z)
        {
            BlocktypeInfo right, left, top, bottom, front, back;
            GetAdjacentBlocks(chunk, x, y, z, out right, out left,
                              out top, out bottom, out front, out back);
            double x1 = 0, x2 = 0, z1 = 0, z2 = 0;
            byte data = chunk.GetData(x, y, z);
            switch (data) {
                case 0:
                    x1 = 0.5; break;
                case 1:
                    x2 = 0.5; break;
                case 2:
                    z1 = 0.5; break;
                case 3:
                    z2 = 0.5; break;
            }
            if (!right.Opaque && right.DrawMode != DrawMode.Stairs) {

                AdjacentLight(chunk, x + 1, y, z);
                GL.Normal3(1.0, 0.0, 0.0);
                if (data == 0) {
                    GL.TexCoord2(info.Left.Right, info.Left.Top);    GL.Vertex3(x+1.0, y+1.0, z);
                    GL.TexCoord2(info.Left.Left,  info.Left.Top);    GL.Vertex3(x+1.0, y+1.0, z+1.0);
                    GL.TexCoord2(info.Left.Left,  info.Left.Bottom); GL.Vertex3(x+1.0, y,     z+1.0);
                    GL.TexCoord2(info.Left.Right, info.Left.Bottom); GL.Vertex3(x+1.0, y,     z);
                } else {
                    GL.TexCoord2(info.Left.Right, info.Left.Top+1/32.0); GL.Vertex3(x+1.0, y+0.5, z);
                    GL.TexCoord2(info.Left.Left,  info.Left.Top+1/32.0); GL.Vertex3(x+1.0, y+0.5, z+1.0);
                    GL.TexCoord2(info.Left.Left,  info.Left.Bottom);     GL.Vertex3(x+1.0, y,     z+1.0);
                    GL.TexCoord2(info.Left.Right, info.Left.Bottom);     GL.Vertex3(x+1.0, y,     z);
                    if (data != 1) {
                        GL.TexCoord2(info.Left.Right-z1/16, info.Left.Top);           GL.Vertex3(x+1.0, y+1.0, z+z1);
                        GL.TexCoord2(info.Left.Left+z2/16,  info.Left.Top);           GL.Vertex3(x+1.0, y+1.0, z+1.0-z2);
                        GL.TexCoord2(info.Left.Left+z2/16,  info.Left.Bottom-1/32.0); GL.Vertex3(x+1.0, y+0.5, z+1.0-z2);
                        GL.TexCoord2(info.Left.Right-z1/16, info.Left.Bottom-1/32.0); GL.Vertex3(x+1.0, y+0.5, z+z1);
                    }
                }
            }
            if (!left.Opaque && left.DrawMode != DrawMode.Stairs) {
                AdjacentLight(chunk, x - 1, y, z);
                GL.Normal3(1.0, 0.0, 0.0);
                if (data == 1) {
                    GL.TexCoord2(info.Right.Right, info.Right.Top);    GL.Vertex3(x, y+1.0, z+1.0);
                    GL.TexCoord2(info.Right.Left,  info.Right.Top);    GL.Vertex3(x, y+1.0, z);
                    GL.TexCoord2(info.Right.Left,  info.Right.Bottom); GL.Vertex3(x, y,     z);
                    GL.TexCoord2(info.Right.Right, info.Right.Bottom); GL.Vertex3(x, y,     z+1.0);
                } else {
                    GL.TexCoord2(info.Right.Right, info.Right.Top+1/32.0); GL.Vertex3(x, y+0.5, z+1.0);
                    GL.TexCoord2(info.Right.Left,  info.Right.Top+1/32.0); GL.Vertex3(x, y+0.5, z);
                    GL.TexCoord2(info.Right.Left,  info.Right.Bottom);     GL.Vertex3(x, y,     z);
                    GL.TexCoord2(info.Right.Right, info.Right.Bottom);     GL.Vertex3(x, y,     z+1.0);
                    if (data != 0) {
                        GL.TexCoord2(info.Left.Right-z2/16, info.Left.Top);           GL.Vertex3(x, y+1.0, z+1.0-z2);
                        GL.TexCoord2(info.Left.Left+z1/16,  info.Left.Top);           GL.Vertex3(x, y+1.0, z+z1);
                        GL.TexCoord2(info.Left.Left+z1/16,  info.Left.Bottom-1/32.0); GL.Vertex3(x, y+0.5, z+z1);
                        GL.TexCoord2(info.Left.Right-z2/16, info.Left.Bottom-1/32.0); GL.Vertex3(x, y+0.5, z+1.0-z2);
                    }
                }
            }
            GL.Normal3(0.0, 1.0, 0.0);
            if (!top.Opaque) {
                AdjacentLight(chunk, x, y + 1, z);
                GL.TexCoord2(info.Top.Right-x1/16, info.Top.Top+z1/16);    GL.Vertex3(x+1.0-x2, y+1.0, z+z1);
                GL.TexCoord2(info.Top.Left+x2/16,  info.Top.Top+z1/16);    GL.Vertex3(x+x1,     y+1.0, z+z1);
                GL.TexCoord2(info.Top.Left+x2/16,  info.Top.Bottom-z2/16); GL.Vertex3(x+x1,     y+1.0, z+1.0-z2);
                GL.TexCoord2(info.Top.Right-x1/16, info.Top.Bottom-z2/16); GL.Vertex3(x+1.0-x2, y+1.0, z+1.0-z2);
            }
            Light(chunk, x, y, z);
            GL.TexCoord2(info.Top.Right-x2/16, info.Top.Top+z2/16);    GL.Vertex3(x+1.0-x1, y+0.5, z+z2);
            GL.TexCoord2(info.Top.Left+x1/16,  info.Top.Top+z2/16);    GL.Vertex3(x+x2,     y+0.5, z+z2);
            GL.TexCoord2(info.Top.Left+x1/16,  info.Top.Bottom-z1/16); GL.Vertex3(x+x2,     y+0.5, z+1.0-z1);
            GL.TexCoord2(info.Top.Right-x2/16, info.Top.Bottom-z1/16); GL.Vertex3(x+1.0-x1, y+0.5, z+1.0-z1);
            switch (data) {
                case 0:
                    GL.Normal3(1.0, 0.0, 0.0);
                    GL.TexCoord2(info.Right.Right, info.Right.Top);           GL.Vertex3(x+0.5, y+1.0, z+1.0);
                    GL.TexCoord2(info.Right.Left,  info.Right.Top);           GL.Vertex3(x+0.5, y+1.0, z);
                    GL.TexCoord2(info.Right.Left,  info.Right.Bottom-1/32.0); GL.Vertex3(x+0.5, y+0.5, z);
                    GL.TexCoord2(info.Right.Right, info.Right.Bottom-1/32.0); GL.Vertex3(x+0.5, y+0.5, z+1.0);
                    break;
                case 1:
                    GL.Normal3(1.0, 0.0, 0.0);
                    GL.TexCoord2(info.Left.Right, info.Left.Top);           GL.Vertex3(x+0.5, y+1.0, z);
                    GL.TexCoord2(info.Left.Left,  info.Left.Top);           GL.Vertex3(x+0.5, y+1.0, z+1.0);
                    GL.TexCoord2(info.Left.Left,  info.Left.Bottom-1/32.0); GL.Vertex3(x+0.5, y+0.5, z+1.0);
                    GL.TexCoord2(info.Left.Right, info.Left.Bottom-1/32.0); GL.Vertex3(x+0.5, y+0.5, z);
                    break;
                case 2:
                    GL.Normal3(0.0, 0.0, 1.0);
                    GL.TexCoord2(info.Back.Right, info.Back.Top);           GL.Vertex3(x,     y+1.0, z+0.5);
                    GL.TexCoord2(info.Back.Left,  info.Back.Top);           GL.Vertex3(x+1.0, y+1.0, z+0.5);
                    GL.TexCoord2(info.Back.Left,  info.Back.Bottom-1/32.0); GL.Vertex3(x+1.0, y+0.5, z+0.5);
                    GL.TexCoord2(info.Back.Right, info.Back.Bottom-1/32.0); GL.Vertex3(x,     y+0.5, z+0.5);
                    break;
                case 3:
                    GL.Normal3(0.0, 0.0, 1.0);
                    GL.TexCoord2(info.Front.Right, info.Front.Top);           GL.Vertex3(x+1.0, y+1.0, z+0.5);
                    GL.TexCoord2(info.Front.Left,  info.Front.Top);           GL.Vertex3(x,     y+1.0, z+0.5);
                    GL.TexCoord2(info.Front.Left,  info.Front.Bottom-1/32.0); GL.Vertex3(x,     y+0.5, z+0.5);
                    GL.TexCoord2(info.Front.Right, info.Front.Bottom-1/32.0); GL.Vertex3(x+1.0, y+0.5, z+0.5);
                    break;
            }
            if (!bottom.Opaque) {
                AdjacentLight(chunk, x, y - 1, z);
                GL.Normal3(0.0, -1.0, 0.0);
                GL.TexCoord2(info.Bottom.Left,  info.Bottom.Top);    GL.Vertex3(x,     y, z);
                GL.TexCoord2(info.Bottom.Right, info.Bottom.Top);    GL.Vertex3(x+1.0, y, z);
                GL.TexCoord2(info.Bottom.Right, info.Bottom.Bottom); GL.Vertex3(x+1.0, y, z+1.0);
                GL.TexCoord2(info.Bottom.Left,  info.Bottom.Bottom); GL.Vertex3(x,     y, z+1.0);
            }
            if (!front.Opaque && front.DrawMode != DrawMode.Stairs) {
                AdjacentLight(chunk, x, y, z + 1);
                GL.Normal3(0.0, 0.0, 1.0);
                if (data == 2) {
                    GL.TexCoord2(info.Front.Right, info.Front.Top);    GL.Vertex3(x+1.0, y+1.0, z+1.0);
                    GL.TexCoord2(info.Front.Left,  info.Front.Top);    GL.Vertex3(x,     y+1.0, z+1.0);
                    GL.TexCoord2(info.Front.Left,  info.Front.Bottom); GL.Vertex3(x,     y,     z+1.0);
                    GL.TexCoord2(info.Front.Right, info.Front.Bottom); GL.Vertex3(x+1.0, y,     z+1.0);
                } else {
                    GL.TexCoord2(info.Front.Right, info.Front.Top+1/32.0); GL.Vertex3(x+1.0, y+0.5, z+1.0);
                    GL.TexCoord2(info.Front.Left,  info.Front.Top+1/32.0); GL.Vertex3(x,     y+0.5, z+1.0);
                    GL.TexCoord2(info.Front.Left,  info.Front.Bottom);     GL.Vertex3(x,     y,     z+1.0);
                    GL.TexCoord2(info.Front.Right, info.Front.Bottom);     GL.Vertex3(x+1.0, y,     z+1.0);
                    if (data != 3) {
                        GL.TexCoord2(info.Front.Right-x2/16, info.Front.Top);           GL.Vertex3(x+1.0-x2, y+1.0, z+1.0);
                        GL.TexCoord2(info.Front.Left+x1/16,  info.Front.Top);           GL.Vertex3(x+x1,     y+1.0, z+1.0);
                        GL.TexCoord2(info.Front.Left+x1/16,  info.Front.Bottom-1/32.0); GL.Vertex3(x+x1,     y+0.5, z+1.0);
                        GL.TexCoord2(info.Front.Right-x2/16, info.Front.Bottom-1/32.0); GL.Vertex3(x+1.0-x2, y+0.5, z+1.0);
                    }
                }
            }
            if (!back.Opaque && back.DrawMode != DrawMode.Stairs) {
                AdjacentLight(chunk, x, y, z - 1);
                GL.Normal3(0.0, 0.0, 1.0);
                if (data == 3) {
                    GL.TexCoord2(info.Back.Right, info.Back.Top);    GL.Vertex3(x,     y+1.0, z);
                    GL.TexCoord2(info.Back.Left,  info.Back.Top);    GL.Vertex3(x+1.0, y+1.0, z);
                    GL.TexCoord2(info.Back.Left,  info.Back.Bottom); GL.Vertex3(x+1.0, y,     z);
                    GL.TexCoord2(info.Back.Right, info.Back.Bottom); GL.Vertex3(x,     y,     z);
                } else {
                    GL.TexCoord2(info.Back.Right, info.Back.Top+1/32.0); GL.Vertex3(x,     y+0.5, z);
                    GL.TexCoord2(info.Back.Left,  info.Back.Top+1/32.0); GL.Vertex3(x+1.0, y+0.5, z);
                    GL.TexCoord2(info.Back.Left,  info.Back.Bottom);     GL.Vertex3(x+1.0, y,     z);
                    GL.TexCoord2(info.Back.Right, info.Back.Bottom);     GL.Vertex3(x,     y,     z);
                    if (data != 2) {
                        GL.TexCoord2(info.Back.Right-x1/16, info.Back.Top);           GL.Vertex3(x+x1,     y+1.0, z);
                        GL.TexCoord2(info.Back.Left+x2/16,  info.Back.Top);           GL.Vertex3(x+1.0-x2, y+1.0, z);
                        GL.TexCoord2(info.Back.Left+x2/16,  info.Back.Bottom-1/32.0); GL.Vertex3(x+1.0-x2, y+0.5, z);
                        GL.TexCoord2(info.Back.Right-x1/16, info.Back.Bottom-1/32.0); GL.Vertex3(x+x1,     y+0.5, z);
                    }
                }
            }
        }
Esempio n. 3
0
 static void RenderFurnace(Chunk chunk, BlocktypeInfo info, int x, int y, int z)
 {
     BlocktypeInfo right, left, top, bottom, front, back;
     GetAdjacentBlocks(chunk, x, y, z, out right, out left,
                       out top, out bottom, out front, out back);
     RectangleF rect_right = info.Right;
     RectangleF rect_left  = info.Right;
     RectangleF rect_front = info.Right;
     RectangleF rect_back  = info.Right;
     byte data = chunk.GetData(x, y, z);
     switch (data) {
         case 2:
             rect_back = info.Front; break;
         case 3:
             rect_front = info.Front; break;
         case 4:
             rect_left = info.Front; break;
         case 5:
             rect_right = info.Front; break;
     }
     if (!right.Opaque) {
         AdjacentLight(chunk, x + 1, y, z);
         GL.Normal3(1.0, 0.0, 0.0);
         GL.TexCoord2(rect_right.Right, rect_right.Top);    GL.Vertex3(x+1.0, y+1.0, z);
         GL.TexCoord2(rect_right.Left,  rect_right.Top);    GL.Vertex3(x+1.0, y+1.0, z+1.0);
         GL.TexCoord2(rect_right.Left,  rect_right.Bottom); GL.Vertex3(x+1.0, y,     z+1.0);
         GL.TexCoord2(rect_right.Right, rect_right.Bottom); GL.Vertex3(x+1.0, y,     z);
     }
     if (!left.Opaque) {
         AdjacentLight(chunk, x - 1, y, z);
         GL.Normal3(1.0, 0.0, 0.0);
         GL.TexCoord2(rect_left.Right, rect_left.Top);    GL.Vertex3(x, y+1.0, z+1.0);
         GL.TexCoord2(rect_left.Left,  rect_left.Top);    GL.Vertex3(x, y+1.0, z);
         GL.TexCoord2(rect_left.Left,  rect_left.Bottom); GL.Vertex3(x, y,     z);
         GL.TexCoord2(rect_left.Right, rect_left.Bottom); GL.Vertex3(x, y,     z+1.0);
     }
     if (!top.Opaque) {
         AdjacentLight(chunk, x, y + 1, z);
         GL.Normal3(0.0, 1.0, 0.0);
         GL.TexCoord2(info.Top.Right, info.Top.Top);    GL.Vertex3(x+1.0, y+1.0, z);
         GL.TexCoord2(info.Top.Left,  info.Top.Top);    GL.Vertex3(x,     y+1.0, z);
         GL.TexCoord2(info.Top.Left,  info.Top.Bottom); GL.Vertex3(x,     y+1.0, z+1.0);
         GL.TexCoord2(info.Top.Right, info.Top.Bottom); GL.Vertex3(x+1.0, y+1.0, z+1.0);
     }
     if (!bottom.Opaque) {
         AdjacentLight(chunk, x, y - 1, z);
         GL.Normal3(0.0, -1.0, 0.0);
         GL.TexCoord2(info.Bottom.Left,  info.Bottom.Top);    GL.Vertex3(x,     y, z);
         GL.TexCoord2(info.Bottom.Right, info.Bottom.Top);    GL.Vertex3(x+1.0, y, z);
         GL.TexCoord2(info.Bottom.Right, info.Bottom.Bottom); GL.Vertex3(x+1.0, y, z+1.0);
         GL.TexCoord2(info.Bottom.Left,  info.Bottom.Bottom); GL.Vertex3(x,     y, z+1.0);
     }
     if (!front.Opaque) {
         AdjacentLight(chunk, x, y, z + 1);
         GL.Normal3(0.0, 0.0, 1.0);
         GL.TexCoord2(rect_front.Right, rect_front.Top);    GL.Vertex3(x+1.0, y+1.0, z+1.0);
         GL.TexCoord2(rect_front.Left,  rect_front.Top);    GL.Vertex3(x,     y+1.0, z+1.0);
         GL.TexCoord2(rect_front.Left,  rect_front.Bottom); GL.Vertex3(x,     y,     z+1.0);
         GL.TexCoord2(rect_front.Right, rect_front.Bottom); GL.Vertex3(x+1.0, y,     z+1.0);
     }
     if (!back.Opaque) {
         AdjacentLight(chunk, x, y, z - 1);
         GL.Normal3(0.0, 0.0, 1.0);
         GL.TexCoord2(rect_back.Right, rect_back.Top);    GL.Vertex3(x,     y+1.0, z);
         GL.TexCoord2(rect_back.Left,  rect_back.Top);    GL.Vertex3(x+1.0, y+1.0, z);
         GL.TexCoord2(rect_back.Left,  rect_back.Bottom); GL.Vertex3(x+1.0, y,     z);
         GL.TexCoord2(rect_back.Right, rect_back.Bottom); GL.Vertex3(x,     y,     z);
     }
 }
Esempio n. 4
0
 static void RenderSoil(Chunk chunk, BlocktypeInfo info, int x, int y, int z)
 {
     BlocktypeInfo right, left, top, bottom, front, back;
     GetAdjacentBlocks(chunk, x, y, z, out right, out left,
                       out top, out bottom, out front, out back);
     byte wet = Math.Min(chunk.GetData(x, y, z), (byte)1);
     if (!right.Opaque) {
         AdjacentLight(chunk, x + 1, y, z);
         GL.Normal3(1.0, 0.0, 0.0);
         GL.TexCoord2(info.Left.Right, info.Left.Top+1/256.0); GL.Vertex3(x+1.0, y+1.0-1/16.0, z);
         GL.TexCoord2(info.Left.Left,  info.Left.Top+1/256.0); GL.Vertex3(x+1.0, y+1.0-1/16.0, z+1.0);
         GL.TexCoord2(info.Left.Left,  info.Left.Bottom);      GL.Vertex3(x+1.0, y,            z+1.0);
         GL.TexCoord2(info.Left.Right, info.Left.Bottom);      GL.Vertex3(x+1.0, y,            z);
     }
     if (!left.Opaque) {
         AdjacentLight(chunk, x - 1, y, z);
         GL.Normal3(1.0, 0.0, 0.0);
         GL.TexCoord2(info.Right.Right, info.Right.Top+1/256.0); GL.Vertex3(x, y+1.0-1/16.0, z+1.0);
         GL.TexCoord2(info.Right.Left,  info.Right.Top+1/256.0); GL.Vertex3(x, y+1.0-1/16.0, z);
         GL.TexCoord2(info.Right.Left,  info.Right.Bottom);      GL.Vertex3(x, y,            z);
         GL.TexCoord2(info.Right.Right, info.Right.Bottom);      GL.Vertex3(x, y,            z+1.0);
     }
     Light(chunk, x, y, z);
     GL.Normal3(0.0, 1.0, 0.0);
     GL.TexCoord2(info.Top.Right-wet/16.0, info.Top.Top);    GL.Vertex3(x+1.0, y+1.0-1/16.0, z);
     GL.TexCoord2(info.Top.Left-wet/16.0,  info.Top.Top);    GL.Vertex3(x,     y+1.0-1/16.0, z);
     GL.TexCoord2(info.Top.Left-wet/16.0,  info.Top.Bottom); GL.Vertex3(x,     y+1.0-1/16.0, z+1.0);
     GL.TexCoord2(info.Top.Right-wet/16.0, info.Top.Bottom); GL.Vertex3(x+1.0, y+1.0-1/16.0, z+1.0);
     if (!bottom.Opaque) {
         AdjacentLight(chunk, x, y - 1, z);
         GL.Normal3(0.0, -1.0, 0.0);
         GL.TexCoord2(info.Bottom.Left,  info.Bottom.Top+1/256.0); GL.Vertex3(x,     y, z);
         GL.TexCoord2(info.Bottom.Right, info.Bottom.Top+1/256.0); GL.Vertex3(x+1.0, y, z);
         GL.TexCoord2(info.Bottom.Right, info.Bottom.Bottom);      GL.Vertex3(x+1.0, y, z+1.0);
         GL.TexCoord2(info.Bottom.Left,  info.Bottom.Bottom);      GL.Vertex3(x,     y, z+1.0);
     }
     if (!front.Opaque) {
         AdjacentLight(chunk, x, y, z + 1);
         GL.Normal3(0.0, 0.0, 1.0);
         GL.TexCoord2(info.Front.Right, info.Front.Top);    GL.Vertex3(x+1.0, y+1.0-1/16.0, z+1.0);
         GL.TexCoord2(info.Front.Left,  info.Front.Top);    GL.Vertex3(x,     y+1.0-1/16.0, z+1.0);
         GL.TexCoord2(info.Front.Left,  info.Front.Bottom); GL.Vertex3(x,     y,            z+1.0);
         GL.TexCoord2(info.Front.Right, info.Front.Bottom); GL.Vertex3(x+1.0, y,            z+1.0);
     }
     if (!back.Opaque) {
         AdjacentLight(chunk, x, y, z - 1);
         GL.Normal3(0.0, 0.0, 1.0);
         GL.TexCoord2(info.Back.Right, info.Back.Top+1/256.0); GL.Vertex3(x,     y+1.0-1/16.0, z);
         GL.TexCoord2(info.Back.Left,  info.Back.Top+1/256.0); GL.Vertex3(x+1.0, y+1.0-1/16.0, z);
         GL.TexCoord2(info.Back.Left,  info.Back.Bottom);      GL.Vertex3(x+1.0, y,            z);
         GL.TexCoord2(info.Back.Right, info.Back.Bottom);      GL.Vertex3(x,     y,            z);
     }
 }
Esempio n. 5
0
 static void RenderCrop(Chunk chunk, BlocktypeInfo info, int x, int y, int z)
 {
     Light(chunk, x, y, z);
     GL.Normal3(0.0, 1.0, 0.0);
     byte data = chunk.GetData(x, y, z);
     GL.TexCoord2(info.Right.Right+data/16.0, info.Right.Top);    GL.Vertex3(x+0.25, y+1.0-1/16.0, z+1.0);
     GL.TexCoord2(info.Right.Left+data/16.0,  info.Right.Top);    GL.Vertex3(x+0.25, y+1.0-1/16.0, z);
     GL.TexCoord2(info.Right.Left+data/16.0,  info.Right.Bottom); GL.Vertex3(x+0.25, y-1/16.0,     z);
     GL.TexCoord2(info.Right.Right+data/16.0, info.Right.Bottom); GL.Vertex3(x+0.25, y-1/16.0,     z+1.0);
     GL.TexCoord2(info.Right.Left+data/16.0,  info.Right.Top);    GL.Vertex3(x+0.25, y+1.0-1/16.0, z);
     GL.TexCoord2(info.Right.Right+data/16.0, info.Right.Top);    GL.Vertex3(x+0.25, y+1.0-1/16.0, z+1.0);
     GL.TexCoord2(info.Right.Right+data/16.0, info.Right.Bottom); GL.Vertex3(x+0.25, y-1/16.0,     z+1.0);
     GL.TexCoord2(info.Right.Left+data/16.0,  info.Right.Bottom); GL.Vertex3(x+0.25, y-1/16.0,     z);
     GL.TexCoord2(info.Left.Right+data/16.0, info.Left.Top);    GL.Vertex3(x+0.75, y+1.0-1/16.0, z);
     GL.TexCoord2(info.Left.Left+data/16.0,  info.Left.Top);    GL.Vertex3(x+0.75, y+1.0-1/16.0, z+1.0);
     GL.TexCoord2(info.Left.Left+data/16.0,  info.Left.Bottom); GL.Vertex3(x+0.75, y-1/16.0,     z+1.0);
     GL.TexCoord2(info.Left.Right+data/16.0, info.Left.Bottom); GL.Vertex3(x+0.75, y-1/16.0,     z);
     GL.TexCoord2(info.Left.Left+data/16.0,  info.Left.Top);    GL.Vertex3(x+0.75, y+1.0-1/16.0, z+1.0);
     GL.TexCoord2(info.Left.Right+data/16.0, info.Left.Top);    GL.Vertex3(x+0.75, y+1.0-1/16.0, z);
     GL.TexCoord2(info.Left.Right+data/16.0, info.Left.Bottom); GL.Vertex3(x+0.75, y-1/16.0,     z);
     GL.TexCoord2(info.Left.Left+data/16.0,  info.Left.Bottom); GL.Vertex3(x+0.75, y-1/16.0,     z+1.0);
     GL.TexCoord2(info.Front.Right+data/16.0, info.Front.Top);    GL.Vertex3(x+1.0, y+1.0-1/16.0, z+0.75);
     GL.TexCoord2(info.Front.Left+data/16.0,  info.Front.Top);    GL.Vertex3(x,     y+1.0-1/16.0, z+0.75);
     GL.TexCoord2(info.Front.Left+data/16.0,  info.Front.Bottom); GL.Vertex3(x,     y-1/16.0,     z+0.75);
     GL.TexCoord2(info.Front.Right+data/16.0, info.Front.Bottom); GL.Vertex3(x+1.0, y-1/16.0,     z+0.75);
     GL.TexCoord2(info.Front.Left+data/16.0,  info.Front.Top);    GL.Vertex3(x,     y+1.0-1/16.0, z+0.75);
     GL.TexCoord2(info.Front.Right+data/16.0, info.Front.Top);    GL.Vertex3(x+1.0, y+1.0-1/16.0, z+0.75);
     GL.TexCoord2(info.Front.Right+data/16.0, info.Front.Bottom); GL.Vertex3(x+1.0, y-1/16.0,     z+0.75);
     GL.TexCoord2(info.Front.Left+data/16.0,  info.Front.Bottom); GL.Vertex3(x,     y-1/16.0,     z+0.75);
     GL.TexCoord2(info.Back.Right+data/16.0, info.Back.Top);    GL.Vertex3(x,     y+1.0-1/16.0, z+0.25);
     GL.TexCoord2(info.Back.Left+data/16.0,  info.Back.Top);    GL.Vertex3(x+1.0, y+1.0-1/16.0, z+0.25);
     GL.TexCoord2(info.Back.Left+data/16.0,  info.Back.Bottom); GL.Vertex3(x+1.0, y-1/16.0,     z+0.25);
     GL.TexCoord2(info.Back.Right+data/16.0, info.Back.Bottom); GL.Vertex3(x,     y-1/16.0,     z+0.25);
     GL.TexCoord2(info.Back.Left+data/16.0,  info.Back.Top);    GL.Vertex3(x+1.0, y+1.0-1/16.0, z+0.25);
     GL.TexCoord2(info.Back.Right+data/16.0, info.Back.Top);    GL.Vertex3(x,     y+1.0-1/16.0, z+0.25);
     GL.TexCoord2(info.Back.Right+data/16.0, info.Back.Bottom); GL.Vertex3(x,     y-1/16.0,     z+0.25);
     GL.TexCoord2(info.Back.Left+data/16.0,  info.Back.Bottom); GL.Vertex3(x+1.0, y-1/16.0,     z+0.25);
 }