public App() { _gridOn = false; _gpressed = false; PrintScreen = false; mode_ = Plain.DataMode.Extrapolator0; COLOR_MODE_ = Plain.ColorMode.GreyScale; mouseRightDown = false; mouseLeftDown = false; manualSteering = false; rotation = 0.0f; _RenderMiniAxis = true; BackgroundColour = new Color4(1.0f, 1.0f, 1.0f, 1.0f); Focus = false; CoordFix = new Point(0, 0); }
private bool HandleInput(float frameTime) { int mouseX, mouseY, mouseZ; float posX, posY, posZ, rotX, rotY, rotZ; if (!_Input.Frame()) { return(false); } if (!Focus) { _Input.ResetTranslation(); return(true); } if (_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.Escape)) { return(false); } mouseZ = _Input.MouseMoveZ(); if (mouseZ != 0) { _Position.IncRadious(mouseZ); } if (_Input.IsLeftMouseButtonDown()) { _Position.OrbitCamera(_Input.MouseMoveX(), _Input.MouseMoveY()); _Position.GetPosition(out posX, out posY, out posZ); if (mouseLeftDown == false) { mouseLeftDown = true; _Input.GetMouseLocation(out mouseX, out mouseY); mouseX -= CoordFix.X; mouseY -= CoordFix.Y; CpuUsage_.SetText(_Direct3D, mouseX.ToString() + "," + mouseY.ToString() + "........"); foreach (var button in ButtonList) { button.Click(mouseX, mouseY); } } } else { _Input.ResetTranslation(); mouseLeftDown = false; } if (_Input.IsRightMouseButtonDown()) { if (mouseRightDown == false) { _Input.GetMouseLocation(out mouseX, out mouseY); mouseX -= CoordFix.X; mouseY -= CoordFix.Y; CpuUsage_.SetText(_Direct3D, mouseX.ToString() + "," + mouseY.ToString() + "........"); TestIntersection(mouseX, mouseY); mouseRightDown = true; } } else { mouseRightDown = false; } _Position.SetFrameTime(frameTime); if (manualSteering) { _Position.TurnLeft(_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.Left)); _Position.TurnRight(_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.Right)); _Position.MoveForward(_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.W)); _Position.MoveBackward(_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.S)); _Position.MoveUpward(_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.E)); _Position.MoveLeft(_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.A)); _Position.MoveRight(_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.D)); _Position.MoveDownward(_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.Q)); _Position.LookUpward(_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.Up)); _Position.LookDownward(_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.Down)); } if (_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.G)) { if (!_gpressed) { _gpressed = true; graph.terrain.RenderGrid = !graph.terrain.RenderGrid; } } else { _gpressed = false; } if (_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.PageUp)) { //_Terrain.Plot.ChangeGridSize(1); //GridDensity_.SetText("Wielkosc siatki: " + _Terrain.Plot.GridDensity.ToString()); todo: } if (_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.PageDown)) { //_Terrain.Plot.ChangeGridSize(-1); //GridDensity_.SetText("Wielkosc siatki: " + _Terrain.Plot.GridDensity.ToString()); todo: } #region TerrainColour if (_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.Z) && COLOR_MODE_ != Plain.ColorMode.GreyScale) { graph.terrain.Plot.ChangeColorMode(Plain.ColorMode.GreyScale); COLOR_MODE_ = Plain.ColorMode.GreyScale; } if (_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.X) && COLOR_MODE_ != Plain.ColorMode.HighContrast) { graph.terrain.Plot.ChangeColorMode(Plain.ColorMode.HighContrast); COLOR_MODE_ = Plain.ColorMode.HighContrast; } if (_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.C) && COLOR_MODE_ != Plain.ColorMode.HCGSHybrid) { graph.terrain.Plot.ChangeColorMode(Plain.ColorMode.HCGSHybrid); COLOR_MODE_ = Plain.ColorMode.HCGSHybrid; } if (_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.V) && COLOR_MODE_ != Plain.ColorMode.FullBit) { graph.terrain.Plot.ChangeColorMode(Plain.ColorMode.FullBit); COLOR_MODE_ = Plain.ColorMode.FullBit; } if (_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.B) && COLOR_MODE_ != Plain.ColorMode.FullBitEyeCorrect) { graph.terrain.Plot.ChangeColorMode(Plain.ColorMode.FullBitEyeCorrect); COLOR_MODE_ = Plain.ColorMode.FullBitEyeCorrect; } #endregion #region Sensivity if (_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.Minus)) { graph.terrain.Sensivity += -0.05f; SensivityZ_.SetText(_Direct3D, "Czulosc Z: " + graph.terrain.Sensivity.ToString()); } if (_Input._keyboardState.IsPressed(SharpDX.DirectInput.Key.Add)) { graph.terrain.Sensivity += 0.05f; SensivityZ_.SetText(_Direct3D, "Czulosc Z: " + graph.terrain.Sensivity.ToString()); } #endregion _Position.GetPosition(out posX, out posY, out posZ); _Position.GetRotation(out rotX, out rotY, out rotZ); _Camera.Position = new Vector3(posX, posY, posZ); _Camera.Rotation = new Vector3(rotX, rotY, rotZ); return(true); }