Beispiel #1
0
        public void InvalidateFrame(int frame)
        {
            if (frame <= 0)
            {
                throw new Exception("Cannot invalidate frame 0 for camera");
            }
            if (frame < _frames.Count)
            {
                _frames.RemoveRange(
                    frame,
                    _frames.Count - frame);
                if (_prevframe <= frame)
                {
                    _prevframe = -1;
                }
            }
            var cachepos = (frame / cacherate);

            if (frame % cacherate != 0)
            {
                cachepos++;
            }

            if (cachepos < _framecache.Count)
            {
                _framecache.RemoveRange(cachepos, _framecache.Count - cachepos);
            }
            if (frame == 1)
            {
                Rider firstframe = _timeline.GetFrame(0);
                var   entry      = new CameraEntry(firstframe.CalculateCenter());
                _frames[0]     = entry;
                _framecache[0] = Vector2d.Zero;
            }
        }
Beispiel #2
0
        private CameraEntry GetNext(CameraEntry prev, Rider rider)
        {
            // todo i really wish this cared about angles
            // it shouldnt center if the next step is going towards the center
            // of the previous
            // something like that
            var center   = rider.CalculateCenter();
            var prevoffs = prev.Position;
            var offset   = (center - prev.Position);

            offset = Vector2d.Lerp(prevoffs, center, 0.15);
            return(new CameraEntry(center, offset, rider.CalculateMomentum()));
        }
 public override void InvalidateFrame(int frame)
 {
     if (frame <= 0)
     {
         throw new Exception("Cannot invalidate frame 0 for camera");
     }
     if (frame < _frames.Count)
     {
         _frames.RemoveRange(
             frame,
             _frames.Count - frame);
         if (_cacheframe <= frame)
         {
             _cacheframe = -1;
         }
     }
     if (frame == 1)
     {
         Rider firstframe = _timeline.GetFrame(0);
         var   entry      = new CameraEntry(firstframe.CalculateCenter());
         _frames[0] = entry;
     }
 }
 public CameraBoundingBox(Rider rider)
 {
     RiderPosition = rider.CalculateCenter();
 }