Exemplo n.º 1
0
        public void DrawDistortion(IDistortionStage stage,
                                   CoordinateSpace target,
                                   FillType type,
                                   Vertex2D[] vertices,
                                   int[] indices,
                                   Colour colour,
                                   ITexture texture0,
                                   ITexture texture1,
                                   TextureCoordinateMode texWrap0,
                                   TextureCoordinateMode texWrap1,
                                   float intensity,
                                   bool validate = false)
        {
            var request = new DistortionDrawRequest
            {
                CoordinateSpace = target,
                FillType        = type,
                Vertices        = vertices,
                Indices         = indices,
                Colour          = new Colour(colour.R * intensity,
                                             colour.G * intensity,
                                             colour.B * intensity,
                                             colour.A * intensity),
                Texture0     = texture0,
                Texture1     = texture1,
                TextureWrap0 = texWrap0,
                TextureWrap1 = texWrap1
            };

            DrawDistortion(stage, ref request, validate);
        }
Exemplo n.º 2
0
        public void Drawing_ValidatingDistortionInput_CatchNullDistortionStage()
        {
            var messenger          = Substitute.For <IFrameworkMessenger>();
            var renderStageManager = Substitute.For <IRenderStageManager>();
            var renderStageVisitor = Substitute.For <IRenderStageVisitor>();
            var fontManager        = Substitute.For <IFontManager>();
            var gpuSurfaceManager  = Substitute.For <IGpuSurfaceManager>();

            IDrawing drawing = new Drawing(messenger,
                                           renderStageManager,
                                           renderStageVisitor,
                                           fontManager,
                                           gpuSurfaceManager);

            IDistortionStage stage = null;

            var request = new DistortionDrawRequest
            {
                Colour          = Colour.White,
                CoordinateSpace = CoordinateSpace.Screen,
                FillType        = FillType.Coloured,
                Indices         = new int[] { 0, 1, 2 },
                Texture0        = new TextureReference(1UL),
                Texture1        = new TextureReference(2UL),
                TextureWrap0    = TextureCoordinateMode.Mirror,
                TextureWrap1    = TextureCoordinateMode.Mirror,
                Vertices        = new Vertex2D[] { new Vertex2D(), new Vertex2D(), new Vertex2D() }
            };

            Assert.Throws <Yak2DException>(() => { drawing.DrawDistortion(stage, ref request, false); });
        }
Exemplo n.º 3
0
        public void SetDistortionConfig(IDistortionStage effect, DistortionEffectConfiguration config, float transitionSeconds)
        {
            if (effect == null)
            {
                throw new Yak2DException("Unable to set distortion effect as stage passed is null");
            }

            SetDistortionConfig(effect.Id, config, transitionSeconds);
        }
Exemplo n.º 4
0
        public void DrawDistortion(IDistortionStage stage, ref DistortionDrawRequest request, bool validate = false)
        {
            if (stage == null)
            {
                throw new Yak2DException("Distortion Draw request failed. Null Draw Stage");
            }

            DrawDistortion(stage.Id, ref request, validate);
        }
Exemplo n.º 5
0
        public void ClearDynamicDistortionRequestQueue(IDistortionStage stage)
        {
            if (stage == null)
            {
                throw new Yak2DException("Unable to clear dynamic distortion draw queue, null draw stage provided");
            }

            ClearDynamicDistortionRequestQueue(stage.Id);
        }
Exemplo n.º 6
0
        public void Draw(IDrawing drawing, IDistortionStage stage)
        {
            if (_numActive == 0)
            {
                return;
            }

            var quadIndices = new int[] { 0, 1, 2, 2, 1, 3 };

            for (var n = 0; n < _collectionSize; n++)
            {
                if (_collection[n].Active)
                {
                    var item = _collection[n];

                    var fraction = item.TimeCount / item.Duration;
                    if (!item.CurrentCountDirectionIsForward)
                    {
                        fraction = 1.0f - fraction;
                    }

                    var halfSize  = 0.5f * Utility.Interpolator.Interpolate(item.InitSize, item.FinalSize, ref fraction);
                    var position  = Utility.Interpolator.Interpolate(item.InitPosition, item.FinalPosition, ref fraction);
                    var intensity = Utility.Interpolator.Interpolate(item.InitIntensity, item.FinalIntensity, ref fraction);
                    var rotation  = Utility.Interpolator.Interpolate(item.InitRotation, item.FinalRotation, ref fraction);

                    drawing.DrawDistortion(stage, item.CoordinateSpace,
                                           FillType.Textured,
                                           new Vertex2D[]
                    {
                        new Vertex2D {
                            Position = RotateDegressClockwise(new Vector2(-halfSize.X, halfSize.Y), rotation) + position, TexCoord0 = new Vector2(0.0f, 0.0f), TexCoord1 = new Vector2(0.0f, 0.0f), TexWeighting = 0.0f, Colour = new Colour(1.0f, 1.0f, 1.0f, 1.0f)
                        },
                        new Vertex2D {
                            Position = RotateDegressClockwise(new Vector2(halfSize.X, halfSize.Y), rotation) + position, TexCoord0 = new Vector2(1.0f, 0.0f), TexCoord1 = new Vector2(1.0f, 0.0f), TexWeighting = 1.0f, Colour = new Colour(1.0f, 1.0f, 1.0f, 1.0f)
                        },
                        new Vertex2D {
                            Position = RotateDegressClockwise(new Vector2(-halfSize.X, -halfSize.Y), rotation) + position, TexCoord0 = new Vector2(0.0f, 1.0f), TexCoord1 = new Vector2(0.0f, 1.0f), TexWeighting = 0.0f, Colour = new Colour(1.0f, 1.0f, 1.0f, 1.0f)
                        },
                        new Vertex2D {
                            Position = RotateDegressClockwise(new Vector2(halfSize.X, -halfSize.Y), rotation) + position, TexCoord0 = new Vector2(1.0f, 1.0f), TexCoord1 = new Vector2(1.0f, 1.0f), TexWeighting = 1.0f, Colour = new Colour(1.0f, 1.0f, 1.0f, 1.0f)
                        },
                    },
                                           quadIndices,
                                           Colour.White,
                                           item.Texture,
                                           null,
                                           TextureCoordinateMode.Wrap,
                                           TextureCoordinateMode.Wrap,
                                           intensity
                                           );
                }
            }
        }
