예제 #1
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (Input.KeyEvents.Count > 0)
                toggle.IsThreeState = !toggle.IsThreeState;
        }
        /// <inheritdoc/>
        public override void Update(GameTime time)
        {
            base.Update(time);
            if (ManageShadows)
            {
                InternalActiveShadowMaps.Clear();
                InternalActiveShadowMapTextures.Clear();

                foreach (var light in Lights)
                {
                    // create new shadow maps
                    if (light.Value.Light.Shadow != null)
                        CreateShadowMap(light.Value);

                    // TODO: handle shadow maps that does no require to be updated like static shadow maps.
                    // update shadow maps info
                    if (light.Value.Light.Enabled && light.Value.Light.Shadow != null && light.Value.Light.Shadow.Enabled && light.Value.ShadowMap.Update)
                    {
                        UpdateEntityLightShadow(light.Value);
                        InternalActiveShadowMaps.Add(light.Value.ShadowMap);
                        InternalActiveShadowMapTextures.Add(light.Value.ShadowMap.Texture);
                    }
                }
            }
        }
예제 #3
0
        public override void Draw(GameTime gameTime)
        {
            if (SceneInstance == null)
            {
                return;
            }

            // If the width or height changed, we have to recycle all temporary allocated resources.
            // NOTE: We assume that they are mostly resolution dependent.
            if (previousWidth != MainRenderFrame.Width || previousHeight != MainRenderFrame.Height)
            {
                // Force a recycle of all allocated temporary textures
                renderContext.Allocator.Recycle(link => true);
            }

            previousWidth = MainRenderFrame.Width;
            previousHeight = MainRenderFrame.Height;

            // Update the entities at draw time.
            renderContext.Time = gameTime;
            SceneInstance.Draw(renderContext);

            // Renders the scene
            SceneInstance.Draw(renderContext, MainRenderFrame);
        }
예제 #4
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (Input.IsKeyReleased(Keys.S))
                SaveTexture(GraphicsDevice.BackBuffer, "sprite-font-bitmap-test.png");
        }
예제 #5
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            const float ChangeFactor = 1.1f;
            const float ChangeFactorInverse = 1 / ChangeFactor;

            // change the size of the virtual resolution
            if (Input.IsKeyReleased(Keys.NumPad0))
                UIComponent.VirtualResolution = new Vector3(GraphicsDevice.BackBuffer.Width / 2f, GraphicsDevice.BackBuffer.Height / 2f, 400);
            if (Input.IsKeyReleased(Keys.NumPad1))
                UIComponent.VirtualResolution = new Vector3(GraphicsDevice.BackBuffer.Width, GraphicsDevice.BackBuffer.Height, 400);
            if (Input.IsKeyReleased(Keys.NumPad2))
                UIComponent.VirtualResolution = new Vector3(2 * GraphicsDevice.BackBuffer.Width, 2 * GraphicsDevice.BackBuffer.Height, 400);
            if (Input.IsKeyReleased(Keys.Right))
                UIComponent.VirtualResolution = new Vector3((ChangeFactor * UIComponent.VirtualResolution.X), UIComponent.VirtualResolution.Y, UIComponent.VirtualResolution.Z);
            if (Input.IsKeyReleased(Keys.Left))
                UIComponent.VirtualResolution = new Vector3((ChangeFactorInverse * UIComponent.VirtualResolution.X), UIComponent.VirtualResolution.Y, UIComponent.VirtualResolution.Z);
            if (Input.IsKeyReleased(Keys.Up))
                UIComponent.VirtualResolution = new Vector3(UIComponent.VirtualResolution.X, (ChangeFactor * UIComponent.VirtualResolution.Y), UIComponent.VirtualResolution.Z);
            if (Input.IsKeyReleased(Keys.Down))
                UIComponent.VirtualResolution = new Vector3(UIComponent.VirtualResolution.X, (ChangeFactorInverse * UIComponent.VirtualResolution.Y), UIComponent.VirtualResolution.Z);

            if (Input.IsKeyReleased(Keys.D1))
                decorator.LocalMatrix = Matrix.Scaling(1);
            if (Input.IsKeyReleased(Keys.D2))
                decorator.LocalMatrix = Matrix.Scaling(1.5f);
            if (Input.IsKeyReleased(Keys.D3))
                decorator.LocalMatrix = Matrix.Scaling(2);
        }
