예제 #1
0
 public override void UpdateScene(float dt)
 {
     base.UpdateScene(dt);
     if (Util.IsKeyDown(Keys.Up))
     {
         _camera.Walk(100.0f * dt);
     }
     if (Util.IsKeyDown(Keys.Down))
     {
         _camera.Walk(-100.0f * dt);
     }
     if (Util.IsKeyDown(Keys.Left))
     {
         _camera.Strafe(-100.0f * dt);
     }
     if (Util.IsKeyDown(Keys.Right))
     {
         _camera.Strafe(100.0f * dt);
     }
     if (Util.IsKeyDown(Keys.PageUp))
     {
         _camera.Zoom(-dt);
     }
     if (Util.IsKeyDown(Keys.PageDown))
     {
         _camera.Zoom(+dt);
     }
     if (Util.IsKeyDown(Keys.Space))
     {
         _camera.LookAt(new Vector3(0, 5, -5), new Vector3(0, 0, 0), Vector3.UnitY);
     }
 }
예제 #2
0
 public override void UpdateScene(float dt)
 {
     base.UpdateScene(dt);
     if (Util.IsKeyDown(Keys.Up))
     {
         _camera.Walk(10.0f * dt);
     }
     if (Util.IsKeyDown(Keys.Down))
     {
         _camera.Walk(-10.0f * dt);
     }
     if (Util.IsKeyDown(Keys.Left))
     {
         _camera.Strafe(-10.0f * dt);
     }
     if (Util.IsKeyDown(Keys.Right))
     {
         _camera.Strafe(10.0f * dt);
     }
     if (Util.IsKeyDown(Keys.PageUp))
     {
         _camera.Zoom(-dt);
     }
     if (Util.IsKeyDown(Keys.PageDown))
     {
         _camera.Zoom(+dt);
     }
     _droneInstance.Update(dt);
     _mageInstance.Update(dt);
     _soldierInstance.Update(dt);
 }
예제 #3
0
        public override void UpdateScene(float dt)
        {
            base.UpdateScene(dt);
            if (Util.IsKeyDown(Keys.Up))
            {
                _camera.Walk(10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Down))
            {
                _camera.Walk(-10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Left))
            {
                _camera.Strafe(-10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Right))
            {
                _camera.Strafe(10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.PageUp))
            {
                _camera.Zoom(-dt);
            }
            if (Util.IsKeyDown(Keys.PageDown))
            {
                _camera.Zoom(+dt);
            }

            _camera.UpdateViewMatrix();
        }
예제 #4
0
        public override void UpdateScene(float dt)
        {
            base.UpdateScene(dt);
            if (Util.IsKeyDown(Keys.Up))
            {
                _camera.Walk(10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Down))
            {
                _camera.Walk(-10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Left))
            {
                _camera.Strafe(-10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Right))
            {
                _camera.Strafe(10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.PageUp))
            {
                _camera.Zoom(-dt * 10.0f);
            }
            if (Util.IsKeyDown(Keys.PageDown))
            {
                _camera.Zoom(+dt * 10.0f);
            }
            if (Util.IsKeyDown(Keys.D1))
            {
                _camWalkMode = true;
            }
            if (Util.IsKeyDown(Keys.D2))
            {
                _camWalkMode = false;
            }
            if (_camWalkMode)
            {
                var camPos = _camera.Position;
                var y      = _terrain.Height(camPos.X, camPos.Z);
                _camera.Position = new Vector3(camPos.X, y + 2.0f, camPos.Z);
            }

            if (Util.IsKeyDown(Keys.R))
            {
                _fire.Reset();
                _rain.Reset();
            }

            _fire.Update(dt, Timer.TotalTime);
            _rain.Update(dt, Timer.TotalTime);

            _camera.UpdateViewMatrix();
        }
예제 #5
0
파일: ShadowsDemo.cs 프로젝트: mrommel/dx11
        public override void UpdateScene(float dt)
        {
            base.UpdateScene(dt);
            if (Util.IsKeyDown(Keys.Up))
            {
                _camera.Walk(10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Down))
            {
                _camera.Walk(-10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Left))
            {
                _camera.Strafe(-10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Right))
            {
                _camera.Strafe(10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.PageUp))
            {
                _camera.Zoom(-dt);
            }
            if (Util.IsKeyDown(Keys.PageDown))
            {
                _camera.Zoom(+dt);
            }

            _lightRotationAngle += 0.1f * dt;

            var r = Matrix.RotationY(_lightRotationAngle);

            for (var i = 0; i < 3; i++)
            {
                var lightDir = _originalLightDirs[i];
                lightDir = Vector3.TransformNormal(lightDir, r);
                _dirLights[i].Direction = lightDir;
            }

            BuildShadowTransform();
            _camera.UpdateViewMatrix();
        }
