public override void Deserialize(BSReader reader) { base.Deserialize(reader); this.UnkUInt06 = reader.ReadUInt32(); this.UnkUInt07 = reader.ReadUInt32(); this.UnkUInt08 = reader.ReadUInt32(); this.UnkUInt09 = reader.ReadUInt32(); this.UnkUInt10 = reader.ReadUInt32(); this.Matrix = reader.ReadMatrix4x4(); }
public void Load(Stream stream) { // Read file structure using (var reader = new BSReader(stream)) { // Signature var signature = reader.ReadString(12); if (signature != LatestSignature) { // TODO: Migrate old version to current if possible. throw new NotSupportedException($"Migration from '{signature}' not supported."); } // File offsets (Material, Mesh, Animation, Skeleton, MeshGroup, AnimationGroup, ModPalette, Collision) reader.SkipRead(32); // Unknown Flags Flag01 = reader.ReadInt32(); Flag02 = reader.ReadInt32(); Flag03 = reader.ReadInt32(); Flag04 = reader.ReadInt32(); Flag05 = reader.ReadInt32(); // Object info this.ObjectInfo = reader.Deserialize <ObjectGeneralInfo>(); // Reserved UnkBuffer = reader.ReadBytes(40); // FileOffset.Collision CollisionMesh = reader.ReadString(); CollisionBox01 = reader.ReadBoundingBoxF(); CollisionBox02 = reader.ReadBoundingBoxF(); UseCollisionMatrix = reader.ReadUInt32() != 0; if (UseCollisionMatrix) { CollisionMatrix = reader.ReadMatrix4x4(); } // FileOffset.Material var count = reader.ReadInt32(); MaterialSet = new List <PrimMtrlSet>(count); for (int i = 0; i < count; i++) { MaterialSet.Add(reader.Deserialize <PrimMtrlSet>()); } // FileOffset.Mesh count = reader.ReadInt32(); MeshSet = new List <PrimMesh>(count); for (int i = 0; i < count; i++) { MeshSet.Add(reader.DeserializeParameterized <PrimMesh>(this.Flag01)); } // FileOffset.Animation AnimationTypeVersion = reader.ReadUInt32(); AnimationTypeUserDefine = reader.ReadUInt32(); count = reader.ReadInt32(); AnimationSet = new List <PrimAnimation>(count); for (int i = 0; i < count; i++) { AnimationSet.Add(reader.Deserialize <PrimAnimation>()); } // FileOffset.Skeleton HasSkeleton = reader.ReadUInt32() != 0; if (HasSkeleton) { SkeletonPath = reader.ReadString(); AttachmentBone = reader.ReadString(); } // FileOffset.MeshGroup count = reader.ReadInt32(); MeshGroups = new List <PrimMeshGroup>(count); for (int i = 0; i < count; i++) { this.MeshGroups.Add(reader.Deserialize <PrimMeshGroup>()); } // FileOffset.AnimationGroup count = reader.ReadInt32(); AnimationGroups = new List <PrimAniGroup>(count); for (int i = 0; i < count; i++) { this.AnimationGroups.Add(reader.Deserialize <PrimAniGroup>()); } // FileOffset.ModPalette count = reader.ReadInt32(); SystemModSets = new List <ModDataSet>(); for (int i = 0; i < count; i++) { SystemModSets.Add(reader.Deserialize <ModDataSet>()); } count = reader.ReadInt32(); AniModSets = new List <ModDataSet>(); for (int i = 0; i < count; i++) { AniModSets.Add(reader.Deserialize <ModDataSet>()); } // ResAttachable ResourceAttachable = reader.DeserializeParameterized <ResAttachable>(ObjectInfo.Type); } }