protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); _font = Content.Load <SpriteFont>("MgGenFont"); _dot = CreateDotTexture(GraphicsDevice, Color.White); _camera = new WaypointCamera(GraphicsDevice, _spriteBatch, _dot, new Vector3(2, 2, 10), new Vector3(0, 0, 0), Vector3.UnitY, 0.1f, 10000f, 1f, true, false); _camera.TransformCamera(_camera.World.Translation, _testTarget, _camera.World.Up); _camera.Up = Vector3.Forward; _camera.WayPointCycleDurationInTotalSeconds = 20f; _camera.MovementSpeedPerSecond = 3f; _camera.SetWayPoints(_wayPoints, true, 100); cspline = new Curve_HermiteSpline(_wayPoints, true, 0.5f); }
protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } if (IsPressedWithDelay(Keys.R, gameTime)) { var elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds; t += elapsed / 10f; if (t > 1f) { t = 0; } } if (IsPressedWithDelay(Keys.T, gameTime)) { var elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds; t -= elapsed / 10f; if (t < 0f) { t = 1f; } } if (IsPressedWithDelay(Keys.Tab, gameTime)) { selectedCp += 1; if (selectedCp > 3) { selectedCp = 0; } } bool redoCurve = false; if (IsPressedWithDelay(Keys.Up, gameTime)) { weight += .1f; if (weight > 2f) { weight = 0f; } redoCurve = true; } if (IsPressedWithDelay(Keys.Down, gameTime)) { weight -= .1f; if (weight < -1f) { weight = 2f; } redoCurve = true; } ms = Mouse.GetState(); if (ms.LeftButton == ButtonState.Pressed) { _wayPoints[selectedCp] = new Vector3(ms.Position.X, ms.Position.Y, 0); redoCurve = true; } if (redoCurve) { cspline = new Curve_HermiteSpline(_wayPoints, true, weight); } msg = $"Hermite " + $"\n" + $"weight " + weight + $"\n" + $"selectedCp " + selectedCp ; if (Keyboard.GetState().IsKeyDown(Keys.Space)) { _useDemoWaypoints = false; } if (Keyboard.GetState().IsKeyDown(Keys.Tab)) { _useDemoWaypoints = true; } _camera.Update(_testTarget, _useDemoWaypoints, gameTime); base.Update(gameTime); }