예제 #6
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (Input.IsKeyPressed(Keys.W))
                textBlock.WrapText = !textBlock.WrapText;

            if (Input.IsKeyPressed(Keys.R))
            {
                textBlock.VerticalAlignment = VerticalAlignment.Stretch;
                textBlock.HorizontalAlignment = HorizontalAlignment.Stretch;
            }

            if (Input.IsKeyReleased(Keys.NumPad1))
                textBlock.VerticalAlignment = VerticalAlignment.Top;
            if (Input.IsKeyReleased(Keys.NumPad2))
                textBlock.VerticalAlignment = VerticalAlignment.Center;
            if (Input.IsKeyReleased(Keys.NumPad3))
                textBlock.VerticalAlignment = VerticalAlignment.Bottom;

            if (Input.IsKeyReleased(Keys.NumPad4))
                textBlock.HorizontalAlignment = HorizontalAlignment.Left;
            if (Input.IsKeyReleased(Keys.NumPad5))
                textBlock.HorizontalAlignment = HorizontalAlignment.Center;
            if (Input.IsKeyReleased(Keys.NumPad6))
                textBlock.HorizontalAlignment = HorizontalAlignment.Right;

            if (Input.IsKeyReleased(Keys.NumPad7))
                textBlock.TextAlignment = TextAlignment.Left;
            if (Input.IsKeyReleased(Keys.NumPad8))
                textBlock.TextAlignment = TextAlignment.Center;
            if (Input.IsKeyReleased(Keys.NumPad9))
                textBlock.TextAlignment = TextAlignment.Right;
        }
예제 #7
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            const float depthIncrement = 1f;
            const float rotationIncrement = 0.1f;

            var localMatrix = elements[1].LocalMatrix;

            if (Input.IsKeyPressed(Keys.Up))
                localMatrix.M43 -= depthIncrement;
            if (Input.IsKeyPressed(Keys.Down))
                localMatrix.M43 += depthIncrement;
            if (Input.IsKeyPressed(Keys.NumPad4))
                localMatrix = localMatrix * Matrix.RotationY(-rotationIncrement);
            if (Input.IsKeyPressed(Keys.NumPad6))
                localMatrix = localMatrix * Matrix.RotationY(+rotationIncrement);
            if (Input.IsKeyPressed(Keys.NumPad2))
                localMatrix = localMatrix * Matrix.RotationX(+rotationIncrement);
            if (Input.IsKeyPressed(Keys.NumPad8))
                localMatrix = localMatrix * Matrix.RotationX(-rotationIncrement);
            if (Input.IsKeyPressed(Keys.NumPad1))
                localMatrix = localMatrix * Matrix.RotationZ(-rotationIncrement);
            if (Input.IsKeyPressed(Keys.NumPad9))
                localMatrix = localMatrix * Matrix.RotationZ(+rotationIncrement);

            if (Input.KeyEvents.Any())
            {
                elements[1].LocalMatrix = localMatrix;

                UpdateTextBlockText();
            }
        }
예제 #8
0
 public override void Update(GameTime gameTime)
 {
     if (SceneInstance != null)
     {
         SceneInstance.Update(gameTime);
     }
 }
예제 #9
0
        protected override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            if(!ScreenShotAutomationEnabled)
                DrawImages();
        }
