public static VmdMorphFrame Parse(BinaryReader br) { return(new VmdMorphFrame { Name = VmdDocument.ReadVmdString(br, 15), FrameTime = br.ReadUInt32(), Weight = br.ReadSingle(), }); }
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); }
public static VmdPropertyFrame Parse(BinaryReader br) { return(new VmdPropertyFrame { FrameTime = br.ReadUInt32(), IsVisible = br.ReadByte() != 0, IKEnabled = Enumerable.Range(0, br.ReadInt32()).Select(_ => Tuple.Create(VmdDocument.ReadVmdString(br, 20), br.ReadByte())).ToDictionary(_ => _.Item1, _ => _.Item2 != 0), }); }