public override uint Update(GL_ControlBase control, float deltaTime) { if (control.MainDrawable == null || !control.Focused || WinInput.Keyboard.Modifiers != WinInput.ModifierKeys.None) { return(0); } float speed = deltaTime * 0.01f; Vector3 vec = Vector3.Zero; if (WinInput.Keyboard.IsKeyDown(WinInput.Key.W)) { vec.Z -= speed; } if (WinInput.Keyboard.IsKeyDown(WinInput.Key.A)) { vec.X -= speed; } if (WinInput.Keyboard.IsKeyDown(WinInput.Key.S)) { vec.Z += speed; } if (WinInput.Keyboard.IsKeyDown(WinInput.Key.D)) { vec.X += speed; } Point mousePos = control.GetMousePos(); Vector2 normCoords = control.NormMouseCoords(mousePos.X, mousePos.Y); vec.X += (-normCoords.X * vec.Z) * control.FactorX; vec.Y += (normCoords.Y * vec.Z) * control.FactorY; float up = 0; if (WinInput.Keyboard.IsKeyDown(WinInput.Key.Q)) { up -= speed; } if (WinInput.Keyboard.IsKeyDown(WinInput.Key.E)) { up += speed; } if (vec == Vector3.Zero && up == 0) { return(0); } control.CameraTarget += Vector3.Transform(control.InvertedRotationMatrix, vec) + Vector3.UnitY * up; (control.MainDrawable as EditorDrawables.EditorSceneBase)?.CurrentAction?.UpdateMousePos(mousePos); (control.MainDrawable as EditorDrawables.EditorSceneBase)?.SelectionTransformAction.UpdateMousePos(mousePos); return(UPDATE_CAMERA); }
public override uint MouseWheel(MouseEventArgs e, GL_ControlBase control) { depth = control.PickingDepth; float delta = (e.Delta * Math.Min(WinInput.Keyboard.IsKeyDown(WinInput.Key.LeftShift) ? 0.04f : 0.01f, depth / 500f)); Vector3 vec; Vector2 normCoords = control.NormMouseCoords(e.Location.X, e.Location.Y); vec.X = (-normCoords.X * delta) * control.FactorX; vec.Y = (normCoords.Y * delta) * control.FactorY; vec.Z = delta; control.CameraTarget -= Vector3.Transform(control.InvertedRotationMatrix, vec); return(UPDATE_CAMERA); }
public override uint MouseWheel(MouseEventArgs e, GL_ControlBase control) { if (WinInput.Keyboard.IsKeyDown(WinInput.Key.LeftCtrl)) { depth = control.PickingDepth; float delta = e.Delta * Math.Min(0.01f, depth / 500f); Vector2 normCoords = control.NormMouseCoords(e.Location.X, e.Location.Y); Vector3 vec = control.InvertedRotationMatrix.Row0 * -normCoords.X * delta * control.FactorX + control.InvertedRotationMatrix.Row1 * normCoords.Y * delta * control.FactorY + control.InvertedRotationMatrix.Row2 * delta; control.CameraTarget -= vec; } else { control.CameraDistance *= 1f - e.Delta * 0.001f; } return(UPDATE_CAMERA); }