예제 #6
0
파일: Program.cs 프로젝트: virus-404/dx11
 public override void UpdateScene(float dt)
 {
     base.UpdateScene(dt);
     if (Util.IsKeyDown(Keys.Up))
     {
         _cam.Walk(10.0f * dt);
     }
     if (Util.IsKeyDown(Keys.Down))
     {
         _cam.Walk(-10.0f * dt);
     }
     if (Util.IsKeyDown(Keys.Left))
     {
         _cam.Strafe(-10.0f * dt);
     }
     if (Util.IsKeyDown(Keys.Right))
     {
         _cam.Strafe(10.0f * dt);
     }
 }
예제 #7
0
        public override void UpdateScene(float dt)
        {
            base.UpdateScene(dt);
            if (Util.IsKeyDown(Keys.Up))
            {
                _camera.Walk(10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Down))
            {
                _camera.Walk(-10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Left))
            {
                _camera.Strafe(-10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Right))
            {
                _camera.Strafe(10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.PageUp))
            {
                _camera.Zoom(-dt);
            }
            if (Util.IsKeyDown(Keys.PageDown))
            {
                _camera.Zoom(+dt);
            }

            if (Util.IsKeyDown(Keys.D1))
            {
                _normalMapped = false;
            }
            if (Util.IsKeyDown(Keys.D2))
            {
                _normalMapped = true;
            }
        }
예제 #8
0
파일: Program.cs 프로젝트: virus-404/dx11
        public override void UpdateScene(float dt)
        {
            base.UpdateScene(dt);
            if (Util.IsKeyDown(Keys.Up))
            {
                _camera.Walk(10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Down))
            {
                _camera.Walk(-10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Left))
            {
                _camera.Strafe(-10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Right))
            {
                _camera.Strafe(10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.PageUp))
            {
                _camera.Zoom(-dt);
            }
            if (Util.IsKeyDown(Keys.PageDown))
            {
                _camera.Zoom(+dt);
            }
            var skullScale        = Matrix.Scaling(0.2f, 0.2f, 0.2f);
            var skullOffset       = Matrix.Translation(3, 2, 0);
            var skullLocalRotate  = Matrix.RotationY(2.0f * Timer.TotalTime);
            var skullGlobalRotate = Matrix.RotationY(0.5f * Timer.TotalTime);

            _skullWorld = skullScale * skullLocalRotate * skullOffset * skullGlobalRotate;

            _camera.UpdateViewMatrix();
        }
예제 #9
0
        public void Update(float dTime)
        {
            if (animate)
            {
                Vector3 pos = camera.Position;
                Vector3 dir = (animationTarget - pos).Normalized();
                pos += (animationTarget - animationTargetDistance * dir - pos) * 2f * dTime;

                Vector3 lookAt = camera.LookAt;
                Vector3 d      = animationTarget - lookAt;
                lookAt += d * 2f * dTime;

                camera.Relocate(pos, lookAt);

                if (d.Length < 0.1f)
                {
                    animate = false;
                }
                return;
            }


            if (moveForward)
            {
                movement.Z = 1.0f;
            }
            if (moveBackward)
            {
                movement.Z = -1.0f;
            }
            if (moveLeft)
            {
                movement.X = 1.0f;
            }
            if (moveRight)
            {
                movement.X = -1.0f;
            }

            //if (movement.Length > 1.0f) movement.Normalize();

            float speed = (fast ? MoveSpeedFast : MoveSpeed);

            camera.Move(dTime * movement.Z * speed);
            camera.Strafe(dTime * movement.X * speed);

            movement *= 0.8f * (1.0f - dTime);
        }
