Esempio n. 1
0
        static IEnumerable <VmdBoneFrame> ReadBoneFrames(BinaryReader br)
        {
            var count = br.ReadUInt32();

            for (uint i = 0; i < count; i++)
            {
                yield return(VmdBoneFrame.Parse(br));
            }
        }
Esempio n. 2
0
        public static VmdBoneFrame Parse(BinaryReader br)
        {
            var rt = new VmdBoneFrame
            {
                Name       = VmdDocument.ReadVmdString(br, 15),
                FrameTime  = br.ReadUInt32(),
                Position   = new[] { br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), },
                Quaternion = new[] { br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), },
            };
            var ipBuffer = br.ReadBytes(64);
            var ipA      = ipBuffer.Take(4)
                           .Zip(ipBuffer.Skip(4).Take(4), (x, y) => new VmdInterpolationPoint(x, y));
            var ipB = ipBuffer.Skip(8)
                      .Take(4)
                      .Zip(ipBuffer.Skip(8 + 4).Take(4), (x, y) => new VmdInterpolationPoint(x, y));
            var ip = ipA.Zip(ipB, (a, b) => new[] { a, b }).ToArray();

            rt.XInterpolation        = ip[0];
            rt.YInterpolation        = ip[1];
            rt.ZInterpolation        = ip[2];
            rt.RotationInterpolation = ip[3];

            return(rt);
        }