Пример #1
0
        public static void CopyTo(this ChannelBuilder srcChannel, MaterialChannel dstChannel)
        {
            Guard.NotNull(srcChannel, nameof(srcChannel));
            Guard.NotNull(dstChannel, nameof(dstChannel));

            foreach (var dstProp in dstChannel.Parameters)
            {
                dstProp.Value = srcChannel.Parameters[dstProp.Name].ToTypeless();
            }

            var srcTex = srcChannel.GetValidTexture();

            if (srcTex == null)
            {
                return;
            }

            Image primary  = null;
            Image fallback = null;

            if (ImageBuilder.IsValid(srcTex.PrimaryImage))
            {
                primary = dstChannel
                          .LogicalParent
                          .LogicalParent
                          .UseImageWithContent(srcTex.PrimaryImage.Content);

                srcTex.PrimaryImage.TryCopyNameAndExtrasTo(primary);
            }

            if (primary == null)
            {
                return;
            }

            if (ImageBuilder.IsValid(srcTex.FallbackImage))
            {
                fallback = dstChannel
                           .LogicalParent
                           .LogicalParent
                           .UseImageWithContent(srcTex.FallbackImage.Content);

                srcTex.FallbackImage.TryCopyNameAndExtrasTo(fallback);
            }

            var dstTex = dstChannel.SetTexture(srcTex.CoordinateSet, primary, fallback, srcTex.WrapS, srcTex.WrapT, srcTex.MinFilter, srcTex.MagFilter);

            srcTex.TryCopyNameAndExtrasTo(dstTex);

            var srcXform = srcTex.Transform;

            if (srcXform != null)
            {
                dstChannel.SetTransform(srcXform.Offset, srcXform.Scale, srcXform.Rotation, srcXform.CoordinateSetOverride);
            }
        }
Пример #2
0
        public static void CopyTo(this Materials.ChannelBuilder srcChannel, MaterialChannel dstChannel)
        {
            Guard.NotNull(srcChannel, nameof(srcChannel));
            Guard.NotNull(dstChannel, nameof(dstChannel));

            dstChannel.Parameter = srcChannel.Parameter;

            var srcTex = srcChannel.Texture;

            if (srcTex == null)
            {
                return;
            }

            Image primary  = null;
            Image fallback = null;

            if (srcTex.PrimaryImage.IsValid)
            {
                primary = dstChannel
                          .LogicalParent
                          .LogicalParent
                          .UseImageWithContent(srcTex.PrimaryImage.GetBuffer().ToArray());
            }

            if (srcTex.FallbackImage.IsValid)
            {
                fallback = dstChannel
                           .LogicalParent
                           .LogicalParent
                           .UseImageWithContent(srcTex.FallbackImage.GetBuffer().ToArray());
            }

            dstChannel.SetTexture(srcTex.CoordinateSet, primary, fallback, srcTex.WrapS, srcTex.WrapT, srcTex.MinFilter, srcTex.MagFilter);

            var srcXform = srcTex.Transform;

            if (srcXform != null)
            {
                dstChannel.SetTransform(srcXform.Offset, srcXform.Scale, srcXform.Rotation, srcXform.CoordinateSetOverride);
            }
        }
Пример #3
0
        public static void CopyTo(this Materials.ChannelBuilder srcChannel, MaterialChannel dstChannel)
        {
            Guard.NotNull(srcChannel, nameof(srcChannel));
            Guard.NotNull(dstChannel, nameof(dstChannel));

            dstChannel.Parameter = srcChannel.Parameter;

            var srcTex = srcChannel.Texture;

            if (srcTex == null)
            {
                return;
            }

            var image = dstChannel.LogicalParent.LogicalParent.UseImageWithContent(srcTex.ImageContent.ToArray());

            dstChannel.SetTexture(srcTex.CoordinateSet, image, srcTex.MinFilter, srcTex.MagFilter, srcTex.WrapS, srcTex.WrapT);

            // dstChannel.SetTransform(srcTex.CoordinateSet, srcTex.Offset, srcTex.Scale, srcTex.Rotation);
        }