public BNFM_Bone(BnfmFile header, FileReader reader) { Name = header.GetString(reader, reader.ReadUInt32()); NameHash = reader.ReadUInt32(); Parent = header.GetString(reader, reader.ReadUInt32()); ParentNameHash = reader.ReadUInt32(); uint boneOffset = reader.ReadUInt32(); uint parentOffset = reader.ReadUInt32(); uint unknown1 = reader.ReadUInt32(); Index = reader.ReadInt32(); uint unknown2 = reader.ReadUInt32(); Position = new Vector3( reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); Scale = new Vector3( reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); reader.Seek(0x14); /* float unknown3 = reader.ReadSingle(); * uint padding1 = reader.ReadUInt32(); * uint padding2 = reader.ReadUInt32(); * uint unknown4 = reader.ReadUInt32(); * uint padding3 = reader.ReadUInt32();*/ InverseTransform = reader.ReadMatrix4(); Transform = reader.ReadMatrix4(); uint unknownOffset = reader.ReadUInt32(); uint unknownOffset2 = reader.ReadUInt32(); uint unknown5 = reader.ReadUInt32(); }
public void Load(System.IO.Stream stream) { Header = new BnfmFile(stream); var model = ToGeneric(); foreach (var node in model.CreateTreeHiearchy().Children) { AddChild(node); } this.Tag = this; this.Label = FileInfo.FileName; if (Header.SkeletalAnimations.Count > 0) { Tag = Header.SkeletalAnimations[0]; } }
public static BNFM_SkeletalAnimation ParseAnimations(BnfmFile header, FileReader reader) { BNFM_SkeletalAnimation anim = new BNFM_SkeletalAnimation(); anim.Name = "Animation0"; List <BNFM_Bone> Bones = new List <BNFM_Bone>(); //Base data uint numBoneInfos = reader.ReadUInt32(); uint numAnimInfos = reader.ReadUInt32(); //1 uint numBoneAnims = reader.ReadUInt32(); uint numTracks = reader.ReadUInt32(); uint unk = reader.ReadUInt32(); //0 uint numConstantTracks = reader.ReadUInt32(); uint numKeyFrames = reader.ReadUInt32(); uint numKeyedTracks = reader.ReadUInt32(); uint unk2 = reader.ReadUInt32(); //0 uint unk3 = reader.ReadUInt32(); //0 uint unk4 = reader.ReadUInt32(); //0 uint boneInfoOffset = reader.ReadUInt32(); uint animInfoOffset = reader.ReadUInt32(); uint boneAnimOffset = reader.ReadUInt32(); uint boneTrackOffset = reader.ReadUInt32(); uint unkOffset = reader.ReadUInt32(); uint constantKeysOffset = reader.ReadUInt32(); uint keyedFramesOffset = reader.ReadUInt32(); uint stringTableOffset = reader.ReadUInt32(); //The same structure as the model bone //This one blanks out some offsets (ie bone connected ones) //Also lacks matrices due to being regenerated on animation if (numBoneInfos > 0) { reader.SeekBegin(boneInfoOffset); for (int i = 0; i < numBoneInfos; i++) { Bones.Add(new BNFM_Bone(header, reader)); } } //This is for multiple animations? //Seems to be 1 so skip using this for now if (numAnimInfos > 0) { reader.SeekBegin(animInfoOffset); for (int i = 0; i < numAnimInfos; i++) { string name = header.GetString(reader, reader.ReadUInt32()); uint nameHash = reader.ReadUInt32(); uint trackOffset = reader.ReadUInt32(); uint numBones = reader.ReadUInt32(); uint unk5 = reader.ReadUInt32(); //1 uint unk6 = reader.ReadUInt32(); //0 uint frameCount = reader.ReadUInt32(); uint unk7 = reader.ReadUInt32(); //0 Console.WriteLine($"frameCount {frameCount}"); anim.FrameCount = frameCount; if (name != string.Empty) { anim.Name = name; } } } for (int i = 0; i < numBoneAnims; i++) { reader.SeekBegin(boneAnimOffset + (i * 0x54)); uint boneOffset = reader.ReadUInt32(); //Bones have 10 tracks for SRT uint[] numKeysPerTrack = reader.ReadUInt32s(10); uint[] trackOffsets = reader.ReadUInt32s(10); var group = new STBoneAnimGroup(); group.UseQuaternion = true; anim.AnimGroups.Add(group); using (reader.TemporarySeek(boneOffset, System.IO.SeekOrigin.Begin)) { group.Name = header.GetString(reader, reader.ReadUInt32()); } LoadTrackList(trackOffsets, group, reader); } return(anim); }
public BNFM_TextureSlot(BnfmFile header, FileReader reader) { Name = header.GetString(reader, reader.ReadUInt32()); NameHash = reader.ReadUInt32(); }