Beispiel #1
0
        public static void CopyTo(this MaterialChannel srcChannel, Materials.ChannelBuilder dstChannel)
        {
            Guard.NotNull(srcChannel, nameof(srcChannel));
            Guard.NotNull(dstChannel, nameof(dstChannel));

            dstChannel.Parameter = srcChannel.Parameter;

            if (srcChannel.Texture == null)
            {
                return;
            }

            if (dstChannel.Texture == null)
            {
                dstChannel.UseTexture();
            }

            dstChannel.Texture.CoordinateSet = srcChannel.TextureCoordinate;
            dstChannel.Texture.MinFilter     = srcChannel.TextureSampler.MinFilter;
            dstChannel.Texture.MagFilter     = srcChannel.TextureSampler.MagFilter;
            dstChannel.Texture.WrapS         = srcChannel.TextureSampler.WrapS;
            dstChannel.Texture.WrapT         = srcChannel.TextureSampler.WrapT;

            /*
             * dstChannel.Texture.Rotation = srcChannel.Transform?.Rotation ?? 0;
             * dstChannel.Texture.Offset = srcChannel.Transform?.Offset ?? Vector2.Zero;
             * dstChannel.Texture.Scale = srcChannel.Transform?.Scale ?? Vector2.One;
             */

            dstChannel.Texture.ImageContent = srcChannel.Texture.Image.GetImageContent();
        }
Beispiel #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);
            }
        }
Beispiel #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);
        }
Beispiel #4
0
        public static void CopyTo(this MaterialChannel srcChannel, Materials.ChannelBuilder dstChannel)
        {
            Guard.NotNull(srcChannel, nameof(srcChannel));
            Guard.NotNull(dstChannel, nameof(dstChannel));

            dstChannel.Parameter = srcChannel.Parameter;

            if (srcChannel.Texture == null)
            {
                return;
            }

            if (dstChannel.Texture == null)
            {
                dstChannel.UseTexture();
            }

            dstChannel.Texture.CoordinateSet = srcChannel.TextureCoordinate;

            if (srcChannel.TextureSampler != null)
            {
                dstChannel.Texture.MinFilter = srcChannel.TextureSampler.MinFilter;
                dstChannel.Texture.MagFilter = srcChannel.TextureSampler.MagFilter;
                dstChannel.Texture.WrapS     = srcChannel.TextureSampler.WrapS;
                dstChannel.Texture.WrapT     = srcChannel.TextureSampler.WrapT;
            }

            var srcXform = srcChannel.TextureTransform;

            if (srcXform != null)
            {
                dstChannel.Texture.WithTransform(srcXform.Offset, srcXform.Scale, srcXform.Rotation, srcXform.TextureCoordinateOverride);
            }

            dstChannel.Texture.PrimaryImageContent = srcChannel.Texture.PrimaryImage.GetImageContent();

            if (srcChannel.Texture.FallbackImage != null)
            {
                dstChannel.Texture.FallbackImageContent = srcChannel.Texture.FallbackImage.GetImageContent();
            }
        }