public void MouseMove(MouseEventInfo e, KeyEventInfo k, Vector2 previousLocation) { var position = e.FullPosition; var movement = new Vector2(position.X, position.Y) - previousLocation; if (e.RightButton == ButtonState.Pressed && !_camera.LockRotation) { if (k.KeyCtrl) { _camera._targetDistance *= 1 - movement.Y * -5 * 0.001f; } else { if (!k.IsKeyDown("y")) { _camera.RotationX += movement.Y * rotFactorX; } if (!k.IsKeyDown("x")) { _camera.RotationY += movement.X * rotFactorY; } //Reset direction _camera.Direction = Camera.FaceDirection.Any; } } if (e.LeftButton == ButtonState.Pressed) { Pan(movement.X * _camera.PanSpeed, movement.Y * _camera.PanSpeed); } _camera.UpdateMatrices(); }
public void MouseMove(MouseEventInfo e, KeyEventInfo k, Vector2 previousLocation) { var position = new Vector2(e.FullPosition.X, e.FullPosition.Y); var movement = position - previousLocation; if ((e.LeftButton == ButtonState.Pressed || e.RightButton == ButtonState.Pressed) && !_camera.LockRotation) { if (k.KeyCtrl) { float delta = ((float)movement.Y * -5 * Math.Min(0.01f, _camera.Depth / 500f)); Vector3 vec; vec.X = 0; vec.Y = 0; vec.Z = delta; _camera.TargetPosition += Vector3.Transform(_camera.InverseRotationMatrix, vec); } else { if (!k.IsKeyDown("y")) { _camera.RotationX += movement.Y * rotFactorX; } if (!k.IsKeyDown("x")) { _camera.RotationY += movement.X * rotFactorY; } //Reset direction _camera.Direction = Camera.FaceDirection.Any; } } if (e.LeftButton == ButtonState.Pressed) { } }
public void KeyPress(KeyEventInfo e) { float movement = 0.2f * _camera.KeyMoveSpeed; Vector3 vec = Vector3.Zero; if (e.KeyShift) { movement *= 2; } if (e.IsKeyDown(KeyController.View3D.MOVE_FORWARD)) { vec.Z -= movement; } if (e.IsKeyDown(KeyController.View3D.MOVE_BACK)) { vec.Z += movement; } if (e.IsKeyDown(KeyController.View3D.MOVE_LEFT)) { vec.X -= movement; } if (e.IsKeyDown(KeyController.View3D.MOVE_RIGHT)) { vec.X += movement; } if (e.IsKeyDown(KeyController.View3D.MOVE_DOWN)) { vec.Y -= movement; } else if (e.IsKeyDown(KeyController.View3D.MOVE_UP)) { vec.Y += movement; } float UP = 0; _camera.TargetPosition += Vector3.Transform(_camera.InverseRotationMatrix, vec) + Vector3.UnitY * UP; }