예제 #10
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            
            if (Input.IsKeyReleased(Keys.D1))
                scrollViewer.Content = grid;
            if (Input.IsKeyReleased(Keys.D2))
                scrollViewer.Content = stackPanel;

            if (Input.IsKeyReleased(Keys.NumPad4))
                scrollViewer.ScrollToBeginning(Orientation.Horizontal);
            if (Input.IsKeyReleased(Keys.NumPad6))
                scrollViewer.ScrollToEnd(Orientation.Horizontal);
            if (Input.IsKeyReleased(Keys.NumPad8))
                scrollViewer.ScrollToBeginning(Orientation.Vertical);
            if (Input.IsKeyReleased(Keys.NumPad2))
                scrollViewer.ScrollToEnd(Orientation.Vertical);

            if (Input.IsKeyReleased(Keys.V))
                scrollViewer.ScrollMode = ScrollingMode.Vertical;
            if (Input.IsKeyReleased(Keys.H))
                scrollViewer.ScrollMode = ScrollingMode.Horizontal;
            if (Input.IsKeyReleased(Keys.B))
                scrollViewer.ScrollMode = ScrollingMode.HorizontalVertical;

            if (Input.IsKeyReleased(Keys.Space)) // check that scroll offsets are correctly updated when content gets smaller (and we are at the end of document)
                grid.Height = float.IsNaN(grid.Height) ? 100 : float.NaN;

            if (Input.IsKeyReleased(Keys.Enter)) // check that scrolling works even when IsArrange is false (try this when ScrollMode is in Horizontal mode)
            {
                grid.Height = 1000;
                scrollViewer.ScrollMode = ScrollingMode.Vertical;
                scrollViewer.ScrollToEnd(Orientation.Vertical);
            }
        }
예제 #11
0
        public override void Update(GameTime gameTime)
        {
            scriptsToStartCopy.Clear();
            scriptsToStartCopy.AddRange(scriptsToStart);

            // Start new scripts
            foreach (var script in scriptsToStartCopy)
            {
                // Start the script
                script.Start();

                // Start a microthread with execute method if it's an async script
                var asyncScript = script as AsyncScript;
                if (asyncScript != null)
                {
                    script.MicroThread = AddTask(asyncScript.Execute);
                }
            }
            scriptsToStart.Clear();

            // Run current micro threads
            Scheduler.Run();

            syncScriptsCopy.Clear();
            syncScriptsCopy.AddRange(syncScripts);

            // Execute sync scripts
            foreach (var script in syncScriptsCopy)
            {
                script.Update();
            }
        }
예제 #12
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (Input.IsKeyReleased(Keys.D1))
                element1.ClipToBounds = !element1.ClipToBounds;
            if (Input.IsKeyReleased(Keys.D2))
                element2.ClipToBounds = !element2.ClipToBounds;
            if (Input.IsKeyReleased(Keys.D3))
                element3.ClipToBounds = !element3.ClipToBounds;
            if (Input.IsKeyReleased(Keys.D4))
                element4.ClipToBounds = !element4.ClipToBounds;

            if (Input.IsKeyDown(Keys.Left))
                element3.LocalMatrix = Matrix.Translation(element3.LocalMatrix.TranslationVector - Vector3.UnitX);
            if (Input.IsKeyDown(Keys.Right))
                element3.LocalMatrix = Matrix.Translation(element3.LocalMatrix.TranslationVector + Vector3.UnitX);

            if (Input.IsKeyDown(Keys.Up))
                element3.LocalMatrix = Matrix.Translation(element3.LocalMatrix.TranslationVector - Vector3.UnitY);
            if (Input.IsKeyDown(Keys.Down))
                element3.LocalMatrix = Matrix.Translation(element3.LocalMatrix.TranslationVector + Vector3.UnitY);

            if (Input.IsKeyDown(Keys.NumPad7))
                MoveElementToLeftTopCorner();
            if (Input.IsKeyDown(Keys.NumPad9))
                MoveElementToRightTopCorner();
            if (Input.IsKeyDown(Keys.NumPad5))
                MoveElementToIntersection();
            if (Input.IsKeyDown(Keys.NumPad3))
                MoveElementToRightBottomCorner();
        }
예제 #13
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (Input.IsKeyReleased(Keys.W))
                textScroller.RepeatText = !textScroller.RepeatText;

            if (Input.IsKeyDown(Keys.Right))
                textScroller.ScrollingSpeed /= 1.1f;

            if (Input.IsKeyDown(Keys.Left))
                textScroller.ScrollingSpeed *= 1.1f;

            if (Input.IsKeyReleased(Keys.C))
                textScroller.ClearText();

            if (Input.IsKeyReleased(Keys.T))
                textScroller.Text = TextWithBlanks;

            if (Input.IsKeyReleased(Keys.A))
                textScroller.AppendText(" Additional Text");

            if (Input.IsKeyReleased(Keys.B))
                IncreaseButtonSize();

            if (Input.IsKeyReleased(Keys.V))
                DecreaseButtonSize();
        }
