public static string SerializeBundleEntryToXml(BundleEntry entry, bool summary = false) { return(xmlWriterToString(xw => BundleXmlSerializer.WriteTo(entry, xw, summary))); }
public static void SerializeBundleEntry(BundleEntry entry, XmlWriter writer, bool summary = false) { BundleXmlSerializer.WriteTo(entry, writer, summary); }
public static string SerializeBundleEntryToJson(BundleEntry entry, bool summary = false) { return(jsonWriterToString(jw => BundleJsonSerializer.WriteTo(entry, jw, summary))); }
public void EditEntry(int index, bool forceHex = false) { BundleEntry entry = GetEntry(index); if (EntryTypeRegistry.IsRegistered(entry.Type) && !forceHex) { IEntryData data = EntryTypeRegistry.GetHandler(entry.Type); TextureCache.ResetCache(); LoadingDialog loader = new LoadingDialog(); loader.Status = "Loading: " + entry.ID.ToString("X8"); Thread loadInstanceThread = null; bool failure = false; loader.Done += (cancelled, value) => { if (cancelled) { loadInstanceThread?.Abort(); } else { if (failure) { MessageBox.Show(this, "Failed to load Entry", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { loader.Hide(); IEntryEditor editor = data.GetEditor(entry); if (editor != null) { editor.ShowDialog(this); } else { DebugUtil.ShowDebug(this, data); } if (ForceOnlySpecificEntry) { Environment.Exit(0); } } } TextureCache.ResetCache(); }; loadInstanceThread = new Thread(() => { try { try { failure = !data.Read(entry, loader); } catch (ReadFailedError ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); failure = true; throw; } } catch (Exception) { MessageBox.Show("Failed to load Entry", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); failure = true; } loader.IsDone = true; }); loadInstanceThread.Start(); loader.ShowDialog(this); } else { EntryEditor editor = new EntryEditor(); editor.ForceHex = forceHex; Task.Run(() => openEditor(editor, index)); editor.ShowDialog(this); } }
/// <summary> /// Map to model /// </summary> public IdentifiedData MapToModel(BundleEntry bundleResource, RestOperationContext context, Bundle bundle) { return(this.MapToModel(bundleResource.Resource.Resource as Immunization, context)); }
public EntryType GetEntryType(BundleEntry entry) { return(EntryType.Renderable); }
public bool Write(BundleEntry entry) { 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); }