public void GenerateTerrain(int x, int y, int z, int value, BlockTerrain.Chunk chunk, MeshGenerator g) { Vector3 v000 = new Vector3(x, y, z); Vector3 v001 = new Vector3(x, y, z + 1.0f); Vector3 v010 = new Vector3(x, y + 1.0f, z); Vector3 v011 = new Vector3(x, y + 1.0f, z + 1.0f); Vector3 v100 = new Vector3(x + 1.0f, y, z); Vector3 v101 = new Vector3(x + 1.0f, y, z + 1.0f); Vector3 v110 = new Vector3(x + 1.0f, y + 1.0f, z); Vector3 v111 = new Vector3(x + 1.0f, y + 1.0f, z + 1.0f); GreedyTerrainMesh terrainMesh = g.AlphaTest; int texSlot = TextureSlot; Color color = map.Lookup(chunk.GetShiftValue(x, z)); int content = chunk.GetCellContent(x - 1, y, z); if (content != BlockTerrain.NULL_BLOCK_CONTENT && content != Index && BlocksData.IsTransparent[content]) { terrainMesh.NormalQuad(v001, v011, v010, v000, texSlot, color); } content = chunk.GetCellContent(x, y - 1, z); if (content != BlockTerrain.NULL_BLOCK_CONTENT && content != Index && BlocksData.IsTransparent[content]) { terrainMesh.NormalQuad(v000, v100, v101, v001, texSlot, color); } content = chunk.GetCellContent(x, y, z - 1); if (content != BlockTerrain.NULL_BLOCK_CONTENT && content != Index && BlocksData.IsTransparent[content]) { terrainMesh.NormalQuad(v000, v010, v110, v100, texSlot, color); } content = chunk.GetCellContent(x + 1, y, z); if (content != BlockTerrain.NULL_BLOCK_CONTENT && content != Index && BlocksData.IsTransparent[content]) { terrainMesh.NormalQuad(v100, v110, v111, v101, texSlot, color); } content = chunk.GetCellContent(x, y + 1, z); if (content != BlockTerrain.NULL_BLOCK_CONTENT && content != Index && BlocksData.IsTransparent[content]) { terrainMesh.NormalQuad(v111, v110, v010, v011, texSlot, color); } content = chunk.GetCellContent(x, y, z + 1); if (content != BlockTerrain.NULL_BLOCK_CONTENT && content != Index && BlocksData.IsTransparent[content]) { terrainMesh.NormalQuad(v101, v111, v011, v001, texSlot, color); } }
public void GenerateTerrain(int x, int y, int z, int value, BlockTerrain.Chunk chunk, MeshGenerator g) { int data = BlockTerrain.GetData(value); int?i = GetColor(data); GreedyTerrainMesh terrainMesh = useAlphaTest ? g.AlphaTest : g.Terrain; if (i.HasValue) { terrainMesh.Mesh(x, y, z, paintedBlockMeshes[GetVariant(data)], BlocksData.DEFAULT_COLORS[i.Value]); } else { terrainMesh.Mesh(x, y, z, blockMeshes[GetVariant(data)], unpaintedColor); } }
public void GenerateFluidTerrain(int x, int y, int z, int value, BlockTerrain.Chunk chunk, GreedyTerrainMesh terrainMesh, Color topColor, Color sideColor) { float height1, height2, height3, height4; int data = BlockTerrain.GetData(value); if (GetIsTop(data)) { int cellValueFast = chunk.GetCellValue(x - 1, y, z - 1); int cellValueFast2 = chunk.GetCellValue(x, y, z - 1); int cellValueFast3 = chunk.GetCellValue(x + 1, y, z - 1); int cellValueFast4 = chunk.GetCellValue(x - 1, y, z); int cellValueFast5 = chunk.GetCellValue(x + 1, y, z); int cellValueFast6 = chunk.GetCellValue(x - 1, y, z + 1); int cellValueFast7 = chunk.GetCellValue(x, y, z + 1); int cellValueFast8 = chunk.GetCellValue(x + 1, y, z + 1); float h = CalculateNeighborHeight(cellValueFast); float num = CalculateNeighborHeight(cellValueFast2); float h2 = CalculateNeighborHeight(cellValueFast3); float num2 = CalculateNeighborHeight(cellValueFast4); float num3 = CalculateNeighborHeight(cellValueFast5); float h3 = CalculateNeighborHeight(cellValueFast6); float num4 = CalculateNeighborHeight(cellValueFast7); float h4 = CalculateNeighborHeight(cellValueFast8); float levelHeight = GetLevelHeight(GetLevel(data)); height1 = CalculateFluidVertexHeight(h, num, num2, levelHeight); height2 = CalculateFluidVertexHeight(num, h2, levelHeight, num3); height3 = CalculateFluidVertexHeight(levelHeight, num3, num4, h4); height4 = CalculateFluidVertexHeight(num2, levelHeight, h3, num4); } else { height1 = 1f; height2 = 1f; height3 = 1f; height4 = 1f; } Vector3 v000 = new Vector3(x, y, z); Vector3 v001 = new Vector3(x, y, z + 1f); Vector3 v010 = new Vector3(x, y + height1, z); Vector3 v011 = new Vector3(x, y + height4, z + 1f); Vector3 v100 = new Vector3(x + 1.0f, y, z); Vector3 v101 = new Vector3(x + 1.0f, y, z + 1f); Vector3 v110 = new Vector3(x + 1.0f, y + height2, z); Vector3 v111 = new Vector3(x + 1.0f, y + height3, z + 1f); int v = chunk.GetCellValue(x - 1, y, z); if (v != BlockTerrain.NULL_BLOCK_VALUE && BlockTerrain.GetContent(v) != Index) { terrainMesh.NormalQuad(v001, v011, v010, v000, TextureSlot, sideColor); } v = chunk.GetCellValue(x, y - 1, z); if (v != BlockTerrain.NULL_BLOCK_VALUE && BlockTerrain.GetContent(v) != Index) { terrainMesh.NormalQuad(v000, v100, v101, v001, TextureSlot, sideColor); } v = chunk.GetCellValue(x, y, z - 1); if (v != BlockTerrain.NULL_BLOCK_VALUE && BlockTerrain.GetContent(v) != Index) { terrainMesh.NormalQuad(v000, v010, v110, v100, TextureSlot, sideColor); } v = chunk.GetCellValue(x + 1, y, z); if (v != BlockTerrain.NULL_BLOCK_VALUE && BlockTerrain.GetContent(v) != Index) { terrainMesh.NormalQuad(v100, v110, v111, v101, TextureSlot, sideColor); } v = chunk.GetCellValue(x, y + 1, z); if (v != BlockTerrain.NULL_BLOCK_VALUE && BlockTerrain.GetContent(v) != Index) { terrainMesh.NormalQuad(v111, v110, v010, v011, TextureSlot, topColor); } v = chunk.GetCellValue(x, y, z + 1); if (v != BlockTerrain.NULL_BLOCK_VALUE && BlockTerrain.GetContent(v) != Index) { terrainMesh.NormalQuad(v101, v111, v011, v001, TextureSlot, sideColor); } }