public ObfNodeListEntry(ObfNodeList parent, EndianBinaryReader reader) { Parent = parent; Offset = reader.BaseStream.Position; GroupIndex = reader.ReadInt32(); ParentNodeID = reader.ReadInt16(); Unknown0x06 = reader.ReadUInt16(); NumTransformIndices = reader.ReadUInt32(); TransformIndices = new uint[NumTransformIndices]; for (int i = 0; i < TransformIndices.Length; i++) { TransformIndices[i] = reader.ReadUInt32(); } }
public Obf(string filePath) : base(filePath) { using (EndianBinaryReader reader = new EndianBinaryReader(File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Endian.BigEndian)) { FileSize = reader.ReadUInt32(); Unknown0x04 = reader.ReadUInt32(); UnknownOffset0x08 = reader.ReadUInt32(); ModelIDListOffset = reader.ReadUInt32(); ObjectListOffset = reader.ReadUInt32(); NodeListOffset = reader.ReadUInt32(); TransformationEntriesOffset = reader.ReadUInt32(); TransformationDataOffset = reader.ReadUInt32(); GroupListOffset = reader.ReadUInt32(); PrimitiveListOffset = reader.ReadUInt32(); VertexDataOffset = reader.ReadUInt32(); TxfListOffset = reader.ReadUInt32(); reader.BaseStream.Seek(ModelIDListOffset, SeekOrigin.Begin); ModelIDList = new ObfModelIDList(this, reader); reader.BaseStream.Seek(ObjectListOffset, SeekOrigin.Begin); ObjectList = new ObfObjectList(this, reader); reader.BaseStream.Seek(NodeListOffset, SeekOrigin.Begin); NodeList = new ObfNodeList(this, reader); reader.BaseStream.Seek(TransformationEntriesOffset, SeekOrigin.Begin); TransformationEntries = new List <ObfTransformationEntry>(); while (reader.BaseStream.Position < TransformationDataOffset) { TransformationEntries.Add(new ObfTransformationEntry(this, reader)); } foreach (ObfTransformationEntry transformEntry in TransformationEntries) { transformEntry.Translation = new Vector3( GetTransformValue(reader, transformEntry.TranslationXIndex), GetTransformValue(reader, transformEntry.TranslationYIndex), -GetTransformValue(reader, transformEntry.TranslationZIndex)); transformEntry.Rotation = new Vector3( GetTransformValue(reader, transformEntry.RotationXIndex), GetTransformValue(reader, transformEntry.RotationYIndex), GetTransformValue(reader, transformEntry.RotationZIndex)); transformEntry.Scale = new Vector3( GetTransformValue(reader, transformEntry.ScaleXIndex), GetTransformValue(reader, transformEntry.ScaleYIndex), GetTransformValue(reader, transformEntry.ScaleZIndex)); } reader.BaseStream.Seek(GroupListOffset, SeekOrigin.Begin); GroupList = new ObfGroupList(this, reader); reader.BaseStream.Seek(PrimitiveListOffset, SeekOrigin.Begin); PrimitiveList = new ObfPrimitiveList(this, reader); reader.BaseStream.Seek(TxfListOffset, SeekOrigin.Begin); TxfList = new ObfTxfList(this, reader); for (int i = 0; i < PrimitiveList.Primitives.Length; i++) { ObfPrimitiveListEntry primitiveListEntry = PrimitiveList.Primitives[i]; primitiveListEntry.Vertices = new ObfVertex[primitiveListEntry.NumVertexIndices]; for (int j = 0; j < primitiveListEntry.Vertices.Length; j++) { reader.BaseStream.Seek(VertexDataOffset + (ObfVertex.Size * primitiveListEntry.VertexIndices[j]), SeekOrigin.Begin); primitiveListEntry.Vertices[j] = new ObfVertex(primitiveListEntry, reader); } } for (int i = 0; i < GroupList.Groups.Length; i++) { ObfGroupListEntry groupListEntry = GroupList.Groups[i]; groupListEntry.Primitives = new ObfPrimitiveListEntry[groupListEntry.NumPrimitives]; for (int j = 0; j < groupListEntry.Primitives.Length; j++) { groupListEntry.Primitives[j] = PrimitiveList.Primitives[groupListEntry.PrimitiveIDs[j]]; } } for (int i = 0; i < NodeList.Nodes.Length; i++) { ObfNodeListEntry nodeListEntry = NodeList.Nodes[i]; if (nodeListEntry.GroupIndex != -1) { nodeListEntry.Group = GroupList.Groups[nodeListEntry.GroupIndex]; } } for (int i = 0; i < ObjectList.Objects.Length; i++) { ObfObjectListEntry objectListEntry = ObjectList.Objects[i]; objectListEntry.Nodes = new ObfNodeListEntry[objectListEntry.NumNodeIndices]; for (int j = 0; j < objectListEntry.Nodes.Length; j++) { objectListEntry.Nodes[j] = NodeList.Nodes[objectListEntry.NodeIndices[j]]; } foreach (ObfNodeListEntry nodeListEntry in objectListEntry.Nodes) { if (nodeListEntry.ParentNodeID != -1) { nodeListEntry.ParentNode = objectListEntry.Nodes[nodeListEntry.ParentNodeID]; } nodeListEntry.Transformations = new ObfTransformationEntry[nodeListEntry.NumTransformIndices]; for (int j = 0; j < nodeListEntry.Transformations.Length; j++) { nodeListEntry.Transformations[j] = TransformationEntries[(int)nodeListEntry.TransformIndices[j]]; } } } } }