public void OnUpdate() { FrameDelta = Clock.GetFrameDelta(); _frameAccumulator += FrameDelta; if (_frameAccumulator >= 1.0f) { FramesPerSecond = Clock.FrameCount / _frameAccumulator; SetInfoText(); _frameAccumulator = 0.0f; Clock.Reset(); } if (_updateReceiver != null) { _updateReceiver.Update(this); } HandleKeyboardInput(); _bodyPicker.Update(); Clock.StartPhysics(); int substepsPassed = Simulation.World.StepSimulation(FrameDelta); Clock.StopPhysics(substepsPassed); if (FreeLook.Update(FrameDelta)) { Graphics.UpdateView(); } Input.ClearKeyCache(); }
public virtual void OnHandleInput() { if (Input.KeysPressed.Count != 0) { switch (Input.KeysPressed[0]) { case Keys.Escape: case Keys.Q: Graphics.Form.Close(); return; case Keys.F1: MessageBox.Show( "Move using WASD + shift\n" + "Left click - point camera\n" + "Right click - pick up an object using a Point2PointConstraint\n" + "Right click + shift - pick up an object using a fixed Generic6DofConstraint\n" + "Space - shoot box\n" + "Q - quit\n" + Graphics.InfoText, "Help"); // Key release won't be captured Input.KeysDown.Remove(Keys.F1); break; case Keys.F3: IsDebugDrawEnabled = !IsDebugDrawEnabled; break; case Keys.F8: Input.ClearKeyCache(); GraphicsLibraryManager.ExitWithReload = true; Graphics.Form.Close(); break; case Keys.F11: Graphics.IsFullScreen = !Graphics.IsFullScreen; break; case (Keys.Control | Keys.F): const int maxSerializeBufferSize = 1024 * 1024 * 5; using (var serializer = new DefaultSerializer(maxSerializeBufferSize)) { World.Serialize(serializer); byte[] dataBytes = new byte[serializer.CurrentBufferSize]; System.Runtime.InteropServices.Marshal.Copy(serializer.BufferPointer, dataBytes, 0, dataBytes.Length); using (var file = new System.IO.FileStream("world.bullet", System.IO.FileMode.Create)) { file.Write(dataBytes, 0, dataBytes.Length); } } break; case Keys.G: //shadowsEnabled = !shadowsEnabled; break; case Keys.Space: ShootBox(Freelook.Eye, GetCameraRayTo()); break; case Keys.Return: ClientResetScene(); break; } } _bodyPicker.Update(); }