/// <inheritdoc /> public override BlockMeshData GetMesh(BlockMeshInfo info) { int texture = info.Liquid.IsLiquid ? wetTextureIndices[(int)info.Side] : dryTextureIndices[(int)info.Side]; return(BlockMeshData.VaryingHeight(texture, TintColor.None)); }
/// <inheritdoc /> public override BlockMeshData GetMesh(BlockMeshInfo info) { Axis axis = ToAxis(info.Data); // Check if the texture has to be rotated. bool rotated = axis == Axis.X && info.Side != BlockSide.Left && info.Side != BlockSide.Right || axis == Axis.Z && info.Side is BlockSide.Left or BlockSide.Right; return(BlockMeshData.Basic(sideTextureIndices[TranslateIndex(info.Side, axis)], rotated)); }
/// <inheritdoc /> public override BlockMeshData GetMesh(BlockMeshInfo info) { BlockMeshData mesh = base.GetMesh(info); if (info.Liquid.IsLiquid) { mesh = mesh.SwapTextureIndex(wetTextureIndices[(int)info.Side]); } return(mesh); }
/// <inheritdoc /> public override BlockMeshData GetMesh(BlockMeshInfo info) { bool isUpper = (info.Data & 0b01) != 0; bool isLowered = (info.Data & 0b10) != 0; return(BlockMeshData.CrossPlant( isUpper ? topTextureIndex : bottomTextureIndex, TintColor.Neutral, hasUpper: true, isLowered, isUpper)); }
/// <inheritdoc /> public override BlockMeshData GetMesh(BlockMeshInfo info) { BlockMeshData mesh = base.GetMesh(info); mesh = mesh.Modified(hasNeutralTint ? TintColor.Neutral : TintColor.None); if (info.Liquid.IsLiquid) { mesh = mesh.SwapTextureIndex(wetTextureIndices[(int)info.Side]); } return(mesh); }
public static Mesh oneSimpleCube(Vector3Int cubeSize) { List <Vector3> verts = new List <Vector3>(); List <int> tris = new List <int>(); List <Vector2> uvs = new List <Vector2>(); List <Vector3> normals = new List <Vector3>(); BlockMeshData Cube = new BlockMeshData(null, cubeSize, 0); Cube.makeSingleCubeMeshData(); verts.AddRange(Cube.verts); tris.AddRange(Cube.tris); uvs.AddRange(Cube.uvs); normals.AddRange(Cube.normals); return(buildingMesh(verts, tris, uvs, normals)); }
private static MeshData blockBlocks(BlockScheme[,,] blockScheme) { MeshData meshData = new MeshData(); for (int x = 0; x < blockScheme.GetLength(0); x++) { for (int y = 0; y < blockScheme.GetLength(1); y++) { for (int z = 0; z < blockScheme.GetLength(2); z++) { if (blockScheme[x, y, z] == null) { continue; } if (blockScheme[x, y, z].children == null) { if (!blockScheme[x, y, z].visible) { continue; } BlockMeshData Cube = new BlockMeshData(blockScheme[x, y, z], blockScheme[x, y, z].size, trisIndexStart); Cube.generateCubeMeshData(); trisIndexStart = Cube.triIndexEnd; meshData.verts.AddRange(Cube.verts); meshData.tris.AddRange(Cube.tris); meshData.uvs.AddRange(Cube.uvs); meshData.normals.AddRange(Cube.normals); } else { MeshData meshDataR = new MeshData(); meshDataR = blockBlocks(blockScheme[x, y, z].children); meshData.verts.AddRange(meshDataR.verts); meshData.tris.AddRange(meshDataR.tris); meshData.uvs.AddRange(meshDataR.uvs); meshData.normals.AddRange(meshDataR.normals); } } } } return(meshData); }
/// <summary> /// Get complex mesh data from this mesh. /// </summary> public BlockMeshData GetComplexMeshData(TintColor?tint = null, bool isAnimated = false) { return(BlockMeshData.Complex(vertexCount, vertices, textureIndices, indices, tint, isAnimated)); }
void MeshSimpleSide(BlockSide side) { ClientSection?neighbor = neighbors[(int)side]; Block? blockToCheck; Vector3i checkPos = side.Offset(pos); if (IsPositionOutOfSection(checkPos)) { checkPos = checkPos.Mod(SectionSize); bool atVerticalEnd = side is BlockSide.Top or BlockSide.Bottom; blockToCheck = neighbor?.GetBlock(checkPos) ?? (atVerticalEnd ? Block.Air : null); } else { blockToCheck = GetBlock(checkPos); } if (blockToCheck == null) { return; } if (!blockToCheck.IsFull || !blockToCheck.IsOpaque && (currentBlock.IsOpaque || currentBlock.RenderFaceAtNonOpaques || blockToCheck.RenderFaceAtNonOpaques)) { BlockMeshData mesh = currentBlock.GetMesh( BlockMeshInfo.Simple(side, data, currentLiquid)); side.Corners(out int[] a, out int[] b, out int[] c, out int[] d); int[][] uvs = BlockModels.GetBlockUVs(mesh.IsTextureRotated); // int: uv-- ---- ---- -xxx xxyy yyyz zzzz (uv: texture coords; xyz: position) int upperDataA = (uvs[0][0] << 31) | (uvs[0][1] << 30) | ((a[0] + x) << 10) | ((a[1] + y) << 5) | (a[2] + z); int upperDataB = (uvs[1][0] << 31) | (uvs[1][1] << 30) | ((b[0] + x) << 10) | ((b[1] + y) << 5) | (b[2] + z); int upperDataC = (uvs[2][0] << 31) | (uvs[2][1] << 30) | ((c[0] + x) << 10) | ((c[1] + y) << 5) | (c[2] + z); int upperDataD = (uvs[3][0] << 31) | (uvs[3][1] << 30) | ((d[0] + x) << 10) | ((d[1] + y) << 5) | (d[2] + z); // int: tttt tttt t--n nn-a ---i iiii iiii iiii (t: tint; n: normal; a: animated; i: texture index) int lowerData = (mesh.Tint.GetBits(blockTint) << 23) | ((int)side << 18) | mesh.GetAnimationBit(shift: 16) | mesh.TextureIndex; blockMeshFaceHolders[(int)side].AddFace( pos, lowerData, (upperDataA, upperDataB, upperDataC, upperDataD), mesh.IsTextureRotated); } }
/// <inheritdoc /> public override BlockMeshData GetMesh(BlockMeshInfo info) { Decode(info.Data, out BlockColor color, out _); return(BlockMeshData.VaryingHeight(textures[(int)info.Side], color.ToTintColor())); }
/// <inheritdoc /> public override BlockMeshData GetMesh(BlockMeshInfo info) { return(BlockMeshData.Empty()); }