Ejemplo n.º 1
0
        public void Update(EngineTime engineTime)
        {
            if (!IsEnabled || !IsAnimating || Animation == null || Math.Abs(PlaybackSpeed) <= float.Epsilon)
            {
                return;
            }

            _IsDirty = true;
            _CurrentPlaybackPosition += engineTime.ElapsedTime.TotalSeconds * PlaybackSpeed;
            if (IsLooping)
            {
                while (_CurrentPlaybackPosition < 0)
                {
                    _CurrentPlaybackPosition += Animation.Duration;
                }
                while (_CurrentPlaybackPosition > Animation.Duration)
                {
                    _CurrentPlaybackPosition -= Animation.Duration;
                }
            }
            else if (_CurrentPlaybackPosition <= 0 || _CurrentPlaybackPosition > Animation.Duration)
            {
                _IsAnimating = false;
            }
        }
Ejemplo n.º 2
0
        public override void Update(EngineTime engineTime)
        {
            if (AnimationPlayer.Animation != null)
            {
                AnimationPlayer.Update(engineTime);

                _AnimationPose = _AnimationPlayer.GetPose();

                for (var i = 0; i < JointMatrixArray.Length; ++i)
                {
                    var skeletonBoneIndex = _BoneMap[i];

                    var invRef = _InvertedReferencePose[skeletonBoneIndex];
                    var pose   = _AnimationPose[skeletonBoneIndex];

                    JointMatrixArray[i] = invRef * pose;
                }
            }
            else
            {
                for (var i = 0; i < JointMatrixArray.Length; ++i)
                {
                    JointMatrixArray[i] = Matrix.Identity;
                }
            }

            base.Update(engineTime);
        }
Ejemplo n.º 3
0
 public void Draw(EngineTime time, ref SharpDX.Matrix world, ref SharpDX.Matrix view, ref SharpDX.Matrix projection)
 {
     foreach (var component in this.OfType <IDrawable3DComponent>().Where(c => c.IsVisible).ToArray())
     {
         component.Draw(time, ref world, ref view, ref projection);
     }
 }
Ejemplo n.º 4
0
        public override void Draw(EngineTime time, ref Matrix world, ref Matrix view, ref Matrix projection)
        {
            base.Draw(time, ref world, ref view, ref projection);

            if (AnimationPlayer.Animation != null)
            {
                if (DisplayAnimationJoints)
                {
                    foreach (var i in _BoneMap)
                    {
                        var m = _AnimationPose[i];
                        var w = Matrix.Scaling(0.025f) * m * world;
                        Engine.Cube.Draw(time, ref w, ref view, ref projection);
                    }
                }
            }
            if (DisplayReferenceJoints)
            {
                foreach (var i in _BoneMap)
                {
                    var m = Skeleton.ReferencePose[i];
                    var w = Matrix.Scaling(0.025f) * m * world;
                    Engine.Cube.Draw(time, ref w, ref view, ref projection);
                }
            }
        }
Ejemplo n.º 5
0
 public void Update(EngineTime engineTime)
 {
     foreach (var component in this.OfType <IUpdateableComponent>().Where(c => c.IsEnabled).ToArray())
     {
         component.Update(engineTime);
     }
 }
Ejemplo n.º 6
0
        protected virtual void Draw(EngineTime time)
        {
            var world = Matrix.Identity;
            var view  = Camera.View;
            var proj  = Camera.Projection;

            Draw3D(time, ref world, ref view, ref proj);
        }
Ejemplo n.º 7
0
 protected virtual void BeforeDraw(EngineTime time)
 {
     Device.ImmediateContext.OutputMerger.SetDepthStencilState(DepthStencilState);
     Device.ImmediateContext.OutputMerger.SetBlendState(BlendState);
     Device.ImmediateContext.Rasterizer.State = RasterizerState;
     Device.ImmediateContext.OutputMerger.SetTargets(_DepthStencilView, _RenderTargetView);
     Device.ImmediateContext.ClearDepthStencilView(_DepthStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1f, 0);
 }
Ejemplo n.º 8
0
        protected void EngineLoop(EngineTime time)
        {
            Update(time);

            BeforeDraw(time);
            Draw(time);
            AfterDraw(time);

            Present();
        }
