public void BuildPlantVertices(Vector3i blockPosition, Vector3i chunkRelativePosition, BlockType blockType, float sunLight, Color localLight) { BlockTexture texture = BlockInformation.GetTexture(blockType); Vector2[] UVList; UVList = TextureHelper.UVMappings[(int)texture * 6 + (int)BlockFaceDirection.XIncreasing]; AddVertex(blockPosition, chunkRelativePosition, new Vector3(0.5f, 1, 1), new Vector3(1, 0, 0), UVList[0], sunLight, localLight); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0.5f, 1, 0), new Vector3(1, 0, 0), UVList[1], sunLight, localLight); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0.5f, 0, 1), new Vector3(1, 0, 0), UVList[2], sunLight, localLight); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0.5f, 0, 0), new Vector3(1, 0, 0), UVList[5], sunLight, localLight); AddIndex(0, 1, 2, 2, 1, 3); UVList = TextureHelper.UVMappings[(int)texture * 6 + (int)BlockFaceDirection.XDecreasing]; AddVertex(blockPosition, chunkRelativePosition, new Vector3(0.5f, 1, 0), new Vector3(-1, 0, 0), UVList[0], sunLight, localLight); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0.5f, 1, 1), new Vector3(-1, 0, 0), UVList[1], sunLight, localLight); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0.5f, 0, 0), new Vector3(-1, 0, 0), UVList[5], sunLight, localLight); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0.5f, 0, 1), new Vector3(-1, 0, 0), UVList[2], sunLight, localLight); AddIndex(0, 1, 3, 0, 3, 2); UVList = TextureHelper.UVMappings[(int)texture * 6 + (int)BlockFaceDirection.ZIncreasing]; AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 1, 0.5f), new Vector3(0, 0, 1), UVList[0], sunLight, localLight); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 1, 0.5f), new Vector3(0, 0, 1), UVList[1], sunLight, localLight); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 0, 0.5f), new Vector3(0, 0, 1), UVList[5], sunLight, localLight); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 0, 0.5f), new Vector3(0, 0, 1), UVList[2], sunLight, localLight); AddIndex(0, 1, 3, 0, 3, 2); UVList = TextureHelper.UVMappings[(int)texture * 6 + (int)BlockFaceDirection.ZDecreasing]; AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 1, 0.5f), new Vector3(0, 0, -1), UVList[0], sunLight, localLight); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 1, 0.5f), new Vector3(0, 0, -1), UVList[1], sunLight, localLight); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 0, 0.5f), new Vector3(0, 0, -1), UVList[2], sunLight, localLight); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 0, 0.5f), new Vector3(0, 0, -1), UVList[5], sunLight, localLight); AddIndex(0, 1, 2, 2, 1, 3); }
public void BuildFaceVertices(Vector3i blockPosition, Vector3i chunkRelativePosition, BlockFaceDirection faceDir, BlockType blockType, float aoTL, float aoTR, float aoBL, float aoBR) { BlockTexture texture = BlockInformation.GetTexture(blockType, faceDir); 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; } int crackStage = 0; Vector2[] UVList = TextureHelper.UVMappings[(int)texture * 6 + faceIndex]; Vector2[] CrackUVList = TextureHelper.CrackMappings[crackStage * 6 + faceIndex]; float light = 2;//TODO light hardcoded to 2 Vector2 aoTilePosition = new Vector2(0, 0); switch (faceDir) { case BlockFaceDirection.XIncreasing: { AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 1, 1), new Vector3(1, 0, 0), light, UVList[0], CrackUVList[0], aoTR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 1, 0), new Vector3(1, 0, 0), light, UVList[1], CrackUVList[1], aoTL); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 0, 1), new Vector3(1, 0, 0), light, UVList[2], CrackUVList[2], aoBR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 0, 1), new Vector3(1, 0, 0), light, UVList[3], CrackUVList[3], aoBR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 1, 0), new Vector3(1, 0, 0), light, UVList[4], CrackUVList[4], aoTL); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 0, 0), new Vector3(1, 0, 0), light, UVList[5], CrackUVList[5], aoBL); } break; case BlockFaceDirection.XDecreasing: { AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 1, 0), new Vector3(-1, 0, 0), light, UVList[0], CrackUVList[0], aoTR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 1, 1), new Vector3(-1, 0, 0), light, UVList[1], CrackUVList[1], aoTL); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 0, 1), new Vector3(-1, 0, 0), light, UVList[2], CrackUVList[2], aoBL); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 1, 0), new Vector3(-1, 0, 0), light, UVList[3], CrackUVList[3], aoTR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 0, 1), new Vector3(-1, 0, 0), light, UVList[4], CrackUVList[4], aoBL); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 0, 0), new Vector3(-1, 0, 0), light, UVList[5], CrackUVList[5], aoBR); } break; case BlockFaceDirection.YIncreasing: { AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 1, 0), new Vector3(0, 1, 0), light, UVList[0], CrackUVList[0], aoBL); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 1, 0), new Vector3(0, 1, 0), light, UVList[1], CrackUVList[1], aoBR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 1, 1), new Vector3(0, 1, 0), light, UVList[2], CrackUVList[2], aoTR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 1, 0), new Vector3(0, 1, 0), light, UVList[3], CrackUVList[3], aoBL); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 1, 1), new Vector3(0, 1, 0), light, UVList[4], CrackUVList[4], aoTR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 1, 1), new Vector3(0, 1, 0), light, UVList[5], CrackUVList[5], aoTL); } break; case BlockFaceDirection.YDecreasing: { AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 0, 1), new Vector3(0, -1, 0), light, UVList[0], CrackUVList[0], aoTR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 0, 0), new Vector3(0, -1, 0), light, UVList[1], CrackUVList[1], aoBR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 0, 1), new Vector3(0, -1, 0), light, UVList[2], CrackUVList[2], aoBL); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 0, 1), new Vector3(0, -1, 0), light, UVList[3], CrackUVList[3], aoBL); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 0, 0), new Vector3(0, -1, 0), light, UVList[4], CrackUVList[4], aoBR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 0, 0), new Vector3(0, -1, 0), light, UVList[5], CrackUVList[5], aoTR); } break; case BlockFaceDirection.ZIncreasing: { AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 1, 1), new Vector3(0, 0, 1), light, UVList[0], CrackUVList[0], aoTR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 1, 1), new Vector3(0, 0, 1), light, UVList[1], CrackUVList[1], aoTL); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 0, 1), new Vector3(0, 0, 1), light, UVList[2], CrackUVList[2], aoBL); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 1, 1), new Vector3(0, 0, 1), light, UVList[3], CrackUVList[3], aoTR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 0, 1), new Vector3(0, 0, 1), light, UVList[4], CrackUVList[4], aoBL); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 0, 1), new Vector3(0, 0, 1), light, UVList[5], CrackUVList[5], aoBR); } break; case BlockFaceDirection.ZDecreasing: { AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 1, 0), new Vector3(0, 0, -1), light, UVList[0], CrackUVList[0], aoTR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 1, 0), new Vector3(0, 0, -1), light, UVList[1], CrackUVList[1], aoTL); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 0, 0), new Vector3(0, 0, -1), light, UVList[2], CrackUVList[2], aoBR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 0, 0), new Vector3(0, 0, -1), light, UVList[3], CrackUVList[3], aoBR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 1, 0), new Vector3(0, 0, -1), light, UVList[4], CrackUVList[4], aoTL); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 0, 0), new Vector3(0, 0, -1), light, UVList[5], CrackUVList[5], aoBL); } break; } }
/// <summary> /// BuildBlockVertices making a block /// TODO surrounding block faces for digging ? /// <param name="block">block to build</param> /// <param name="blockPosition"> in viewableWorld coordinates already offset with current chunk position </param> /// </summary> public void BuildBlockVertices(ref List <VertexPositionTextureShade> vertexList, Block block, Chunk chunk, Vector3i chunkRelativePosition) { //optimized by using chunk.Blocks[][][] except for "out of current chunk" blocks Vector3i blockPosition = chunk.Position + chunkRelativePosition; Block blockXDecreasing, blockXIncreasing, blockYDecreasing, blockYIncreasing, blockZDecreasing, blockZIncreasing; if (chunkRelativePosition.X == 0 || chunkRelativePosition.Y == 0 || chunkRelativePosition.Z == 0 || chunkRelativePosition.X == Chunk.MAX.X || chunkRelativePosition.Y == Chunk.MAX.Y || chunkRelativePosition.Z == Chunk.MAX.Z) { blockXDecreasing = world.BlockAt(blockPosition.X - 1, blockPosition.Y, blockPosition.Z); blockYDecreasing = world.BlockAt(blockPosition.X, blockPosition.Y - 1, blockPosition.Z); blockZDecreasing = world.BlockAt(blockPosition.X, blockPosition.Y, blockPosition.Z - 1); blockXIncreasing = world.BlockAt(blockPosition.X + 1, blockPosition.Y, blockPosition.Z); blockYIncreasing = world.BlockAt(blockPosition.X, blockPosition.Y + 1, blockPosition.Z); blockZIncreasing = world.BlockAt(blockPosition.X, blockPosition.Y, blockPosition.Z + 1); } else { //blockXDecreasing = chunk.Blocks[chunkRelativePosition.X - 1, chunkRelativePosition.Y, chunkRelativePosition.Z]; blockXDecreasing = chunk.Blocks[(chunkRelativePosition.X - 1) * Chunk.FlattenOffset + chunkRelativePosition.Z * Chunk.SIZE.Y + chunkRelativePosition.Y]; //blockXIncreasing = chunk.Blocks[chunkRelativePosition.X + 1, chunkRelativePosition.Y, chunkRelativePosition.Z]; blockXIncreasing = chunk.Blocks[(chunkRelativePosition.X + 1) * Chunk.FlattenOffset + chunkRelativePosition.Z * Chunk.SIZE.Y + chunkRelativePosition.Y]; //blockYDecreasing = chunk.Blocks[chunkRelativePosition.X, chunkRelativePosition.Y - 1, chunkRelativePosition.Z]; blockYDecreasing = chunk.Blocks[chunkRelativePosition.X * Chunk.FlattenOffset + chunkRelativePosition.Z * Chunk.SIZE.Y + (chunkRelativePosition.Y - 1)]; //blockYIncreasing = chunk.Blocks[chunkRelativePosition.X, chunkRelativePosition.Y + 1, chunkRelativePosition.Z]; blockYIncreasing = chunk.Blocks[chunkRelativePosition.X * Chunk.FlattenOffset + chunkRelativePosition.Z * Chunk.SIZE.Y + (chunkRelativePosition.Y + 1)]; //blockZDecreasing = chunk.Blocks[chunkRelativePosition.X, chunkRelativePosition.Y, chunkRelativePosition.Z - 1]; blockZDecreasing = chunk.Blocks[chunkRelativePosition.X * Chunk.FlattenOffset + (chunkRelativePosition.Z - 1) * Chunk.SIZE.Y + chunkRelativePosition.Y]; //blockZIncreasing = chunk.Blocks[chunkRelativePosition.X, chunkRelativePosition.Y, chunkRelativePosition.Z + 1]; blockZIncreasing = chunk.Blocks[chunkRelativePosition.X * Chunk.FlattenOffset + (chunkRelativePosition.Z + 1) * Chunk.SIZE.Y + chunkRelativePosition.Y]; } if (!BlockInformation.IsSolidBlock(blockXDecreasing.Type)) { BuildFaceVertices(ref vertexList, blockPosition, BlockFaceDirection.XDecreasing, block.Type); } if (!BlockInformation.IsSolidBlock(blockXIncreasing.Type)) { BuildFaceVertices(ref vertexList, blockPosition, BlockFaceDirection.XIncreasing, block.Type); } if (!BlockInformation.IsSolidBlock(blockYDecreasing.Type)) { BuildFaceVertices(ref vertexList, blockPosition, BlockFaceDirection.YDecreasing, block.Type); } if (!BlockInformation.IsSolidBlock(blockYIncreasing.Type)) { BuildFaceVertices(ref vertexList, blockPosition, BlockFaceDirection.YIncreasing, block.Type); } if (!BlockInformation.IsSolidBlock(blockZDecreasing.Type)) { BuildFaceVertices(ref vertexList, blockPosition, BlockFaceDirection.ZDecreasing, block.Type); } if (!BlockInformation.IsSolidBlock(blockZIncreasing.Type)) { BuildFaceVertices(ref vertexList, blockPosition, BlockFaceDirection.ZIncreasing, block.Type); } }
public void BuildFaceVertices(ref List <VertexPositionTextureShade> vertexList, Vector3i blockPosition, BlockFaceDirection faceDir, BlockType blockType) { BlockTexture texture = BlockInformation.GetTexture(blockType, faceDir); //Debug.WriteLine(string.Format("BuildBlockVertices ({0},{1},{2}) : {3} ->{4} :", x, y, z, faceDir, 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 = TextureHelper.UVMappings[(int)texture * 6 + faceIndex]; float light = 2;//TODO light hardcoded to 2 switch (faceDir) { case BlockFaceDirection.XIncreasing: { vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.One, Vector3.UnitX, light, UVList[0])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, vector110, Vector3.UnitX, light, UVList[1])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, vector101, Vector3.UnitX, light, UVList[2])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, vector101, Vector3.UnitX, light, UVList[3])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, vector110, Vector3.UnitX, light, UVList[4])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.UnitX, Vector3.UnitX, light, UVList[5])); } break; case BlockFaceDirection.XDecreasing: { vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.UnitY, Vector3.Left, light, UVList[0])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, vector011, Vector3.Left, light, UVList[1])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.UnitZ, Vector3.Left, light, UVList[2])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.UnitY, Vector3.Left, light, UVList[3])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.UnitZ, Vector3.Left, light, UVList[4])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.Zero, Vector3.Left, light, UVList[5])); } break; case BlockFaceDirection.YIncreasing: { vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.UnitY, Vector3.UnitY, light, UVList[0])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, vector110, Vector3.UnitY, light, UVList[1])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.One, Vector3.UnitY, light, UVList[2])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.UnitY, Vector3.UnitY, light, UVList[3])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.One, Vector3.UnitY, light, UVList[4])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, vector011, Vector3.UnitY, light, UVList[5])); } break; case BlockFaceDirection.YDecreasing: { vertexList.Add(ToVertexPositionTextureShade(blockPosition, vector101, Vector3.Down, light, UVList[0])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.UnitX, Vector3.Down, light, UVList[1])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.UnitZ, Vector3.Down, light, UVList[2])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.UnitZ, Vector3.Down, light, UVList[3])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.UnitX, Vector3.Down, light, UVList[4])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.Zero, Vector3.Down, light, UVList[5])); } break; case BlockFaceDirection.ZIncreasing: { vertexList.Add(ToVertexPositionTextureShade(blockPosition, vector011, Vector3.UnitZ, light, UVList[0])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.One, Vector3.UnitZ, light, UVList[1])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, vector101, Vector3.UnitZ, light, UVList[2])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, vector011, Vector3.UnitZ, light, UVList[3])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, vector101, Vector3.UnitZ, light, UVList[4])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.UnitZ, Vector3.UnitZ, light, UVList[5])); } break; case BlockFaceDirection.ZDecreasing: { vertexList.Add(ToVertexPositionTextureShade(blockPosition, vector110, Vector3.Forward, light, UVList[0])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.UnitY, Vector3.Forward, light, UVList[1])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.UnitX, Vector3.Forward, light, UVList[2])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.UnitX, Vector3.Forward, light, UVList[3])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.UnitY, Vector3.Forward, light, UVList[4])); vertexList.Add(ToVertexPositionTextureShade(blockPosition, Vector3.Zero, Vector3.Forward, light, UVList[5])); } break; } }
public void BuildFaceVertices(Vector3i blockPosition, Vector3i chunkRelativePosition, BlockFaceDirection faceDir, BlockType blockType, float sunLightTL, float sunLightTR, float sunLightBL, float sunLightBR, Color localLightTL, Color localLightTR, Color localLightBL, Color localLightBR) { BlockTexture texture = BlockInformation.GetTexture(blockType, faceDir); int faceIndex = (int)faceDir; Vector2[] UVList = TextureHelper.UVMappings[(int)texture * 6 + faceIndex]; switch (faceDir) { case BlockFaceDirection.XIncreasing: { //TR,TL,BR,BR,TL,BL AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 1, 1), new Vector3(1, 0, 0), UVList[0], sunLightTR, localLightTR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 1, 0), new Vector3(1, 0, 0), UVList[1], sunLightTL, localLightTL); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 0, 1), new Vector3(1, 0, 0), UVList[2], sunLightBR, localLightBR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 0, 0), new Vector3(1, 0, 0), UVList[5], sunLightBL, localLightBL); AddIndex(0, 1, 2, 2, 1, 3); } break; case BlockFaceDirection.XDecreasing: { //TR,TL,BL,TR,BL,BR AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 1, 0), new Vector3(-1, 0, 0), UVList[0], sunLightTR, localLightTR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 1, 1), new Vector3(-1, 0, 0), UVList[1], sunLightTL, localLightTL); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 0, 0), new Vector3(-1, 0, 0), UVList[5], sunLightBR, localLightBR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 0, 1), new Vector3(-1, 0, 0), UVList[2], sunLightBL, localLightBL); AddIndex(0, 1, 3, 0, 3, 2); } break; case BlockFaceDirection.YIncreasing: { //BL,BR,TR,BL,TR,TL AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 1, 1), new Vector3(0, 1, 0), UVList[4], sunLightTR, localLightTR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 1, 1), new Vector3(0, 1, 0), UVList[5], sunLightTL, localLightTL); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 1, 0), new Vector3(0, 1, 0), UVList[1], sunLightBR, localLightBR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 1, 0), new Vector3(0, 1, 0), UVList[3], sunLightBL, localLightBL); AddIndex(3, 2, 0, 3, 0, 1); } break; case BlockFaceDirection.YDecreasing: { //TR,BR,TL,TL,BR,BL AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 0, 1), new Vector3(0, -1, 0), UVList[0], sunLightTR, localLightTR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 0, 1), new Vector3(0, -1, 0), UVList[2], sunLightTL, localLightTL); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 0, 0), new Vector3(0, -1, 0), UVList[4], sunLightBR, localLightBR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 0, 0), new Vector3(0, -1, 0), UVList[5], sunLightBL, localLightBL); AddIndex(0, 2, 1, 1, 2, 3); } break; case BlockFaceDirection.ZIncreasing: { //TR,TL,BL,TR,BL,BR AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 1, 1), new Vector3(0, 0, 1), UVList[0], sunLightTR, localLightTR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 1, 1), new Vector3(0, 0, 1), UVList[1], sunLightTL, localLightTL); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 0, 1), new Vector3(0, 0, 1), UVList[5], sunLightBR, localLightBR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 0, 1), new Vector3(0, 0, 1), UVList[2], sunLightBL, localLightBL); AddIndex(0, 1, 3, 0, 3, 2); } break; case BlockFaceDirection.ZDecreasing: { //TR,TL,BR,BR,TL,BL AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 1, 0), new Vector3(0, 0, -1), UVList[0], sunLightTR, localLightTR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 1, 0), new Vector3(0, 0, -1), UVList[1], sunLightTL, localLightTL); AddVertex(blockPosition, chunkRelativePosition, new Vector3(1, 0, 0), new Vector3(0, 0, -1), UVList[2], sunLightBR, localLightBR); AddVertex(blockPosition, chunkRelativePosition, new Vector3(0, 0, 0), new Vector3(0, 0, -1), UVList[5], sunLightBL, localLightBL); AddIndex(0, 1, 2, 2, 1, 3); } break; } }