Lerp() public static méthode

public static Lerp ( Frame left, Frame right, float lerp ) : Frame
left Frame
right Frame
lerp float
Résultat Frame
Exemple #1
0
        public void SetPoseLerp(Frame src, Frame dest, float lerp)
        {
            _checkBone();

            var frame = Frame.Lerp(src, dest, lerp);

            SetPose(frame);
        }
Exemple #2
0
        void RecCrossFrame()
        {
            if (this._crossTimer >= 0 && crossFrame != null)
            {
                Frame f = new Frame();

                float l = 1.0f - _crossTimer / _crossTimerTotal;
                crossFrame = Frame.Lerp(crossFrame, lastClip.frames[lastframe], l);
            }
            else
            {
                crossFrame = lastClip.frames[lastframe];
            }
        }
        public void ResetLerpFrameSegment(int frame)
        {
            //搜索开始与结束帧
            if (frames[frame].key)
            {
                return;
            }
            if (frame <= 0 || frame >= frames.Count - 1)
            {
                return;
            }
            int ibegin = frame;

            for (; ibegin >= 0; ibegin--)
            {
                if (frames[ibegin].key)
                {
                    break;
                }
            }
            if (ibegin == frame)
            {
                return;
            }
            int iend = frame;

            for (; iend < frames.Count; iend++)
            {
                if (frames[iend].key)
                {
                    break;
                }
            }
            if (iend == frame)
            {
                return;
            }
            //找到最近两个关键帧之间 插值
            for (int i = ibegin + 1; i < iend; i++)
            {
                float d1   = (i - ibegin);
                float d2   = (iend - i);
                float lerp = d1 / (d1 + d2);
                frames[i] = Frame.Lerp(frames[ibegin], frames[iend], lerp);
                //frames[i].lerp = lerp;
                frames[i].fid = i;
            }
        }
Exemple #4
0
        public void CalcLerpFrameOne(int frame)
        {
            //搜索开始与结束帧
            if (frames[frame].key)
            {
                return;
            }
            if (frame <= 0 || frame >= frames.Count - 1)
            {
                return;
            }
            int ibegin = frame;

            for (; ibegin >= 0; ibegin--)
            {
                if (frames[ibegin].key)
                {
                    break;
                }
            }
            if (ibegin == frame)
            {
                return;
            }
            int iend = frame;

            for (; iend < frames.Count; iend++)
            {
                if (frames[iend].key)
                {
                    break;
                }
            }
            if (iend == frame)
            {
                return;
            }

            int i = frame;
            {
                //float d1 = (i - ibegin);
                //float d2 = (iend - i);
                float lerp = frames[i].lerp;
                frames[i]      = Frame.Lerp(frames[ibegin], frames[iend], lerp);
                frames[i].lerp = lerp;
                frames[i].fid  = i;
            }
        }
Exemple #5
0
 public void ResetLerpFrameAll()
 {
     for (int ibegin = 0; ibegin < frames.Count - 1; ibegin++)
     {
         if (frames[ibegin].key)
         {
             if (frames[ibegin + 1].key)
             {
                 //下一帧就是关键帧,没法玩,坑了
                 continue;
             }
             for (int iend = ibegin + 2; iend < frames.Count; iend++)
             {
                 if (frames[iend].key)
                 {
                     //发现一个需要计算的
                     //Debug.LogWarning("find need calc:" + ibegin + "-" + iend);
                     for (int i = ibegin + 1; i < iend; i++)
                     {
                         float d1   = (i - ibegin);
                         float d2   = (iend - i);
                         float lerp = d1 / (d1 + d2);
                         frames[i]      = Frame.Lerp(frames[ibegin], frames[iend], lerp);
                         frames[i].lerp = lerp;
                         frames[i].fid  = i;
                     }
                     break;
                 }
             }
         }
     }
     for (int i = 0; i < frames.Count; i++)
     {
         if (i == 0 && !this.loop)
         {
             continue;
         }
         int ilast = i - 1;
         if (ilast < 0)
         {
             ilast = frames.Count - 1;
         }
         frames[i].LinkLoop(frames[ilast]);
     }
 }
Exemple #6
0
        void RecCrossFrame()
        {
            if (this._crossTimer >= 0 && crossFrame != null)
            {
                //Frame f = new Frame();

                float l = 1.0f - _crossTimer / _crossTimerTotal;
                lastClip.frames[lastframe].boneinfo = lastClip.boneinfo;
                lastClip.frames[lastframe].bonehash = lastClip.bonehash;
                crossFrame = Frame.Lerp(crossFrame, lastClip.frames[lastframe], l);
            }
            else
            {
                crossFrame          = lastClip.frames[lastframe];
                crossFrame.boneinfo = lastClip.boneinfo;
                crossFrame.bonehash = lastClip.bonehash;
            }
        }