internal void Update(PerspectiveCamera camera, float elapsed) { var step = elapsed * this.Velocity; var forward = camera.Forward; var backward = -forward; var up = camera.Up; var down = -up; var left = camera.Left; var right = -left; var movementVector = this.KeyboardInput.AsArray(InputState.Pressed, Keys.W, Keys.S, Keys.A, Keys.D, Keys.Space, Keys.C); var translation = Vector3.Zero; translation += movementVector[0] * forward; translation += movementVector[1] * backward; translation += movementVector[2] * left; translation += movementVector[3] * right; translation += movementVector[4] * up; translation += movementVector[5] * down; translation *= step; var rotation = Quaternion.Identity; if (this.MouseInput.Held(MouseButtons.Middle)) { var mouseMovement = new Vector2(this.MouseInput.Movement.X, this.MouseInput.Movement.Y) * this.RadiansPerPixel; rotation *= Quaternion.CreateFromAxisAngle(up, mouseMovement.X); rotation *= Quaternion.CreateFromAxisAngle(right, mouseMovement.Y); } if (this.MouseInput.ScrolledUp) { this.Velocity = Math.Min(this.Velocity + 1, MaxVelocity); } if (this.MouseInput.ScrolledDown) { this.Velocity = Math.Max(this.Velocity - 1, MinVelocity); } if (translation.LengthSquared() != 0 || rotation != Quaternion.Identity) { camera.Transform.MoveTo(camera.Position + translation); var lookAt = camera.Position + Vector3.Transform(camera.Transform.Forward, rotation); camera.Transform.FaceTargetConstrained(lookAt, Vector3.Up); camera.Update(); } if (this.KeyboardInput.Held(Keys.R)) { camera.Transform.MoveTo(Vector3.Backward * 10); camera.Transform.FaceTargetConstrained(Vector3.Zero, Vector3.Up); camera.Update(); } }
public void UpdateCamera() { NavigationCamera.Aspect = (float)mBoundControl.Width / (float)mBoundControl.Height; switch (CurrentAction) { case NavigationAction.Dragging: DragCamera(); break; case NavigationAction.Rotating: RotateCamera(); break; } NavigationCamera.Update(); }
internal override void Update(GameTime gameTime) { if (!Textbox.Visible) { World.Update(gameTime); } _camera.Update(); Textbox.Update(); _locationSign.Update(); if (!Textbox.Visible) { if (!StartMenu.Visible && GameboyInputs.StartPressed()) { StartMenu.Show(); } else { StartMenu.Update(); } } if (_locationSign.Visible && (Textbox.Visible || StartMenu.Visible || EncounterStarted)) { _locationSign.Close(); } World.IsPaused = Textbox.Visible || StartMenu.Visible || EncounterStarted; #if DEBUG if (GetComponent <GameDevCommon.Input.KeyboardHandler>().KeyPressed(Microsoft.Xna.Framework.Input.Keys.B)) { OnWildEncounter(new EncounterResult { Id = 152, Level = 5 }); } #endif _shader.Update(); _encounterAnimation?.Update(gameTime); }
private void OnUpdate() { node.AngleYInDegrees = x; x += 1.0f; //node.ScaleY = (float)(Math.Sin(x) * 5); x++; if (x == 360 && light != null) { x = 0; att++; if (att == 4) { att = 0; } if (att == 0) { light.Attenuation = Attenuation.None; } if (att == 1) { light.Attenuation = Attenuation.Inverse; } if (att == 2) { light.Attenuation = Attenuation.DualRadius; } if (att == 3) { light.Attenuation = Attenuation.InverseSquare; } } camera.Update(); // Update the scene scene.Update(); }