public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int pos, NBTGameObject nbtGO) { ca.pos = pos; ca.blockData = blockData; if (!chunk.HasOpaqueBlock(pos.x, pos.y, pos.z - 1)) { FaceAttributes fa = GetFrontFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x + 1, pos.y, pos.z)) { FaceAttributes fa = GetRightFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x - 1, pos.y, pos.z)) { FaceAttributes fa = GetLeftFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x, pos.y, pos.z + 1)) { FaceAttributes fa = GetBackFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } AddFace(nbtGO.nbtMesh, GetTopFaceAttributes(chunk, nbtGO.nbtMesh, ca), ca); if (!chunk.HasOpaqueBlock(pos.x, pos.y - 1, pos.z)) { FaceAttributes fa = GetBottomFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } }
public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int pos, NBTGameObject nbtGO) { ca.pos = pos; ca.blockData = blockData; InitBlockAttributes(chunk, ref ca); bool topIsSnow = chunk.GetBlockByte(pos.x, pos.y + 1, pos.z) == 78; if (!chunk.HasOpaqueBlock(pos.x, pos.y, pos.z - 1)) { FaceAttributes fa = GetFrontFaceAttributes(chunk, nbtGO.nbtMesh, ca); if (topIsSnow) { fa.faceIndex = TextureArrayManager.GetIndexByName("grass_side_snowed"); } AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x + 1, pos.y, pos.z)) { FaceAttributes fa = GetRightFaceAttributes(chunk, nbtGO.nbtMesh, ca); if (topIsSnow) { fa.faceIndex = TextureArrayManager.GetIndexByName("grass_side_snowed"); } AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x - 1, pos.y, pos.z)) { FaceAttributes fa = GetLeftFaceAttributes(chunk, nbtGO.nbtMesh, ca); if (topIsSnow) { fa.faceIndex = TextureArrayManager.GetIndexByName("grass_side_snowed"); } AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x, pos.y, pos.z + 1)) { FaceAttributes fa = GetBackFaceAttributes(chunk, nbtGO.nbtMesh, ca); if (topIsSnow) { fa.faceIndex = TextureArrayManager.GetIndexByName("grass_side_snowed"); } AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x, pos.y + 1, pos.z)) { FaceAttributes fa = GetTopFaceAttributes(chunk, nbtGO.nbtMesh, ca); if (topIsSnow) { fa.faceIndex = TextureArrayManager.GetIndexByName("snow"); } AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x, pos.y - 1, pos.z)) { FaceAttributes fa = GetBottomFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } }
BlockLightAttributes InitBlockLightAttributes(NBTChunk chunk, int xInChunk, int worldY, int zInChunk) { BlockLightAttributes bla = new BlockLightAttributes(); bla.exist = chunk.HasOpaqueBlock(xInChunk, worldY, zInChunk) ? HAS_BLOCK : NO_BLOCK; if (bla.exist == 0) { chunk.GetLightsByte(xInChunk, worldY, zInChunk, out bla.skyLight, out bla.blockLight, true); } else { bla.skyLight = 0; bla.blockLight = 0; } return(bla); }
public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int pos, NBTGameObject nbtGO) { ca.pos = pos; ca.blockData = blockData; InitBlockAttributes(chunk, ref ca); if (!chunk.HasOpaqueBlock(pos.x, pos.y, pos.z - 1)) { FaceAttributes fa = GetFrontFaceAttributes(chunk, nbtGO.nbtMesh, ca); fa.pos = frontVertices; fa.uv = uv_side; AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x + 1, pos.y, pos.z)) { FaceAttributes fa = GetRightFaceAttributes(chunk, nbtGO.nbtMesh, ca); fa.pos = rightVertices; fa.uv = uv_side; AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x - 1, pos.y, pos.z)) { FaceAttributes fa = GetLeftFaceAttributes(chunk, nbtGO.nbtMesh, ca); fa.pos = leftVertices; fa.uv = uv_side; AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x, pos.y, pos.z + 1)) { FaceAttributes fa = GetBackFaceAttributes(chunk, nbtGO.nbtMesh, ca); fa.pos = backVertices; fa.uv = uv_side; AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x, pos.y + 1, pos.z)) { FaceAttributes fa = GetTopFaceAttributes(chunk, nbtGO.nbtMesh, ca); fa.pos = topVertices; AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x, pos.y - 1, pos.z)) { FaceAttributes fa = GetBottomFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } }
public override void AddCube(NBTChunk chunk, byte blockData, byte skyLight, Vector3Int pos, NBTGameObject nbtGO) { this.pos = pos; this.blockData = blockData; vertices = nbtGO.vertexList; triangles = nbtGO.triangles; topIndex = GetTopIndexByData(chunk, blockData); bottomIndex = GetBottomIndexByData(chunk, blockData); frontIndex = GetFrontIndexByData(chunk, blockData); backIndex = GetBackIndexByData(chunk, blockData); leftIndex = GetLeftIndexByData(chunk, blockData); rightIndex = GetRightIndexByData(chunk, blockData); topColor = GetTopTintColorByData(chunk, blockData); bottomColor = GetBottomTintColorByData(chunk, blockData); frontColor = GetFrontTintColorByData(chunk, blockData); backColor = GetBackTintColorByData(chunk, blockData); leftColor = GetLeftTintColorByData(chunk, blockData); rightColor = GetRightTintColorByData(chunk, blockData); if (!chunk.HasOpaqueBlock(pos.x, pos.y, pos.z - 1)) { AddFrontFace(blockData); } if (!chunk.HasOpaqueBlock(pos.x + 1, pos.y, pos.z)) { AddRightFace(blockData); } if (!chunk.HasOpaqueBlock(pos.x - 1, pos.y, pos.z)) { AddLeftFace(blockData); } if (!chunk.HasOpaqueBlock(pos.x, pos.y, pos.z + 1)) { AddBackFace(blockData); } if (blockData < 8 || !chunk.HasOpaqueBlock(pos.x, pos.y + 1, pos.z)) { AddTopFace(blockData); } if (blockData >= 8 || !chunk.HasOpaqueBlock(pos.x, pos.y - 1, pos.z)) { AddBottomFace(blockData); } }