Ejemplo n.º 9
0
 public void Update(EngineTime engineTime)
 {
     var buttons = _Engine.InputService.GetDownMouseButtons();
     var pos = _Engine.InputService.MousePosition;
     _CurrentState.AbsolutePosition = new Vector2(pos.X, pos.Y);
     _CurrentState.RelativePosition = new Vector2(_CurrentState.AbsolutePosition.X / (float)_Engine.ViewportSize.Width, _CurrentState.AbsolutePosition.Y / (float)_Engine.ViewportSize.Height);
     _CurrentState.LeftButton = buttons.Contains(System.Windows.Forms.MouseButtons.Left);
     _CurrentState.RightButton = buttons.Contains(System.Windows.Forms.MouseButtons.Right);
     _CurrentState.MiddleButton = buttons.Contains(System.Windows.Forms.MouseButtons.Middle);
 }
Ejemplo n.º 10
0
        public void Update(EngineTime engineTime)
        {
            var buttons = _Engine.InputService.GetDownMouseButtons();
            var pos     = _Engine.InputService.MousePosition;

            _CurrentState.AbsolutePosition = new Vector2(pos.X, pos.Y);
            _CurrentState.RelativePosition = new Vector2(_CurrentState.AbsolutePosition.X / (float)_Engine.ViewportSize.Width, _CurrentState.AbsolutePosition.Y / (float)_Engine.ViewportSize.Height);
            _CurrentState.LeftButton       = buttons.Contains(System.Windows.Forms.MouseButtons.Left);
            _CurrentState.RightButton      = buttons.Contains(System.Windows.Forms.MouseButtons.Right);
            _CurrentState.MiddleButton     = buttons.Contains(System.Windows.Forms.MouseButtons.Middle);
        }
Ejemplo n.º 11
0
        public void Update(EngineTime time)
        {
            _ReleasedKeys.Clear();
            _PressedKeys.Clear();

            var downKeys = _Engine.InputService.GetDownKeys();
            _PressedKeys.AddRange(downKeys.Except(_DownKeys));
            _ReleasedKeys.AddRange(_DownKeys.Except(downKeys));

            _DownKeys.AddRange(_PressedKeys);
            foreach (var k in _ReleasedKeys)
                _DownKeys.Remove(k);
        }
Ejemplo n.º 12
0
        protected override void Update(EngineTime time)
        {
            if (_IsResizePending)
            {
                var elapsed = _ResizeTimer.ElapsedMilliseconds;
                if (elapsed > ResizeDelay)
                {
                    ResizeToClient();
                    _ResizeTimer.Reset();
                    _IsResizePending = false;
                }
            }
            if (Keyboard.WasKeyPressed(System.Windows.Forms.Keys.F12))
            {
                if (_ScreenshotTargetView == null)
                {
                    var rtTexDesc = RenderTarget.Description;
                    rtTexDesc.SampleDescription = new SampleDescription(1, 0);
                    rtTexDesc.Width             = ScreenshotWidth;
                    rtTexDesc.Height            = ScreenshotHeight;

                    _ScreenshotTarget     = new Texture2D(Device, rtTexDesc);
                    _ScreenshotTargetView = new RenderTargetView(Device, _ScreenshotTarget);

                    var dsTexDesc = new Texture2DDescription {
                        Format            = Format.D24_UNorm_S8_UInt,
                        ArraySize         = 1,
                        MipLevels         = 1,
                        Width             = _ScreenshotTarget.Description.Width,
                        Height            = _ScreenshotTarget.Description.Height,
                        SampleDescription = _ScreenshotTarget.Description.SampleDescription,
                        Usage             = ResourceUsage.Default,
                        BindFlags         = BindFlags.DepthStencil,
                        CpuAccessFlags    = CpuAccessFlags.None,
                        OptionFlags       = ResourceOptionFlags.None,
                    };
                    _ScreenshotStencil     = new Texture2D(Device, dsTexDesc);
                    _ScreenshotStencilView = new DepthStencilView(Device, _ScreenshotStencil, new DepthStencilViewDescription {
                        Flags     = DepthStencilViewFlags.None,
                        Dimension = DepthStencilViewDimension.Texture2DMultisampled,
                        Format    = dsTexDesc.Format
                    });
                }
                ResizeToScreenshot();
                TakeScreenshot(time);
                ResizeToClient();
            }

            _Form.Text = Camera.OrthoLookAt.X.ToString() + ", " + Camera.OrthoLookAt.Z.ToString();
            base.Update(time);
        }
