Exemple #1
0
        protected override void _Update()
        {
            foreach (var ent in Game.EntityManager.Entities)
            {
                if (ent.EntityGameObject == null ||
                    ent.InterpolationMode == InterpolationMode.None)
                {
                    continue;
                }

                switch (ent.InterpolationMode)
                {
                case InterpolationMode.Frame:
                    var lerped = EntityFrame.Interpolate(_frameStates[ent].From, _frameStates[ent].To, (float)Game.Alpha);
                    ent.EntityGameObject.Position = lerped.Position;
                    ent.EntityGameObject.Rotation = lerped.Angles;
                    break;

                case InterpolationMode.Snap:
                    ent.EntityGameObject.Position = ent.Origin;
                    ent.EntityGameObject.Rotation = ent.Angles;
                    break;
                }
            }
        }
Exemple #2
0
        public static EntityFrame Interpolate(EntityFrame from, EntityFrame to, float alpha)
        {
            var result = new EntityFrame()
            {
                Position = Vector3.Lerp(from.Position, to.Position, alpha),
                Angles   = Quaternion.Slerp(Quaternion.Euler(from.Angles), Quaternion.Euler(to.Angles), alpha).eulerAngles
            };

            return(result);
        }
Exemple #3
0
 protected override void _Tick()
 {
     foreach (var ent in Game.EntityManager.Entities)
     {
         if (ent.EntityGameObject &&
             ent.InterpolationMode == InterpolationMode.Frame)
         {
             var newFromFrame = _frameStates[ent].To;
             var newToFrame   = new EntityFrame(ent);
             _frameStates[ent] = new FrameStates()
             {
                 From = newFromFrame,
                 To   = newToFrame
             };
         }
     }
 }