예제 #1
0
        /// <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));
        }
예제 #2
0
        /// <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));
        }
예제 #3
0
        /// <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);
        }
예제 #6
0
        /// <inheritdoc />
        public override BlockMeshData GetMesh(BlockMeshInfo info)
        {
            bool north = (info.Data & 0b00_1000) != 0;
            bool east  = (info.Data & 0b00_0100) != 0;
            bool south = (info.Data & 0b00_0010) != 0;
            bool west  = (info.Data & 0b00_0001) != 0;

            bool useStraightZ = north && south && !east && !west;
            bool useStraightX = !north && !south && east && west;

            if (useStraightZ || useStraightX)
            {
                return(useStraightZ ? straightZ.GetComplexMeshData() : straightX.GetComplexMeshData());
            }

            return(base.GetMesh(info));
        }
예제 #7
0
                            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);
                                }
                            }
예제 #8
0
        /// <inheritdoc />
        public override BlockMeshData GetMesh(BlockMeshInfo info)
        {
            Decode(info.Data, out BlockColor color, out _);

            return(BlockMeshData.VaryingHeight(textures[(int)info.Side], color.ToTintColor()));
        }
예제 #9
0
 /// <inheritdoc />
 public override BlockMeshData GetMesh(BlockMeshInfo info)
 {
     return(BlockMeshData.Empty());
 }
예제 #10
0
 /// <inheritdoc />
 public override BlockMeshData GetMesh(BlockMeshInfo info)
 {
     return(base.GetMesh(info).Modified(info.Liquid.IsLiquid ? TintColor.LightGray : TintColor.None));
 }
예제 #11
0
 /// <inheritdoc />
 public override BlockMeshData GetMesh(BlockMeshInfo info)
 {
     return(BlockMeshData.Basic(
                sideTextureIndices[TranslateIndex(info.Side, (Orientation)(info.Data & 0b00_0011))],
예제 #12
0
 /// <summary>
 ///     Returns the mesh of a block side at given conditions.
 /// </summary>
 /// <param name="info">Information about the conditions the mesh should be created in.</param>
 /// <returns>The mesh data.</returns>
 public abstract BlockMeshData GetMesh(BlockMeshInfo info);
 /// <inheritdoc />
 public override BlockMeshData GetMesh(BlockMeshInfo info)
 {
     return(base.GetMesh(info).Modified(TintColor.Neutral));
 }