Ejemplo n.º 13
0
        protected void EngineLoop()
        {
            if (_RunTimer == null)
            {
                _RunTimer = new Stopwatch();
                _RunTimer.Start();
            }
            var elapsed = _RunTimer.Elapsed;

            _RunTimer.Restart();
            _TotalElapsedTime += elapsed.Ticks;
            var time = new EngineTime(TimeSpan.FromTicks(_TotalElapsedTime), elapsed);

            EngineLoop(time);
        }
Ejemplo n.º 14
0
        protected void TakeScreenshot(EngineTime time)
        {
            Camera.Update(time);

            Device.ImmediateContext.OutputMerger.SetDepthStencilState(DepthStencilState);
            Device.ImmediateContext.OutputMerger.SetBlendState(BlendState);
            Device.ImmediateContext.Rasterizer.State = RasterizerState;
            Device.ImmediateContext.OutputMerger.SetTargets(_ScreenshotStencilView, _ScreenshotTargetView);
            Device.ImmediateContext.ClearDepthStencilView(_ScreenshotStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1f, 0);

            Device.ImmediateContext.ClearRenderTargetView(_ScreenshotTargetView, Color.Transparent);
            base.Draw(time);

            Texture2D.ToFile(Device.ImmediateContext, _ScreenshotTarget, ImageFileFormat.Png, string.Format("SS-{0:yyyyMMdd-HHmmss}.png", DateTime.Now));
            ResizeToClient();
        }
Ejemplo n.º 15
0
        public void Update(EngineTime time)
        {
            _ReleasedKeys.Clear();
            _PressedKeys.Clear();

            var downKeys = _Engine.InputService.GetDownKeys();

            _PressedKeys.AddRange(downKeys.Except(_DownKeys));
            _ReleasedKeys.AddRange(_DownKeys.Except(downKeys));

            _DownKeys.AddRange(_PressedKeys);
            foreach (var k in _ReleasedKeys)
            {
                _DownKeys.Remove(k);
            }
        }
