Exemple #1
0
 public virtual void Start()
 {
     RenderPass   = new BasicRenderPass(Graphics);
     SpriteEffect = new SpriteEffect(
         Graphics,
         RenderPass,
         MaxActors,
         PreviousEffect?.FinalLayout ?? ImageLayout.Undefined,
         PreviousEffect?.FinalAccess ?? Accesses.None,
         PreviousEffect?.FinalStage ?? PipelineStages.TopOfPipe
         );
     SpriteEffect.Start();
     SpriteEffect.SetCamera(Vector2.Zero, new Vector2(Graphics.Window.Size.X, -Graphics.Window.Size.Y));
 }
        /// <summary>
        /// Called when starting the scene
        /// </summary>
        public override void OnStart()
        {
            // Create render pass
            TriangleRenderPass = new BasicRenderPass(Graphics);
            // Create and start a clear effect
            ClearEffect = new ClearEffect(Graphics, TriangleRenderPass);
            ClearEffect.Start();
            ClearEffect.ClearColor = new ClearColorValue(0.5f, 0.7f, 0.9f);
            // Create and start triangle effect
            SpriteEffect = new SpriteEffect(
                Graphics,
                TriangleRenderPass,
                2000,
                ClearEffect.FinalLayout,
                ClearEffect.FinalAccess,
                ClearEffect.FinalStage
                );
            SpriteEffect.Start();
            var rand  = new Random();
            var tex   = Content["TriangleTexture"] as Texture2D;
            var anims = new[] {
                new Animation(new[] {
                    Animation.Instruction.SetRotation(0f, 0f),
                    Animation.Instruction.SetScale(0f, new Vector2(12f, 12f)),
                    Animation.Instruction.LerpScale(0f, 1f, new Vector2(30f, 10f)),
                    Animation.Instruction.SetRectangle(0f, new Vector2(0f, 0f), new Vector2(1f, 1f)),
                    Animation.Instruction.LerpScale(1f, 1f, new Vector2(8f, 20f)),
                    Animation.Instruction.LerpRotation(1f, 1f, 1f),
                    Animation.Instruction.SetRectangle(1f, new Vector2(0.6f, 0.6f), new Vector2(1f, 1f)),
                    Animation.Instruction.LerpScale(2f, 1f, new Vector2(12f, 12f)),
                    Animation.Instruction.LerpRotation(2f, 1f, 0f),
                    Animation.Instruction.None(3f)
                }),
                new Animation(new[] {
                    Animation.Instruction.SetScale(0f, new Vector2(26f, 26f)),
                    Animation.Instruction.LerpScale(0f, 1f, new Vector2(8f, 30f)),
                    Animation.Instruction.SetRectangle(0f, new Vector2(0f, 0f), new Vector2(1f, 1f)),
                    Animation.Instruction.LerpScale(0.7f, 1f, new Vector2(20f, 8f)),
                    Animation.Instruction.SetRectangle(0.7f, new Vector2(0f, 0f), new Vector2(0.5f, 0.5f)),
                    Animation.Instruction.LerpScale(1.4f, 1f, new Vector2(26f, 26f)),
                    Animation.Instruction.None(2.141f)
                }),
                new Animation(new[] {
                    Animation.Instruction.SetScale(0f, new Vector2(26f, 26f)),
                    Animation.Instruction.LerpScale(0f, 1f, new Vector2(8f, 30f)),
                    Animation.Instruction.SetRectangle(0f, new Vector2(0f, 0f), new Vector2(1f, 1f)),
                    Animation.Instruction.LerpScale(1.861f, 1f, new Vector2(20f, 8f)),
                    Animation.Instruction.SetRectangle(1.861f, new Vector2(0f, 0f), new Vector2(0.5f, 0.5f)),
                    Animation.Instruction.LerpScale(3f, 1f, new Vector2(26f, 26f)),
                    Animation.Instruction.None(5.12f)
                })
            };

            for (var i = 0; i < 2000; i++)
            {
                var vel = new Vector3(
                    -75f + (float)rand.NextDouble() * 150f,
                    -75f + (float)rand.NextDouble() * 150f,
                    0f
                    );
                var pos = new Vector3(
                    -100f + (float)rand.NextDouble() * 200f,
                    -100f + (float)rand.NextDouble() * 200f,
                    -1f + (float)rand.NextDouble() * 2f
                    );
                new SpriteInstance(
                    SpriteEffect,
                    pos,
                    vel,
                    new Vector2(32, 32),
                    tex,
                    new Vector4(0, 0, 32f / tex.Image.Extent.Width, 32f / tex.Image.Extent.Height),
                    anims[i % 3]
                    );
            }
            TransitionEffect = new TransitionEffect(
                Graphics,
                SpriteEffect.FinalLayout,
                SpriteEffect.FinalAccess,
                SpriteEffect.FinalStage,
                ImageLayout.ColorAttachmentOptimal,
                Accesses.MemoryRead,
                PipelineStages.BottomOfPipe
                );
            TransitionEffect.Start();
        }