예제 #14
0
        protected override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            if (!ScreenShotAutomationEnabled)
                RenderToTexture();
        }
예제 #15
0
            public void ManualUpdates(double elapsedSeconds, int updateTimes)
            {
                var elapsedSpan = TimeSpan.FromSeconds(elapsedSeconds);
                var gameTime = new GameTime(elapsedSpan, elapsedSpan);

                for (int i = 0; i < updateTimes; i++)
                    base.Update(gameTime);
            }
예제 #16
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (gameTime.FrameCount == StopOnFrameCount)
            {
                Exit();
            }
        }
예제 #17
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (Input.IsKeyDown(Keys.Escape))
            {
                Exit();
            }
        }
        protected override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            accumulatedSeconds += 1 / 60f;

            if(!ScreenShotAutomationEnabled)
                DrawText();
        }
예제 #19
0
        public override void Update(GameTime gameTime)
        {
            scriptsToStartCopy.Clear();
            scriptsToStartCopy.AddRange(scriptsToStart);
            scriptsToStart.Clear();

            // Start new scripts
            foreach (var script in scriptsToStartCopy)
            {
                // Start the script
                var startupScript = script as StartupScript;
                if (startupScript != null)
                {
                    try
                    {
                        startupScript.Start();
                    }
                    catch (Exception e)
                    {
                        HandleSynchronousException(script, e);
                    }
                }

                // Start a microthread with execute method if it's an async script
                var asyncScript = script as AsyncScript;
                if (asyncScript != null)
                {
                    script.MicroThread = AddTask(asyncScript.Execute);
                }
            }

            // Run current micro threads
            Scheduler.Run();

            // Flag scripts as not being live reloaded after starting/executing them for the first time
            foreach (var script in scriptsToStartCopy)
            {
                if (script.IsLiveReloading)
                    script.IsLiveReloading = false;
            }

            syncScriptsCopy.Clear();
            syncScriptsCopy.AddRange(syncScripts);

            // Execute sync scripts
            foreach (var script in syncScriptsCopy)
            {
                try
                {
                    script.Update();
                }
                catch (Exception e)
                {
                    HandleSynchronousException(script, e);
                }
            }
        }
예제 #20
0
        protected override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            timeInSeconds += 1 / 60f; // frame dependent for graphic unit testing.

            if (!ScreenShotAutomationEnabled)
                DrawScene();
        }
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (Input.IsKeyReleased(Keys.Left))
                spriteBatch.VirtualResolution = 3 / 4f * spriteBatch.VirtualResolution;
            if (Input.IsKeyReleased(Keys.Right))
                spriteBatch.VirtualResolution = 4 / 3f * spriteBatch.VirtualResolution;
        }
예제 #22
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (Input.IsKeyPressed(Keys.NumPad1))
                samplesCount = Math.Max(1, samplesCount / 2);

            if (Input.IsKeyPressed(Keys.NumPad3))
                samplesCount = Math.Min(1024, samplesCount * 2);
        }
예제 #23
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (Input.IsKeyPressed(Keys.I))
                displayedTexture = inputTexture;

            if (Input.IsKeyPressed(Keys.O))
                displayedTexture = outputTexture;
        }
예제 #24
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (IsAutomatic)
            {
                zValue = 100 * (1 + (float)Math.Sin(gameTime.Total.TotalSeconds));

                element1.LocalMatrix = Matrix.Translation(0, 0, zValue);
            }
        }
예제 #25
0
        protected override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
            
            if (!ScreenShotAutomationEnabled)
            {
                rotationAngle += 1 / 60f; // frame-dependent and not time-dependent

                DrawSpriteFont();
            }
        }
