public static FB.PosePlus.AniClip ReadAniClip(System.IO.Stream s)
{
var buf4 = new byte[4];
var clip = new FB.PosePlus.AniClip();
//name
int slen = s.ReadByte();
byte[] buf = new byte[slen];
s.Read(buf, 0, slen);
clip.name = System.Text.Encoding.UTF8.GetString(buf);
//fps
s.Read(buf4, 0, 4);
clip.fps = BitConverter.ToSingle(buf4, 0);
//loop
clip.loop = s.ReadByte() > 0;
{
//boneinfo
s.Read(buf4, 0, 4);
int bcount = BitConverter.ToInt32(buf4, 0);
for (int i = 0; i < bcount; i++)
{
slen = s.ReadByte();
buf = new byte[slen];
s.Read(buf, 0, slen);
string bone = System.Text.Encoding.UTF8.GetString(buf);
clip.boneinfo.Add(bone);
}
}
{
//subclips
s.Read(buf4, 0, 4);
int scount = BitConverter.ToInt32(buf4, 0);
for (int i = 0; i < scount; i++)
{
FB.PosePlus.SubClip sc = new FB.PosePlus.SubClip();
slen = s.ReadByte();
buf = new byte[slen];
s.Read(buf, 0, slen);
sc.name = System.Text.Encoding.UTF8.GetString(buf);
sc.loop = s.ReadByte() > 0;
s.Read(buf4, 0, 4);
sc.startframe = BitConverter.ToUInt32(buf4,0);
s.Read(buf4, 0, 4);
sc.endframe = BitConverter.ToUInt32(buf4,0);
clip.subclips.Add(sc);
}
}
{//frame
s.Read(buf4, 0, 4);
int fcount = BitConverter.ToInt32(buf4, 0);
for (int i = 0; i < fcount; i++)
{
FB.PosePlus.Frame f = new FB.PosePlus.Frame();
s.Read(buf4, 0, 4);
f.fid = BitConverter.ToInt32(buf4, 0);
f.key = s.ReadByte() > 0;
clip.frames.Add(f);
for (int ib = 0; ib < clip.boneinfo.Count; ib++)
{
clip.frames[i].bonesinfo.Add(new FB.PosePlus.PoseBoneMatrix());
clip.frames[i].bonesinfo[ib].Load(s,
i > 0 ? clip.frames[i - 1].bonesinfo[ib] : null);
}
}
}
return clip;
}
}