Ejemplo n.º 16
0
        public void Update(EngineTime time)
        {
            _PreviousMouseState = _CurrentMouseState;
            _CurrentMouseState  = _Engine.Mouse.GetState();

            var     amount      = (float)(time.ElapsedTime.TotalMilliseconds / 2000f);
            Vector3 moveVector  = new Vector3(0, 0, 0);
            var     aspectRatio = (float)(_Engine.ViewportSize.Width / (float)_Engine.ViewportSize.Height);

            //  Toggle orthogonal mode if we want.
            if (_Engine.IsActive)
            {
                if (_Engine.Keyboard.IsKeyDown(Keys.O))
                {
                    if (!OKeyWasDown)
                    {
                        OrthoMode = !OrthoMode;
                    }
                    OKeyWasDown = true;
                }
                else
                {
                    OKeyWasDown = false;
                }
            }

            if (_Engine.IsActive)
            {
                var modFactor = 2f;
                if (_Engine.Keyboard.IsKeyDown(Keys.Space))
                {
                    modFactor *= 10f;
                }
                if (_Engine.Keyboard.IsKeyDown(Keys.ShiftKey))
                {
                    amount *= modFactor;
                }
                if (_Engine.Keyboard.IsKeyDown(Keys.ControlKey))
                {
                    amount /= modFactor;
                }

                if (_Engine.Keyboard.IsKeyDown(Keys.W))
                {
                    moveVector += new Vector3(0, 0, -1);
                }
                if (_Engine.Keyboard.IsKeyDown(Keys.S))
                {
                    moveVector += new Vector3(0, 0, 1);
                }
                if (_Engine.Keyboard.IsKeyDown(Keys.D))
                {
                    moveVector += new Vector3(1, 0, 0);
                }
                if (_Engine.Keyboard.IsKeyDown(Keys.A))
                {
                    moveVector += new Vector3(-1, 0, 0);
                }
                if (_Engine.Keyboard.IsKeyDown(Keys.Q))
                {
                    moveVector += new Vector3(0, 1, 0);
                }
                if (_Engine.Keyboard.IsKeyDown(Keys.Z))
                {
                    moveVector += new Vector3(0, -1, 0);
                }
                if (_Engine.Keyboard.IsKeyDown(Keys.R))
                {
                    Reset();
                }

                if (OrthoMode)
                {
                    if (_Engine.Keyboard.IsKeyDown(Keys.Q))
                    {
                        OrthoScale *= 1.0f + 0.01f * amount;
                    }
                    if (_Engine.Keyboard.IsKeyDown(Keys.Z))
                    {
                        OrthoScale *= 1.0f - 0.01f * amount;
                    }
                    if (_Engine.Keyboard.IsKeyDown(Keys.W))
                    {
                        _OrthoLookAt.Z -= amount * 10.0f;
                    }
                    if (_Engine.Keyboard.IsKeyDown(Keys.S))
                    {
                        _OrthoLookAt.Z += amount * 10.0f;
                    }
                    if (_Engine.Keyboard.IsKeyDown(Keys.D))
                    {
                        _OrthoLookAt.X += amount * 10.0f;
                    }
                    if (_Engine.Keyboard.IsKeyDown(Keys.A))
                    {
                        _OrthoLookAt.X -= amount * 10.0f;
                    }
                }

                if (_Engine.Keyboard.IsKeyDown(Keys.Left))
                {
                    _Yaw += RotationSpeed * amount * 2;
                }
                if (_Engine.Keyboard.IsKeyDown(Keys.Right))
                {
                    _Yaw -= RotationSpeed * amount * 2;
                }

                if (_Engine.Keyboard.IsKeyDown(Keys.Up))
                {
                    _Pitch += RotationSpeed * amount * 2;
                }
                if (_Engine.Keyboard.IsKeyDown(Keys.Down))
                {
                    _Pitch -= RotationSpeed * amount * 2;
                }

                if (_CurrentMouseState.LeftButton)
                {
                    if (_CurrentMouseState.RightButton)
                    {
                        moveVector += new Vector3(0, 0, -1);
                    }
                    var mouseMove = _CurrentMouseState.AbsolutePosition - _PreviousMouseState.AbsolutePosition;
                    _Yaw   -= mouseMove.X * MouseRotationSpeedYaw;
                    _Pitch -= mouseMove.Y * MouseRotationSpeedPitch;

                    if (OrthoMode)
                    {
                        _OrthoLookAt.X -= mouseMove.X * MouseOrthoPanSpeed * OrthoScale;
                        _OrthoLookAt.Z -= mouseMove.Y * MouseOrthoPanSpeed * OrthoScale;
                    }
                }

                float scrollAmount = (float)System.Math.Sign(_CurrentMouseState.MouseWheelDelta);

                if (OrthoMode)
                {
                    OrthoScale *= 1.0f - (0.1f * scrollAmount * MouseOrthoZoomSpeed);
                }

                AddToCameraPosition(moveVector * amount);
            }

            UpdateViewMatrix();

            float orthoAspectRatio = (float)_Engine.ViewportSize.Width / (float)_Engine.ViewportSize.Height;

            if (OrthoMode)
            {
                _Projection = Matrix.OrthoRH(OrthoScale * 1000.0f * orthoAspectRatio, OrthoScale * 1000.0f, 0.1f, 100000.0f);
            }
            else
            {
                _Projection = Matrix.PerspectiveFovRH(FoV, aspectRatio, 0.1f, 10000.0f);
            }
        }
Ejemplo n.º 17
0
        protected void EngineLoop(EngineTime time)
        {
            Update(time);

            BeforeDraw(time);
            Draw(time);
            AfterDraw(time);

            Present();
        }
Ejemplo n.º 18
0
 public abstract void Draw(EngineTime time, ref SharpDX.Matrix world, ref SharpDX.Matrix view, ref SharpDX.Matrix projection);