예제 #26
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (Input.IsKeyPressed(Keys.Left))
                textBlock.TextSize = 3 * textBlock.TextSize / 4;
            if (Input.IsKeyPressed(Keys.Right))
                textBlock.TextSize = 4 * textBlock.TextSize / 3;
            if (Input.IsKeyPressed(Keys.Delete))
                textBlock.TextSize = textBlock.Font.Size;
        }
예제 #27
0
        protected override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            GraphicsDevice.Clear(output, Color4.White);
            renderHammersley.ThreadGroupCounts = new Int3(samplesCount, 1, 1);
            renderHammersley.ThreadNumbers = new Int3(1);
            renderHammersley.Parameters.Set(HammersleyTestKeys.OutputTexture, output);
            renderHammersley.Parameters.Set(HammersleyTestKeys.SamplesCount, samplesCount);
            renderHammersley.Draw();

            GraphicsDevice.DrawTexture(output);
        }
예제 #28
0
        protected override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            if(!ScreenShotAutomationEnabled)
                DrawQuad();

            if (firstSave)
            {
                SaveTexture(offlineTarget, "offlineTarget.png");
                SaveTexture(GraphicsDevice.BackBuffer, "backBuffer.png");
                firstSave = false;
            }
        }
예제 #29
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            
            const float DepthIncrement = 10f;
            const float RotationIncrement = 0.1f;

            var localMatrix = border.LocalMatrix;

            if (Input.IsKeyPressed(Keys.Up))
                localMatrix.M43 -= DepthIncrement;
            if (Input.IsKeyPressed(Keys.Down))
                localMatrix.M43 += DepthIncrement;
            if (Input.IsKeyPressed(Keys.NumPad4))
                localMatrix = localMatrix * Matrix.RotationY(-RotationIncrement);
            if (Input.IsKeyPressed(Keys.NumPad6))
                localMatrix = localMatrix * Matrix.RotationY(+RotationIncrement);
            if (Input.IsKeyPressed(Keys.NumPad2))
                localMatrix = localMatrix * Matrix.RotationX(+RotationIncrement);
            if (Input.IsKeyPressed(Keys.NumPad8))
                localMatrix = localMatrix * Matrix.RotationX(-RotationIncrement);
            if (Input.IsKeyPressed(Keys.NumPad1))
                localMatrix = localMatrix * Matrix.RotationZ(-RotationIncrement);
            if (Input.IsKeyPressed(Keys.NumPad9))
                localMatrix = localMatrix * Matrix.RotationZ(+RotationIncrement);

            if (Input.IsKeyPressed(Keys.L))
                border.BorderThickness += new Thickness(1, 0, 0, 0, 0, 0);
            if (Input.IsKeyPressed(Keys.R))
                border.BorderThickness += new Thickness(0, 0, 0, 1, 0, 0);
            if (Input.IsKeyPressed(Keys.T))
                border.BorderThickness += new Thickness(0, 1, 0, 0, 0, 0);
            if (Input.IsKeyPressed(Keys.B))
                border.BorderThickness += new Thickness(0, 0, 0, 0, 1, 0);
            if (Input.IsKeyPressed(Keys.F))
                border.BorderThickness += new Thickness(0, 0, 0, 0, 0, 1);
            if (Input.IsKeyPressed(Keys.S))
                border.BorderThickness += new Thickness(0, 0, 1, 0, 0, 0);

            if (Input.KeyEvents.Any())
                border.LocalMatrix = localMatrix;

            if (Input.IsKeyPressed(Keys.D1))
                ResetBorderElement();
            if (Input.IsKeyPressed(Keys.D2))
                TurnBorderElement();
            if (Input.IsKeyPressed(Keys.D3))
                FlattenBorderElement();
        }
예제 #30
0
        protected override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            if(!ScreenShotAutomationEnabled)
                RenderToTexture();

            if (firstSave)
            {
                SaveTexture(UVTexture, "a_uvTex.png");
                SaveTexture(offlineTarget0, "a_firstRT.png");
                SaveTexture(offlineTarget2, "a_secondRT.png");
                firstSave = false;
            }
        }