Exemplo n.º 7
0
        public IPersistentDistortionQueue CreatePersistentDistortQueue(IDistortionStage stage,
                                                                       DistortionDrawRequest[] requests,
                                                                       bool validate = false)
        {
            if (stage == null)
            {
                throw new Yak2DException("Unable to create persistent distortion draw queue, null draw stage passed");
            }

            return(CreatePersistentDistortQueue(stage.Id, requests, validate));
        }
Exemplo n.º 8
0
        public void RemovePersistentDistortQueue(IDistortionStage stage, IPersistentDistortionQueue queue)
        {
            if (stage == null)
            {
                throw new Yak2DException("Unable to remove persistent distortion draw queue, null draw stage provided");
            }

            if (queue == null)
            {
                throw new Yak2DException("Unable to remove persistent distortion draw queue, null queue provided");
            }

            RemovePersistentDistortQueue(stage.Id, queue.Id);
        }
Exemplo n.º 9
0
        public void Drawing_ClearDynamicDrawQueue_CatchNullStage()
        {
            var messenger          = Substitute.For <IFrameworkMessenger>();
            var renderStageManager = Substitute.For <IRenderStageManager>();
            var renderStageVisitor = Substitute.For <IRenderStageVisitor>();
            var fontManager        = Substitute.For <IFontManager>();
            var gpuSurfaceManager  = Substitute.For <IGpuSurfaceManager>();

            IDrawing drawing = new Drawing(messenger,
                                           renderStageManager,
                                           renderStageVisitor,
                                           fontManager,
                                           gpuSurfaceManager);

            IDistortionStage stage = null;

            Assert.Throws <Yak2DException>(() => { drawing.ClearDynamicDistortionRequestQueue(stage); });
        }
Exemplo n.º 10
0
        public void Drawing_RemovePersistentDistortQueue_CatchNullStage()
        {
            var messenger          = Substitute.For <IFrameworkMessenger>();
            var renderStageManager = Substitute.For <IRenderStageManager>();
            var renderStageVisitor = Substitute.For <IRenderStageVisitor>();
            var fontManager        = Substitute.For <IFontManager>();
            var gpuSurfaceManager  = Substitute.For <IGpuSurfaceManager>();

            IDrawing drawing = new Drawing(messenger,
                                           renderStageManager,
                                           renderStageVisitor,
                                           fontManager,
                                           gpuSurfaceManager);

            IDistortionStage stage = null;
            var queue = Substitute.For <IPersistentDistortionQueue>();

            Assert.Throws <Yak2DException>(() => { drawing.RemovePersistentDistortQueue(stage, queue); });
        }
Exemplo n.º 11
0
        public void Distortion(IDistortionStage stage, ICamera2D camera, ITexture source, IRenderTarget target)
        {
            if (stage == null)
            {
                throw new Yak2DException("Unable to queue DistortionStage. Stage is null", new ArgumentNullException());
            }

            if (camera == null)
            {
                throw new Yak2DException("Unable to queue DistortionStage. Camera is null", new ArgumentNullException());
            }

            if (source == null)
            {
                throw new Yak2DException("Unable to queue DistortionStage. Source is null", new ArgumentNullException());
            }

            if (target == null)
            {
                throw new Yak2DException("Unable to queue DistortionStage. Target is null", new ArgumentNullException());
            }

            if (source.Id == target.Id)
            {
                throw new Yak2DException("Unable to queue DistortionStage. Source and Target Surfaces cannot be the same", new ArgumentNullException());
            }

            _commandQueue.Add(RenderCommandType.DistortionStage,
                              stage.Id,
                              target.Id,
                              camera.Id,
                              source.Id,
                              0UL,
                              0UL,
                              0UL,
                              RgbaFloat.Clear);
        }
Exemplo n.º 12
0
 public void DrawDistortion(IDistortionStage stage, DistortionDrawRequest request, bool validate = false)
 {
     DrawDistortion(stage, ref request, validate);
 }