Ejemplo n.º 19
0
        public void Update(EngineTime time)
        {
            _PreviousMouseState = _CurrentMouseState;
            _CurrentMouseState  = _Engine.Mouse.GetState();

            var     amount      = (float)(time.ElapsedTime.TotalMilliseconds / 2000f);
            Vector3 moveVector  = new Vector3(0, 0, 0);
            var     aspectRatio = (float)(_Engine.ViewportSize.Width / (float)_Engine.ViewportSize.Height);

            if (_Engine.IsActive)
            {
                var modFactor = 2f;
                if (_Engine.Keyboard.IsKeyDown(Keys.Space))
                {
                    modFactor *= 2f;
                }
                if (_Engine.Keyboard.IsKeyDown(Keys.ShiftKey))
                {
                    amount *= modFactor;
                }
                if (_Engine.Keyboard.IsKeyDown(Keys.ControlKey))
                {
                    amount /= modFactor;
                }

                if (_Engine.Keyboard.IsKeyDown(Keys.W))
                {
                    moveVector += new Vector3(0, 0, -1);
                }
                if (_Engine.Keyboard.IsKeyDown(Keys.S))
                {
                    moveVector += new Vector3(0, 0, 1);
                }
                if (_Engine.Keyboard.IsKeyDown(Keys.D))
                {
                    moveVector += new Vector3(1, 0, 0);
                }
                if (_Engine.Keyboard.IsKeyDown(Keys.A))
                {
                    moveVector += new Vector3(-1, 0, 0);
                }
                if (_Engine.Keyboard.IsKeyDown(Keys.Q))
                {
                    moveVector += new Vector3(0, 1, 0);
                }
                if (_Engine.Keyboard.IsKeyDown(Keys.Z))
                {
                    moveVector += new Vector3(0, -1, 0);
                }
                if (_Engine.Keyboard.IsKeyDown(Keys.R))
                {
                    Reset();
                }

                if (_Engine.Keyboard.IsKeyDown(Keys.Left))
                {
                    _Yaw += RotationSpeed * amount * 2;
                }
                if (_Engine.Keyboard.IsKeyDown(Keys.Right))
                {
                    _Yaw -= RotationSpeed * amount * 2;
                }

                if (_Engine.Keyboard.IsKeyDown(Keys.Up))
                {
                    _Pitch += RotationSpeed * amount * 2;
                }
                if (_Engine.Keyboard.IsKeyDown(Keys.Down))
                {
                    _Pitch -= RotationSpeed * amount * 2;
                }

                if (_CurrentMouseState.LeftButton)
                {
                    if (_CurrentMouseState.RightButton)
                    {
                        moveVector += new Vector3(0, 0, -1);
                    }
                    var mouseMove = _CurrentMouseState.AbsolutePosition - _PreviousMouseState.AbsolutePosition;
                    _Yaw   -= mouseMove.X * MouseRotationSpeedYaw;
                    _Pitch -= mouseMove.Y * MouseRotationSpeedPitch;
                }

                AddToCameraPosition(moveVector * amount);
            }

            UpdateViewMatrix();

            _Projection = Matrix.PerspectiveFovRH(FoV, aspectRatio, 0.1f, 10000.0f);
        }
Ejemplo n.º 20
0
 public virtual void Update(EngineTime engineTime)
 {
 }
Ejemplo n.º 21
0
        protected void TakeScreenshot(EngineTime time)
        {
            Camera.Update(time);

            Device.ImmediateContext.OutputMerger.SetDepthStencilState(DepthStencilState);
            Device.ImmediateContext.OutputMerger.SetBlendState(BlendState);
            Device.ImmediateContext.Rasterizer.State = RasterizerState;
            Device.ImmediateContext.OutputMerger.SetTargets(_ScreenshotStencilView, _ScreenshotTargetView);
            Device.ImmediateContext.ClearDepthStencilView(_ScreenshotStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1f, 0);

            Device.ImmediateContext.ClearRenderTargetView(_ScreenshotTargetView, Color.Transparent);
            base.Draw(time);

            Texture2D.ToFile(Device.ImmediateContext, _ScreenshotTarget, ImageFileFormat.Png, string.Format("SS-{0:yyyyMMdd-HHmmss}.png", DateTime.Now));
            ResizeToClient();
        }
Ejemplo n.º 22
0
 public abstract void Draw(EngineTime time, ref SharpDX.Matrix world, ref SharpDX.Matrix view, ref SharpDX.Matrix projection);
Ejemplo n.º 23
0
 protected virtual void AfterDraw(EngineTime time)
 {
 }
Ejemplo n.º 24
0
 protected virtual void BeforeDraw(EngineTime time)
 {
     Device.ImmediateContext.OutputMerger.SetDepthStencilState(DepthStencilState);
     Device.ImmediateContext.OutputMerger.SetBlendState(BlendState);
     Device.ImmediateContext.Rasterizer.State = RasterizerState;
     Device.ImmediateContext.OutputMerger.SetTargets(_DepthStencilView, _RenderTargetView);
     Device.ImmediateContext.ClearDepthStencilView(_DepthStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1f, 0);
 }
