protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } if (Keyboard.GetState().IsKeyDown(Keys.R)) { var elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds; t += elapsed / 10f; if (t > 1f) { t = 0; } } if (Keyboard.GetState().IsKeyDown(Keys.T)) { var elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds; t -= elapsed / 10f; if (t < 0f) { t = 1f; } } if (Keyboard.GetState().IsKeyDown(Keys.Up)) { weight += .01f; if (weight > 2f) { weight = 0f; } cspline = new Curve_CatMullSpline(_wayPoints, true, weight); } ms = Mouse.GetState(); if (ms.LeftButton == ButtonState.Pressed) { _wayPoints[0] = new Vector3(ms.Position.X, ms.Position.Y, 0); cspline = new Curve_CatMullSpline(_wayPoints, true, weight); } msg = $"weight " + weight; if (Keyboard.GetState().IsKeyDown(Keys.Space)) { _useDemoWaypoints = false; } if (Keyboard.GetState().IsKeyDown(Keys.Tab)) { _useDemoWaypoints = true; } _camera.Update(_testTarget, _useDemoWaypoints, gameTime); base.Update(gameTime); }
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 CatMullSpline(_wayPoints); cspline = new Curve_CatMullSpline(_wayPoints, true, 0.5f); }