public M2BoneAnimator(Stormlib.MPQFile file, M2Info parent) { string AnimPath = parent.FileDirectory + parent.ModelName; M2Animation[] anims = new M2Animation[parent.Header.nAnimations]; file.Position = parent.Header.ofsAnimations; file.Read(anims); Stormlib.MPQFile[] AnimFiles = new Stormlib.MPQFile[parent.Header.nAnimations]; for (int i = 0; i < parent.Header.nAnimations; ++i) { string full = AnimPath + anims[i].AnimationID.ToString("D4") + "-" + anims[i].SubAnimationID.ToString("D2") + ".anim"; if (Stormlib.MPQFile.Exists(full)) { Console.WriteLine(full); AnimFiles[i] = new Stormlib.MPQFile(full); } } Animations.AddRange(anims); this.file = file; var bones = new M2Bone[parent.Header.nBones]; file.Position = parent.Header.ofsBones; file.Read(bones); foreach (var bone in bones) { M2AnimationBone ab = new M2AnimationBone(bone, this, file, parent.GlobalSequences, AnimFiles); Bones.Add(ab); ab.BoneIndex = Bones.Count - 1; } foreach (var bone in Bones) { bone.Init(); } }
public void Init() { ParentBone = Animator.GetBone(fileInfo.ParentBone); }