public bool Update(float frameDelta) { var ks = Keyboard.GetState(); var pressedKeys = ks.GetPressedKeys(); if (_mouseController.Update() == false && pressedKeys.Length == 0) { if (!_doUpdate) { return(false); } _doUpdate = false; } // MouseController is Y-up, convert to Up-up Matrix swapAxis = Matrix.CreateFromAxisAngle(Vector3.Cross(Vector3.UnitY, Up), Angle(Vector3.UnitY, Up)); Vector3 direction = Vector3.Transform(-_mouseController.Vector, swapAxis); if (pressedKeys.Length != 0) { Vector3 relDirection = frameDelta * direction; float flySpeed = ks.IsKeyDown(Keys.LeftShift) ? 15 : 5; if (ks.IsKeyDown(Keys.W)) { Eye += flySpeed * relDirection; } if (ks.IsKeyDown(Keys.S)) { Eye -= flySpeed * relDirection; } if (ks.IsKeyDown(Keys.A)) { Eye -= Vector3.Cross(relDirection, Up); } if (ks.IsKeyDown(Keys.D)) { Eye += Vector3.Cross(relDirection, Up); } } Target = Eye + (Eye - Target).Length() * direction; return(true); }
public bool Update(float frameDelta) { if (mouseController.Update() == false && input.KeysDown.Count == 0) { if (!doUpdate) { return(false); } doUpdate = false; } // MouseController is Y-up, convert to Up-up Matrix swapAxis = Matrix.RotationAxis(Vector3.Cross(Vector3.UnitY, Up), Angle(Vector3.UnitY, Up)); Vector3 direction = Vector3.TransformCoordinate(-mouseController.Vector, swapAxis); if (input.KeysDown.Count != 0) { Vector3 relDirection = frameDelta * direction; float flySpeed = input.KeysDown.Contains(Keys.ShiftKey) ? 45 : 15; if (input.KeysDown.Contains(Keys.W)) { Eye += flySpeed * relDirection; } if (input.KeysDown.Contains(Keys.S)) { Eye -= flySpeed * relDirection; } if (input.KeysDown.Contains(Keys.A)) { Eye += flySpeed * Vector3.Cross(relDirection, Up); } if (input.KeysDown.Contains(Keys.D)) { Eye -= flySpeed * Vector3.Cross(relDirection, Up); } } Target = Eye + (Eye - Target).Length() * direction; return(true); }
public bool Update(float frameDelta) { if (!_mouseController.Update() && _input.KeysDown.Count == 0) { if (!_doUpdate) { return(false); } _doUpdate = false; } Vector3 direction = Vector3.TransformCoordinate(-_mouseController.Vector, _yToUpTransform); if (_input.KeysDown.Count != 0) { Vector3 relDirection = frameDelta * direction; float flySpeed = _input.KeysDown.Contains(Keys.ShiftKey) ? 15 : 5; if (_input.KeysDown.Contains(Keys.W)) { _eye += flySpeed * relDirection; } if (_input.KeysDown.Contains(Keys.S)) { _eye -= flySpeed * relDirection; } if (_input.KeysDown.Contains(Keys.A)) { _eye += Vector3.Cross(relDirection, _up); } if (_input.KeysDown.Contains(Keys.D)) { _eye -= Vector3.Cross(relDirection, _up); } } _target = _eye + (_eye - _target).Length * direction; return(true); }
public bool Update(float frameDelta) { if (mouseController.Update() == false && input.KeysDown.Count == 0) { return(false); } Vector3 direction = Vector3.Normalize(-mouseController.Vector); if (input.KeysDown.Count != 0) { Vector3 relDirection = frameDelta * direction; float flySpeed = input.KeysDown.Contains(Keys.ShiftKey) ? 15 : 5; if (input.KeysDown.Contains(Keys.W)) { Eye += flySpeed * relDirection; } if (input.KeysDown.Contains(Keys.S)) { Eye -= flySpeed * relDirection; } if (input.KeysDown.Contains(Keys.A)) { Eye += Vector3.Cross(relDirection, Up); } if (input.KeysDown.Contains(Keys.D)) { Eye -= Vector3.Cross(relDirection, Up); } } Target = Eye + direction; Recalculate(); return(true); }