Beispiel #1
0
 public int CompareTo(object obj)
 {
     if (obj is VmdNodeFrame)
     {
         VmdNodeFrame other = (VmdNodeFrame)obj;
         return(index.CompareTo(other.index));
     }
     else
     {
         throw new ArgumentException("Object is not a VmdFrame");
     }
 }
Beispiel #2
0
        VmdMat[] CreateMatrices(List <VmdNodeFrame> frames)
        {
            frames.Sort();

            VmdMat[] matrices = new VmdMat[frame_length];
            for (int i = 1; i < frames.Count; i++)
            {
                VmdNodeFrame fa = frames[i - 1];
                VmdNodeFrame fb = frames[i];
                for (int index = fa.index; index < fb.index; index++)
                {
                    float  ratio = ((float)(index - fa.index)) / ((float)(fb.index - fa.index));
                    VmdMat mat   = new VmdMat();
                    mat.rotation      = Quaternion.Slerp(fa.rotation, fb.rotation, ratio);
                    mat.translation.X = Lerp(fa.translation.X, fb.translation.X, ratio);
                    mat.translation.Y = Lerp(fa.translation.Y, fb.translation.Y, ratio);
                    mat.translation.Z = Lerp(fa.translation.Z, fb.translation.Z, ratio);
                    matrices[index]   = mat;
                }
                {
                    VmdMat mat = new VmdMat();
                    mat.rotation       = fb.rotation;
                    mat.translation    = fb.translation;
                    matrices[fb.index] = mat;
                }
            }
            {
                VmdNodeFrame last_frame = frames[frames.Count - 1];
                for (int index = last_frame.index; index < frame_length; index++)
                {
                    VmdMat mat = new VmdMat();
                    mat.rotation    = last_frame.rotation;
                    mat.translation = last_frame.translation;
                    matrices[index] = mat;
                }
            }
            return(matrices);
        }