Lerp() public static method

public static Lerp ( PoseBoneMatrix left, PoseBoneMatrix right, float lerp ) : PoseBoneMatrix
left PoseBoneMatrix
right PoseBoneMatrix
lerp float
return PoseBoneMatrix
Esempio n. 1
0
        public static Frame Lerp(Frame left, Frame right, float lerp)
        {
            Frame f = new Frame();

            f.key = false;
            f.fid = left.fid;
            //f.bonesinfo = new PoseBoneMatrix[left.bonesinfo.Length];
            f.bonesinfo = new List <PoseBoneMatrix>(left.bonesinfo);
            for (int i = 0; i < f.bonesinfo.Count; i++)
            {
                f.bonesinfo[i] = PoseBoneMatrix.Lerp(left.bonesinfo[i], right.bonesinfo[i], lerp);
            }
            return(f);
        }
Esempio n. 2
0
        public static Frame Lerp(Frame left, Frame right, float lerp)
        {
            Frame f = new Frame();

            f.key = false;
            f.fid = left.fid;
            if (left.boneinfo != null && right.boneinfo != null && left.bonehash != right.bonehash)
            {
                Dictionary <string, int3> rebone = new Dictionary <string, int3>();

                for (int i = 0; i < left.boneinfo.Count; i++)
                {
                    string b  = left.boneinfo[i];
                    int3   it = new int3(rebone.Count, i, -1);
                    rebone[b] = it;
                }
                for (int i = 0; i < right.boneinfo.Count; i++)
                {
                    string b = right.boneinfo[i];
                    if (rebone.ContainsKey(b) == false)
                    {
                        int3 it = new int3(rebone.Count, -1, i);
                        rebone[b] = it;
                    }
                    else
                    {
                        rebone[b].boneright = i;
                    }
                }
                //Debug.LogWarning("bone mix:"+rebone.Count);

                f.boneinfo  = new List <string>(rebone.Keys);
                f.bonesinfo = new List <PoseBoneMatrix>(new PoseBoneMatrix[rebone.Count]);

                foreach (var v in rebone.Values)
                {
                    if (v.boneleft == -1)
                    {
                        f.bonesinfo[v.idnew] = right.bonesinfo[v.boneright].Clone() as PoseBoneMatrix;
                    }
                    else if (v.boneright == -1)
                    {
                        f.bonesinfo[v.idnew] = left.bonesinfo[v.boneleft].Clone() as PoseBoneMatrix;
                    }
                    else
                    {
                        //Debug.Log("bc:" + v.idnew + "/" + f.bonesinfo.Count);
                        //Debug.Log("lb:" + v.boneleft + "/" + left.bonesinfo.Count);
                        //Debug.Log("rb:" + v.boneright + "/" + right.bonesinfo.Count);
                        f.bonesinfo[v.idnew] = PoseBoneMatrix.Lerp(left.bonesinfo[v.boneleft], right.bonesinfo[v.boneright], lerp);
                    }
                }
            }
            else
            {            //single mix
                //f.bonesinfo = new PoseBoneMatrix[left.bonesinfo.Length];
                f.bonesinfo = new List <PoseBoneMatrix>(left.bonesinfo);
                if (left.boneinfo != null)
                {
                    f.boneinfo = left.boneinfo;
                    f.bonehash = left.bonehash;
                }
                for (int i = 0; i < f.bonesinfo.Count; i++)
                {
                    f.bonesinfo[i] = PoseBoneMatrix.Lerp(left.bonesinfo[i], right.bonesinfo[i], lerp);
                }
            }
            return(f);
        }