public static void Update(GameTime gameTime, IEditorCamera camera) { mouseLastState = mouseState; keyboardLastState = keyboardState; mouseState = Mouse.GetState(); keyboardState = Keyboard.GetState(); KeyboardEvents(gameTime, camera); MouseEvents(camera); }
protected override void Initialize() { // TODO: Add your initialization logic here _imGuiRenderer = new ImGuiRenderer(this); _imGuiRenderer.RebuildFontAtlas(); SetupDarkStyle(); Camera = new PerspectiveCamera(new Vector3(-10, 5, -15), Vector3.Zero); _renderer = new Renderer.Renderer(Camera); CurrentFolder = AppContext.BaseDirectory; base.Initialize(); }
private static void KeyboardEvents(GameTime gameTime, IEditorCamera perspectiveCamera) { //if (DebugScreen.ConsoleOpen) return; float delta = (float)gameTime.ElapsedGameTime.TotalMilliseconds * 60 / 1000; Vector3 direction = perspectiveCamera.Forward; direction.Normalize(); Vector3 normal = Vector3.Cross(direction, perspectiveCamera.Up); float amount = 0.8f * delta; float amountNormal = 0.2f * delta; if (keyboardState.IsKeyDown(Keys.W)) { perspectiveCamera.Transform.Position += direction * amount; } if (keyboardState.IsKeyDown(Keys.S)) { perspectiveCamera.Transform.Position -= direction * amount; } if (keyboardState.IsKeyDown(Keys.D)) { perspectiveCamera.Transform.Position += normal * amountNormal; } if (keyboardState.IsKeyDown(Keys.A)) { perspectiveCamera.Transform.Position -= normal * amountNormal; } }
private static void MouseEvents(IEditorCamera perspectiveCamera) { float mouseAmount = 0.01f; Vector3 direction = perspectiveCamera.Forward; direction.Normalize(); Vector3 normal = Vector3.Cross(direction, perspectiveCamera.Up); if (mouseState.RightButton == ButtonState.Pressed) { float y = mouseState.Y - mouseLastState.Y; float x = mouseState.X - mouseLastState.X; y *= GameSettings.g_screenheight / 800.0f; x *= GameSettings.g_screenwidth / 1280.0f; perspectiveCamera.Forward += x * mouseAmount * normal; perspectiveCamera.Forward -= y * mouseAmount * perspectiveCamera.Up; perspectiveCamera.Forward.Normalize(); } }
public Renderer(IEditorCamera perspectiveCamera) { _perspectiveCamera = perspectiveCamera; }