Ejemplo n.º 25
0
        protected virtual void Draw(EngineTime time)
        {
            var world = Matrix.Identity;
            var view = Camera.View;
            var proj = Camera.Projection;

            Draw3D(time, ref world, ref view, ref proj);
        }
Ejemplo n.º 26
0
 private void Draw3D(EngineTime time, ref Matrix world, ref Matrix view, ref Matrix proj)
 {
     CoreComponents.Draw(time, ref world, ref view, ref proj);
     Components.Draw(time, ref world, ref view, ref proj);
 }
Ejemplo n.º 27
0
 protected virtual void Update(EngineTime time)
 {
     CoreComponents.Update(time);
     Components.Update(time);
 }
Ejemplo n.º 28
0
        public virtual void Update(EngineTime engineTime) {

        }
Ejemplo n.º 29
0
        protected override void Draw(EngineTime time)
        {
            Device.ImmediateContext.ClearRenderTargetView(RenderTargetView, Color.CornflowerBlue);

            base.Draw(time);
        }
Ejemplo n.º 30
0
 private void Draw3D(EngineTime time, ref Matrix world, ref Matrix view, ref Matrix proj)
 {
     CoreComponents.Draw(time, ref world, ref view, ref proj);
     Components.Draw(time, ref world, ref view, ref proj);
 }
Ejemplo n.º 31
0
        protected override void Update(EngineTime time)
        {
            if (_IsResizePending) {
                var elapsed = _ResizeTimer.ElapsedMilliseconds;
                if (elapsed > ResizeDelay) {
                    ResizeToClient();
                    _ResizeTimer.Reset();
                    _IsResizePending = false;
                }
            }
            if (Keyboard.WasKeyPressed(System.Windows.Forms.Keys.F12)) {
                if (_ScreenshotTargetView == null) {
                    var rtTexDesc = RenderTarget.Description;
                    rtTexDesc.SampleDescription = new SampleDescription(1, 0);
                    rtTexDesc.Width = ScreenshotWidth;
                    rtTexDesc.Height = ScreenshotHeight;

                    _ScreenshotTarget = new Texture2D(Device, rtTexDesc);
                    _ScreenshotTargetView = new RenderTargetView(Device, _ScreenshotTarget);

                    var dsTexDesc = new Texture2DDescription {
                        Format = Format.D24_UNorm_S8_UInt,
                        ArraySize = 1,
                        MipLevels = 1,
                        Width = _ScreenshotTarget.Description.Width,
                        Height = _ScreenshotTarget.Description.Height,
                        SampleDescription = _ScreenshotTarget.Description.SampleDescription,
                        Usage = ResourceUsage.Default,
                        BindFlags = BindFlags.DepthStencil,
                        CpuAccessFlags = CpuAccessFlags.None,
                        OptionFlags = ResourceOptionFlags.None,
                    };
                    _ScreenshotStencil = new Texture2D(Device, dsTexDesc);
                    _ScreenshotStencilView = new DepthStencilView(Device, _ScreenshotStencil, new DepthStencilViewDescription {
                        Flags = DepthStencilViewFlags.None,
                        Dimension = DepthStencilViewDimension.Texture2DMultisampled,
                        Format = dsTexDesc.Format
                    });
                }
                ResizeToScreenshot();
                TakeScreenshot(time);
                ResizeToClient();
            }

            base.Update(time);
        }
            public void Update(EngineTime engineTime)
            {
                if (!string.IsNullOrWhiteSpace(SetTitle)) {
                    _Engine.Form.Text = SetTitle;
                    SetTitle = null;
                }
                if (Replacement != null) {
                    lock (AddQueue)
                        AddQueue.Clear();
                    _InnerContainer.Clear();
                    var l = Replacement(_Engine);
                    foreach (var c in l) {
                        if (c != null)
                            _InnerContainer.Add(c);
                    }
                    Replacement = null;
                }
                EngineHelper.MultiComponentFunction[] toAdd;
                lock (AddQueue) {
                    toAdd = AddQueue.ToArray();
                    AddQueue.Clear();
                }
                foreach (var f in toAdd) {
                    var l = f(_Engine);
                    foreach (var c in l) {
                        if (c != null)
                            _InnerContainer.Add(c);
                    }
                }

                _InnerContainer.Update(engineTime);
            }
Ejemplo n.º 33
0
        protected override void Draw(EngineTime time)
        {
            Device.ImmediateContext.ClearRenderTargetView(RenderTargetView, _BackgroundColor);

            base.Draw(time);
        }
