public void Execute() { for (int i = 0; i < 16 * 22 * 16; i++) { treeBlocks[i] = Block.air; } for (int i = 0; i < trees.Length; i++) { uint hash = Hash((uint)(i + trees[i].x * 1007 + trees[i].y * 53 + trees[i].z)) % 1000; if ((hash > 10 && hash < 15) || (hash > 100 && hash < 105)) { GenerateTree(new Vector3(trees[i].x, trees[i].y, trees[i].z)); } } for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { for (int y = 0; y < 22; y++) { Block block = treeBlocks[BlockUtils.GetBlockIndex16x22x16(new int3(x, y, z))]; if (block.IsEmpty()) { continue; } // Loop all posible directions on cube and if // the next block in the direction is not empty, // save UVs to mesh data for (int i = 0; i < 6; i++) { if (Check(BlockUtils.GetPositionInDirection((Directions)i, x, y, z)) && ((Directions)i != Directions.Down || block != Block.tree)) { CreateFace((Directions)i, new int3(x, y, z)); meshData.uvs.Add(blockData.uvs[(int)block][0]); meshData.uvs.Add(blockData.uvs[(int)block][1]); meshData.uvs.Add(blockData.uvs[(int)block][2]); meshData.uvs.Add(blockData.uvs[(int)block][3]); } } } } } }
public void Execute() { for (int x = 1; x < 17; x++) { for (int z = 1; z < 17; z++) { for (int y = 1; y < 17; y++) { Block block = chunkData.blocks[BlockUtils.GetBlockIndex(new int3(x, y, z))]; if (block.IsEmpty()) { continue; } // Loop all posible directions on cube and if // the next block in the direction is not empty, // save UVs to mesh data for (int i = 0; i < 6; i++) { if (Check(BlockUtils.GetPositionInDirection((Directions)i, x, y, z))) { CreateFace((Directions)i, new int3(x - 1, y - 1, z - 1)); if (block == Block.dirt && i == (int)Directions.Up) { meshData.uvs.Add(blockData.uvs[(int)Block.grass][0]); meshData.uvs.Add(blockData.uvs[(int)Block.grass][1]); meshData.uvs.Add(blockData.uvs[(int)Block.grass][2]); meshData.uvs.Add(blockData.uvs[(int)Block.grass][3]); } else { meshData.uvs.Add(blockData.uvs[(int)block][0]); meshData.uvs.Add(blockData.uvs[(int)block][1]); meshData.uvs.Add(blockData.uvs[(int)block][2]); meshData.uvs.Add(blockData.uvs[(int)block][3]); } } } } } } }