protected override void OnUpdateFrame(FrameEventArgs e) { double displacement = 500; base.OnUpdateFrame(e); Planet.Update(CamPos); if (Focused) { var Keyboard = OpenTK.Input.Keyboard.GetState(); Matrix4d rot = Matrix4d.CreateFromQuaternion(CamRot); Vector3d left = rot.Row0.Xyz; Vector3d up = rot.Row1.Xyz; Vector3d front = rot.Row2.Xyz;; if (Keyboard[OpenTK.Input.Key.ShiftLeft]) { displacement *= 100; } if (Keyboard[OpenTK.Input.Key.W]) { CamPos -= front * displacement; } if (Keyboard[OpenTK.Input.Key.S]) { CamPos += front * displacement; } if (Keyboard[OpenTK.Input.Key.D]) { CamPos += left * displacement; } if (Keyboard[OpenTK.Input.Key.A]) { CamPos -= left * displacement; } if (Keyboard[OpenTK.Input.Key.Q]) { CamPos -= up * displacement; } if (Keyboard[OpenTK.Input.Key.E]) { CamPos += up * displacement; } Vector3d NewCamRot = new Vector3d(); if (Keyboard[OpenTK.Input.Key.I]) { NewCamRot.X -= 0.1; } if (Keyboard[OpenTK.Input.Key.K]) { NewCamRot.X += 0.1; } if (Keyboard[OpenTK.Input.Key.J]) { NewCamRot.Y -= 0.1; } if (Keyboard[OpenTK.Input.Key.L]) { NewCamRot.Y += 0.1; } if (Keyboard[OpenTK.Input.Key.U]) { NewCamRot.Z -= 0.1; } if (Keyboard[OpenTK.Input.Key.O]) { NewCamRot.Z += 0.1; } if (Keyboard[OpenTK.Input.Key.Space]) { CamPos = DefaultPos; CamRot = Quaterniond.Identity; } if (Keyboard[OpenTK.Input.Key.R]) { Shader.Recompile(); } if (Keyboard[OpenTK.Input.Key.X]) { if (IsLine) { GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); IsLine = false; } else { GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); IsLine = true; } } if (Keyboard[OpenTK.Input.Key.Z]) { Integrator.Reset(); Planet.Layers[0].RegeneratePlanet(); } if (Keyboard[OpenTK.Input.Key.Escape]) { Exit(); } Frustum.SetCamDef(CamPos, CamPos + front, up); CamRot *= Quaterniond.FromMatrix(Matrix3d.CreateRotationX(NewCamRot.X) * Matrix3d.CreateRotationY(NewCamRot.Y) * Matrix3d.CreateRotationZ(NewCamRot.Z)); } }