Esempio n. 1
0
        public FirstpersonCamera(Game game, IFollowable target=null)
            : base(game)
        {
            this.Target = target;
            this.start = this.real = null;

            time = 0;
            Enabled = false;

            UpdateProjection();
            game.GraphicsDevice.DeviceReset += delegate(object s, EventArgs a)
            {
                UpdateProjection();
            };
        }
Esempio n. 2
0
 public void HardSet(IFollowable target = null)
 {
     if (target != null)
     {
         start = new Followable(target);
         real = new Followable(target);
         this.time = FirstpersonCamera.Delay;
         this.Enabled = true;
     }
     else
     {
         time = 0;
         this.start = this.real = null;
         this.Enabled = false;
     }
 }
Esempio n. 3
0
        public override void Update(GameTime gameTime)
        {
            float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (time > 0)
            {
                this.real.Position = Vector3.Lerp(this.Target.Position, this.start.Position, time / FirstpersonCamera.Delay);
                this.real.Orientation = Quaternion.Slerp(this.Target.Orientation, this.start.Orientation, time / FirstpersonCamera.Delay);
                time -= dt;
            }
            else
            {
                time = 0;
                this.start = this.real = null;
                this.Enabled = false;
            }

            base.Update(gameTime);
        }