Ejemplo n.º 34
0
        protected override void Draw(EngineTime time)
        {
            Device.ImmediateContext.ClearRenderTargetView(RenderTargetView, Color.CornflowerBlue);

            base.Draw(time);
        }
Ejemplo n.º 35
0
        public void Update(EngineTime time)
        {
            _PreviousMouseState = _CurrentMouseState;
            _CurrentMouseState = _Engine.Mouse.GetState();

            var amount = (float)(time.ElapsedTime.TotalMilliseconds / 2000f);
            Vector3 moveVector = new Vector3(0, 0, 0);
            var aspectRatio = (float)(_Engine.ViewportSize.Width / (float)_Engine.ViewportSize.Height);

            if (_Engine.IsActive) {
                var modFactor = 2f;
                if (_Engine.Keyboard.IsKeyDown(Keys.Space))
                    modFactor *= 2f;
                if (_Engine.Keyboard.IsKeyDown(Keys.ShiftKey))
                    amount *= modFactor;
                if (_Engine.Keyboard.IsKeyDown(Keys.ControlKey))
                    amount /= modFactor;

                if (_Engine.Keyboard.IsKeyDown(Keys.W))
                    moveVector += new Vector3(0, 0, -1);
                if (_Engine.Keyboard.IsKeyDown(Keys.S))
                    moveVector += new Vector3(0, 0, 1);
                if (_Engine.Keyboard.IsKeyDown(Keys.D))
                    moveVector += new Vector3(1, 0, 0);
                if (_Engine.Keyboard.IsKeyDown(Keys.A))
                    moveVector += new Vector3(-1, 0, 0);
                if (_Engine.Keyboard.IsKeyDown(Keys.Q))
                    moveVector += new Vector3(0, 1, 0);
                if (_Engine.Keyboard.IsKeyDown(Keys.Z))
                    moveVector += new Vector3(0, -1, 0);
                if (_Engine.Keyboard.IsKeyDown(Keys.R))
                    Reset();

                if (_Engine.Keyboard.IsKeyDown(Keys.Left))
                    _Yaw += RotationSpeed * amount * 2;
                if (_Engine.Keyboard.IsKeyDown(Keys.Right))
                    _Yaw -= RotationSpeed * amount * 2;

                if (_Engine.Keyboard.IsKeyDown(Keys.Up))
                    _Pitch += RotationSpeed * amount * 2;
                if (_Engine.Keyboard.IsKeyDown(Keys.Down))
                    _Pitch -= RotationSpeed * amount * 2;

                if (_CurrentMouseState.LeftButton) {
                    if (_CurrentMouseState.RightButton)
                        moveVector += new Vector3(0, 0, -1);
                    var mouseMove = _CurrentMouseState.AbsolutePosition - _PreviousMouseState.AbsolutePosition;
                    _Yaw -= mouseMove.X * MouseRotationSpeedYaw;
                    _Pitch -= mouseMove.Y * MouseRotationSpeedPitch;
                }

                AddToCameraPosition(moveVector * amount);
            }

            UpdateViewMatrix();

            _Projection = Matrix.PerspectiveFovRH(FoV, aspectRatio, 0.1f, 10000.0f);
        }
Ejemplo n.º 36
0
 protected virtual void AfterDraw(EngineTime time)
 {
 }
Ejemplo n.º 37
0
        protected override void Draw(EngineTime time)
        {
            Device.ImmediateContext.ClearRenderTargetView(RenderTargetView, _BackgroundColor);

            base.Draw(time);
        }
Ejemplo n.º 38
0
 protected virtual void Update(EngineTime time)
 {
     CoreComponents.Update(time);
     Components.Update(time);
 }
 public void Draw(EngineTime time, ref SharpDX.Matrix world, ref SharpDX.Matrix view, ref SharpDX.Matrix projection)
 {
     _InnerContainer.Draw(time, ref world, ref view, ref projection);
 }
Ejemplo n.º 40
0
        protected void EngineLoop()
        {
            if (_RunTimer == null) {
                _RunTimer = new Stopwatch();
                _RunTimer.Start();
            }
            var elapsed = _RunTimer.Elapsed;
            _RunTimer.Restart();
            _TotalElapsedTime += elapsed.Ticks;
            var time = new EngineTime(TimeSpan.FromTicks(_TotalElapsedTime), elapsed);

            EngineLoop(time);
        }