Exemplo n.º 1
0
        public static void GenerateFullBlockSimple(GeneratableMesh meshInfo, BlockDescription desc, BlockData data, Vector3 rootPos, VisibilityFlags visibility, LightInfo light)
        {
            var pointer = meshInfo.Vertices.Count;
            var tile    = desc.Subtypes[Mathf.Clamp(data.Subtype, 0, desc.Subtypes.Count - 1)].FaceTiles[0];
            var uvs     = GetCachedUVsForTile(tile);
            var h       = (byte)(data.AddColor >> 8);
            var l       = (byte)(data.AddColor % 256);

            if (VisibilityFlagsHelper.IsSet(visibility, VisibilityFlags.Backward))
            {
                var calcColor = new Color32(light.SunBackward, light.OBackward, h, l);
                AddPlaneWithUVs(meshInfo, _fullBlockBackSide, uvs, rootPos, pointer, calcColor);
                pointer += 4;
            }
            if (VisibilityFlagsHelper.IsSet(visibility, VisibilityFlags.Forward))
            {
                var calcColor = new Color32(light.SunForward, light.OForward, h, l);
                AddPlaneWithUVs(meshInfo, _fullBlockFrontSide, uvs, rootPos, pointer, calcColor);
                pointer += 4;
            }
            if (VisibilityFlagsHelper.IsSet(visibility, VisibilityFlags.Left))
            {
                var calcColor = new Color32(light.SunLeft, light.OLeft, h, l);
                AddPlaneWithUVs(meshInfo, _fullBlockLeftSide, uvs, rootPos, pointer, calcColor);
                pointer += 4;
            }
            if (VisibilityFlagsHelper.IsSet(visibility, VisibilityFlags.Right))
            {
                var calcColor = new Color32(light.SunRight, light.ORight, h, l);
                AddPlaneWithUVs(meshInfo, _fullBlockRightSide, uvs, rootPos, pointer, calcColor);
                pointer += 4;
            }
            if (VisibilityFlagsHelper.IsSet(visibility, VisibilityFlags.Up))
            {
                var calcColor = new Color32(light.SunUp, light.OUp, h, l);
                AddPlaneWithUVs(meshInfo, _fullBlockUpSide, uvs, rootPos, pointer, calcColor);
                pointer += 4;
            }
            if (VisibilityFlagsHelper.IsSet(visibility, VisibilityFlags.Down))
            {
                var calcColor = new Color32(light.SunDown, light.ODown, h, l);
                AddPlaneWithUVs(meshInfo, _fullBlockDownSide, uvs, rootPos, pointer, calcColor);
                pointer += 4;
            }
        }
Exemplo n.º 2
0
        public static void GenerateHalfBlockDown(GeneratableMesh meshInfo, BlockDescription desc, BlockData data, Vector3 rootPos, VisibilityFlags visibility, LightInfo light)
        {
            var pointer = meshInfo.Vertices.Count;
            var sub     = desc.Subtypes[Mathf.Clamp(data.Subtype, 0, desc.Subtypes.Count - 1)];
            var h       = (byte)(data.AddColor >> 8);
            var l       = (byte)(data.AddColor % 256);

            if (VisibilityFlagsHelper.IsSet(visibility, VisibilityFlags.Backward))
            {
                var calcColor = new Color32(light.SunBackward, light.OBackward, h, l);
                AddPlane(meshInfo, _halfBlockDBackSide, sub.FaceTiles[0], rootPos, pointer, calcColor);
                pointer += 4;
            }
            if (VisibilityFlagsHelper.IsSet(visibility, VisibilityFlags.Forward))
            {
                var calcColor = new Color32(light.SunForward, light.OForward, h, l);
                AddPlane(meshInfo, _halfBlockDFrontSide, sub.FaceTiles[1], rootPos, pointer, calcColor);
                pointer += 4;
            }
            if (VisibilityFlagsHelper.IsSet(visibility, VisibilityFlags.Left))
            {
                var calcColor = new Color32(light.SunLeft, light.OLeft, h, l);
                AddPlane(meshInfo, _halfBlockDLeftSide, sub.FaceTiles[2], rootPos, pointer, calcColor);
                pointer += 4;
            }
            if (VisibilityFlagsHelper.IsSet(visibility, VisibilityFlags.Right))
            {
                var calcColor = new Color32(light.SunRight, light.ORight, h, l);
                AddPlane(meshInfo, _halfBlockDRightSide, sub.FaceTiles[3], rootPos, pointer, calcColor);
                pointer += 4;
            }

            if (VisibilityFlagsHelper.IsSet(visibility, VisibilityFlags.Up))
            {
                var calcColor = new Color32(light.SunUp, light.OUp, h, l);
                AddPlane(meshInfo, _halfBlockDUpside, sub.FaceTiles[4], rootPos, pointer, calcColor);
                pointer += 4;
            }
            if (VisibilityFlagsHelper.IsSet(visibility, VisibilityFlags.Down))
            {
                var calcColor = new Color32(light.SunDown, light.ODown, h, l);
                AddPlane(meshInfo, _fullBlockDownSide, sub.FaceTiles[5], rootPos, pointer, calcColor);
                pointer += 4;
            }
        }