예제 #10
0
파일: Program.cs 프로젝트: mrommel/dx11
        public override void UpdateScene(float dt)
        {
            base.UpdateScene(dt);
            if (Util.IsKeyDown(Keys.Up))
            {
                _cam.Walk(10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Down))
            {
                _cam.Walk(-10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Left))
            {
                _cam.Strafe(-10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Right))
            {
                _cam.Strafe(10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.D1))
            {
                _frustumCullingEnabled = true;
            }
            if (Util.IsKeyDown(Keys.D2))
            {
                _frustumCullingEnabled = false;
            }
            if (Util.IsKeyDown(Keys.U))
            {
                _instancing = false;
            }
            if (Util.IsKeyDown(Keys.I))
            {
                _instancing = true;
            }
            if (Util.IsKeyDown(Keys.B))
            {
                _skullsOrBoxes = false;
            }
            if (Util.IsKeyDown(Keys.S))
            {
                _skullsOrBoxes = true;
            }
            _cam.UpdateViewMatrix();
            _visibleObjectCount = 0;
            if (_frustumCullingEnabled)
            {
                var db = ImmediateContext.MapSubresource(_instanceBuffer, MapMode.WriteDiscard, MapFlags.None);

                foreach (var instancedData in _instancedData)
                {
                    var w   = instancedData.World;
                    var box = new BoundingBox(
                        Vector3.TransformCoordinate(_skullBox.Minimum, w),
                        Vector3.TransformCoordinate(_skullBox.Maximum, w)
                        );

                    if (_cam.Visible(box))
                    {
                        db.Data.Write(instancedData);
                        _visibleObjectCount++;
                    }
                }

                ImmediateContext.UnmapSubresource(_instanceBuffer, 0);
            }
            else
            {
                var db = ImmediateContext.MapSubresource(_instanceBuffer, MapMode.WriteDiscard, MapFlags.None);
                foreach (var instancedData in _instancedData)
                {
                    db.Data.Write(instancedData);
                    _visibleObjectCount++;
                }

                ImmediateContext.UnmapSubresource(_instanceBuffer, 0);
            }
            MainWindowCaption = String.Format("Instancing and Culling Demo    {0} objects visible out of {1}", _visibleObjectCount, _instancedData.Count);
        }
예제 #11
0
파일: Program.cs 프로젝트: mrommel/dx11
        public override void UpdateScene(float dt)
        {
            base.UpdateScene(dt);

            if (Util.IsKeyDown(Keys.Up))
            {
                if (_useFpsCamera)
                {
                    _cam.Walk(10.0f * dt);
                }
                else
                {
                    _cam2.Walk(10.0f * dt);
                }
            }
            if (Util.IsKeyDown(Keys.Down))
            {
                if (_useFpsCamera)
                {
                    _cam.Walk(-10.0f * dt);
                }
                else
                {
                    _cam2.Walk(-10.0f * dt);
                }
            }

            if (Util.IsKeyDown(Keys.Left))
            {
                if (_useFpsCamera)
                {
                    _cam.Strafe(-10.0f * dt);
                }
                else
                {
                    _cam2.Strafe(-10.0f * dt);
                }
            }
            if (Util.IsKeyDown(Keys.Right))
            {
                if (_useFpsCamera)
                {
                    _cam.Strafe(10.0f * dt);
                }
                else
                {
                    _cam2.Strafe(10.0f * dt);
                }
            }
            if (Util.IsKeyDown(Keys.L))
            {
                _useFpsCamera = false;
            }
            if (Util.IsKeyDown(Keys.F))
            {
                _useFpsCamera = true;
            }

            if (Util.IsKeyDown(Keys.PageUp))
            {
                if (!_useFpsCamera)
                {
                    _cam2.Zoom(-10.0f * dt);
                }
                else
                {
                    _cam.Zoom(-dt);
                }
            }
            if (Util.IsKeyDown(Keys.PageDown))
            {
                if (!_useFpsCamera)
                {
                    _cam2.Zoom(10.0f * dt);
                }
                else
                {
                    _cam.Zoom(+dt);
                }
            }
        }
예제 #12
0
        public override void UpdateScene(float dt)
        {
            base.UpdateScene(dt);
            if (Util.IsKeyDown(Keys.Up))
            {
                _camera.Walk(10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Down))
            {
                _camera.Walk(-10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Left))
            {
                _camera.Strafe(-10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.Right))
            {
                _camera.Strafe(10.0f * dt);
            }
            if (Util.IsKeyDown(Keys.PageUp))
            {
                _camera.Zoom(-dt);
            }
            if (Util.IsKeyDown(Keys.PageDown))
            {
                _camera.Zoom(+dt);
            }

            _camera.UpdateViewMatrix();

            for (var index = 0; index < _ammo.Count; index++)
            {
                var shot = _ammo[index];
                shot.Particle.Integrate(dt);
                if (shot.Particle.Position.Y < 0.0f || shot.StartTime + 10.0f < Timer.TotalTime || shot.Particle.Position.Z > 200.0f)
                {
                    _ammo.Remove(shot);
                }
            }
            _fireDelay -= dt;
            if (Util.IsKeyDown(Keys.D1))
            {
                _currentShotType = ShotType.Pistol;
            }
            else if (Util.IsKeyDown(Keys.D2))
            {
                _currentShotType = ShotType.Artillery;
            }
            else if (Util.IsKeyDown(Keys.D3))
            {
                _currentShotType = ShotType.Fireball;
            }
            else if (Util.IsKeyDown(Keys.D4))
            {
                _currentShotType = ShotType.Laser;
            }
            else if (Util.IsKeyDown(Keys.Space) && _fireDelay < 0)
            {
                Fire();
                _fireDelay = 0.2f;
            }
        }