public bool Read(BundleEntry entry, ILoader loader = null) { Clear(); Entry = entry; MemoryStream ms = entry.MakeStream(); BinaryReader2 br = new BinaryReader2(ms); br.BigEndian = entry.Console; Unknown1 = br.ReadInt32(); int instanceCount = br.ReadInt32(); Unknown2 = br.ReadInt32(); Unknown3 = br.ReadInt32(); for (int i = 0; i < instanceCount; i++) { ModelInstance instance = ModelInstance.Read(br); instance.ModelEntryID = entry.GetDependencies()[i].EntryID; Instances.Add(instance); } RemainingBytes = br.ReadBytes((int)(br.BaseStream.Length - br.BaseStream.Position)); br.Close(); ms.Close(); //_scene = MakeScene(loader); return(true); }
public bool Read(BundleEntry entry, ILoader loader = null) { Clear(); MemoryStream ms = entry.MakeStream(); BinaryReader2 br = new BinaryReader2(ms); br.BigEndian = entry.Console; Unknown1 = br.ReadInt32(); int count = br.ReadInt32(); Unknown2 = br.ReadInt32(); for (int i = 0; i < count - 1; i++) { uint id = br.ReadUInt32(); string txt = br.ReadCStringPtr(); Data.Add(id, txt); } br.Close(); ms.Close(); //result.Write(entry); return(true); }
public static MaterialEntry Read(BundleEntry entry) { MaterialEntry result = new MaterialEntry(); List <BundleDependency> dependencies = entry.GetDependencies(); foreach (BundleDependency dependency in dependencies) { ulong id = dependency.EntryID; //DebugTimer t = DebugTimer.Start("LoadDep"); BundleEntry descEntry1 = entry.Archive.GetEntryByID(id); if (descEntry1 == null) { string file = BundleCache.GetFileByEntryID(id); if (!string.IsNullOrEmpty(file)) { BundleArchive archive = BundleArchive.Read(file); descEntry1 = archive.GetEntryByID(id); } } //t.StopLog(); //DebugTimer t2 = DebugTimer.Start("LoadTextureState"); if (descEntry1 != null && descEntry1.Type == EntryType.TextureState) { TextureState state = TextureState.Read(descEntry1); result.TextureStates.Add(state); } //t2.StopLog(); } MemoryStream ms = entry.MakeStream(); BinaryReader2 br = new BinaryReader2(ms); br.BigEndian = entry.Console; // TODO: Read Material br.Close(); ms.Close(); result.Color = Color.White; if (result.TextureStates.Count > 0) { result.DiffuseMap = result.TextureStates[0].Texture; } if (result.TextureStates.Count > 1) { result.NormalMap = result.TextureStates[1].Texture; } if (result.TextureStates.Count > 2) { result.SpecularMap = result.TextureStates[2].Texture; } return(result); }
public bool Read(BundleEntry entry, ILoader loader = null) { Clear(); MemoryStream ms = entry.MakeStream(); BinaryReader2 br = new BinaryReader2(ms); br.BigEndian = entry.Console; Unknown1 = br.ReadInt16(); Unknown2 = br.ReadInt16(); FileSize = br.ReadInt32(); TrackCount = br.ReadInt32(); Unknown3 = br.ReadInt32(); PointerOffset = br.ReadInt32(); Unknown4 = br.ReadInt16(); Unknown5 = br.ReadInt16(); Unknown6 = br.ReadByte(); Unknown7 = br.ReadByte(); Unknown8 = br.ReadInt16(); Unknown9 = br.ReadInt16(); Unknown10 = br.ReadInt16(); Section1Offset = br.ReadUInt32(); Section2Offset = br.ReadUInt32(); Section3Offset = br.ReadUInt32(); Section4Offset = br.ReadUInt32(); Section5Offset = br.ReadUInt32(); Section6Offset = br.ReadUInt32(); Section7Offset = br.ReadUInt32(); Section8Offset = br.ReadUInt32(); Unknown11 = br.ReadByte(); Unknown12 = br.ReadByte(); Unknown13 = br.ReadInt16(); UnknownOffset1 = br.ReadUInt32(); UnknownOffset2 = br.ReadUInt32(); UnknownOffset3 = br.ReadUInt32(); UnknownOffset4 = br.ReadUInt32(); UnknownOffset5 = br.ReadUInt32(); Unknown14 = br.ReadInt16(); Unknown15 = br.ReadInt16(); for (int i = 0; i < 128; i++) { UnknownShorts.Add(br.ReadInt16()); } br.Close(); ms.Close(); return(true); }
public bool Read(BundleEntry entry, ILoader loader = null) { Clear(); MemoryStream ms = entry.MakeStream(); BinaryReader2 br = new BinaryReader2(ms); br.BigEndian = entry.Console; int vltPos = br.ReadInt32(); int vltSize = br.ReadInt32(); int binPos = br.ReadInt32(); int binSize = br.ReadInt32(); br.BaseStream.Position = vltPos; byte[] vlt = br.ReadBytes(vltSize); MemoryStream vltStream = new MemoryStream(vlt); BinaryReader2 vltBr = new BinaryReader2(vltStream); vltBr.BigEndian = entry.Console; ReadVlt(loader, vltBr); vltBr.Close(); br.BaseStream.Position = binPos; byte[] bin = br.ReadBytes(binSize); MemoryStream binStream = new MemoryStream(bin); BinaryReader2 binBr = new BinaryReader2(binStream); binBr.BigEndian = entry.Console; ReadBin(loader, binBr); binBr.Close(); br.Close(); ms.Close(); return(true); }
public bool Read(BundleEntry entry, ILoader loader = null) { Clear(); MemoryStream ms = entry.MakeStream(); BinaryReader2 br = new BinaryReader2(ms); br.BigEndian = entry.Console; ReferenceEntryIDOffset = br.ReadInt32(); Unknown2 = br.ReadInt32(); Unknown3 = br.ReadInt32(); Unknown4 = br.ReadInt32(); ReferenceEntryID = br.ReadUInt64(); Unknown6 = br.ReadInt32(); Unknown7 = br.ReadInt32(); br.Close(); ms.Close(); return(true); }
public bool Read(BundleEntry entry, ILoader loader = null) { Clear(); MemoryStream ms = entry.MakeStream(); BinaryReader2 br = new BinaryReader2(ms); br.BigEndian = entry.Console; br.BaseStream.Position += 4; // magic or something: 0C B0 B0 B0 FileSize = br.ReadUInt32(); SecondsPerFrame = br.ReadSingle(); Section1RecordCount = br.ReadInt32(); Section1Offset = br.ReadUInt32(); ImageIDCount = br.ReadInt32(); ImageIDListOffset = br.ReadUInt32(); GeometryVerticesCount = br.ReadInt32(); GeometryVerticesOffset = br.ReadUInt32(); TextStyleCount = br.ReadInt32(); TextStyleListOffset = br.ReadUInt32(); Section5And6RecordCount = br.ReadInt32(); Section5Offset = br.ReadUInt32(); Section6Offset = br.ReadUInt32(); EventBindsCount = br.ReadInt32(); EventBindsOffset = br.ReadUInt32(); TextStringsCount = br.ReadInt32(); TextStringsOffset = br.ReadUInt32(); DependencyRefStringsCount = br.ReadInt32(); DependencyRefStringsOffset = br.ReadUInt32(); CharacterRefStringsCount = br.ReadInt32(); CharacterRefStringsOffset = br.ReadUInt32(); br.BaseStream.Position = Section1Offset; for (int i = 0; i < Section1RecordCount; i++) { FlaptSection1Entry section1Entry = new FlaptSection1Entry(); section1Entry.Unknown00 = br.ReadByte(); section1Entry.Unknown01 = br.ReadByte(); section1Entry.Unknown02 = br.ReadByte(); section1Entry.Unknown03 = br.ReadByte(); section1Entry.Unknown04 = br.ReadByte(); section1Entry.Unknown05 = br.ReadByte(); section1Entry.Unknown06 = br.ReadByte(); section1Entry.Unknown07 = br.ReadByte(); section1Entry.List1Count = br.ReadInt16(); section1Entry.Unknown0A = br.ReadInt16(); section1Entry.Unknown0C = br.ReadInt32(); section1Entry.List1Offset = br.ReadUInt32(); section1Entry.Unknown14 = br.ReadUInt32(); section1Entry.Unknown18 = br.ReadUInt32(); section1Entry.Unknown1C = br.ReadUInt32(); section1Entry.Unknown20 = br.ReadUInt32(); section1Entry.Unknown24 = br.ReadUInt32(); section1Entry.Unknown28 = br.ReadUInt32(); section1Entry.Unknown2C = br.ReadUInt32(); section1Entry.Unknown30 = br.ReadUInt32(); section1Entry.Unknown34 = br.ReadUInt32(); section1Entry.Unknown38 = br.ReadUInt32(); section1Entry.Unknown3C = br.ReadUInt32(); section1Entry.NameOffset = br.ReadUInt32(); long oldPos = br.BaseStream.Position; if (section1Entry.List1Offset != 0) { br.BaseStream.Position = section1Entry.List1Offset; section1Entry.List1 = new List <short>(section1Entry.List1Count); for (int j = 0; j < section1Entry.List1Count; j++) { section1Entry.List1.Add(br.ReadInt16()); } } if (section1Entry.NameOffset != 0) { br.BaseStream.Position = section1Entry.NameOffset; section1Entry.Name = br.ReadCStr(); } br.BaseStream.Position = oldPos; Section1Entries.Add(section1Entry); } br.BaseStream.Position = ImageIDListOffset; for (int i = 0; i < ImageIDCount; i++) { ImageIDs.Add(br.ReadSByte()); br.BaseStream.Position += 3; // Weird padding? } br.BaseStream.Position = GeometryVerticesOffset; for (int i = 0; i < GeometryVerticesCount; i++) { GeometryVertex vertex = new GeometryVertex(); vertex.X = br.ReadSingle(); vertex.Y = br.ReadSingle(); vertex.Colour = U8Colour.FromARGB32(br.ReadUInt32()); vertex.U = br.ReadSingle(); vertex.V = br.ReadSingle(); GeometryVertices.Add(vertex); } br.BaseStream.Position = TextStyleListOffset; for (int i = 0; i < TextStyleCount; i++) { TextStyle textStyle = new TextStyle(); textStyle.FontNameOffset = br.ReadUInt32(); long oldPos = br.BaseStream.Position; br.BaseStream.Position = textStyle.FontNameOffset; textStyle.FontName = br.ReadCStr(); br.BaseStream.Position = oldPos; textStyle.Colour = U8Colour.FromARGB32(br.ReadUInt32()); textStyle.TextHeight = br.ReadSingle(); TextStyleEntries.Add(textStyle); } br.BaseStream.Position = Section5Offset; for (int i = 0; i < Section5And6RecordCount; i++) { FlaptSection5Entry section5Entry = new FlaptSection5Entry(); section5Entry.Hash = br.ReadUInt32(); section5Entry.CharacterNameOffset = br.ReadUInt32(); long oldPos = br.BaseStream.Position; br.BaseStream.Position = section5Entry.CharacterNameOffset; section5Entry.CharacterName = br.ReadCStr(); br.BaseStream.Position = oldPos; Section5Entries.Add(section5Entry); } br.BaseStream.Position = Section6Offset; for (int i = 0; i < Section5And6RecordCount; i++) { byte[] bytes = new byte[33]; for (int j = 0; j < 33; j++) { bytes[j] = br.ReadByte(); } Section6Entries.Add(bytes); } br.BaseStream.Position = EventBindsOffset; for (int i = 0; i < EventBindsCount; i++) { FlaptEventBinding eventBinding = new FlaptEventBinding(); eventBinding.CharacterNameOffset = br.ReadUInt32(); eventBinding.EventNameOffset = br.ReadUInt32(); eventBinding.ActionNameOffset = br.ReadUInt32(); eventBinding.UnusedInt = br.ReadInt32(); long oldPos = br.BaseStream.Position; br.BaseStream.Position = eventBinding.CharacterNameOffset; eventBinding.CharacterName = br.ReadCStr(); if (eventBinding.EventNameOffset != 0) { br.BaseStream.Position = eventBinding.EventNameOffset; eventBinding.EventName = br.ReadCStr(); } if (eventBinding.ActionNameOffset != 0) { br.BaseStream.Position = eventBinding.ActionNameOffset; eventBinding.ActionName = br.ReadCStr(); } br.BaseStream.Position = oldPos; EventBinds.Add(eventBinding); } br.BaseStream.Position = TextStringsOffset; for (int i = 0; i < TextStringsCount; i++) { StringPointer textString = new StringPointer(); textString.StringOffset = br.ReadUInt32(); long oldPos = br.BaseStream.Position; br.BaseStream.Position = textString.StringOffset; textString.String = br.ReadCStr(); br.BaseStream.Position = oldPos; TextStrings.Add(textString); } br.BaseStream.Position = DependencyRefStringsOffset; for (int i = 0; i < DependencyRefStringsCount; i++) { StringPointer dependencyRefString = new StringPointer(); dependencyRefString.StringOffset = br.ReadUInt32(); long oldPos = br.BaseStream.Position; br.BaseStream.Position = dependencyRefString.StringOffset; dependencyRefString.String = br.ReadCStr(); br.BaseStream.Position = oldPos; DependencyRefStrings.Add(dependencyRefString); } br.BaseStream.Position = CharacterRefStringsOffset; for (int i = 0; i < CharacterRefStringsCount; i++) { StringPointer characterRefString = new StringPointer(); characterRefString.StringOffset = br.ReadUInt32(); long oldPos = br.BaseStream.Position; br.BaseStream.Position = characterRefString.StringOffset; characterRefString.String = br.ReadCStr(); br.BaseStream.Position = oldPos; CharacterRefStrings.Add(characterRefString); } br.Close(); ms.Close(); return(true); }
public bool Read(BundleEntry entry, ILoader loader) { Clear(); Stream s = entry.MakeStream(); BinaryReader2 br = new BinaryReader2(s); br.BigEndian = entry.Console; PointsPtr = br.ReadUInt32(); ZonePtr = br.ReadUInt32(); ZonePointStart1 = br.ReadUInt32(); ZonePointStart2 = br.ReadUInt32(); ZonePointCount = br.ReadUInt32(); TotalZones = br.ReadUInt32(); TotalPoints = br.ReadUInt32(); Padding = br.ReadUInt32(); for (uint i = 0; i < ZonePointCount; i++) { PVSZone pvsEntry = new PVSZone(); pvsEntry.Address = (uint)br.BaseStream.Position; pvsEntry.PointsPtr = br.ReadUInt32(); pvsEntry.SafeNeighboursPtr = br.ReadUInt32(); pvsEntry.UnsafeNeighboursPtr = br.ReadUInt32(); pvsEntry.Unknown = br.ReadUInt32(); pvsEntry.ZoneID = br.ReadInt64(); pvsEntry.ZoneType = br.ReadInt16(); pvsEntry.NumPoints = br.ReadInt16(); pvsEntry.NumSafeNeighbours = br.ReadInt16(); pvsEntry.NumUnsafeNeighbours = br.ReadInt16(); pvsEntry.Flags = br.ReadInt32(); pvsEntry.Padding1 = br.ReadInt32(); pvsEntry.Padding2 = br.ReadInt32(); pvsEntry.Padding3 = br.ReadInt32(); long pos = br.BaseStream.Position; br.BaseStream.Position = (long)pvsEntry.PointsPtr; pvsEntry.Points = new List <ZonePoint>(); for (int j = 0; j < pvsEntry.NumPoints; j++) { ZonePoint data = new ZonePoint(); data.X = br.ReadSingle(); data.Y = br.ReadSingle(); data.Padding1 = br.ReadInt32(); data.Padding2 = br.ReadInt32(); pvsEntry.Points.Add(data); } br.BaseStream.Position = (long)pvsEntry.UnsafeNeighboursPtr; pvsEntry.UnsafeNeighbours = new List <ZoneNeighbour>(); for (int j = 0; j < pvsEntry.NumUnsafeNeighbours; j++) { ZoneNeighbour data = new ZoneNeighbour(); data.NeighborIndex = -1; data.NeighborPtr = br.ReadUInt32(); data.Flags = (NeighbourFlags)br.ReadInt32(); data.Padding1 = br.ReadInt32(); data.Padding2 = br.ReadInt32(); pvsEntry.UnsafeNeighbours.Add(data); } br.BaseStream.Position = pos; Zones.Add(pvsEntry); } for (int i = 0; i < Zones.Count; i++) { for (int k = 0; k < Zones[i].UnsafeNeighbours.Count; k++) { ZoneNeighbour data = Zones[i].UnsafeNeighbours[k]; uint ptr = data.NeighborPtr; for (int j = 0; j < Zones.Count; j++) { if (Zones[j].Address == ptr) { data.NeighborIndex = j; Zones[i].UnsafeNeighbours[k] = data; break; } } } } br.Close(); s.Close(); _gameMap = GetGameMap(entry.Archive); return(true); }
public static TextureState Read(BundleEntry entry) { TextureState result = new TextureState(); List <BundleDependency> dependencies = entry.GetDependencies(); foreach (BundleDependency dependency in dependencies) { ulong id = dependency.EntryID; if (TextureCache.Contains(id)) { result.Texture = TextureCache.GetTexture(id); } else { BundleEntry descEntry1 = entry.Archive.GetEntryByID(id); if (descEntry1 == null) { string file = BundleCache.GetFileByEntryID(id); if (!string.IsNullOrEmpty(file)) { BundleArchive archive = BundleArchive.Read(file); if (archive != null) { descEntry1 = archive.GetEntryByID(id); } } } if (descEntry1 != null && descEntry1.Type == EntryType.Texture) { if (entry.Console) { result.Texture = GameImage.GetImagePS3(descEntry1.EntryBlocks[0].Data, descEntry1.EntryBlocks[1].Data); } else { result.Texture = GameImage.GetImage(descEntry1.EntryBlocks[0].Data, descEntry1.EntryBlocks[1].Data); } if (result.Texture != null) { TextureCache.AddToCache(id, result.Texture); } break; } } } MemoryStream ms = entry.MakeStream(); BinaryReader2 br = new BinaryReader2(ms); br.BigEndian = entry.Console; // TODO: Read Texture State br.Close(); ms.Close(); return(result); }
public bool Read(BundleEntry entry, ILoader loader = null) { Clear(); MemoryStream ms = entry.MakeStream(); BinaryReader2 br = new BinaryReader2(ms); br.BigEndian = entry.Console; uint componentName2Ptr = br.ReadUInt32(); uint componentName1Ptr = br.ReadUInt32(); uint aptDataOffset = br.ReadUInt32(); uint constOffset = br.ReadUInt32(); uint geometryOffset = br.ReadUInt32(); uint fileSize = br.ReadUInt32(); /*int numPadding = (int)(16 - br.BaseStream.Position % 16); * for (int i = 0; i < numPadding; i++) * br.ReadByte();*/ br.BaseStream.Position = componentName1Ptr; Component1Name = br.ReadCStr(); br.BaseStream.Position = componentName2Ptr; Component2Name = br.ReadCStr(); br.BaseStream.Position = constOffset; byte[] constMagic = br.ReadBytes(20); uint movieOffset = br.ReadUInt32(); int constCount = br.ReadInt32(); uint constantStartOffset = br.ReadUInt32(); br.BaseStream.Position = constOffset + constantStartOffset; for (int i = 0; i < constCount; i++) { AptConst constant = new AptConst(); constant.Type = (AptConstType)br.ReadUInt32(); constant.Data = br.ReadUInt32(); Constants.Add(constant); } for (int i = 0; i < Constants.Count; i++) { if (Constants[i].Type == AptConstType.String) { br.BaseStream.Position = constOffset + Constants[i].Data; Constants[i].String = br.ReadCStr(); // 4 byte aligned } } br.BaseStream.Position = aptDataOffset; byte[] dataMagic = br.ReadBytes(16); br.BaseStream.Position = aptDataOffset + movieOffset; RootMovie = Character.Read(br, aptDataOffset); // TODO: Finish Read br.Close(); ms.Close(); return(true); }
public bool Read(BundleEntry entry, ILoader loader = null) { Clear(); MemoryStream ms = entry.MakeStream(); BinaryReader2 br = new BinaryReader2(ms); br.BigEndian = entry.Console; Min = br.ReadVector3F(); Unknown4 = br.ReadInt32(); Max = br.ReadVector3F(); Unknown8 = br.ReadInt32(); uint chunkPointerStart = br.ReadUInt32(); uint boxListStart = br.ReadUInt32(); int chunkCount = br.ReadInt32(); br.ReadUInt32(); // FileSize List <uint> chunkPointers = new List <uint>(); // No Data if (chunkCount == 0) { br.Close(); ms.Close(); return(true); } br.BaseStream.Position = chunkPointerStart; for (int i = 0; i < chunkCount; i++) { chunkPointers.Add(br.ReadUInt32()); } for (int i = 0; i < chunkCount; i++) { // Read Vertically long pos = boxListStart + 0x70 * (i / 4) + 4 * (i % 4); BoxF boundingBox = new BoxF(); br.BaseStream.Position = pos; float minX = br.ReadSingle(); br.BaseStream.Position += 12; float minY = br.ReadSingle(); br.BaseStream.Position += 12; float minZ = br.ReadSingle(); boundingBox.Min = new Vector3(minX, minY, minZ); br.BaseStream.Position += 12; float maxX = br.ReadSingle(); br.BaseStream.Position += 12; float maxY = br.ReadSingle(); br.BaseStream.Position += 12; float maxZ = br.ReadSingle(); br.BaseStream.Position += 12; boundingBox.Max = new Vector3(maxX, maxY, maxZ); PolygonSoupBoundingBox box = new PolygonSoupBoundingBox(boundingBox, br.ReadInt32()); BoundingBoxes.Add(box); } for (int i = 0; i < chunkPointers.Count; i++) { br.BaseStream.Position = chunkPointers[i]; Chunks.Add(PolygonSoupChunk.Read(br)); } br.Close(); ms.Close(); return(true); }
public bool Read(BundleEntry entry, ILoader loader = null) { Clear(); MemoryStream ms = entry.MakeStream(); BinaryReader2 br = new BinaryReader2(ms); br.BigEndian = entry.Console; FormatRevision = br.ReadInt32(); FileSize = br.ReadUInt32(); Unknown0C = br.ReadInt32(); Unknown10 = br.ReadInt32(); DevSpawnPositionX = br.ReadSingle(); DevSpawnPositionY = br.ReadSingle(); DevSpawnPositionZ = br.ReadSingle(); DevSpawnUnknownHash = br.ReadUInt32(); DevSpawnRotationX = br.ReadSingle(); DevSpawnRotationY = br.ReadSingle(); DevSpawnRotationZ = br.ReadSingle(); DevSpawnUnknownFloat = br.ReadSingle(); LandmarkTriggersOffset = br.ReadUInt32(); LandmarkTriggersCount = br.ReadInt32(); LandmarkNonFinishLineCount = br.ReadInt32(); BlackspotTriggersOffset = br.ReadUInt32(); BlackspotTriggersCount = br.ReadInt32(); GenericRegionTriggersOffset = br.ReadUInt32(); GenericRegionTriggersCount = br.ReadInt32(); Section4Offset = br.ReadUInt32(); Section4Count = br.ReadInt32(); VFXBoxRegionOffset = br.ReadUInt32(); VFXBoxRegionCount = br.ReadInt32(); StartPositionsOffset = br.ReadUInt32(); StartPositionsCount = br.ReadInt32(); RoamingLocationsOffset = br.ReadUInt32(); RoamingLocationsCount = br.ReadInt32(); SpawnLocationsOffset = br.ReadUInt32(); SpawnLocationsCount = br.ReadInt32(); TriggerOffsetListOffset = br.ReadUInt32(); TriggerOffsetListCount = br.ReadInt32(); br.BaseStream.Position = LandmarkTriggersOffset; for (int i = 0; i < LandmarkTriggersCount; i++) { LandmarkTrigger landmarkTrigger = new LandmarkTrigger(); landmarkTrigger.PositionX = br.ReadSingle(); landmarkTrigger.PositionY = br.ReadSingle(); landmarkTrigger.PositionZ = br.ReadSingle(); landmarkTrigger.RotationX = br.ReadSingle(); landmarkTrigger.RotationY = br.ReadSingle(); landmarkTrigger.RotationZ = br.ReadSingle(); landmarkTrigger.SizeX = br.ReadSingle(); landmarkTrigger.SizeY = br.ReadSingle(); landmarkTrigger.SizeZ = br.ReadSingle(); landmarkTrigger.GameDBID = br.ReadInt32(); landmarkTrigger.GlobalIndex = br.ReadInt16(); landmarkTrigger.Type = br.ReadByte(); landmarkTrigger.UnknownByte2B = br.ReadByte(); landmarkTrigger.UnknownOffset = br.ReadUInt32(); landmarkTrigger.UnknownByte30 = br.ReadByte(); landmarkTrigger.LocalIndex = br.ReadByte(); landmarkTrigger.Subtype = br.ReadByte(); landmarkTrigger.UnknownByte33 = br.ReadByte(); LandmarkTriggers.Add(landmarkTrigger); } br.BaseStream.Position = GenericRegionTriggersOffset; for (int i = 0; i < GenericRegionTriggersCount; i++) { long startPosition = br.BaseStream.Position; GenericRegionTrigger genericRegionTrigger = new GenericRegionTrigger(); genericRegionTrigger.PositionX = br.ReadSingle(); genericRegionTrigger.PositionY = br.ReadSingle(); genericRegionTrigger.PositionZ = br.ReadSingle(); genericRegionTrigger.RotationX = br.ReadSingle(); genericRegionTrigger.RotationY = br.ReadSingle(); genericRegionTrigger.RotationZ = br.ReadSingle(); genericRegionTrigger.SizeX = br.ReadSingle(); genericRegionTrigger.SizeY = br.ReadSingle(); genericRegionTrigger.SizeZ = br.ReadSingle(); genericRegionTrigger.GameDBID = br.ReadInt32(); genericRegionTrigger.Index = br.ReadInt16(); genericRegionTrigger.Type = br.ReadByte(); genericRegionTrigger.UnknownByte2B = br.ReadByte(); genericRegionTrigger.GameDBID2 = br.ReadInt32(); genericRegionTrigger.UnknownShort30 = br.ReadInt16(); genericRegionTrigger.UnknownShort32 = br.ReadInt16(); genericRegionTrigger.UnknownByte34 = br.ReadByte(); genericRegionTrigger.UnknownByte35 = br.ReadByte(); genericRegionTrigger.Subtype = br.ReadByte(); genericRegionTrigger.UnknownByte37 = br.ReadByte(); GenericRegionTriggers.Add((uint)startPosition, genericRegionTrigger); } br.BaseStream.Position = Section4Offset; for (int i = 0; i < Section4Count; i++) { TriggerSection4Entry section4Entry = new TriggerSection4Entry(); section4Entry.TriggerOffsetListOffset = br.ReadUInt32(); section4Entry.TriggerOffsetListCount = br.ReadInt32(); section4Entry.GameDBIDListOffset = br.ReadUInt32(); section4Entry.GameDBIDListCount = br.ReadInt32(); long oldPosition = br.BaseStream.Position; br.BaseStream.Position = section4Entry.TriggerOffsetListOffset; section4Entry.Triggers = new List <GenericRegionTrigger>(); for (int j = 0; j < section4Entry.TriggerOffsetListCount; j++) { uint offset = br.ReadUInt32(); section4Entry.Triggers.Add(GenericRegionTriggers[offset]); } br.BaseStream.Position = section4Entry.GameDBIDListOffset; section4Entry.GameDBIDs = new List <long>(); for (int j = 0; j < section4Entry.GameDBIDListCount; j++) { section4Entry.GameDBIDs.Add(br.ReadInt64()); } br.BaseStream.Position = oldPosition; Section4Entries.Add(section4Entry); } br.BaseStream.Position = RoamingLocationsOffset; for (int i = 0; i < RoamingLocationsCount; i++) { RoamingLocation roamingLocation = new RoamingLocation(); roamingLocation.PositionX = br.ReadSingle(); roamingLocation.PositionY = br.ReadSingle(); roamingLocation.PositionZ = br.ReadSingle(); roamingLocation.UnknownHash = br.ReadUInt32(); roamingLocation.Subdistrict = br.ReadByte(); roamingLocation.UnknownByte11 = br.ReadByte(); roamingLocation.UnknownByte12 = br.ReadByte(); roamingLocation.UnknownByte13 = br.ReadByte(); roamingLocation.UnknownInt14 = br.ReadInt32(); roamingLocation.UnknownInt18 = br.ReadInt32(); roamingLocation.UnknownInt1C = br.ReadInt32(); RoamingLocationEntries.Add(roamingLocation); } br.BaseStream.Position = SpawnLocationsOffset; for (int i = 0; i < SpawnLocationsCount; i++) { SpawnLocation spawnLocation = new SpawnLocation(); spawnLocation.PositionX = br.ReadSingle(); spawnLocation.PositionY = br.ReadSingle(); spawnLocation.PositionZ = br.ReadSingle(); spawnLocation.UnknownHash = br.ReadUInt32(); spawnLocation.RotationX = br.ReadSingle(); spawnLocation.RotationY = br.ReadSingle(); spawnLocation.RotationZ = br.ReadSingle(); spawnLocation.UnknownFloat1C = br.ReadSingle(); spawnLocation.JunkyardGameDBID = br.ReadInt64(); spawnLocation.UnknownByte28 = br.ReadByte(); spawnLocation.UnknownByte29 = br.ReadByte(); spawnLocation.UnknownByte30 = br.ReadByte(); spawnLocation.UnknownByte31 = br.ReadByte(); spawnLocation.UnknownInt32 = br.ReadInt32(); foreach (GenericRegionTrigger trigger in GenericRegionTriggers.Values) { if (trigger.GameDBID == spawnLocation.JunkyardGameDBID) { spawnLocation.JunkyardTrigger = trigger; break; } } SpawnLocationEntries.Add(spawnLocation); } br.BaseStream.Position = TriggerOffsetListOffset; for (int i = 0; i < TriggerOffsetListCount; i++) { uint section6Entry = br.ReadUInt32(); TriggerOffsets.Add(section6Entry); } br.Close(); ms.Close(); return(true); }
public bool Read(BundleEntry entry, ILoader loader = null) { Clear(); MemoryStream ms = entry.MakeStream(); BinaryReader2 br = new BinaryReader2(ms); br.BigEndian = entry.Console; Unknown1 = br.ReadInt32(); FileSize = br.ReadInt32(); Unknown3 = br.ReadInt32(); Section2Offset = br.ReadInt32(); StreetOffset = br.ReadInt32(); RoadRuleOffset = br.ReadInt32(); Section1Count = br.ReadInt32(); RoadRuleCount = br.ReadInt32(); StreetCount = br.ReadInt32(); Unknown9 = br.ReadInt32(); Unknown10 = br.ReadInt32(); Unknown11 = br.ReadInt32(); for (int i = 0; i < Section1Count; i++) { StreetSection1 streetSection1 = new StreetSection1(); streetSection1.Unknown1 = br.ReadInt32(); streetSection1.Index = br.ReadInt16(); streetSection1.Unknown3 = br.ReadInt32(); streetSection1.Unknown4 = br.ReadInt16(); streetSection1.Unknown5 = br.ReadInt16(); streetSection1.Unknown6 = br.ReadInt16(); StreetSection1s.Add(streetSection1); } br.BaseStream.Seek(Section2Offset, SeekOrigin.Begin); for (int i = 0; i < RoadRuleCount; i++) { StreetSection2 section2 = new StreetSection2(); section2.Unknown1 = br.ReadInt32(); section2.ID = br.ReadInt16(); section2.Unknown3 = br.ReadInt16(); section2.Unknown4 = br.ReadByte(); section2.Unknown5 = br.ReadByte(); section2.Unknown6 = br.ReadInt16(); section2.Unknown7 = br.ReadInt32(); section2.Unknown8 = br.ReadInt32(); section2.Unknown9 = br.ReadInt32(); section2.Unknown10 = br.ReadInt32(); section2.Unknown11 = br.ReadInt32(); section2.Unknown12 = br.ReadInt32(); StreetSection2s.Add(section2); } br.BaseStream.Seek(StreetOffset, SeekOrigin.Begin); for (int i = 0; i < StreetCount; i++) { StreetInfo section3 = new StreetInfo(); section3.Coords = br.ReadVector3F(); section3.Unknown4 = br.ReadInt32(); section3.StreetID = br.ReadInt64(); section3.Unknown6 = br.ReadInt64(); section3.Unknown7 = br.ReadInt64(); section3.StreetNameID = Encoding.ASCII.GetString(br.ReadBytes(20)); section3.Unknown8 = br.ReadInt32(); //if (entry.Console) // section3.Unknown9 = 1; //else section3.Unknown9 = br.ReadInt32(); section3.Unknown10 = br.ReadInt32(); StreetInfos.Add(section3); } br.BaseStream.Seek(RoadRuleOffset, SeekOrigin.Begin); for (int i = 0; i < RoadRuleCount; i++) { RoadRuleInfo section4 = new RoadRuleInfo(); section4.Unknown1 = br.ReadInt64(); section4.Unknown2 = br.ReadInt64(); section4.Time = br.ReadInt32(); section4.ShowTime = br.ReadInt32(); section4.Unknown5 = br.ReadInt64(); section4.Unknown6 = br.ReadInt64(); RoadRuleInfos.Add(section4); } while (br.BaseStream.Position < FileSize) { StreetSection5 section5 = new StreetSection5(); section5.Section1Index = br.ReadInt16(); section5.Unknown2 = br.ReadInt16(); section5.Unknown3 = br.ReadInt16(); section5.Unknown4 = br.ReadInt16(); StreetSection5s.Add(section5); } // TODO: TEMP //StreetInfo info1 = result.StreetInfos[1]; //StreetInfo info70 = result.StreetInfos[70]; //result.StreetInfos[1] = info70; //result.StreetInfos[70] = info1; //result.Write(entry); return(true); }
public bool Read(BundleEntry entry, ILoader loader = null) { Clear(); MemoryStream ms = entry.MakeStream(); BinaryReader2 br = new BinaryReader2(ms); br.BigEndian = entry.Console; FormatRevision = br.ReadInt32(); FileSize = br.ReadUInt32(); InitialCarIDListOffset = br.ReadUInt32(); InitialCarIDCount = br.ReadInt32(); LicenceDataOffset = br.ReadUInt32(); LicenceDataCount = br.ReadInt32(); EventJunctionOffset = br.ReadUInt32(); EventJunctionCount = br.ReadInt32(); EventDataOffset = br.ReadUInt32(); EventDataCount = br.ReadInt32(); RivalOffset = br.ReadUInt32(); RivalCount = br.ReadInt32(); Section6Offset = br.ReadUInt32(); Section6Count = br.ReadInt32(); Section7Offset = br.ReadUInt32(); Section7Count = br.ReadInt32(); CarbonCarUnlockDataOffset = br.ReadUInt32(); CarbonCarUnlockDataCount = br.ReadInt32(); PlayerOpponentsDataOffset = br.ReadUInt32(); PlayerOpponentsDataCount = br.ReadInt32(); br.BaseStream.Position = InitialCarIDListOffset; for (int i = 0; i < InitialCarIDCount; i++) { InitialCarIDEntries.Add(new EncryptedString(br.ReadUInt64())); } br.BaseStream.Position = LicenceDataOffset; for (int i = 0; i < LicenceDataCount; i++) { LicenceData licenceData = new LicenceData(); licenceData.Unknown00 = br.ReadSingle(); licenceData.Unknown04 = br.ReadSingle(); licenceData.Unknown08 = br.ReadSingle(); licenceData.Unknown0C = br.ReadSingle(); licenceData.Unknown10 = br.ReadSingle(); licenceData.Unknown14 = br.ReadSingle(); licenceData.Unknown18 = br.ReadSingle(); licenceData.Unknown1C = br.ReadSingle(); licenceData.Unknown20 = br.ReadSingle(); licenceData.Unknown24 = br.ReadSingle(); licenceData.GameDBID = br.ReadInt32(); licenceData.Unknown2C = br.ReadSingle(); licenceData.Unknown30 = br.ReadSingle(); licenceData.Unknown34 = br.ReadSingle(); licenceData.Unknown38 = br.ReadSingle(); licenceData.Unknown3C = br.ReadSingle(); licenceData.Unknown40 = br.ReadSingle(); licenceData.Unknown44 = br.ReadSingle(); licenceData.Unknown48 = br.ReadSingle(); licenceData.NumEventWinsRequired = br.ReadInt16(); licenceData.Unknown4E = br.ReadInt16(); licenceData.Unknown50 = br.ReadInt16(); licenceData.Unknown52 = br.ReadInt16(); licenceData.Unknown54 = br.ReadInt16(); licenceData.Unknown56 = br.ReadInt16(); licenceData.Unknown58 = br.ReadInt16(); licenceData.Unknown5A = br.ReadInt16(); licenceData.Unknown5C = br.ReadByte(); licenceData.Unknown5D = br.ReadByte(); licenceData.Unknown5E = br.ReadByte(); licenceData.Unknown5F = br.ReadByte(); licenceData.Unknown60 = br.ReadByte(); licenceData.Unknown61 = br.ReadByte(); licenceData.Unknown62 = br.ReadByte(); licenceData.Unknown63 = br.ReadByte(); br.BaseStream.Position += 4; // padding licenceData.VehicleUnlocked = new EncryptedString(br.ReadUInt64()); LicenceDataEntries.Add(licenceData); } br.BaseStream.Position = EventJunctionOffset; for (int i = 0; i < EventJunctionCount; i++) { EventJunction eventJunction = new EventJunction(); eventJunction.GameDBID = br.ReadInt32(); eventJunction.CarEventDataOffset = br.ReadUInt32(); eventJunction.BTTEventDataOffset = br.ReadUInt32(); if (FormatRevision >= 44) { eventJunction.BikeEventDataOffset = br.ReadUInt32(); } eventJunction.UnknownGameDBID = br.ReadInt32(); EventJunctionEntries.Add(eventJunction); } br.BaseStream.Position = EventDataOffset; for (int i = 0; i < EventDataCount; i++) { long origPosition = br.BaseStream.Position; EventData eventData = new EventData(); eventData.GameDBID = br.ReadInt32(); eventData.AppearsWhen = br.ReadInt32(); eventData.TrafficDensityMultiplier = br.ReadSingle(); eventData.Unknown0C = br.ReadSingle(); eventData.LockVehicleID = new EncryptedString(br.ReadUInt64()); eventData.EventLandmarkDataOffset = br.ReadUInt32(); eventData.EventLandmarkCount = br.ReadInt32(); eventData.TargetTimeUnused = br.ReadSingle(); eventData.TargetTime = br.ReadSingle(); eventData.StuntRunTargetScoreTier1 = br.ReadInt32(); eventData.StuntRunTargetScoreTier2 = br.ReadInt32(); eventData.StuntRunTargetScoreTier3 = br.ReadInt32(); eventData.StuntRunTargetScoreTier4 = br.ReadInt32(); eventData.StuntRunTargetScoreTier5 = br.ReadInt32(); eventData.StuntRunTargetScoreTier6 = br.ReadInt32(); eventData.StuntRunTimeLimitTier1 = br.ReadSingle(); eventData.StuntRunTimeLimitTier2 = br.ReadSingle(); eventData.StuntRunTimeLimitTier3 = br.ReadSingle(); eventData.StuntRunTimeLimitTier4 = br.ReadSingle(); eventData.StuntRunTimeLimitTier5 = br.ReadSingle(); eventData.StuntRunTimeLimitTier6 = br.ReadSingle(); eventData.Unknown58 = br.ReadInt32(); eventData.RivalData = new EventRivalData[7]; for (int j = 0; j < 7; j++) { EventRivalData rivalData = new EventRivalData(); rivalData.Unknown00 = br.ReadInt32(); rivalData.Unknown04 = br.ReadInt32(); rivalData.Unknown08 = br.ReadInt32(); rivalData.Unknown0C = br.ReadInt32(); rivalData.Unknown10 = br.ReadByte(); rivalData.Unknown11 = br.ReadByte(); rivalData.Unknown12 = br.ReadByte(); rivalData.Unknown13 = br.ReadByte(); eventData.RivalData[j] = rivalData; } eventData.RivalDataCount = br.ReadInt32(); Array.Resize(ref eventData.RivalData, eventData.RivalDataCount); eventData.Type = br.ReadByte(); eventData.UnknownED = br.ReadByte(); eventData.NumberOfAIRivalsToUse = br.ReadByte(); eventData.UnknownEF = br.ReadByte(); eventData.UnknownF0 = br.ReadInt32(); eventData.UnknownF4 = br.ReadByte(); eventData.UnknownF5 = br.ReadByte(); br.BaseStream.Position += 2; // padding long oldPos = br.BaseStream.Position; eventData.EventLandmarkData = new EventLandmarkData[eventData.EventLandmarkCount]; br.BaseStream.Position = eventData.EventLandmarkDataOffset; for (int j = 0; j < eventData.EventLandmarkCount; j++) { EventLandmarkData landmarkData = new EventLandmarkData(); landmarkData.TriggerID = br.ReadInt32(); landmarkData.NumAIGameDBIDs = br.ReadInt32(); landmarkData.AIGameDBIDs = new int[landmarkData.NumAIGameDBIDs]; for (int k = 0; k < 8; k++) { int gameDBID = br.ReadInt32(); if (k < landmarkData.NumAIGameDBIDs) { landmarkData.AIGameDBIDs[k] = gameDBID; } } eventData.EventLandmarkData[j] = landmarkData; } br.BaseStream.Position = oldPos; EventDataEntries.Add((uint)origPosition, eventData); } for (int i = 0; i < EventJunctionCount; i++) { EventJunction junction = EventJunctionEntries[i]; if (junction.CarEventDataOffset != 0) { junction.CarEventData = EventDataEntries[junction.CarEventDataOffset]; } if (junction.BTTEventDataOffset != 0) { junction.BTTEventData = EventDataEntries[junction.BTTEventDataOffset]; } if (junction.BikeEventDataOffset != 0) { junction.BikeEventData = EventDataEntries[junction.BikeEventDataOffset]; } EventJunctionEntries[i] = junction; } br.BaseStream.Position = RivalOffset; for (int i = 0; i < RivalCount; i++) { Rival rival = new Rival(); rival.RivalID = br.ReadInt64(); rival.VehicleID = new EncryptedString(br.ReadUInt64()); rival.Unknown10 = br.ReadInt16(); rival.Unknown12 = br.ReadInt16(); rival.Unknown14 = br.ReadByte(); rival.Unknown15 = br.ReadByte(); rival.WinsUntilRoam = br.ReadByte(); rival.DoesNotRoam = br.ReadBoolean(); rival.Name = br.ReadLenString(0x20); RivalEntries.Add(rival); } br.BaseStream.Position = Section6Offset; for (int i = 0; i < Section6Count; i++) { ProgressionSection6Entry section6Entry = new ProgressionSection6Entry(); section6Entry.Unknown00 = br.ReadSingle(); section6Entry.Unknown04 = br.ReadSingle(); section6Entry.Unknown08 = br.ReadSingle(); section6Entry.Unknown0C = br.ReadSingle(); section6Entry.Unknown10 = br.ReadSingle(); section6Entry.Unknown14 = br.ReadSingle(); section6Entry.Unknown18 = br.ReadSingle(); section6Entry.Unknown1C = br.ReadSingle(); section6Entry.Unknown20 = br.ReadSingle(); section6Entry.Unknown24 = br.ReadSingle(); section6Entry.Unknown28 = br.ReadSingle(); section6Entry.Unknown2C = br.ReadSingle(); section6Entry.Unknown30 = br.ReadSingle(); section6Entry.Unknown34 = br.ReadSingle(); section6Entry.Unknown38 = br.ReadSingle(); section6Entry.Unknown3C = br.ReadSingle(); section6Entry.Unknown40 = br.ReadByte(); section6Entry.Unknown41 = br.ReadByte(); section6Entry.Unknown42 = br.ReadByte(); section6Entry.Unknown43 = br.ReadByte(); Section6Entries.Add(section6Entry); } br.BaseStream.Position = Section7Offset; for (int i = 0; i < Section7Count; i++) { ProgressionSection7Entry section7Entry = new ProgressionSection7Entry(); section7Entry.Unknown00 = br.ReadSingle(); section7Entry.Unknown04 = br.ReadSingle(); section7Entry.Unknown08 = br.ReadSingle(); section7Entry.Unknown0C = br.ReadSingle(); Section7Entries.Add(section7Entry); } br.BaseStream.Position = CarbonCarUnlockDataOffset; for (int i = 0; i < CarbonCarUnlockDataCount; i++) { CarbonCarUnlockData unlockData = new CarbonCarUnlockData(); unlockData.Unknown00 = br.ReadInt32(); unlockData.Unknown04 = br.ReadInt16(); unlockData.Unknown06 = br.ReadByte(); unlockData.Unknown07 = br.ReadByte(); unlockData.VehicleID = new EncryptedString(br.ReadUInt64()); CarbonCarUnlockDataEntries.Add(unlockData); } br.BaseStream.Position = PlayerOpponentsDataOffset; for (int i = 0; i < PlayerOpponentsDataCount; i++) { PlayerOpponentsData opponentsData = new PlayerOpponentsData(); opponentsData.PlayerVehicleID = new EncryptedString(br.ReadUInt64()); opponentsData.Unknown08 = br.ReadInt32(); opponentsData.Unknown0C = br.ReadInt32(); opponentsData.Opponent1VehicleID = new EncryptedString(br.ReadUInt64()); opponentsData.Unknown18 = br.ReadInt32(); opponentsData.Unknown1C = br.ReadInt32(); opponentsData.Opponent2VehicleID = new EncryptedString(br.ReadUInt64()); opponentsData.Unknown28 = br.ReadInt32(); opponentsData.Unknown2C = br.ReadInt32(); opponentsData.Opponent3VehicleID = new EncryptedString(br.ReadUInt64()); opponentsData.Unknown38 = br.ReadInt32(); opponentsData.Unknown3C = br.ReadInt32(); opponentsData.Opponent4VehicleID = new EncryptedString(br.ReadUInt64()); opponentsData.Unknown48 = br.ReadInt32(); opponentsData.Unknown4C = br.ReadInt32(); opponentsData.Opponent5VehicleID = new EncryptedString(br.ReadUInt64()); opponentsData.Unknown58 = br.ReadInt32(); opponentsData.Unknown5C = br.ReadInt32(); opponentsData.Opponent6VehicleID = new EncryptedString(br.ReadUInt64()); opponentsData.Unknown68 = br.ReadInt32(); opponentsData.Unknown6C = br.ReadInt32(); opponentsData.Opponent7VehicleID = new EncryptedString(br.ReadUInt64()); opponentsData.Unknown78 = br.ReadInt32(); opponentsData.Unknown7C = br.ReadInt32(); opponentsData.Opponent8VehicleID = new EncryptedString(br.ReadUInt64()); opponentsData.Unknown88 = br.ReadInt32(); opponentsData.NumOpponents = br.ReadInt32(); PlayerOpponentsDataEntries.Add(opponentsData); } br.Close(); ms.Close(); return(true); }
public bool Read(BundleEntry entry, ILoader loader) { Clear(); List <BundleDependency> dependencies = entry.GetDependencies(); ID = entry.ID; MemoryStream ms = entry.MakeStream(); BinaryReader2 br = new BinaryReader2(ms); br.BigEndian = entry.Console; Unknown1 = br.ReadSingle(); Unknown2 = br.ReadSingle(); Unknown3 = br.ReadSingle(); Unknown4 = br.ReadSingle(); Unknown5 = br.ReadInt16(); MeshCount = br.ReadInt16(); StartOffset = br.ReadInt32(); Unknown8 = br.ReadInt32(); Unknown9 = br.ReadInt32(); Unknown10 = br.ReadInt16(); Unknown10_1 = br.ReadInt16(); UnknownOffset = br.ReadInt32(); Unknown12 = br.ReadInt32(); Unknown13 = br.ReadInt32(); br.BaseStream.Position = StartOffset; for (int i = 0; i < MeshCount; i++) { int offset = br.ReadInt32(); MeshVertexOffsets.Add(offset); } /*if (entry.Platform == BundlePlatform.PS3) * { * br.BaseStream.Position += 16 - (br.BaseStream.Position % 16); * result.NumIndices = br.ReadInt16(); * result.Unknown = br.ReadInt16(); * } * else * {*/ NumIndices = br.ReadInt32(); //} Unknown15 = br.ReadInt32(); Unknown16 = br.ReadInt32(); Unknown17 = br.ReadInt32(); // some extra data here in BPR br.BaseStream.Position = UnknownOffset; if (NumIndices == 0) // BPR { // ??? br.BaseStream.Position += 12; } VertexBlockAddress = br.ReadInt32(); Unknown18 = (NumIndices == 0) ? 0 : br.ReadInt32(); VertexBlockSize = br.ReadInt32(); for (int i = 0; i < MeshCount; i++) { br.BaseStream.Position = MeshVertexOffsets[i]; RenderableMesh mesh = new RenderableMesh(); mesh.RotationMatrix = br.ReadMatrix4(); mesh.Unknown19 = br.ReadInt32(); mesh.Unknown20 = br.ReadInt32(); mesh.IndexOffsetCount = br.ReadInt32(); if (NumIndices == 0) // BPR { mesh.NumFaces = br.ReadInt32() / 3; } else { mesh.NumVertices = br.ReadInt32(); mesh.VertexOffsetCount = br.ReadInt32(); mesh.VertexOffsetCount = 0; mesh.NumFaces = br.ReadInt32(); } int cPos = (int)br.BaseStream.Position; mesh.MaterialIDInternal = br.ReadInt32(); foreach (BundleDependency dependency in dependencies) { if (dependency.EntryPointerOffset == cPos) { mesh.MaterialID = dependency.EntryID; break; } } mesh.Unknown21 = br.ReadInt16(); mesh.Unknown22 = br.ReadInt16(); mesh.NumIndicesOffset = br.ReadInt32(); mesh.VerticesOffsetPtr = br.ReadInt32(); mesh.VertexDescriptionsInternal = new int[6]; mesh.VertexDescriptionIDs = new ulong[6]; for (int j = 0; j < mesh.VertexDescriptionsInternal.Length; j++) { int pos = (int)br.BaseStream.Position; foreach (BundleDependency dependency in dependencies) { if (dependency.EntryPointerOffset == pos) { mesh.VertexDescriptionIDs[j] = dependency.EntryID; break; } } mesh.VertexDescriptionsInternal[j] = br.ReadInt32(); } Meshes.Add(mesh); } br.Close(); ms.Close(); loader?.SetStatus("Loading Meshes"); for (int i = 0; i < Meshes.Count; i++) { RenderableMesh mesh = Meshes[i]; int progress = (i + 1) * 100 / Meshes.Count; loader?.SetStatus("Loading Meshes: " + (i + 1) + "/" + Meshes.Count); loader?.SetProgress(progress); if (LoadMaterials) { BundleEntry descEntry1 = entry.Archive.GetEntryByID(mesh.MaterialID); if (descEntry1 == null) { string file = BundleCache.GetFileByEntryID(mesh.MaterialID); if (!string.IsNullOrEmpty(file)) { BundleArchive archive = BundleArchive.Read(file); descEntry1 = archive.GetEntryByID(mesh.MaterialID); } } if (descEntry1 != null) { mesh.Material = MaterialEntry.Read(descEntry1); } } mesh.VertexDescriptions = new VertexDesc[6]; for (int j = 0; j < mesh.VertexDescriptions.Length; j++) { ulong vertexDescID = mesh.VertexDescriptionIDs[j]; BundleEntry descEntry = entry.Archive.GetEntryByID(vertexDescID); if (descEntry == null) { string file = BundleCache.GetFileByEntryID(vertexDescID); if (!string.IsNullOrEmpty(file)) { BundleArchive archive = BundleArchive.Read(file); descEntry = archive.GetEntryByID(vertexDescID); } } if (descEntry != null) { mesh.VertexDescriptions[j] = VertexDesc.Read(descEntry); } } } ms = entry.MakeStream(true); br = new BinaryReader2(ms); br.BigEndian = entry.Console; ReadBody(br); br.Close(); ms.Close(); BuildModel(); _scene = MakeScene(loader); return(true); }