public void LetsDump() { pb1.Minimum = 0; pb1.Maximum = pcc.Exports.Count; rtb1.Text = ""; int count = 0; string t = ""; for (int i = 0; i < pcc.Exports.Count; i++) { PCCObject.ExportEntry e = pcc.Exports[i]; string s = "Properties for Object #" + i + " \"" + e.ObjectName + "\" :\n\n"; List <PropertyReader.Property> p = PropertyReader.getPropList(pcc, e.Data); foreach (PropertyReader.Property prop in p) { s += PropertyReader.PropertyToText(prop, pcc) + "\n"; } s += "\n"; t += s; if (count++ > 100) { count = 0; pb1.Value = i; Status.Text = "State : " + i + " / " + pcc.Exports.Count; Application.DoEvents(); } } Status.Text = "State : Done"; rtb1.Text = t; rtb1.SelectionStart = rtb1.TextLength; rtb1.SelectionLength = 0; rtb1.ScrollToCaret(); pb1.Value = 0; }
public TreeNode FindSequences(PCCObject pcc, int index, bool wantFullName = false) { TreeNode ret = new TreeNode("#" + index.ToString() + ": " + (wantFullName ? pcc.Exports[index].GetFullPath : pcc.Exports[index].ObjectName)); ret.Name = index.ToString(); Sequence seq = new Sequence(pcc, index); if (seq.SequenceObjects != null) { for (int i = 0; i < seq.SequenceObjects.Count(); i++) { if (pcc.Exports[seq.SequenceObjects[i] - 1].ClassName == "Sequence" || pcc.Exports[seq.SequenceObjects[i] - 1].ClassName.StartsWith("PrefabSequence")) { TreeNode t = FindSequences(pcc, seq.SequenceObjects[i] - 1, wantFullName); ret.Nodes.Add(t); } else if (pcc.Exports[seq.SequenceObjects[i] - 1].ClassName == "SequenceReference") { var props = PropertyReader.getPropList(pcc, pcc.Exports[seq.SequenceObjects[i] - 1]); var propSequenceReference = props.FirstOrDefault(p => pcc.getNameEntry(p.Name).Equals("oSequenceReference")); if (propSequenceReference != null) { TreeNode t = FindSequences(pcc, propSequenceReference.Value.IntValue - 1, wantFullName); ret.Nodes.Add(t); } } } } return(ret); }
public Sequence(PCCPackage Pcc, int index) { pcc = Pcc; MyIndex = index; byte[] buff = pcc.GetObjectData(index + 1); Props = PropertyReader.getPropList(pcc, buff); Objects = new List <int>(); foreach (PropertyReader.Property p in Props) { string s = pcc.GetName(p.Name); switch (s) { case "SequenceObjects": int count = BitConverter.ToInt32(p.raw, 24); for (int i = 0; i < count; i++) { Objects.Add(BitConverter.ToInt32(p.raw, 28 + i * 4)); } break; } } for (int i = 0; i < pcc.Exports.Count; i++) { if (pcc.Exports[i].idxLink == MyIndex + 1) { Objects.Add(i + 1); } } Objects.Sort(); }
public AnimSet(PCCObject Pcc, int Index) { pcc = Pcc; MyIndex = Index; if (pcc.isExport(Index)) { data = pcc.Exports[Index].Data; } Props = PropertyReader.getPropList(pcc, pcc.Exports[Index]); BitConverter.IsLittleEndian = true; Sequences = new List <int>(); foreach (PropertyReader.Property p in Props) { switch (pcc.getNameEntry(p.Name)) { case "PreviewSkelMeshName": PreviewSkelMeshName = p.Value.IntValue; break; case "m_pBioAnimSetData": m_pBioAnimSetData = p.Value.IntValue; if (pcc.isExport(m_pBioAnimSetData - 1) && pcc.Exports[m_pBioAnimSetData - 1].ClassName == "BioAnimSetData") { SetData = new BioAnimSetData(pcc, m_pBioAnimSetData - 1); } break; case "Sequences": ReadSequences(p.raw); break; } } }
public MaterialOverrides(IMEPackage pcc, int index) { byte[] data = pcc.Exports[index].Data; List <PropertyReader.Property> props = PropertyReader.getPropList(pcc.Exports[index]); foreach (PropertyReader.Property p in props) { string propName = pcc.getNameEntry(p.Name); switch (propName) { case "m_aTextureOverrides": ReadTextures(p, pcc); break; case "m_aColorOverrides": ReadColors(p, pcc); break; case "m_aScalarOverrides": ReadScalars(p, pcc); break; case "None": break; } } }
public bool TryFindQuestMap(PCCPackage pcc, out int exportIndex, out int dataOffset) { var index = pcc.FindClass("BioQuestMap"); exportIndex = -1; dataOffset = -1; if (index == 0) { return(false); } exportIndex = pcc.Exports.FindIndex(entry => entry.idxClass == index); if (exportIndex < 0) { return(false); } var mapData = pcc.Exports[exportIndex].Data; var mapProperties = PropertyReader.getPropList(pcc, mapData); if (mapProperties.Count <= 0) { return(false); } var mapProperty = mapProperties.Find(property => property.TypeVal == PropertyReader.Type.None); dataOffset = mapProperty.offend; return(true); }
private void Load() { InterpCurveTracks = new List <InterpCurve>(); List <PropertyReader.Property> props = PropertyReader.getPropList(expEntry); CurveType throwaway = CurveType.InterpCurveVector; foreach (var p in props) { if (p.TypeVal == PropertyType.StructProperty) { if (Enum.TryParse(pcc.getNameEntry(p.Value.IntValue), out throwaway)) { InterpCurveTracks.Add(new InterpCurve(pcc, p)); } } } Action saveChanges = () => Commit(); foreach (var interpCurve in InterpCurveTracks) { foreach (var curve in interpCurve.Curves) { curve.SaveChanges = saveChanges; } } TrackList.ItemsSource = InterpCurveTracks; graph.Paint(); }
public BioAnimSetData(PCCObject Pcc, int Index) { pcc = Pcc; MyIndex = Index; if (pcc.isExport(Index)) { data = pcc.Exports[Index].Data; } Props = PropertyReader.getPropList(pcc, pcc.Exports[Index]); BitConverter.IsLittleEndian = true; TrackBoneNames = new List <string>(); UseTranslationBoneNames = new List <string>(); foreach (PropertyReader.Property p in Props) { switch (pcc.getNameEntry(p.Name)) { case "bAnimRotationOnly": if (p.raw[p.raw.Length - 1] == 1) { bAnimRotationOnly = true; } break; case "TrackBoneNames": ReadTBN(p.raw); break; case "UseTranslationBoneNames": ReadUTBN(p.raw); break; } } }
public void LoadData() { Save.ExtractME1Package(0, "load.upk"); ME1Package pcc = MEPackageHandler.OpenME1Package("load.upk"); File.Delete("load.upk"); byte[] buff = pcc.Exports[1].Data; List <PropertyReader.Property> props = PropertyReader.getPropList(pcc.Exports[1]); foreach (PropertyReader.Property p in props) { string name = pcc.getNameEntry(p.Name); switch (name) { case "m_nResourceCredits": textBox1.Text = BitConverter.ToInt32(buff, p.offend - 4).ToString(); break; case "m_nResourceGrenades": textBox2.Text = BitConverter.ToInt32(buff, p.offend - 4).ToString(); break; case "m_fResourceMedigel": textBox3.Text = BitConverter.ToSingle(buff, p.offend - 4).ToString(); break; case "m_fResourceSalvage": textBox4.Text = BitConverter.ToSingle(buff, p.offend - 4).ToString(); break; } } textBox5.Text = BitConverter.ToInt32(Save.Files[1].memory.ToArray(), 0x4A7).ToString(); //Paragon textBox6.Text = BitConverter.ToInt32(Save.Files[1].memory.ToArray(), 0x4A3).ToString(); //Renegade }
public StaticMeshCollectionActor(ME3Package Pcc, int Index) { pcc = Pcc; MyIndex = Index; if (pcc.isExport(Index)) { data = pcc.Exports[Index].Data; } Props = PropertyReader.getPropList(pcc.Exports[Index]); foreach (PropertyReader.Property p in Props) { switch (pcc.getNameEntry(p.Name)) { case "bCanStepUpOn": if (p.raw[p.raw.Length - 1] == 1) { bCanStepUpOn = true; } break; case "Tag": Tag = p.Value.IntValue; break; case "CreationTime": CreationTime = BitConverter.ToSingle(p.raw, p.raw.Length - 4); break; } } ReadObjects(); ReadMatrices(); }
public void InitInterpreter(BioTlkFileSet editorTalkset = null) { DynamicByteProvider db = new DynamicByteProvider(pcc.Exports[Index].Data); hb1.ByteProvider = db; memory = pcc.Exports[Index].Data; memsize = memory.Length; // attempt to find a TlkFileSet associated with the object, else just pick the first one and hope it's correct if (editorTalkset == null) { PropertyReader.Property tlkSetRef = PropertyReader.getPropList(pcc, pcc.Exports[Index].Data).FirstOrDefault(x => pcc.getNameEntry(x.Name) == "m_oTlkFileSet"); if (tlkSetRef != null) { tlkset = new BioTlkFileSet(pcc, tlkSetRef.Value.IntValue - 1); } else { tlkset = new BioTlkFileSet(pcc); } } else { tlkset = editorTalkset; } }
private void Commit() { List <PropertyReader.Property> props = PropertyReader.getPropList(expEntry); int diff = 0; foreach (var p in props) { if (p.TypeVal == PropertyType.StructProperty) { foreach (InterpCurve item in InterpCurveTracks) { if (pcc.getNameEntry(p.Name) == item.Name) { int offset = p.offsetval - 24 + diff; List <byte> data = expEntry.Data.ToList(); data.RemoveRange(offset, p.raw.Length); byte[] newVal = item.Serialize(); data.InsertRange(offset, newVal); expEntry.Data = data.ToArray(); diff = newVal.Length - p.raw.Length; } } } } }
public void GetEntries() { CodexMap = new List <EntryStruct>(); byte[] buff = pcc.Exports[0].Data; List <PropertyReader.Property> props = PropertyReader.getPropList(pcc, buff); int pos = props[props.Count - 1].offend; BitConverter.IsLittleEndian = true; while (pos < buff.Length) { int count = BitConverter.ToInt32(buff, pos); pos += 4; for (int i = 0; i < count; i++) { EntryStruct entry = new EntryStruct(); entry.offset = pos; entry.Values = new int[8]; for (int j = 0; j < 8; j++) { entry.Values[j] = BitConverter.ToInt32(buff, pos + j * 4); } CodexMap.Add(entry); pos += 32; } } }
private void saveGUIDCacheToolStripMenuItem_Click(object sender, EventArgs e) { if (pcc == null || GUIDs == null) { return; } MemoryStream m = new MemoryStream(); byte[] buff = pcc.Exports[0].Data; props = PropertyReader.getPropList(pcc, buff); int pos = props[props.Count - 1].offend; m.Write(buff, 0, pos); m.Write(BitConverter.GetBytes(GUIDs.Count), 0, 4); foreach (GuidEntry g in GUIDs) { m.Write(BitConverter.GetBytes(g.NameIdx), 0, 4); m.Write(BitConverter.GetBytes((int)0), 0, 4); foreach (byte b in g.GUID) { m.WriteByte(b); } } pcc.Exports[0].Data = m.ToArray(); pcc.Exports[0].hasChanged = true; pcc.altSaveToFile(pcc.pccFileName, true, 30); //weird header! MessageBox.Show("Done."); RefreshLists(); }
public void PreviewProps() { int n = GetSelected(); if (n == -1 || !(CurrentView == 2 || CurrentView == 3)) { return; } List <PropertyReader.Property> p; switch (pcc.Exports[n].ClassName) { default: byte[] buff = pcc.Exports[n].Data; p = PropertyReader.getPropList(pcc, buff); break; } pg = new PropGrid(); propGrid.SelectedObject = pg; pg.Add(new CustomProperty("Name", "_Meta", pcc.Exports[n].ObjectName, typeof(string), true, true)); pg.Add(new CustomProperty("Class", "_Meta", pcc.Exports[n].ClassName, typeof(string), true, true)); pg.Add(new CustomProperty("Data Offset", "_Meta", pcc.Exports[n].DataOffset, typeof(int), true, true)); pg.Add(new CustomProperty("Data Size", "_Meta", pcc.Exports[n].DataSize, typeof(int), true, true)); for (int l = 0; l < p.Count; l++) { pg.Add(PropertyReader.PropertyToGrid(p[l], pcc)); } propGrid.Refresh(); propGrid.ExpandAllGridItems(); }
public Level(PCCPackage Pcc, int index) { pcc = Pcc; MyIndex = index; byte[] buff = pcc.GetObjectData(index); Props = PropertyReader.getPropList(pcc, buff); int off = Props[Props.Count() - 1].offend + 4; int count = BitConverter.ToInt32(buff, off); Objects = new List <int>(); for (int i = 0; i < count; i++) { int idx = BitConverter.ToInt32(buff, off + 4 + i * 4); Objects.Add(idx); } for (int i = 0; i < pcc.Exports.Count; i++) { if (pcc.Exports[i].idxLink - 1 == index) { bool found = false; foreach (int j in Objects) { if (j == i + 1) { found = true; } } if (!found) { Objects.Add(i + 1); } } } RenderObjects = new List <_DXRenderableObject>(); foreach (int i in Objects) { if (i > 0) { string c = pcc.GetObject(pcc.Exports[i - 1].idxClass); switch (c) { case "ModelComponent": RenderObjects.Add(new ModelComponent(pcc, i - 1)); break; case "StaticMeshActor": case "InterpActor": RenderObjects.Add(new StaticMeshActor(pcc, i - 1)); break; case "StaticMeshCollectionActor": RenderObjects.Add(new StaticMeshCollectionActor(pcc, i - 1)); break; default: break; } } } }
public StaticMeshCollectionActor(PCCPackage Pcc, int index) { pcc = Pcc; MyIndex = index; data = pcc.GetObjectData(index); Props = PropertyReader.getPropList(pcc, data); ReadObjects(); ReadMatrices(); }
public StaticMeshComponent(PCCPackage Pcc, int index, Matrix transform) { pcc = Pcc; MyIndex = index; byte[] buff = pcc.GetObjectData(index); Props = PropertyReader.getPropList(pcc, buff); ParentMatrix = transform; foreach (PropertyReader.Property p in Props) { string s = pcc.GetName(p.Name); switch (s) { case "StaticMesh": idxSTM = p.Value.IntValue; break; case "Scale": Scale = BitConverter.ToSingle(p.raw, p.raw.Length - 4); break; case "Scale3D": Scale3D = new Vector3(BitConverter.ToSingle(p.raw, p.raw.Length - 12), BitConverter.ToSingle(p.raw, p.raw.Length - 8), BitConverter.ToSingle(p.raw, p.raw.Length - 4)); break; case "Rotation": Rotation = new Vector3(BitConverter.ToInt32(p.raw, p.raw.Length - 12), BitConverter.ToInt32(p.raw, p.raw.Length - 8), BitConverter.ToInt32(p.raw, p.raw.Length - 4)); break; case "Translation": Translation = new Vector3(BitConverter.ToSingle(p.raw, p.raw.Length - 12), BitConverter.ToSingle(p.raw, p.raw.Length - 8), BitConverter.ToSingle(p.raw, p.raw.Length - 4)); break; default: break; } } MyMatrix = Matrix.Identity; MyMatrix *= Matrix.Scaling(Scale3D); MyMatrix *= Matrix.Scaling(new Vector3(Scale, Scale, Scale)); Vector3 rot = DXHelper.RotatorToDX(Rotation); MyMatrix *= Matrix.RotationYawPitchRoll(rot.X, rot.Y, rot.Z); MyMatrix *= Matrix.Translation(Translation); Matrix t = MyMatrix * ParentMatrix; if (idxSTM > 0 && !pcc.getObjectName(idxSTM).ToLower().Contains("volumetric") && !pcc.getObjectName(idxSTM).ToLower().Contains("spheremesh")) { STM = new StaticMesh(pcc, idxSTM - 1, t); } }
public LightVolume(ME3Package Pcc, int Index) { pcc = Pcc; MyIndex = Index; if (pcc.isExport(Index)) { data = pcc.Exports[Index].Data; } Props = PropertyReader.getPropList(pcc.Exports[Index]); foreach (PropertyReader.Property p in Props) { switch (pcc.getNameEntry(p.Name)) { #region case "bColored": if (p.raw[p.raw.Length - 1] == 1) { bColored = true; } break; case "Tag": Tag = p.Value.IntValue; break; case "Brush": Brush = p.Value.IntValue; break; case "BrushComponent": BrushComponent = p.Value.IntValue; if (pcc.isExport(BrushComponent - 1) && pcc.Exports[BrushComponent - 1].ClassName == "BrushComponent") { brush = new BrushComponent(pcc, BrushComponent - 1); } break; case "CollisionComponent": CollisionComponent = p.Value.IntValue; break; case "CreationTime": CreationTime = BitConverter.ToSingle(p.raw, p.raw.Length - 4); break; case "location": location = new Vector3(BitConverter.ToSingle(p.raw, p.raw.Length - 12), BitConverter.ToSingle(p.raw, p.raw.Length - 8), BitConverter.ToSingle(p.raw, p.raw.Length - 4)); break; #endregion } } MyMatrix = Matrix.Translation(location); }
public StaticMesh(PCCPackage Pcc, int index, Matrix transform) { pcc = Pcc; MyIndex = index; byte[] buff = pcc.GetObjectData(index); Props = PropertyReader.getPropList(pcc, buff); ParentMatrix = transform; int off = Props[Props.Count() - 1].offend; DeserializeDump(buff, off); }
public ME3FaceFXAnimSet(IMEPackage Pcc, IExportEntry Entry) { pcc = Pcc; export = Entry; List <PropertyReader.Property> props = PropertyReader.getPropList(export); int start = props[props.Count - 1].offend + 4; SerializingContainer Container = new SerializingContainer(new MemoryStream(export.Data.Skip(start).ToArray())); Container.isLoading = true; Serialize(Container); }
private void ReadData() { Unk1 = BitConverter.ToInt32(Memory, 0); Props = PropertyReader.getPropList(pcc.Exports[MyIndex]); ReadStartingList(); ReadEntryList(); ReadReplyList(); ReadSpeakerList(); ReadScriptList(); ReadMaleFaceSets(); ReadFemaleFaceSets(); }
public StaticMeshActor(PCCPackage Pcc, int index) { pcc = Pcc; MyIndex = index; byte[] buff = pcc.GetObjectData(index); Props = PropertyReader.getPropList(pcc, buff); foreach (PropertyReader.Property p in Props) { string s = pcc.GetName(p.Name); switch (s) { case "StaticMeshComponent": idxSTM = p.Value.IntValue; break; case "DrawScale": DrawScale = BitConverter.ToSingle(p.raw, p.raw.Length - 4); break; case "DrawScale3D": DrawScale3D = new Vector3(BitConverter.ToSingle(p.raw, p.raw.Length - 12), BitConverter.ToSingle(p.raw, p.raw.Length - 8), BitConverter.ToSingle(p.raw, p.raw.Length - 4)); break; case "Rotation": Rotator = new Vector3(BitConverter.ToInt32(p.raw, p.raw.Length - 12), BitConverter.ToInt32(p.raw, p.raw.Length - 8), BitConverter.ToInt32(p.raw, p.raw.Length - 4)); break; case "location": location = new Vector3(BitConverter.ToSingle(p.raw, p.raw.Length - 12), BitConverter.ToSingle(p.raw, p.raw.Length - 8), BitConverter.ToSingle(p.raw, p.raw.Length - 4)); break; default: break; } } MyMatrix = Matrix.Identity; MyMatrix *= Matrix.Scaling(DrawScale3D); MyMatrix *= Matrix.Scaling(new Vector3(DrawScale, DrawScale, DrawScale)); Vector3 rot = DXHelper.RotatorToDX(Rotator); MyMatrix *= Matrix.RotationYawPitchRoll(rot.X, rot.Y, rot.Z); MyMatrix *= Matrix.Translation(location); if (idxSTM != 0) { STMC = new StaticMeshComponent(pcc, idxSTM - 1, MyMatrix); } }
void ReadData() { Unk1 = BitConverter.ToInt32(export.Data, 0); Props = PropertyReader.getPropList(export); ReadStartingList(); ReadEntryList(); ReadReplyList(); ReadSpeakerList(); ReadStageDirections(); ReadMaleFaceSets(); ReadFemaleFaceSets(); }
private void ReadData() { Unk1 = BitConverter.ToInt32(Memory, 0); Props = PropertyReader.getPropList(pcc.Exports[MyIndex]); TlkFileSet = Props[FindPropByName("m_oTlkFileSet")].Value.IntValue; ReadStartingList(); ReadEntryList(); ReadReplyList(); ReadSpeakerList(); ReadScriptList(); ReadMaleFaceSets(); ReadFemaleFaceSets(); }
private void ReadData() { BitConverter.IsLittleEndian = true; Unk1 = BitConverter.ToInt32(Memory, 0); Props = PropertyReader.getPropList(pcc, pcc.Exports[MyIndex]); ReadStartingList(); ReadEntryList(); ReadReplyList(); ReadSpeakerList(); ReadStageDirections(); ReadMaleFaceSets(); ReadFemaleFaceSets(); }
public void Deserialize(bool SimpleRead) { List <PropertyReader.Property> props = PropertyReader.getPropList(pcc, pcc.Exports[Index]); int off = props[props.Count() - 1].offend + 4; if (SimpleRead) { ReadObjectsSimple(off); } else { ReadObjects(off); } }
public void SaveData() { Save.ExtractME1Package(0, "save.upk"); ME1Package pcc = MEPackageHandler.OpenME1Package("save.upk"); File.Delete("save.upk"); byte[] buff = pcc.Exports[1].Data; List <PropertyReader.Property> props = PropertyReader.getPropList(pcc.Exports[1]); int v; float f; foreach (PropertyReader.Property p in props) { string name = pcc.getNameEntry(p.Name); switch (name) { case "m_nResourceCredits": v = Convert.ToInt32(textBox1.Text); buff = WriteInt(buff, p.offend - 4, v); break; case "m_nResourceGrenades": v = Convert.ToInt32(textBox2.Text); buff = WriteInt(buff, p.offend - 4, v); break; case "m_fResourceMedigel": f = Convert.ToSingle(textBox3.Text); buff = WriteFloat(buff, p.offend - 4, f); break; case "m_fResourceSalvage": f = Convert.ToSingle(textBox4.Text); buff = WriteFloat(buff, p.offend - 4, f); break; } } pcc.Exports[1].Data = buff; pcc.save(); Save.ImportME1Package(0, "save.upk"); File.Delete("save.upk"); v = Convert.ToInt32(textBox5.Text); buff = Save.Files[1].memory.ToArray(); buff = WriteInt(buff, 0x4A7, v); //Paragon v = Convert.ToInt32(textBox6.Text); buff = WriteInt(buff, 0x4A3, v); //Renegade SaveGame.SaveFileEntry e = Save.Files[1]; e.memory = new MemoryStream(buff); Save.Files[1] = e; }
private void ReadData() { BitConverter.IsLittleEndian = true; Unk1 = BitConverter.ToInt32(Memory, 0); Props = PropertyReader.getPropList(pcc, Memory); TlkFileSet = Props[FindPropByName("m_oTlkFileSet")].Value.IntValue; ReadStartingList(); ReadEntryList(); ReadReplyList(); ReadSpeakerList(); ReadScriptList(); ReadMaleFaceSets(); ReadFemaleFaceSets(); }
public void ReadProperties() { props = PropertyReader.getPropList(pcc, memory); Textures = new List <TextureParam>(); for (int i = 0; i < props.Count(); i++) { string name = pcc.getNameEntry(props[i].Name); switch (name) { case "TextureParameterValues": ReadTextureParams(props[i].raw); break; } } }